diff options
-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); /** |