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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Jul 4 22:05:30 CEST 2008


Revision: 32908
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32908&view=rev
Author:   Tanoku
Date:     2008-07-04 13:05:30 -0700 (Fri, 04 Jul 2008)

Log Message:
-----------
Memory leaks.
Bug fixes.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
    scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
    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/common/xmlparser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-07-04 17:55:19 UTC (rev 32907)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-07-04 20:05:30 UTC (rev 32908)
@@ -143,10 +143,7 @@
 	_pos = 0;
 	_activeKey.clear();
 	
-	while (_text[_pos]) {
-		if (_state == kParserError)
-			break;
-
+	while (_text[_pos] && _state != kParserError) {
 		if (skipSpaces())
 			continue;
 

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-04 17:55:19 UTC (rev 32907)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-07-04 20:05:30 UTC (rev 32908)
@@ -535,22 +535,17 @@
 	 * @see VectorRenderer::copyFrame()
 	 */
 	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->getBasePtr(r.left, r.top), 
-			_activeSurface->w, r.top, r.left, r.width(), r.height());
-#else
-		sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(r.left, r.top), 
-			_activeSurface->w, r.top, r.left, r.width(), r.height());
-#endif
+		sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(r.left, r.top),
+			_activeSurface->w, r.left, r.top, r.width(), r.height());
 	}
 
 	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);
+			_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);
+			_activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
 #endif
 	}
 

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-04 17:55:19 UTC (rev 32907)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeParser.cpp	2008-07-04 20:05:30 UTC (rev 32908)
@@ -223,7 +223,9 @@
 	if (!parseDrawStep(stepNode, drawstep, true))
 		return false;
 
-	_theme->addDrawStep(drawdataNode->values["id"], drawstep);
+	_theme->addDrawStep(drawdataNode->values["id"], *drawstep);
+	delete drawstep;
+
 	return true;
 }
 

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-04 17:55:19 UTC (rev 32907)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-04 20:05:30 UTC (rev 32908)
@@ -99,7 +99,7 @@
 		resetDrawArea();
 	}
 
-	if (!_themeOk || isThemeLoadingRequired()) {
+	if (isThemeLoadingRequired() || !_themeOk) {
 		loadTheme(_themeName);
 
 		Theme::loadTheme(_defaultConfig);
@@ -173,7 +173,7 @@
 	_vectorRenderer->setSurface(_screen);
 }
 
-void ThemeRenderer::addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step) {
+void ThemeRenderer::addDrawStep(Common::String &drawDataId, Graphics::DrawStep step) {
 	DrawData id = getDrawDataId(drawDataId);
 	
 	assert(_widgets[id] != 0);
@@ -252,8 +252,9 @@
 	if (isWidgetCached(type, r)) {
 		drawCached(type, r);
 	} else if (_widgets[type] != 0) {
-		for (uint i = 0; i < _widgets[type]->_steps.size(); ++i)
-			_vectorRenderer->drawStep(r, *_widgets[type]->_steps[i]);
+		for (Common::List<Graphics::DrawStep>::const_iterator step = _widgets[type]->_steps.begin(); 
+			 step != _widgets[type]->_steps.end(); ++step)
+			_vectorRenderer->drawStep(r, *step);
 	}
 }
 
@@ -316,8 +317,7 @@
 }
 
 void ThemeRenderer::updateScreen() {
-//	renderDirtyScreen();
-	_vectorRenderer->copyWholeFrame(_system);
+	renderDirtyScreen();
 }
 
 void ThemeRenderer::renderDirtyScreen() {
@@ -329,7 +329,6 @@
 	for (uint i = 0; i < _dirtyScreen.size(); ++i)
 		_vectorRenderer->copyFrame(_system, _dirtyScreen[i]);
 
-//	_system->updateScreen();
 	_dirtyScreen.clear();
 }
 

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-04 17:55:19 UTC (rev 32907)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-04 20:05:30 UTC (rev 32908)
@@ -42,16 +42,13 @@
 struct WidgetDrawData;
 
 struct WidgetDrawData {
-	Common::Array<Graphics::DrawStep*> _steps;
+	Common::List<Graphics::DrawStep> _steps;
 
 	bool _cached;
 	Graphics::Surface *_surfaceCache;
 	uint32 _cachedW, _cachedH;
 
 	~WidgetDrawData() {
-		for (uint i = 0; i < _steps.size(); ++i)
-			delete _steps[i];
-
 		_steps.clear();
 
 		if (_surfaceCache) {
@@ -69,9 +66,12 @@
 	friend class GUI::Dialog;
 	friend class GUI::GuiObject;
 
+	/** Strings representing each value in the DrawData enum */
 	static const char *kDrawDataStrings[];
-	static const int kMaxDialogDepth = 4;
 
+	/** Constant value to expand dirty rectangles, to make sure they are fully copied */
+	static const int kDirtyRectangleThreshold = 2;
+
 public:
 	enum GraphicsMode {
 		kGfxDisabled = 0,
@@ -159,6 +159,7 @@
 	void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {}
 
 	bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
+		r.grow(kDirtyRectangleThreshold);
 		_dirtyScreen.push_back(r);
 		return true;
 	}
@@ -172,7 +173,7 @@
 		return (DrawData)-1;
 	}
 
-	void addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step);
+	void addDrawStep(Common::String &drawDataId, Graphics::DrawStep step);
 	bool addDrawData(DrawData data_id, bool cached);
 
 	ThemeParser *parser() {

Modified: scummvm/branches/gsoc2008-gui/gui/newgui.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-07-04 17:55:19 UTC (rev 32907)
+++ scummvm/branches/gsoc2008-gui/gui/newgui.cpp	2008-07-04 20:05:30 UTC (rev 32908)
@@ -242,7 +242,7 @@
 	while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
 		if (_needRedraw) {
 			redraw();
-//			_needRedraw = false;
+			_needRedraw = false;
 		}
 
 		// Don't "tickle" the dialog until the theme has had a chance


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