From 85e7d2d9a99a0b7663881c6b5e1ce066d2efc49c Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 26 Sep 2011 00:17:21 -0400 Subject: PEGASUS: Update the GraphicsManager a bit - Only update the screen if we drew something to it, not if a dirty rect was present. - Add ability to clear the screen. --- engines/pegasus/graphics.cpp | 22 ++++++++++++++++------ engines/pegasus/graphics.h | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp index e37150e75a..05217fabcd 100644 --- a/engines/pegasus/graphics.cpp +++ b/engines/pegasus/graphics.cpp @@ -44,6 +44,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) { _firstDisplayElement = _lastDisplayElement = 0; _workArea.create(640, 480, _vm->_system->getScreenFormat()); _lastMousePosition = Common::Point(-1, -1); + _modifiedScreen = false; } GraphicsManager::~GraphicsManager() { @@ -162,22 +163,31 @@ void GraphicsManager::updateDisplay() { // TODO: Better logic; it does a bit more work than it probably needs to // but it should work fine for now. - if (bounds.intersects(_dirtyRect) && runner->validToDraw(_backLayer, _frontLayer)) + if (bounds.intersects(_dirtyRect) && runner->validToDraw(_backLayer, _frontLayer)) { runner->draw(bounds); + screenDirty = true; + } } // Copy only the dirty rect to the screen - g_system->copyRectToScreen((byte *)_workArea.getBasePtr(_dirtyRect.left, _dirtyRect.top), _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height()); - - // Mark the screen as dirty - screenDirty = true; + if (screenDirty) + g_system->copyRectToScreen((byte *)_workArea.getBasePtr(_dirtyRect.left, _dirtyRect.top), _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height()); // Clear the dirty rect _dirtyRect = Common::Rect(); } - if (screenDirty) + if (screenDirty || _modifiedScreen) g_system->updateScreen(); + + _modifiedScreen = false; +} + +void GraphicsManager::clearScreen() { + Graphics::Surface *screen = g_system->lockScreen(); + screen->fillRect(Common::Rect(0, 0, 640, 480), g_system->getScreenFormat().RGBToColor(0, 0, 0)); + g_system->unlockScreen(); + _modifiedScreen = true; } } // End of namespace Pegasus diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h index ebaaeb2c6c..90d0f33a73 100644 --- a/engines/pegasus/graphics.h +++ b/engines/pegasus/graphics.h @@ -52,10 +52,12 @@ public: tDisplayOrder getFrontOfActiveLayer() const { return _frontLayer; } void updateDisplay(); Graphics::Surface *getWorkArea() { return &_workArea; } + void clearScreen(); private: PegasusEngine *_vm; + bool _modifiedScreen; Common::Rect _dirtyRect; tDisplayOrder _backLayer, _frontLayer; DisplayElement *_firstDisplayElement, *_lastDisplayElement; -- cgit v1.2.3