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

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Thu May 8 00:51:46 CEST 2008


Revision: 31936
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31936&view=rev
Author:   Tanoku
Date:     2008-05-07 15:51:45 -0700 (Wed, 07 May 2008)

Log Message:
-----------
- Fixed compiling in MSVC2008
- Aliased circles optimized (drawn using pointers directly)
- Filling for aliased circles
- Rounded squares
- Filling for rounded squares

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/dists/msvc9/scumm.vcproj
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h

Modified: scummvm/branches/gsoc2008-gui/dists/msvc9/scumm.vcproj
===================================================================
--- scummvm/branches/gsoc2008-gui/dists/msvc9/scumm.vcproj	2008-05-07 22:48:44 UTC (rev 31935)
+++ scummvm/branches/gsoc2008-gui/dists/msvc9/scumm.vcproj	2008-05-07 22:51:45 UTC (rev 31936)
@@ -43,7 +43,7 @@
 				AdditionalOptions="/wd4201 /wd4512 /wd4511 /wd4100 /wd4121 /wd4310 /wd4706 /wd4127 /wd4189 /wd4702 /wd4996"
 				Optimization="0"
 				AdditionalIncludeDirectories="../..;../../engines"
-				PreprocessorDefinitions="WIN32;_DEBUG;USE_ZLIB;USE_MAD;USE_VORBIS"
+				PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS"
 				MinimalRebuild="true"
 				ExceptionHandling="1"
 				BasicRuntimeChecks="3"
@@ -116,7 +116,7 @@
 				InlineFunctionExpansion="1"
 				OmitFramePointers="true"
 				AdditionalIncludeDirectories="../..;../../engines"
-				PreprocessorDefinitions="WIN32;NDEBUG;USE_ZLIB;USE_MAD;USE_VORBIS"
+				PreprocessorDefinitions="WIN32;NDEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS"
 				StringPooling="true"
 				ExceptionHandling="1"
 				RuntimeLibrary="0"

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-05-07 22:48:44 UTC (rev 31935)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.cpp	2008-05-07 22:51:45 UTC (rev 31936)
@@ -65,8 +65,9 @@
 		vr->fillSurface();
 		vr->setColor(255, 0, 0 );
 		vr->drawLine(25, 25, 125, 300);
-		vr->drawCircle(250, 250, 10);
-		vr->drawSquare(150, 25, 100, 100, true);
+		vr->drawCircle(250, 250, 100);
+//		vr->drawSquare(150, 25, 100, 100, true);
+		vr->drawRoundedSquare( 150, 25, 8, 100, 75 );
 		_system->copyRectToOverlay((OverlayColor*)_screen.getBasePtr(0, 0), _screen.w, 0, 0, _screen.w, _screen.w);
 		_system->updateScreen();
 
@@ -288,42 +289,143 @@
 template<typename PixelType, typename PixelFormat>
 void VectorRendererSpec<PixelType, PixelFormat>::
 drawCircleAlg(int x1, int y1, int r) {
+	int f = 1 - r;
+	int ddF_x = 0, ddF_y = -2 * r;
+	int x = 0, y = r, px, py;
+	int pitch = Base::surfacePitch();
+	PixelType *ptr = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
+	bool fill = true;
 
-#define __CIRCLE_SIM(x,y) { \
-	putPixel(x1 + (x), y1 + (y)); /* 1st quad */ \
-	putPixel(x1 + (y), y1 - (x)); \
-	putPixel(x1 - (x), y1 - (y)); /* 2nd quad */ \
-	putPixel(x1 - (y), y1 - (x)); \
-	putPixel(x1 - (y), y1 + (x)); /* 3rd quad */ \
-	putPixel(x1 - (x), y1 + (y)); \
-	putPixel(x1 + (y), y1 + (x)); /* 4th quad */ \
-	putPixel(x1 + (x), y1 - (y)); \
-}
+	px = 0;
+	py = pitch*y;
 
-	int f = 1 - r;
-	int ddF_x = 0;
-	int ddF_y = -2 * r;
-	int x = 0;
-	int y = r;
+	*(ptr + y) = _color;
+	*(ptr - y) = _color;
+	*(ptr + py) = _color;
+	*(ptr - py) = _color;
 
-	__CIRCLE_SIM(x,y);
+	if (fill) Common::set_to(ptr - r, ptr + r, _color);
 
 	while (x++ < y) {
 		if (f >= 0) {
 			y--;
 			ddF_y += 2;
 			f += ddF_y;
+			py -= pitch;
 		}
 
+		px += pitch;
 		ddF_x += 2;
-		f += ddF_x + 1;    
-	
-		__CIRCLE_SIM(x,y);
+		f += ddF_x + 1;
+
+		if (fill) {
+			Common::set_to(ptr - x + py, ptr + x + py, _color);
+			Common::set_to(ptr - x - py, ptr + x - py, _color);
+			Common::set_to(ptr - y + px, ptr + y + px, _color);
+			Common::set_to(ptr - y - px, ptr + y - px, _color);
+		}
+
+		*(ptr + x + py) = _color;
+		*(ptr + y - px) = _color;
+		*(ptr - x - py) = _color; 
+		*(ptr - y - px) = _color;
+		*(ptr - y + px) = _color;
+		*(ptr - x + py) = _color;
+		*(ptr + y + px) = _color;
+		*(ptr + x - py) = _color;
 	}
 }
 
 template<typename PixelType, typename PixelFormat>
 void VectorRendererAA<PixelType, PixelFormat>::
