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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Wed Jul 16 12:48:15 CEST 2008


Revision: 33084
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33084&view=rev
Author:   Tanoku
Date:     2008-07-16 03:48:14 -0700 (Wed, 16 Jul 2008)

Log Message:
-----------
Stroking on tab widgets. Basic support for backcaching.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-07-16 09:08:44 UTC (rev 33083)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-07-16 10:48:14 UTC (rev 33084)
@@ -402,10 +402,15 @@
 			return;
 		
 		case kFillGradient:
-		case kFillForeground:
 		case kFillBackground:
 			drawTabAlg(x, y, w, h, r, (Base::_fillMode == kFillBackground) ? _bgColor : _fgColor, Base::_fillMode);
+			if (Base::_strokeWidth)
+				drawTabAlg(x, y, w, h, r, _fgColor, kFillDisabled);
 			break;
+			
+		case kFillForeground:
+			drawTabAlg(x, y, w, h, r, (Base::_fillMode == kFillBackground) ? _bgColor : _fgColor, Base::_fillMode);
+			break;
 	}
 }
 
@@ -471,45 +476,83 @@
 	int f, ddF_x, ddF_y;
 	int x, y, px, py;
 	int pitch = Base::surfacePitch();
+	int sw  = 0, sp = 0, hp = 0;
 	
 	PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
 	PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r);
 	PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
 
 	int real_radius = r;
-	int short_h = h - (r) + 2;
+	int short_h = h - r + 2;
 	int long_h = h;
-
-	__BE_RESET();
 	PixelType color1, color2;
 	
 	if (fill_m == kFillForeground || fill_m == kFillBackground)
 		color1 = color2 = color;
-	
-	while (x++ < y) {
-		__BE_ALGORITHM();
 		
-		if (fill_m == kFillGradient) {
-			color1 = calcGradient(real_radius - x, long_h);
-			color2 = calcGradient(real_radius - y, long_h);
+	if (fill_m == kFillDisabled) {
+		while (sw++ < Base::_strokeWidth) {
+			colorFill(ptr_fill + sp + r, ptr_fill + w + 1 + sp - r, color);
+			colorFill(ptr_fill + hp - sp + r, ptr_fill + w + hp + 1 - sp - r, color);
+			sp += pitch;
+
+			__BE_RESET();
+			r--;
+			
+			while (x++ < y) {
+				__BE_ALGORITHM();
+				*(ptr_tr + (y) - (px)) = color;
+				*(ptr_tr + (x) - (py)) = color;
+				*(ptr_tl - (x) - (py)) = color;
+				*(ptr_tl - (y) - (px)) = color;
+
+				if (Base::_strokeWidth > 1) {
+					*(ptr_tr + (y) - (px)) = color;
+					*(ptr_tr + (x - 1) - (py)) = color;
+					*(ptr_tl - (x - 1) - (py)) = color;
+					*(ptr_tl - (y) - (px)) = color;
+					*(ptr_tr + (y) - (px - pitch)) = color;
+					*(ptr_tr + (x) - (py)) = color;
+					*(ptr_tl - (x) - (py)) = color;
+					*(ptr_tl - (y) - (px - pitch)) = color;
+				}
+			} 
 		}
+
+		ptr_fill += pitch * real_radius;
+		while (short_h--) {
+			colorFill(ptr_fill, ptr_fill + Base::_strokeWidth, color);
+			colorFill(ptr_fill + w - Base::_strokeWidth + 1, ptr_fill + w + 1, color);
+			ptr_fill += pitch;
+		}
+	} else {
+		__BE_RESET();
 		
-		colorFill(ptr_tl - x - py, ptr_tr + x - py, color2);
-		colorFill(ptr_tl - y - px, ptr_tr + y - px, color1);
-		
-		*(ptr_tr + (y) - (px)) = color;
-		*(ptr_tr + (x) - (py)) = color;
-		*(ptr_tl - (x) - (py)) = color;
-		*(ptr_tl - (y) - (px)) = color;
+		while (x++ < y) {
+			__BE_ALGORITHM();
+	
+			if (fill_m == kFillGradient) {
+				color1 = calcGradient(real_radius - x, long_h);
+				color2 = calcGradient(real_radius - y, long_h);
+			}
+	
+			colorFill(ptr_tl - x - py, ptr_tr + x - py, color2);
+			colorFill(ptr_tl - y - px, ptr_tr + y - px, color1);
+	
+			*(ptr_tr + (y) - (px)) = color1;
+			*(ptr_tr + (x) - (py)) = color2;
+			*(ptr_tl - (x) - (py)) = color2;
+			*(ptr_tl - (y) - (px)) = color1;
+		}
+	
+		ptr_fill += pitch * r;
+		while (short_h--) {
+			if (fill_m == kFillGradient)
+				color = calcGradient(real_radius++, long_h);
+			colorFill(ptr_fill, ptr_fill + w + 1, color);
+			ptr_fill += pitch;
+		}
 	}
-		
-	ptr_fill += pitch * r;
-	while (short_h--) {
-		if (fill_m == kFillGradient)
-			color = calcGradient(real_radius++, long_h);
-		colorFill(ptr_fill, ptr_fill + w + 1, color);
-		ptr_fill += pitch;
-	}
 }
 
 /** SQUARE ALGORITHM **/

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-16 09:08:44 UTC (rev 33083)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeDefaultXML.cpp	2008-07-16 10:48:14 UTC (rev 33084)
@@ -63,7 +63,7 @@
 	
 	"<drawdata id = 'tab_active' cache = false>"
 		"<text vertical_align = 'center' horizontal_align = 'center' color = '255, 255, 255' />"
-		"<drawstep func = 'tab' radius = '8' stroke = '0' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 3 />"
+		"<drawstep func = 'tab' radius = '8' stroke = '2' fill = 'gradient' gradient_start = '206, 121, 99' gradient_end = '173, 40, 8' shadow = 3 />"
 	"</drawdata>"
 	
 	"<drawdata id = 'tab_inactive' cache = false>"

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-16 09:08:44 UTC (rev 33083)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-07-16 10:48:14 UTC (rev 33084)
@@ -76,7 +76,7 @@
 
 ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) : 
 	_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled), 
