[Scummvm-git-logs] scummvm master -> ad33a3063b02ff9086ade41b9532e1917b15e710

ccawley2011 noreply at scummvm.org
Thu Mar 2 15:11:38 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ad33a3063b GRAPHICS: Add Surface::convertFrom()


Commit: ad33a3063b02ff9086ade41b9532e1917b15e710
    https://github.com/scummvm/scummvm/commit/ad33a3063b02ff9086ade41b9532e1917b15e710
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-03-02T15:11:24Z

Commit Message:
GRAPHICS: Add Surface::convertFrom()

Changed paths:
    graphics/surface.cpp
    graphics/surface.h


diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 7f8c52d8d08..98c6cf85d92 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -98,6 +98,11 @@ void Surface::copyFrom(const Surface &surf) {
 	copyBlit((byte *)pixels, (const byte *)surf.pixels, pitch, surf.pitch, w, h, format.bytesPerPixel);
 }
 
+void Surface::convertFrom(const Surface &surf, const PixelFormat &f) {
+	create(surf.w, surf.h, f);
+	crossBlit((byte *)pixels, (const byte *)surf.pixels, pitch, surf.pitch, w, h, format, surf.format);
+}
+
 Surface Surface::getSubArea(const Common::Rect &area) {
 	Common::Rect effectiveArea(area);
 	effectiveArea.clip(w, h);
diff --git a/graphics/surface.h b/graphics/surface.h
index c68aa197745..857e1768e64 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -237,6 +237,18 @@ public:
 	 */
 	void copyFrom(const Surface &surf);
 
+	/**
+	 * Convert the data from another surface to the specified format.
+	 *
+	 * This calls @ref free on the current surface to assure that it is
+	 * clean. Make sure that the current data was created using @ref create.
+	 * Otherwise, the results are undefined.
+	 *
+	 * @param surf    The surface to convert from.
+	 * @param format  The pixel format to convert to.
+	 */
+	void convertFrom(const Surface &surf, const PixelFormat &format);
+
 	/**
 	 * Create a surface that represents a sub-area of this Surface object.
 	 *




More information about the Scummvm-git-logs mailing list