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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Thu Jul 3 12:26:55 CEST 2008


Revision: 32882
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32882&view=rev
Author:   Tanoku
Date:     2008-07-03 03:26:55 -0700 (Thu, 03 Jul 2008)

Log Message:
-----------
Rendering pipeline. WIP.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/base/main.cpp
    scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
    scummvm/branches/gsoc2008-gui/common/xmlparser.h
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
    scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
    scummvm/branches/gsoc2008-gui/gui/newgui.cpp

Modified: scummvm/branches/gsoc2008-gui/base/main.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/base/main.cpp	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/base/main.cpp	2008-07-03 10:26:55 UTC (rev 32882)
@@ -70,7 +70,7 @@
 	// Clear the main screen
 	system.clearScreen();
 
-	GUI::ThemeRenderer *test = new GUI::ThemeRenderer;
+//	GUI::ThemeRenderer *test = new GUI::ThemeRenderer("modern", GUI::ThemeRenderer::kGfxAntialias16bit);
 
 #if defined LOL
 

Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-07-03 10:26:55 UTC (rev 32882)
@@ -134,6 +134,8 @@
 	if (_text.ready() == false)
 		return parserError("XML stream not ready for reading.");
 
+	cleanup();
+
 	bool activeClosure = false;
 	bool selfClosure = false;
 

Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.h	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.h	2008-07-03 10:26:55 UTC (rev 32882)
@@ -332,6 +332,14 @@
 		return (*key == 0);
 	}
 
+	/**
+	 * Internal state cleanup. Overload this if your parser needs
+	 * to clean itself up before doing a second parse.
+	 * E.g. the Theme Parser cleans the color palette after parsing
+	 * a theme.
+	 */
+	virtual void cleanup() {}
+
 	int _pos; /** Current position on the XML buffer. */
 	XMLStream _text; /** Buffer with the text being parsed */
 	Common::String _fileName;

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-03 10:26:55 UTC (rev 32882)
@@ -406,7 +406,8 @@
 	 *
 	 * @param sys Pointer to the global System class
 	 */
-	virtual void copyFrame(OSystem *sys, Common::Rect &r) = 0;
+	virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0;
+	virtual void copyWholeFrame(OSystem *sys) = 0;
 
 	/**
 	 * Blits a given graphics surface on top of the current drawing surface.
@@ -533,7 +534,7 @@
 	/**
 	 * @see VectorRenderer::copyFrame()
 	 */
-	virtual void copyFrame(OSystem *sys, Common::Rect &r) {
+	virtual void copyFrame(OSystem *sys, const Common::Rect &r) {
 #ifdef OVERLAY_MULTIPLE_DEPTHS // TODO: change OSystem to support templated copyRectToOverlay
 		sys->copyRectToOverlay((const PixelType*)_activeSurface->pixels, 
 			_activeSurface->pitch, r.top, r.left, r.width(), r.height());
@@ -543,6 +544,16 @@
 #endif
 	}
 
+	virtual void copyWholeFrame(OSystem *sys) {
+#ifdef OVERLAY_MULTIPLE_DEPTHS
+		sys->copyRectToOverlay((const PixelType*)_activeSurface->getBasePtr(0, 0),
+		_activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
+#else
+		sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(0, 0),
+		_activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
+#endif
+	}
+
 	/**
 	 * @see VectorRenderer::blitSurface()
 	 */

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-03 10:26:55 UTC (rev 32882)
@@ -58,7 +58,7 @@
 "<layout_info>"
 "</layout_info>";
 
-	if (!parser()->loadBuffer(defaultXML, true))
+	if (!parser()->loadBuffer(defaultXML, false))
 		return false;
 
 	return parser()->parse();

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-03 10:26:55 UTC (rev 32882)
@@ -63,6 +63,15 @@
 	_theme = parent;
 }
 
+void ThemeParser::cleanup() {
+	delete _defaultStepGlobal;
+	delete _defaultStepLocal;
+
+	_defaultStepGlobal = defaultDrawStep();
+	_defaultStepLocal = 0;
+	_palette.clear();
+}
+
 bool ThemeParser::keyCallback(Common::String keyName) {
 	// automatically handle with a function from the hash table.
 	if (!_callbacks.contains(_activeKey.top()->name))

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.h	2008-07-03 10:26:55 UTC (rev 32882)
@@ -329,6 +329,8 @@
 	bool parserCallback_layoutInfo();
 	bool parserCallback_defaultSet();
 
+	void cleanup();
+
 	Graphics::DrawStep *newDrawStep();
 	Graphics::DrawStep *defaultDrawStep();
 	bool parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawstep, bool functionSpecific);

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-03 10:26:55 UTC (rev 32882)
@@ -68,10 +68,9 @@
 	"separator"
 };
 
