[Scummvm-cvs-logs] SF.net SVN: scummvm:[48756] scummvm/trunk/graphics/surface.cpp

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Tue Apr 20 22:22:34 CEST 2010


Revision: 48756
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48756&view=rev
Author:   dhewg
Date:     2010-04-20 20:22:33 +0000 (Tue, 20 Apr 2010)

Log Message:
-----------
Use the faster memset() in Surface::fillRect() for 16bit modes when possible.

Modified Paths:
--------------
    scummvm/trunk/graphics/surface.cpp

Modified: scummvm/trunk/graphics/surface.cpp
===================================================================
--- scummvm/trunk/graphics/surface.cpp	2010-04-20 19:37:58 UTC (rev 48755)
+++ scummvm/trunk/graphics/surface.cpp	2010-04-20 20:22:33 UTC (rev 48756)
@@ -135,23 +135,30 @@
 		return;
 
 	int width = r.width();
+	int lineLen = width;
 	int height = r.height();
-//	int i;
+	bool useMemset = true;
 
-	if (bytesPerPixel == 1) {
+	if (bytesPerPixel == 2) {
+		lineLen *= 2;
+		if ((uint16)color != ((color & 0xff) | (color & 0xff) << 8))
+			useMemset = false;
+	} else if (bytesPerPixel != 1) {
+		error("Surface::fillRect: bytesPerPixel must be 1 or 2");
+	}
+
+	if (useMemset) {
 		byte *ptr = (byte *)getBasePtr(r.left, r.top);
 		while (height--) {
-			memset(ptr, (byte)color, width);
+			memset(ptr, (byte)color, lineLen);
 			ptr += pitch;
 		}
-	} else if (bytesPerPixel == 2) {
+	} else {
 		uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top);
 		while (height--) {
 			Common::set_to(ptr, ptr + width, (uint16)color);
 			ptr += pitch/2;
 		}
-	} else {
-		error("Surface::fillRect: bytesPerPixel must be 1 or 2");
 	}
 }
 


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