diff options
author | Max Horn | 2009-04-09 17:07:38 +0000 |
---|---|---|
committer | Max Horn | 2009-04-09 17:07:38 +0000 |
commit | 9d4c917f59bae0fc072d11c4b6b2c7e42ea9295b (patch) | |
tree | d5e19d0997c713d50c0783c6e12ba79242319d94 | |
parent | a2b5829101e256d5dfd1dc304ffc7d89b83c3e99 (diff) | |
download | scummvm-rg350-9d4c917f59bae0fc072d11c4b6b2c7e42ea9295b.tar.gz scummvm-rg350-9d4c917f59bae0fc072d11c4b6b2c7e42ea9295b.tar.bz2 scummvm-rg350-9d4c917f59bae0fc072d11c4b6b2c7e42ea9295b.zip |
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
svn-id: r39909
-rw-r--r-- | gui/ThemeEngine.cpp | 32 | ||||
-rw-r--r-- | gui/ThemeEngine.h | 16 |
2 files changed, 33 insertions, 15 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 5e160d6f1b..5437d56d0e 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1103,16 +1103,40 @@ void ThemeEngine::updateScreen() { 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); } diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 3749b65b53..a7bec4d9a3 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -311,19 +311,13 @@ public: /** - * 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); /** |