[Scummvm-cvs-logs] SF.net SVN: scummvm:[44032] scummvm/trunk/engines/cruise

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Fri Sep 11 13:36:16 CEST 2009


Revision: 44032
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44032&view=rev
Author:   dreammaster
Date:     2009-09-11 11:36:16 +0000 (Fri, 11 Sep 2009)

Log Message:
-----------
Added an experimental screen transition dirty rect calculation code which should make background changes faster on slower devices or when scalers are active 

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/gfxModule.cpp
    scummvm/trunk/engines/cruise/gfxModule.h
    scummvm/trunk/engines/cruise/mainDraw.cpp

Modified: scummvm/trunk/engines/cruise/gfxModule.cpp
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.cpp	2009-09-11 11:02:15 UTC (rev 44031)
+++ scummvm/trunk/engines/cruise/gfxModule.cpp	2009-09-11 11:36:16 UTC (rev 44032)
@@ -330,4 +330,46 @@
 	memset(dataPtr, 0, dataSize);
 }
 
+/**
+ * This method compares a new background being switched in against the current background,
+ * to figure out rectangles of changed areas for dirty rectangles
+ */
+void switchBackground(const byte *newBg) {
+	const byte *bg = gfxModuleData.pPage00;
+	int sliceXStart, sliceXEnd;
+
+	// If both the upper corners are different, presume it's a full screen change
+	if ((*newBg != *bg) && (*(newBg + 319) != *(bg + 319))) {
+		gfxModuleData_addDirtyRect(Common::Rect(0, 0, 320, 200));
+		return;
+	}
+
+	/* For an optimisation, any changes are stored as a series of slices than have a height of a single
+	 * line each. It is left up to the screen redraw code to automatically merge these together 
+	 */
+
+	for (int yp = 0; yp < 200; ++yp) {
+		sliceXStart = -1; sliceXEnd = -1;
+		for (int xp = 0; xp < 320; ++xp, ++bg, ++newBg) {
+			if (*bg != *newBg) {
+				if (sliceXStart == -1) {
+					// Start of a new slice
+					sliceXStart = xp;
+					sliceXEnd = MIN(xp + 7, 320);
+				} else
+					// Carry on of changed area
+					sliceXEnd = MAX(xp + 7, sliceXEnd);
+
+			} else if ((sliceXEnd != -1) && (xp >= (sliceXEnd + 10))) {
+				// If more than 10 pixels have gone by without any changes, then end the slice
+				gfxModuleData_addDirtyRect(Common::Rect(sliceXStart, yp, sliceXEnd, yp + 1));
+				sliceXStart = sliceXEnd = -1;
+			}
+		}
+
+		if (sliceXStart != -1)
+			gfxModuleData_addDirtyRect(Common::Rect(sliceXStart, yp, 320, yp + 1));
+	}
+}
+
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/gfxModule.h
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.h	2009-09-11 11:02:15 UTC (rev 44031)
+++ scummvm/trunk/engines/cruise/gfxModule.h	2009-09-11 11:36:16 UTC (rev 44032)
@@ -67,6 +67,8 @@
 void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour);
 void resetBitmap(uint8 *dataPtr, int32 dataSize);
 
+void switchBackground(const byte *newBg);
+
 } // End of namespace Cruise
 
 #endif

Modified: scummvm/trunk/engines/cruise/mainDraw.cpp
===================================================================
--- scummvm/trunk/engines/cruise/mainDraw.cpp	2009-09-11 11:02:15 UTC (rev 44031)
+++ scummvm/trunk/engines/cruise/mainDraw.cpp	2009-09-11 11:36:16 UTC (rev 44032)
@@ -1415,7 +1415,7 @@
 		gfxModuleData_gfxCopyScreen(bgPtr, gfxModuleData.pPage10);
 		if (backgroundChanged[masterScreen]) {
 			backgroundChanged[masterScreen] = false;
-			gfxModuleData_addDirtyRect(Common::Rect(0, 0, 320, 200));
+			switchBackground(bgPtr);
 		}
 	}
 


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