[Scummvm-cvs-logs] SF.net SVN: scummvm: [28371] scummvm/trunk/engines/touche/graphics.cpp

cyx at users.sourceforge.net cyx at users.sourceforge.net
Tue Jul 31 23:19:45 CEST 2007


Revision: 28371
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28371&view=rev
Author:   cyx
Date:     2007-07-31 14:19:45 -0700 (Tue, 31 Jul 2007)

Log Message:
-----------
add missing clipping

Modified Paths:
--------------
    scummvm/trunk/engines/touche/graphics.cpp

Modified: scummvm/trunk/engines/touche/graphics.cpp
===================================================================
--- scummvm/trunk/engines/touche/graphics.cpp	2007-07-31 21:17:15 UTC (rev 28370)
+++ scummvm/trunk/engines/touche/graphics.cpp	2007-07-31 21:19:45 UTC (rev 28371)
@@ -177,34 +177,58 @@
 }
 
 void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) {
-	if (w != 0 && h != 0) {
-		dst += dstY * dstPitch + dstX;
-		src += srcY * srcPitch + srcX;
-		while (h--) {
-			for (int i = 0; i < w; ++i) {
-				if ((flags & kTransparent) == 0 || src[i] != 0) {
-					dst[i] = src[i];
-				}
+	if (dstX < 0) {
+		w += dstX;
+		dstX = 0;
+	}
+	if (w <= 0) {
+		return;
+	}
+	if (dstY < 0) {
+		h += dstY;
+		dstY = 0;
+	}
+	if (h <= 0) {
+		return;
+	}
+	dst += dstY * dstPitch + dstX;
+	src += srcY * srcPitch + srcX;
+	while (h--) {
+		for (int i = 0; i < w; ++i) {
+			if ((flags & kTransparent) == 0 || src[i] != 0) {
+				dst[i] = src[i];
 			}
-			dst += dstPitch;
-			src += srcPitch;
 		}
+		dst += dstPitch;
+		src += srcPitch;
 	}
 }
 
 void Graphics::copyMask(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, uint8 fillColor) {
-	if (w != 0 && h != 0) {
-		dst += dstY * dstPitch + dstX;
-		src += srcY * srcPitch + srcX;
-		while (h--) {
-			for (int i = 0; i < w; ++i) {
-				if (src[i] != 0) {
-					dst[i] = fillColor;
-				}
+	if (dstX < 0) {
+		w += dstX;
+		dstX = 0;
+	}
+	if (w <= 0) {
+		return;
+	}
+	if (dstY < 0) {
+		h += dstY;
+		dstY = 0;
+	}
+	if (h <= 0) {
+		return;
+	}
+	dst += dstY * dstPitch + dstX;
+	src += srcY * srcPitch + srcX;
+	while (h--) {
+		for (int i = 0; i < w; ++i) {
+			if (src[i] != 0) {
+				dst[i] = fillColor;
 			}
-			dst += dstPitch;
-			src += srcPitch;
 		}
+		dst += dstPitch;
+		src += srcPitch;
 	}
 }
 


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