[Scummvm-cvs-logs] SF.net SVN: scummvm:[35285] scummvm/trunk/engines/saga/render.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Dec 8 18:48:39 CET 2008


Revision: 35285
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35285&view=rev
Author:   thebluegr
Date:     2008-12-08 17:48:39 +0000 (Mon, 08 Dec 2008)

Log Message:
-----------
More dirty rectangle related changes

Modified Paths:
--------------
    scummvm/trunk/engines/saga/render.cpp

Modified: scummvm/trunk/engines/saga/render.cpp
===================================================================
--- scummvm/trunk/engines/saga/render.cpp	2008-12-07 22:46:45 UTC (rev 35284)
+++ scummvm/trunk/engines/saga/render.cpp	2008-12-08 17:48:39 UTC (rev 35285)
@@ -95,17 +95,10 @@
 	restoreChangedRects();
 
 	if (!(_flags & (RF_DEMO_SUBST | RF_MAP) || curMode == kPanelPlacard)) {
-		// Do not redraw the whole scene and the actors if the scene is fading out or
-		// if an overlay is drawn above it (e.g. the options menu)
-		if (_vm->_interface->getFadeMode() != kFadeOut &&
-			(curMode != kPanelOption && curMode != kPanelQuit &&
-			 curMode != kPanelLoad && curMode != kPanelSave &&
-			 curMode != kPanelProtect)) {
+		if (_vm->_interface->getFadeMode() != kFadeOut) {
 			// Display scene background
-			if (_fullRefresh) {
-				if (!(_flags & RF_DISABLE_ACTORS) || _vm->getGameType() == GType_ITE)
-					_vm->_scene->draw();
-			}
+			if (!(_flags & RF_DISABLE_ACTORS) || _vm->getGameType() == GType_ITE)
+				_vm->_scene->draw();
 
 			if (_vm->_puzzle->isActive()) {
 				_vm->_puzzle->movePiece(mousePoint);
@@ -211,14 +204,22 @@
 }
 
 void Render::addDirtyRect(Common::Rect rect) {
-	// Check if the new rectangle is contained within another in the list
- 	Common::List<Common::Rect>::const_iterator it;
- 	for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
-		if (it->contains(rect))
-			return;
+	// Clip rectangle
+	int x1 = MAX<int>(rect.left, 0);
+	int y1 = MAX<int>(rect.top, 0);
+	int x2 = MIN<int>(rect.width(), _backGroundSurface.w);
+	int y2 = MIN<int>(rect.height(), _backGroundSurface.h);
+	if (x2 > x1 && y2 > y1) {
+		Common::Rect rectClipped(x1, y1, x2, y2);
+		// Check if the new rectangle is contained within another in the list
+ 		Common::List<Common::Rect>::const_iterator it;
+ 		for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+			if (it->contains(rectClipped))
+				return;
+		}
+
+		_dirtyRects.push_back(rectClipped);
 	}
-
-	_dirtyRects.push_back(rect);
 }
 
 void Render::restoreChangedRects() {
@@ -232,14 +233,14 @@
 }
 
 void Render::drawDirtyRects() {
-	if (_fullRefresh) {
-		_system->copyRectToScreen(_vm->_gfx->getBackBufferPixels(), _vm->_gfx->getBackBufferWidth(), 0, 0,
-								  _vm->_gfx->getBackBufferWidth(), _vm->_gfx->getBackBufferHeight());
-	} else {
+	if (!_fullRefresh) {
  	 	Common::List<Common::Rect>::const_iterator it;
  	 	for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
 			g_system->copyRectToScreen(_vm->_gfx->getBackBufferPixels(), _backGroundSurface.w, it->left, it->top, it->width(), it->height());
 		}
+	} else {
+		_system->copyRectToScreen(_vm->_gfx->getBackBufferPixels(), _vm->_gfx->getBackBufferWidth(), 0, 0,
+								  _vm->_gfx->getBackBufferWidth(), _vm->_gfx->getBackBufferHeight());
 	}
 }
 


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