diff options
author | Einar Johan Trøan Sømåen | 2013-01-24 14:33:08 +0100 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2013-01-24 15:11:28 +0100 |
commit | 519821b53b16f263cf911a125ff846a9d8cd22d9 (patch) | |
tree | 8b7fe8b8ac16213cceb988911c75b9bafccfeb29 /engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | |
parent | 0143a5d938fc314d19f2ddcac2192a49a790cb6a (diff) | |
download | scummvm-rg350-519821b53b16f263cf911a125ff846a9d8cd22d9.tar.gz scummvm-rg350-519821b53b16f263cf911a125ff846a9d8cd22d9.tar.bz2 scummvm-rg350-519821b53b16f263cf911a125ff846a9d8cd22d9.zip |
WINTERMUTE: Further improve UITiledImage-drawing.
Diffstat (limited to 'engines/wintermute/base/gfx/osystem/base_render_osystem.cpp')
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index d1884a5a1b..4030ea0659 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -54,6 +54,7 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _spriteBatch = false; _batchNum = 0; _skipThisFrame = false; + _previousTicket = NULL; _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; @@ -279,8 +280,9 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (owner) { // Fade-tickets are owner-less RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); compare._batchNum = _batchNum; - if (_spriteBatch) + if (_spriteBatch) { _batchNum++; + } compare._colorMod = _colorMod; RenderQueueIterator it; // Avoid calling end() and operator* every time, when potentially going through @@ -295,6 +297,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S drawFromSurface(compareTicket); } else { drawFromTicket(compareTicket); + _previousTicket = compareTicket; } return; } @@ -305,12 +308,53 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (!_disableDirtyRects) { drawFromTicket(ticket); drawFromSurface(ticket); + _previousTicket = ticket; } else { ticket->_wantsDraw = true; _renderQueue.push_back(ticket); } } +void BaseRenderOSystem::repeatLastDraw(int offsetX, int offsetY, int numTimesX, int numTimesY) { + if (_previousTicket && _lastAddedTicket != _renderQueue.end()) { + RenderTicket *origTicket = _previousTicket; + + // Make sure drawSurface WILL start from the correct _lastAddedTicket + if (*_lastAddedTicket != origTicket) { + RenderQueueIterator it; + RenderQueueIterator endIterator = _renderQueue.end(); + for (it = _renderQueue.begin(); it != endIterator; ++it) { + if ((*it) == _previousTicket) { + _lastAddedTicket = it; + break; + } + } + } + Common::Rect srcRect(0, 0, 0, 0); + srcRect.setWidth(origTicket->getSrcRect()->width()); + srcRect.setHeight(origTicket->getSrcRect()->height()); + + Common::Rect dstRect = origTicket->_dstRect; + int initLeft = dstRect.left; + int initRight = dstRect.right; + + for (int i = 0; i < numTimesY; i++) { + if (i == 0) { + dstRect.translate(offsetX, 0); + } + for (int j = (i == 0 ? 1 : 0); j < numTimesX; j++) { + drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, false, false); + dstRect.translate(offsetX, 0); + } + dstRect.left = initLeft; + dstRect.right = initRight; + dstRect.translate(0, offsetY); + } + } else { + error("Repeat-draw failed (did you forget to draw something before this?)"); + } +} + void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); renderTicket->_isValid = false; @@ -359,6 +403,7 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { // Was drawn last round, still in the same order if (_drawNum == renderTicket->_drawNum) { _drawNum++; + ++_lastAddedTicket; } else { // Remove the ticket from the list RenderQueueIterator it = _renderQueue.begin(); @@ -379,7 +424,6 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { // Is not in order, so readd it as if it was a new ticket renderTicket->_drawNum = 0; drawFromTicket(renderTicket); - _lastAddedTicket = it; } } } |