-ThemeRenderer::ThemeRenderer() : 
+ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) : 
 	_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled), 
-	_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false),
-	_needThemeLoad(false), _enabled(false) {
+	_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false) {
 	_system = g_system;
 	_parser = new ThemeParser(this);
 
@@ -79,10 +78,52 @@
 		_widgets[i] = 0;
 	}
 
-	_graphicsMode = kGfxAntialias16bit; // default GFX mode
-	// TODO: load this from a config file
+	_graphicsMode = mode;
+	setGraphicsMode(_graphicsMode);
+
+	if (isThemeLoadingRequired())
+		loadTheme(themeName);
+
+	_initOk = true;
+	_themeName = themeName;
 }
 
+bool ThemeRenderer::init() {
+	// reset everything and reload the graphics
+	deinit();
+	setGraphicsMode(_graphicsMode);
+
+	if (_screen->pixels) {
+		_initOk = true;
+		clearAll();
+		resetDrawArea();
+	}
+
+	if (isThemeLoadingRequired())
+		loadTheme(_themeName);
+
+	return true;
+}
+
+void ThemeRenderer::deinit() {
+	if (_initOk) {
+		_system->hideOverlay();
+		freeRenderer();
+		freeScreen();
+		unloadTheme();
+		_initOk = false;
+	}
+}
+
+void ThemeRenderer::clearAll() {
+	if (!_initOk)
+		return;
+
+	_vectorRenderer->clearSurface();
+	_vectorRenderer->copyWholeFrame(_system);
+	_system->updateScreen();
+}
+
 template<typename PixelType> 
 void ThemeRenderer::screenInit() {
 	freeScreen();
@@ -92,16 +133,7 @@
 	_system->clearOverlay();
 }
 
-void ThemeRenderer::setGraphicsMode(Graphics_Mode mode) {
-
-	// FIXME: reload theme everytime we change resolution...
-	// what if we change the renderer too?
-	// ...We may need to reload it to re-cache the widget
-	// surfaces
-	if (_system->getOverlayWidth() != _screen->w ||
-		_system->getOverlayHeight() != _screen->h)
-		_needThemeLoad = true;
-
+void ThemeRenderer::setGraphicsMode(GraphicsMode mode) {
 	switch (mode) {
 	case kGfxStandard16bit:
 	case kGfxAntialias16bit:
@@ -133,6 +165,7 @@
 
 	_widgets[data_id] = new WidgetDrawData;
 	_widgets[data_id]->_cached = cached;
+	_widgets[data_id]->_surfaceCache = 0;
 
 	return true;
 }
@@ -158,7 +191,6 @@
 		}
 	}
 
-	_needThemeLoad = false;
 	_themeOk = true;
 	return true;
 }
@@ -182,18 +214,6 @@
 	return parser()->parse();
 }
 
