aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-08-24 12:24:12 +0200
committerWillem Jan Palenstijn2013-09-26 02:17:22 +0200
commitdbbf95ca50a9ebad1d6741c672192a9c93107e9e (patch)
tree85cf4191a3a4569b1a53b77889d95b5d021692e7 /engines/wintermute/base
parentc6220a9cd1b5400242773dcb89dfbbc2a98453bd (diff)
downloadscummvm-rg350-dbbf95ca50a9ebad1d6741c672192a9c93107e9e.tar.gz
scummvm-rg350-dbbf95ca50a9ebad1d6741c672192a9c93107e9e.tar.bz2
scummvm-rg350-dbbf95ca50a9ebad1d6741c672192a9c93107e9e.zip
WINTERMUTE: Mirror _drawNum with an iterator
Diffstat (limited to 'engines/wintermute/base')
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp21
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 96bc3186b6..3a78437f35 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -52,6 +52,7 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) {
_renderSurface = new Graphics::Surface();
_blankSurface = new Graphics::Surface();
_drawNum = 1;
+ _lastFrameIter = _renderQueue.end();
_needsFlip = true;
_skipThisFrame = false;
_previousTicket = nullptr;
@@ -159,6 +160,7 @@ bool BaseRenderOSystem::flip() {
g_system->updateScreen();
_needsFlip = false;
_drawNum = 1;
+ _lastFrameIter = _renderQueue.end();
addDirtyRect(_renderRect);
return true;
}
@@ -189,6 +191,7 @@ bool BaseRenderOSystem::flip() {
_needsFlip = false;
}
_drawNum = 1;
+ _lastFrameIter = _renderQueue.end();
return STATUS_OK;
}
@@ -372,10 +375,15 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) {
renderTicket->_wantsDraw = true;
// A new item always has _drawNum == 0
if (renderTicket->_drawNum == 0) {
+ ++_lastFrameIter;
// In-order
if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) {
+ assert(_renderQueue.empty() || _lastFrameIter == _renderQueue.end());
+ _lastFrameIter--;
renderTicket->_drawNum = _drawNum++;
_renderQueue.push_back(renderTicket);
+ ++_lastFrameIter;
+ assert(*_lastFrameIter == renderTicket);
addDirtyRect(renderTicket->_dstRect);
++_lastAddedTicket;
} else {
@@ -386,23 +394,34 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) {
break;
}
}
+ assert(!_renderQueue.empty() && _lastFrameIter != _renderQueue.end());
+ assert(pos == _lastFrameIter);
_renderQueue.insert(pos, renderTicket);
renderTicket->_drawNum = _drawNum++;
+ --_lastFrameIter;
+ assert(*_lastFrameIter == renderTicket);
// Increment the following tickets, so they still are in line
RenderQueueIterator it;
for (it = pos; it != _renderQueue.end(); ++it) {
(*it)->_drawNum++;
+ assert((*it)->_wantsDraw == false);
(*it)->_wantsDraw = false;
}
addDirtyRect(renderTicket->_dstRect);
_lastAddedTicket = pos;
}
} else {
+ ++_lastFrameIter;
// Was drawn last round, still in the same order
if (_drawNum == renderTicket->_drawNum) {
+ assert((*_lastFrameIter)->_drawNum == _drawNum);
+ assert(*_lastFrameIter == renderTicket);
_drawNum++;
++_lastAddedTicket;
} else {
+ assert(*_lastFrameIter != renderTicket);
+ --_lastFrameIter;
+ assert(_drawNum < renderTicket->_drawNum);
// Remove the ticket from the list
RenderQueueIterator it = _renderQueue.begin();
while (it != _renderQueue.end()) {
@@ -470,6 +489,7 @@ void BaseRenderOSystem::drawTickets() {
// Apply the clear-color to the dirty rect.
_renderSurface->fillRect(*_dirtyRect, _clearColor);
_drawNum = 1;
+ _lastFrameIter = _renderQueue.end();
for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) {
RenderTicket *ticket = *it;
assert(ticket->_drawNum == _drawNum);
@@ -641,6 +661,7 @@ void BaseRenderOSystem::endSaveLoad() {
// so just skip this single frame.
_skipThisFrame = true;
_drawNum = 1;
+ _lastFrameIter = _renderQueue.end();
_renderSurface->fillRect(Common::Rect(0, 0, _renderSurface->h, _renderSurface->w), _renderSurface->format.ARGBToColor(255, 0, 0, 0));
g_system->copyRectToScreen((byte *)_renderSurface->getPixels(), _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h);
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index dd3cc6140e..3de696fb81 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -128,6 +128,7 @@ private:
bool _needsFlip;
uint32 _drawNum; ///< The global number of the current draw-operation.
+ RenderQueueIterator _lastFrameIter;
Common::Rect _renderRect;
Graphics::Surface *_renderSurface;
Graphics::Surface *_blankSurface;