[Scummvm-cvs-logs] SF.net SVN: scummvm: [29587] scummvm/trunk/backends/platform/iphone

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Tue Nov 20 23:20:52 CET 2007


Revision: 29587
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29587&view=rev
Author:   vinterstum
Date:     2007-11-20 14:20:52 -0800 (Tue, 20 Nov 2007)

Log Message:
-----------
Optimized dirty rects handling a bit, makes AGOS engine games run better

Modified Paths:
--------------
    scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
    scummvm/trunk/backends/platform/iphone/osys_iphone.h

Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.cpp	2007-11-20 21:00:41 UTC (rev 29586)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.cpp	2007-11-20 22:20:52 UTC (rev 29587)
@@ -62,7 +62,7 @@
 	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0),
 	_secondaryTapped(false), _lastSecondaryTap(0), _landscapeMode(true),
 	_needEventRestPeriod(false), _mouseClickAndDragEnabled(false),
-	_gestureStartX(-1), _gestureStartY(-1)
+	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false)
 {	
 	_queuedInputEvent.type = (Common::EventType)0;
 }
@@ -155,7 +155,7 @@
 	else
 		iPhone_initSurface(width, height, false);
 
-	_dirtyRects.push_back(Common::Rect(0, 0, width, height));
+	dirtyFullScreen();
 	_mouseVisible = false;
 	updateScreen();
 }
@@ -177,7 +177,7 @@
 		b += 4;
 	}
 	
-	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+	dirtyFullScreen();
 }
 
 void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
@@ -210,7 +210,10 @@
 	if (w <= 0 || h <= 0)
 		return;
 	
-	_dirtyRects.push_back(Common::Rect(x, y, x + w + 1, y + h + 1));
+	if (!_fullScreenIsDirty) {
+		_dirtyRects.push_back(Common::Rect(x, y, x + w + 1, y + h + 1));
+	}
+	
 		
 	byte *dst = _offscreen + y * _screenWidth + x;
 	if (_screenWidth == pitch && pitch == w)
@@ -225,6 +228,10 @@
 }
 
 void OSystem_IPHONE::addDirtyRect(int16 x, int16 y, int16 w, int16 h) {
+	if (_fullScreenIsDirty) {
+		return;
+	}
+	
 	if (x < 0) {
 		w += x;
 		x = 0;
@@ -253,6 +260,8 @@
 	if (_dirtyRects.size() == 0)
 		return;
 	
+	_fullScreenIsDirty = false;
+
 	if (_landscapeMode)
 		internUpdateScreen<true>();
 	else
@@ -318,9 +327,9 @@
 		}
 
 		uint16 *surface = iPhone_getSurface();
-		if (dirtyRect.right == _screenWidth && dirtyRect.bottom == _screenHeight) {
+		if (dirtyRect.right == _screenWidth && dirtyRect.bottom == _screenHeight)
 			memcpy(surface, _fullscreen, _screenWidth * _screenHeight * 2);
-		} else {
+		else {
 			for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
 				if (landscapeMode) {
 					row = (_screenWidth - x - 1) * _screenHeight;
@@ -349,8 +358,7 @@
 
 void OSystem_IPHONE::unlockScreen() {
 	//printf("unlockScreen()\n");
-	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
-	updateScreen();
+	dirtyFullScreen();
 }
 
 void OSystem_IPHONE::setShakePos(int shakeOffset) {
@@ -360,19 +368,19 @@
 void OSystem_IPHONE::showOverlay() {
 	//printf("showOverlay()\n");
 	_overlayVisible = true;
-	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+	dirtyFullScreen();
 }
 
 void OSystem_IPHONE::hideOverlay() {
 	//printf("hideOverlay()\n");
 	_overlayVisible = false;
-	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+	dirtyFullScreen();
 }
 
 void OSystem_IPHONE::clearOverlay() {
 	//printf("clearOverlay()\n");
 	bzero(_overlayBuffer, _screenWidth * _screenHeight * sizeof(OverlayColor));
-	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+	dirtyFullScreen();
 }
 
 void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
@@ -412,7 +420,9 @@
 	if (w <= 0 || h <= 0)
 		return;
 
-	_dirtyRects.push_back(Common::Rect(x, y, x + w + 1, y + h + 1));
+	if (!_fullScreenIsDirty) {
+		_dirtyRects.push_back(Common::Rect(x, y, x + w + 1, y + h + 1));		
+	}
 		
 	OverlayColor *dst = _overlayBuffer + (y * _screenWidth + x);
 	if (_screenWidth == pitch && pitch == w)
@@ -454,6 +464,13 @@
 	addDirtyRect(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY, _mouseX + _mouseWidth - _mouseHotspotX + 1, _mouseY + _mouseHeight - _mouseHotspotY + 1);	
 }
 
+void OSystem_IPHONE::dirtyFullScreen() {
+	if (!_fullScreenIsDirty) {
+		_dirtyRects.clear();
+		_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));		
+	}
+}
+
 void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
 	//printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY);
 
@@ -654,7 +671,7 @@
 					else
 						iPhone_initSurface(_screenWidth, _screenHeight, false);
 
-					_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+					dirtyFullScreen();
 				}				
 				break;
 			case kInputKeyPressed:

Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.h	2007-11-20 21:00:41 UTC (rev 29586)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.h	2007-11-20 22:20:52 UTC (rev 29587)
@@ -87,6 +87,7 @@
 
 	Common::Array<Common::Rect> _dirtyRects;
 	bool _landscapeMode;
+	bool _fullScreenIsDirty;
 
 public:
 
@@ -153,6 +154,7 @@
 	inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h);
 	template <bool landscapeMode> void internUpdateScreen();
 	void dirtyMouseCursor();
+	void dirtyFullScreen();
 
 	static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
 	static int timerHandler(int t);


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