-bool ThemeRenderer::init() {
-	if (!_screen || _system->getOverlayWidth() != _screen->w ||
-		_system->getOverlayHeight() != _screen->h )
-		setGraphicsMode(_graphicsMode);
-
-	if (needThemeReload())
-		loadTheme();
-
-	_initOk = true;
-	return true;
-}
-
 bool ThemeRenderer::isWidgetCached(DrawData type, const Common::Rect &r) {
 	return _widgets[type] && _widgets[type]->_cached &&
 		_widgets[type]->_surfaceCache->w == r.width() && 

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-03 10:26:55 UTC (rev 32882)
@@ -73,7 +73,7 @@
 	static const int kMaxDialogDepth = 4;
 
 public:
-	enum Graphics_Mode {
+	enum GraphicsMode {
 		kGfxDisabled = 0,
 		kGfxStandard16bit,
 		kGfxAntialias16bit
@@ -109,35 +109,32 @@
 		kDrawDataMAX
 	};
 
-	ThemeRenderer();
+	ThemeRenderer(Common::String themeName, GraphicsMode mode);
 
 	~ThemeRenderer() {
 		freeRenderer();
 		freeScreen();
 		unloadTheme();
 		delete _parser;
-
-		while (!_dialogStack.empty())
-			delete _dialogStack.pop();
 	}
 
 	// virtual methods from Theme
 	bool init();
-	void deinit() {}
+	void deinit();
+	void clearAll();
+
 	void refresh() {}
 	void enable() {}
 	void disable() {}
 	void openDialog() {}
 	void closeAllDialogs() {}
-	void clearAll() {}
+	
+
 	void updateScreen() {}
 	void resetDrawArea() {}
+
 	void openDialog(bool top) {}
 
-	virtual bool isDynamic() {
-		return true;
-	}
-
 	/** Font management */
 	const Graphics::Font *getFont(FontStyle font) const { return _font; }
 	int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; }
@@ -185,7 +182,8 @@
 		return _initOk && _themeOk;
 	}
 
-	bool loadTheme() {
+	// REMOVED: theme name is looked up in NewGUI and passed to the constructor
+/*	bool loadTheme() {
 		ConfMan.registerDefault("gui_theme", "default");
 		Common::String style(ConfMan.get("gui_theme"));
 
@@ -193,17 +191,11 @@
 			style = "modern";
 
 		return loadTheme(style);
-	}
+	} */
 
 	bool loadTheme(Common::String themeName);
-	
-	void closeTopDialog() {
-		assert(_dialogStack.empty() == false);
-		delete _dialogStack.pop();
-	}
+	void setGraphicsMode(GraphicsMode mode);
 
-	void setGraphicsMode(Graphics_Mode mode);
-
 protected:
 	template<typename PixelType> void screenInit();
 
@@ -236,16 +228,6 @@
 		}
 	}
 
-	Dialog *getTopDialog() const {
-		if (_dialogStack.empty())
-			return 0;
-		return _dialogStack.top();
-	}
-
-	bool needThemeReload() {
-		return (_themeOk == false || _needThemeLoad == true);
-	}
-
 	bool needRedraw() {
 		return true;
 	}
@@ -275,20 +257,19 @@
 	Graphics::Surface *_screen;
 
 	int _bytesPerPixel;
-	Graphics_Mode _graphicsMode;
+	GraphicsMode _graphicsMode;
 
 	Common::String _fontName;
 	const Graphics::Font *_font;
 
 	WidgetDrawData *_widgets[kDrawDataMAX];
-	Common::FixedStack<Dialog *, kMaxDialogDepth> _dialogStack;
 	Common::Array<Common::Rect> _dirtyScreen;
 
 	bool _initOk;
 	bool _themeOk;
 	bool _caching;
-	bool _needThemeLoad;
-	bool _enabled;
+
+	Common::String _themeName;
 };
 
 } // end of namespace GUI.

Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-07-03 10:25:38 UTC (rev 32881)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-07-03 10:26:55 UTC (rev 32882)
@@ -31,6 +31,7 @@
 #include "gui/eval.h"
 #include "gui/ThemeModern.h"
 #include "gui/ThemeClassic.h"
+#include "gui/ThemeRenderer.h"
 
 #include "common/config-manager.h"
 
@@ -142,7 +143,7 @@
 	delete _theme;
 	_theme = 0;
 
-	if (style.compareToIgnoreCase("classic (builtin)") == 0 ||
+/*	if (style.compareToIgnoreCase("classic (builtin)") == 0 ||
 		style.compareToIgnoreCase("classic") == 0) {
 		_theme = new ThemeClassic(_system, style);
 	} else {
@@ -159,8 +160,10 @@
 			warning("Config '%s' is NOT usable for themes or not found", style.c_str());
 		}
 	}
-	cfg.clear();
+	cfg.clear(); */
 
+	_theme = new ThemeRenderer(style, GUI::ThemeRenderer::kGfxAntialias16bit);
+
 	if (!_theme)
 		return (!oldTheme.empty() ? loadNewTheme(oldTheme) : false);
 


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