[Scummvm-cvs-logs] SF.net SVN: scummvm:[33097] scummvm/branches/gsoc2008-gui/gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Jul 18 18:44:42 CEST 2008


Revision: 33097
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33097&view=rev
Author:   Tanoku
Date:     2008-07-18 16:44:42 +0000 (Fri, 18 Jul 2008)

Log Message:
-----------
Background restoration in rendering pipeline. WIP.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
    scummvm/branches/gsoc2008-gui/gui/newgui.cpp
    scummvm/branches/gsoc2008-gui/gui/theme.h

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-18 14:01:53 UTC (rev 33096)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-18 16:44:42 UTC (rev 33097)
@@ -77,7 +77,7 @@
 ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) : 
 	_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled), 
 	_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false), 
-	_themeOk(false), _enabled(false), _dialogCount(0), _cachedDialog(0) {
+	_themeOk(false), _enabled(false), _buffering(false) {
 	_system = g_system;
 	_parser = new ThemeParser(this);
 
@@ -214,9 +214,16 @@
 
 	_widgets[data_id] = new WidgetDrawData;
 	_widgets[data_id]->_cached = cached;
+	_widgets[data_id]->_buffer = false;
 	_widgets[data_id]->_surfaceCache = 0;
 	_widgets[data_id]->_hasText = false;
 
+	// TODO: set this only when needed
+	// possibly add an option to the parser to set this
+	// on each drawdata...
+	if (data_id >= kDDMainDialogBackground && data_id <= kDDWidgetBackgroundSlider)
+		_widgets[data_id]->_buffer = true;
+
 	return true;
 }
 
@@ -303,7 +310,11 @@
 	extendedRect.right += _widgets[type]->_backgroundOffset;
 	extendedRect.bottom += _widgets[type]->_backgroundOffset;
 
-	restoreBackground(extendedRect);
+	if (_buffering && _widgets[type]->_buffer)
+		_vectorRenderer->setSurface(_backBuffer);
+	else
+		restoreBackground(extendedRect);
+
 	addDirtyRect(extendedRect);
 		
 	if (isWidgetCached(type, r)) {
@@ -313,6 +324,11 @@
 			 step != _widgets[type]->_steps.end(); ++step)
 			_vectorRenderer->drawStep(r, *step, dynamicData);
 	}
+
+	if (_buffering && _widgets[type]->_buffer) {
+		_vectorRenderer->setSurface(_screen);
+		memcpy(_screen->pixels, _backBuffer->pixels, _screen->w * _screen->h * _screen->bytesPerPixel);
+	}
 }
 
 void ThemeRenderer::drawDDText(DrawData type, const Common::Rect &r, const Common::String &text) {
@@ -336,7 +352,7 @@
 }
 
 void ThemeRenderer::restoreBackground(Common::Rect r, bool special) {
-/*	const OverlayColor *src = (const OverlayColor*)_backBuffer->getBasePtr(r.left, r.top);
+	const OverlayColor *src = (const OverlayColor*)_backBuffer->getBasePtr(r.left, r.top);
 	OverlayColor *dst = (OverlayColor*)_screen->getBasePtr(r.left, r.top);
 
 	int h = r.height();
@@ -345,10 +361,10 @@
 		memcpy(dst, src, w * sizeof(OverlayColor));
 		src += _backBuffer->w;
 		dst += _screen->w;
-	}*/
+	}
 
-	debugWidgetPosition("", r);
-	printf(" BG_RESTORE ");
+//	debugWidgetPosition("", r);
+//	printf(" BG_RESTORE ");
 }
 
 void ThemeRenderer::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
@@ -537,24 +553,11 @@
 	_dirtyScreen.clear();
 }
 
