diff options
author | Willem Jan Palenstijn | 2013-08-24 12:13:04 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-09-26 02:17:26 +0200 |
commit | b27ac796d84670d77bff73276de5d6f8affb0323 (patch) | |
tree | d65479307cc0945a13fd20b5e4a3d72517e234a0 /engines/wintermute/base/gfx/osystem | |
parent | dbbf95ca50a9ebad1d6741c672192a9c93107e9e (diff) | |
download | scummvm-rg350-b27ac796d84670d77bff73276de5d6f8affb0323.tar.gz scummvm-rg350-b27ac796d84670d77bff73276de5d6f8affb0323.tar.bz2 scummvm-rg350-b27ac796d84670d77bff73276de5d6f8affb0323.zip |
WINTERMUTE: Remove unnecessary re-iteration
Diffstat (limited to 'engines/wintermute/base/gfx/osystem')
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 24 | ||||
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.h | 12 |
2 files changed, 21 insertions, 15 deletions
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 3a78437f35..d7a8378ae2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -295,7 +295,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (_disableDirtyRects) { drawFromSurface(compareTicket); } else { - drawFromTicket(compareTicket); + drawFromQueuedTicket(it); _previousTicket = compareTicket; } return; @@ -374,7 +374,8 @@ void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { renderTicket->_wantsDraw = true; // A new item always has _drawNum == 0 - if (renderTicket->_drawNum == 0) { + assert(renderTicket->_drawNum == 0); + { ++_lastFrameIter; // In-order if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { @@ -410,7 +411,14 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); _lastAddedTicket = pos; } - } else { + } +} + +void BaseRenderOSystem::drawFromQueuedTicket(const RenderQueueIterator &ticket) { + RenderTicket *renderTicket = *ticket; + renderTicket->_wantsDraw = true; + assert(renderTicket->_drawNum != 0); + { ++_lastFrameIter; // Was drawn last round, still in the same order if (_drawNum == renderTicket->_drawNum) { @@ -423,15 +431,7 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { --_lastFrameIter; assert(_drawNum < renderTicket->_drawNum); // Remove the ticket from the list - RenderQueueIterator it = _renderQueue.begin(); - while (it != _renderQueue.end()) { - if ((*it) == renderTicket) { - it = _renderQueue.erase(it); - break; - } else { - ++it; - } - } + RenderQueueIterator it = _renderQueue.erase(ticket); if (it != _renderQueue.end()) { // Decreement the following tickets. for (; it != _renderQueue.end(); ++it) { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 3de696fb81..fd5d33622e 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -62,6 +62,8 @@ public: BaseRenderOSystem(BaseGame *inGame); ~BaseRenderOSystem(); + typedef Common::List<RenderTicket *>::iterator RenderQueueIterator; + Common::String getName() const; bool initRenderer(int width, int height, bool windowed) override; @@ -79,11 +81,16 @@ public: void invalidateTicket(RenderTicket *renderTicket); void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); /** - * Insert a ticket into the queue, adding a dirty rect if it's - * new, or out-of-order from last draw from the ticket. + * Insert a new ticket into the queue, adding a dirty rect * param renderTicket the ticket to be added. */ void drawFromTicket(RenderTicket *renderTicket); + /** + * Re-insert an existing ticket into the queue, adding a dirty rect + * out-of-order from last draw from the ticket. + * param ticket iterator pointing to the ticket to be added. + */ + void drawFromQueuedTicket(const RenderQueueIterator &ticket); bool setViewport(int left, int top, int right, int bottom) override; bool setViewport(Rect32 *rect) override { return BaseRenderer::setViewport(rect); } @@ -120,7 +127,6 @@ private: void drawFromSurface(RenderTicket *ticket); // Dirty-rects: void drawFromSurface(RenderTicket *ticket, Common::Rect *dstRect, Common::Rect *clipRect); - typedef Common::List<RenderTicket *>::iterator RenderQueueIterator; Common::Rect *_dirtyRect; Common::List<RenderTicket *> _renderQueue; RenderQueueIterator _lastAddedTicket; |