From 024d1305a21e61e431ecdc9cdcda6fada2dd08bb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 18 Apr 2016 10:36:09 +0200 Subject: WAGE: Manage window redraws in the WM --- engines/wage/gui.cpp | 4 ++++ engines/wage/macwindow.cpp | 7 ++++++- engines/wage/macwindow.h | 5 ++++- engines/wage/macwindowmanager.cpp | 18 +++++++++++++++--- engines/wage/macwindowmanager.h | 6 +++++- 5 files changed, 34 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 436d17c56f..6cb762851d 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -154,6 +154,8 @@ Gui::Gui(WageEngine *engine) { _consoleFullRedraw = true; _screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _wm.setScreen(&_screen); + _scrollPos = 0; _consoleLineHeight = 8; // Dummy value which makes sense _consoleNumLines = 24; // Dummy value @@ -287,6 +289,7 @@ void Gui::drawScene() { w->setTitle(_scene->_name); _scene->paint(w->getSurface(), 0, 0); w->draw(&_screen); + w->setDirty(true); g_system->copyRectToScreen(_screen.getBasePtr(_scene->_designBounds->left - 2, _scene->_designBounds->top - 2), _screen.pitch, _scene->_designBounds->left - 2, _scene->_designBounds->top - 2, _scene->_designBounds->width(), _scene->_designBounds->height()); @@ -317,6 +320,7 @@ void Gui::drawConsole() { renderConsole(w->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2, _scene->_textBounds->width() - kBorderWidth, _scene->_textBounds->height() - kBorderWidth)); w->draw(&_screen); + w->setDirty(true); g_system->copyRectToScreen(_screen.getBasePtr(_scene->_textBounds->left - 2, _scene->_textBounds->top - 2), _screen.pitch, _scene->_textBounds->left - 2, _scene->_textBounds->top - 2, _scene->_textBounds->width(), _scene->_textBounds->height()); diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 41d842286a..83907400c4 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -97,7 +97,10 @@ void MacWindow::setDimensions(const Common::Rect &r) { _dims.moveTo(r.left, r.top); } -void MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) { +bool MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) { + if (!_borderIsDirty && !_contentIsDirty && !forceRedraw) + return false; + if (_borderIsDirty || forceRedraw) drawBorder(); @@ -106,6 +109,8 @@ void MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) { _composeSurface.transBlitFrom(_borderSurface, kColorGreen); g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2); + + return true; } const Graphics::Font *MacWindow::getTitleFont() { diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index e635528c23..51bc9dfe16 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -75,12 +75,14 @@ public: void move(int x, int y); void resize(int w, int h); void setDimensions(const Common::Rect &r); - void draw(Graphics::ManagedSurface *g, bool forceRedraw = false); + const Common::Rect &getDimensions() { return _dims; } + bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false); void setActive(bool active); Graphics::ManagedSurface *getSurface() { return &_surface; } void setTitle(Common::String &title) { _title = title; } void setHighlight(BorderHighlight highlightedPart) { _highlightedPart = highlightedPart; } void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; } + void setDirty(bool dirty) { _contentIsDirty = dirty; } private: void drawBorder(); @@ -96,6 +98,7 @@ private: bool _scrollable; bool _active; bool _borderIsDirty; + bool _contentIsDirty; BorderHighlight _highlightedPart; float _scrollPos, _scrollSize; diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 72f01fac67..4f5f8b1abb 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -47,6 +47,7 @@ #include "common/list.h" #include "common/array.h" +#include "common/system.h" #include "graphics/managed_surface.h" @@ -57,6 +58,7 @@ namespace Wage { MacWindowManager::MacWindowManager() { + _screen = 0; _lastId = 0; _activeWindow = -1; } @@ -94,9 +96,19 @@ void MacWindowManager::setActive(int id) { _fullRefresh = true; } -void MacWindowManager::draw(Graphics::ManagedSurface *g) { - for (Common::List::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) - (*it)->draw(g, _fullRefresh); +void MacWindowManager::draw() { + assert(_screen); + + for (Common::List::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) { + MacWindow *w = *it; + if (w->draw(_screen, _fullRefresh)) { + w->setDirty(false); + + g_system->copyRectToScreen(_screen->getBasePtr(w->getDimensions().left - 2, w->getDimensions().top - 2), + _screen->pitch, w->getDimensions().left - 2, w->getDimensions().top - 2, + w->getDimensions().width(), w->getDimensions().height()); + } + } _fullRefresh = false; } diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index 1c8ed02a85..ae4f356d12 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -57,14 +57,18 @@ public: MacWindowManager(); ~MacWindowManager(); + void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; } + int add(bool scrollable); void setActive(int id); - void draw(Graphics::ManagedSurface *g); + void draw(); MacWindow *getWindow(int id) { return _windows[id]; } private: + Graphics::ManagedSurface *_screen; + Common::List _windowStack; Common::Array _windows; -- cgit v1.2.3