[Scummvm-cvs-logs] scummvm master -> 024d1305a21e61e431ecdc9cdcda6fada2dd08bb

sev- sev at scummvm.org
Mon Apr 18 13:12:33 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
024d1305a2 WAGE: Manage window redraws in the WM


Commit: 024d1305a21e61e431ecdc9cdcda6fada2dd08bb
    https://github.com/scummvm/scummvm/commit/024d1305a21e61e431ecdc9cdcda6fada2dd08bb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-18T13:11:48+02:00

Commit Message:
WAGE: Manage window redraws in the WM

Changed paths:
    engines/wage/gui.cpp
    engines/wage/macwindow.cpp
    engines/wage/macwindow.h
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 436d17c..6cb7628 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 41d8422..8390740 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 e635528..51bc9df 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 72f01fa..4f5f8b1 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<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++)
-        (*it)->draw(g, _fullRefresh);
+void MacWindowManager::draw() {
+    assert(_screen);
+
+    for (Common::List<MacWindow *>::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 1c8ed02..ae4f356 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<MacWindow *> _windowStack;
 	Common::Array<MacWindow *> _windows;
 






More information about the Scummvm-git-logs mailing list