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 /gui/ThemeEngine.cpp | |
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
Diffstat (limited to 'gui/ThemeEngine.cpp')
-rw-r--r-- | gui/ThemeEngine.cpp | 32 |
1 files changed, 28 insertions, 4 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); } |