-void ThemeRenderer::openDialog(bool top) {
-	if (_dialogCount++ == 0)
-		return;
+void ThemeRenderer::openDialog(bool doBuffer) {
+	if (doBuffer)
+		_buffering = true;
 
-	_cachedDialog = _dialogCount - 1;
 	memcpy(_backBuffer->pixels, _screen->pixels, _screen->w * _screen->h * _screen->bytesPerPixel);
 }
 
-bool ThemeRenderer::closeDialog() {
-	assert(_dialogCount);
-
-	_dialogCount--;
-
-	if (_dialogCount != _cachedDialog)
-		return false;
-
-	memcpy(_screen->pixels, _backBuffer->pixels, _screen->w * _screen->h * _screen->bytesPerPixel);
-	return true;
-}
-
 } // end of namespace GUI.

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-18 14:01:53 UTC (rev 33096)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-18 16:44:42 UTC (rev 33097)
@@ -56,6 +56,7 @@
 
 	/** Sets whether the widget is cached beforehand. */
 	bool _cached;
+	bool _buffer;
 
 	/** Texture where the cached widget is stored. */
 	Graphics::Surface *_surfaceCache;
@@ -156,17 +157,12 @@
 	void enable();
 	void disable();
 
-	void closeAllDialogs() {
-		_dialogCount = 0;
-		_cachedDialog = 0;
-	}
+	void closeAllDialogs() {}
 	
-
-	void updateScreen(); //{}
+	void updateScreen();
 	void resetDrawArea() {}
 
-	void openDialog(bool top);// {}
-	bool closeDialog();// {}
+	void openDialog(bool top);
 
 	/** Font management */
 	const Graphics::Font *getFont(FontStyle font) const { return _font; }
@@ -220,6 +216,10 @@
 	bool loadTheme(Common::String themeName);
 	void setGraphicsMode(GraphicsMode mode);
 
+	void finishBuffering() {
+		_buffering = false;
+	}
+
 protected:
 	template<typename PixelType> void screenInit(bool backBuffer);
 
@@ -310,8 +310,7 @@
 
 	Graphics::Surface *_screen;
 	Graphics::Surface *_backBuffer;
-	uint32 _dialogCount;
-	uint32 _cachedDialog;
+	bool _buffering;
 
 	int _bytesPerPixel;
 	GraphicsMode _graphicsMode;

Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-07-18 14:01:53 UTC (rev 33096)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-07-18 16:44:42 UTC (rev 33097)
@@ -192,37 +192,28 @@
 
 	switch (_redrawStatus) {
 		case kRedrawCloseDialog:
-			printf("Dialog closed!\n");
-			if (_theme->closeDialog())
-				break;
-
 		case kRedrawFull:
 			_theme->clearAll();
 			_theme->closeAllDialogs();
 
 			for (i = 0; i < _dialogStack.size(); i++) {
-				if ((i == _dialogStack.size() - 2) && !_dialogStack[i + 1]->dimsInactive())
-					_theme->openDialog(true);
-				else if ((i != (_dialogStack.size() - 1)) || !_dialogStack[i]->dimsInactive())
-					_theme->openDialog(false);
-				else
-					_theme->openDialog(true);
-
+				_theme->openDialog(true);
 				_dialogStack[i]->drawDialog();
 			}
 			break;
 
-		case kRedrawTopDialog:
-			_dialogStack.top()->drawDialog();
-			printf("Top dialog redraw!\n");
-			break;
-
 		case kRedrawOpenDialog:
 			_theme->openDialog(true);
 			_dialogStack.top()->drawDialog();
+			_theme->finishBuffering();
 			printf("Dialog opened!\n");
 			break;
 
+		case kRedrawTopDialog:
+			_dialogStack.top()->drawDialog();
+			printf("Top dialog redraw!\n");
+			break;
+
 		default:
 			return;
 	}

Modified: scummvm/branches/gsoc2008-gui/gui/theme.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/theme.h	2008-07-18 14:01:53 UTC (rev 33096)
+++ scummvm/branches/gsoc2008-gui/gui/theme.h	2008-07-18 16:44:42 UTC (rev 33097)
@@ -251,6 +251,7 @@
 	 *          the dialog stack from scratch.
 	 */
 	virtual bool closeDialog() { return false; }
+	virtual void finishBuffering() {}
 
 	/**
 	 * Clear the complete GUI screen.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list