-	_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false), _enabled(false) {
+	_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false), _themeOk(false), _enabled(false) {
 	_system = g_system;
 	_parser = new ThemeParser(this);
 
@@ -153,9 +153,15 @@
 }
 
 template<typename PixelType> 
-void ThemeRenderer::screenInit() {
+void ThemeRenderer::screenInit(bool backBuffer) {
 	freeScreen();
-
+	freeBackbuffer();
+	
+	if (backBuffer) {
+		_backBuffer = new Surface;
+		_backBuffer->create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(PixelType));
+	}
+	
 	_screen = new Surface;
 	_screen->create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(PixelType));
 	_system->clearOverlay();
@@ -166,7 +172,7 @@
 	case kGfxStandard16bit:
 	case kGfxAntialias16bit:
 		_bytesPerPixel = sizeof(uint16);
-		screenInit<uint16>();
+		screenInit<uint16>(kEnableBackCaching);
 		break;
 
 	default:

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-16 09:08:44 UTC (rev 33083)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.h	2008-07-16 10:48:14 UTC (rev 33084)
@@ -73,6 +73,9 @@
 
 	/** Constant value to expand dirty rectangles, to make sure they are fully copied */
 	static const int kDirtyRectangleThreshold = 2;
+	
+	/** Sets whether backcaching is enabled */
+	static const bool kEnableBackCaching = true;
 
 public:
 	enum GraphicsMode {
@@ -204,7 +207,7 @@
 	void setGraphicsMode(GraphicsMode mode);
 
 protected:
-	template<typename PixelType> void screenInit();
+	template<typename PixelType> void screenInit(bool backBuffer);
 
 	bool loadThemeXML(Common::String themeName);
 	bool loadDefaultXML();
@@ -228,6 +231,14 @@
 		delete _vectorRenderer;
 		_vectorRenderer = 0;
 	}
+	
+	void freeBackbuffer() {
+		if (_backBuffer != 0) {
+			_backBuffer->free();
+			delete _backBuffer;
+			_backBuffer = 0;
+		}
+	}
 
 	void freeScreen() {
 		if (_screen != 0) {
@@ -283,6 +294,7 @@
 	GUI::ThemeParser *_parser;
 
 	Graphics::Surface *_screen;
+	Graphics::Surface *_backBuffer;
 
 	int _bytesPerPixel;
 	GraphicsMode _graphicsMode;


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