[Scummvm-cvs-logs] SF.net SVN: scummvm:[39909] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Apr 9 19:07:38 CEST 2009


Revision: 39909
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39909&view=rev
Author:   fingolfin
Date:     2009-04-09 17:07:38 +0000 (Thu, 09 Apr 2009)

Log Message:
-----------
GUI: Rewrote the dirty rect handling code. Previously it was possible that the dirty rect list got clobbered by many rects containg other rects in the list. Also got rid of some obsolete params to addDirtyRect as well as the obsolete return value

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeEngine.cpp
    scummvm/trunk/gui/ThemeEngine.h

Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp	2009-04-09 17:07:24 UTC (rev 39908)
+++ scummvm/trunk/gui/ThemeEngine.cpp	2009-04-09 17:07:38 UTC (rev 39909)
@@ -1103,16 +1103,40 @@
 	renderDirtyScreen();
 }
 
+void ThemeEngine::addDirtyRect(Common::Rect r) {
+	// Clip the rect to screen coords
+	r.clip(_screen.w, _screen.h);
+
+	// If it is empty after clipping, we are done
+	if (r.isEmpty())
+		return;
+
+	// Check if the new rectangle is contained within another in the list
+	Common::List<Common::Rect>::iterator it;
+	for (it = _dirtyScreen.begin(); it != _dirtyScreen.end(); ) {
+		// If we find a rectangle which fully contains the new one,
+		// we can abort the search.
+		if (it->contains(r))
+			return;
+
+		// Conversely, if we find rectangles which are contained in
+		// the new one, we can remove them
+		if (r.contains(*it))
+			it = _dirtyScreen.erase(it);
+		else;
+			++it;
+	}
+
+	// If we got here, we can safely add r to the list of dirty rects.
+	_dirtyScreen.push_back(r);
+}
+
 void ThemeEngine::renderDirtyScreen() {
 	if (_dirtyScreen.empty())
 		return;
 
 	Common::List<Common::Rect>::iterator i, j;
 	for (i = _dirtyScreen.begin(); i != _dirtyScreen.end(); ++i) {
-		for (j = i; j != _dirtyScreen.end(); ++j)
-			if (j != i && i->contains(*j))
-				j = _dirtyScreen.reverse_erase(j);
-
 		_vectorRenderer->copyFrame(_system, *i);
 	}
 

Modified: scummvm/trunk/gui/ThemeEngine.h
===================================================================
--- scummvm/trunk/gui/ThemeEngine.h	2009-04-09 17:07:24 UTC (rev 39908)
+++ scummvm/trunk/gui/ThemeEngine.h	2009-04-09 17:07:38 UTC (rev 39909)
@@ -311,19 +311,13 @@
 
 
 	/**
-	 *	Actual implementation of a Dirty Rect drawing routine.
-	 *	Dirty rectangles are queued on a list and are later merged/calculated
-	 *	before the actual drawing.
+	 * Actual implementation of a dirty rect handling.
+	 * Dirty rectangles are queued on a list and are later used for the
+	 * actual drawing.
 	 *
-	 *	@param r Area of the dirty rect.
-	 *	@param backup Deprecated.
-	 *	@param special Deprecated.
+	 * @param r Area of the dirty rect.
 	 */
-	bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
-		r.clip(_screen.w, _screen.h);
-		_dirtyScreen.push_back(r);
-		return true;
-	}
+	void addDirtyRect(Common::Rect r);
 
 
 	/**


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