+drawRoundedSquareAlg(int x1, int y1, int r, int w, int h) {
+	int x = r;
+	int y = 0;
+	int p = Base::surfacePitch(), px, py;
+	uint32 rsq = (r * r) << 16;
+	uint32 T = 0, oldT;
+	uint8 a1, a2;
+	bool fill = true;
+
+	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_bl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + h - r);
+	PixelType *ptr_br = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + h - r);
+	PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
+
+	Common::set_to(ptr_fill + r, ptr_fill + w - r + 1, Base::_color);
+	Common::set_to(ptr_fill + r + h*p, ptr_fill + w - r + 1 + h*p, Base::_color);
+
+	h -= 2*r;
+	ptr_fill += p*r;
+
+	if (!fill) {
+		while (h-- >= 0) {
+			*(ptr_fill) = (PixelType)Base::_color;
+			*(ptr_fill + w) = (PixelType)Base::_color;
+			ptr_fill += p;
+		}
+	} else {
+		while (h-- >= 0) {
+			Common::set_to(ptr_fill, ptr_fill + w + 1, Base::_color);
+			ptr_fill += p;
+		}
+	}
+
+	px = p*x;
+	py = 0;
+
+	while (x > y++)
+	{
+		oldT = T;
+		T = fp_sqroot(rsq - ((y * y) << 16)) ^ 0xFFFF;
+
+		py += p;
+
+		if (T < oldT) {
+			x--;
+			px -= p;
+		}
+
+		a2 = (T >> 8);
+		a1 = ~a2;
+
+		if (fill) {
+			Common::set_to( ptr_tl - x - py, ptr_tr + x - py, Base::_color );
+			Common::set_to( ptr_tl - y - px, ptr_tr + y - px, Base::_color );
+
+			Common::set_to( ptr_bl - x + py, ptr_br + x + py, Base::_color );
+			Common::set_to( ptr_bl - y + px, ptr_br + y + px, Base::_color );
+		} else {
+			blendPixelPtr(ptr_tr + y - (px-p), a2);
+			blendPixelPtr(ptr_tr + x - 1 - py, a2);
+
+			blendPixelPtr(ptr_tl - x + 1 - py, a2);
+			blendPixelPtr(ptr_tl - y - (px-p), a2);
+
+			blendPixelPtr(ptr_bl - y + (px-p), a2);
+			blendPixelPtr(ptr_bl - x + 1 + py, a2);
+
+			blendPixelPtr(ptr_br + x - 1 + py, a2);
+			blendPixelPtr(ptr_br + y + (px-p), a2);
+		} 
+
+		blendPixelPtr(ptr_tr + y - px, a1);
+		blendPixelPtr(ptr_tr + x - py, a1);
+
+		blendPixelPtr(ptr_tl - x - py, a1);
+		blendPixelPtr(ptr_tl - y - px, a1);
+
+		blendPixelPtr(ptr_bl - y + px, a1);
+		blendPixelPtr(ptr_bl - x + py, a1);
+
+		blendPixelPtr(ptr_br + x + py, a1);
+		blendPixelPtr(ptr_br + y + px, a1);
+	}
+}
+
+template<typename PixelType, typename PixelFormat>
+void VectorRendererAA<PixelType, PixelFormat>::
 drawCircleAlg(int x1, int y1, int r) {
 	int x = r;
 	int y = 0;

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-05-07 22:48:44 UTC (rev 31935)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-05-07 22:51:45 UTC (rev 31936)
@@ -77,6 +77,8 @@
 
 	virtual void drawSquare(int x, int y, int w, int h, bool fill) = 0;
 
+	virtual void drawRoundedSquare(int x1, int y1, int r, int w, int h) = 0;
+
 	/**
 	 * Gets the pixel pitch for the current drawing surface.
 	 * Note: This is a real pixel-pitch, not a byte-pitch.
@@ -178,6 +180,8 @@
 	 */
 	virtual void drawCircleAlg(int x, int y, int r) = 0;
 
+	virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h) = 0;
+
 	Surface *_activeSurface; /** Pointer to the surface currently being drawn */
 };
 
@@ -218,6 +222,10 @@
 
 	void drawSquare(int x, int y, int w, int h, bool fill);
 
+	void drawRoundedSquare(int x1, int y1, int r, int w, int h) {
+		drawRoundedSquareAlg( x1, y1, r, w, h );
+	}
+
 	/**
 	 * @see VectorRenderer::setColor()
 	 */
@@ -269,6 +277,9 @@
 	 */
 	virtual void drawCircleAlg(int x, int y, int r);
 
+	virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h) {
+	}
+
 	PixelType _color; /** Color currently being used to draw on the renderer */
 };
 
@@ -337,6 +348,8 @@
 	 * @see VectorRenderer::drawCircleAlg()
 	 */
 	virtual void drawCircleAlg(int x, int y, int r);
+
+	virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h);
 };
 
 } // end of namespace Graphics


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