[Scummvm-cvs-logs] SF.net SVN: scummvm:[42451] scummvm/branches/gsoc2009-16bit/graphics/ conversion.cpp

upthorn at users.sourceforge.net upthorn at users.sourceforge.net
Mon Jul 13 21:45:25 CEST 2009


Revision: 42451
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42451&view=rev
Author:   upthorn
Date:     2009-07-13 19:45:25 +0000 (Mon, 13 Jul 2009)

Log Message:
-----------
Fixed logic error in Graphics::crossBlit which would result in no blit occuring if src and dst have the same format. Converted Graphics::crossBlit to take PixelFormats by reference, instead of copying them for each call.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-16bit/graphics/conversion.cpp

Modified: scummvm/branches/gsoc2009-16bit/graphics/conversion.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/conversion.cpp	2009-07-13 19:24:41 UTC (rev 42450)
+++ scummvm/branches/gsoc2009-16bit/graphics/conversion.cpp	2009-07-13 19:45:25 UTC (rev 42451)
@@ -30,7 +30,7 @@
 
 // Function to blit a rect from one color format to another
 bool crossBlit(byte *dst, const byte *src, int dstpitch, int srcpitch,
-						int w, int h, Graphics::PixelFormat dstFmt, Graphics::PixelFormat srcFmt) {
+						int w, int h, const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt) {
 	// Error out if conversion is impossible
 	if ((srcFmt.bytesPerPixel == 1) || (dstFmt.bytesPerPixel == 1)
 			 || (!srcFmt.bytesPerPixel) || (!dstFmt.bytesPerPixel)
@@ -38,8 +38,21 @@
 		return false;
 
 	// Don't perform unnecessary conversion
-	if (srcFmt == dstFmt)
-		return true;
+	if (srcFmt == dstFmt) {
+		if (dst == src) 
+			return true;
+		if (dstpitch == srcpitch && ((w * dstFmt.bytesPerPixel) == dstpitch)) {
+			memcpy(dst,src,dstpitch * h);
+			return true;
+		} else {
+			for (int i = 0; i < h; i++) {
+				memcpy(dst,src,w * dstFmt.bytesPerPixel);
+				dst += dstpitch;
+				src += srcpitch;
+			}
+			return true;
+		}
+	}
 
 	// Faster, but larger, to provide optimized handling for each case.
 	int srcDelta, dstDelta;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list