[Scummvm-cvs-logs] SF.net SVN: scummvm:[53316] scummvm/trunk/engines/sword25/gfx/image

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Oct 13 01:35:14 CEST 2010


Revision: 53316
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53316&view=rev
Author:   sev
Date:     2010-10-12 23:35:14 +0000 (Tue, 12 Oct 2010)

Log Message:
-----------
SWORD25: partial fix for vector image rendering

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/gfx/image/vectorimage.cpp
    scummvm/trunk/engines/sword25/gfx/image/vectorimage.h
    scummvm/trunk/engines/sword25/gfx/image/vectorimagerenderer.cpp

Modified: scummvm/trunk/engines/sword25/gfx/image/vectorimage.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/vectorimage.cpp	2010-10-12 23:34:47 UTC (rev 53315)
+++ scummvm/trunk/engines/sword25/gfx/image/vectorimage.cpp	2010-10-12 23:35:14 UTC (rev 53316)
@@ -186,19 +186,7 @@
 	return Common::Rect(xMin, yMin, xMax + 1, yMax + 1);
 }
 
-
 // -----------------------------------------------------------------------------
-// Konvertiert SWF-Farben in AntiGrain Farben
-// -----------------------------------------------------------------------------
-
-uint32 flashColorToAGGRGBA8(uint flashColor) {
-	uint32 resultColor = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(flashColor >> 24, (flashColor >> 16) & 0xff, (flashColor >> 8) & 0xff, flashColor & 0xff);
-
-	return resultColor;
-}
-
-
-// -----------------------------------------------------------------------------
 // Berechnet die Bounding-Box eines BS_VectorImageElement
 // -----------------------------------------------------------------------------
 
@@ -343,8 +331,6 @@
 	return bez;
 }
 
-#define SWF_SCALE_FACTOR		(1/20.0)
-
 bool VectorImage::parseDefineShape(uint shapeType, SWFBitStream &bs) {
 	/*uint32 shapeID = */bs.getUInt16();
 
@@ -393,8 +379,8 @@
 			} else {
 				if (stateMoveTo) {
 					uint32 moveToBits = bs.getBits(5);
-					curX = bs.getSignedBits(moveToBits) * SWF_SCALE_FACTOR;
-					curY = bs.getSignedBits(moveToBits) * SWF_SCALE_FACTOR;
+					curX = bs.getSignedBits(moveToBits);
+					curY = bs.getSignedBits(moveToBits);
 				}
 
 				if (stateFillStyle0) {
@@ -448,10 +434,10 @@
 
 			// Curved edge
 			if (edgeFlag == 0) {
-				double controlDeltaX = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
-				double controlDeltaY = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
-				double anchorDeltaX = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
-				double anchorDeltaY = bs.getSignedBits(numBits) * SWF_SCALE_FACTOR;
+				double controlDeltaX = bs.getSignedBits(numBits);
+				double controlDeltaY = bs.getSignedBits(numBits);
+				double anchorDeltaX = bs.getSignedBits(numBits);
+				double anchorDeltaY = bs.getSignedBits(numBits);
 
 				double newX = curX + controlDeltaX;
 				double newY = curY + controlDeltaY;
@@ -489,8 +475,8 @@
 						deltaX = bs.getSignedBits(numBits);
 				}
 
-				curX += deltaX * SWF_SCALE_FACTOR;
-				curY += deltaY * SWF_SCALE_FACTOR;
+				curX += deltaX;
+				curY += deltaY;
 
 				bezNodes++;
 				bez = ensureBezStorage(bez, bezNodes, &bezAllocated);
@@ -535,14 +521,20 @@
 	for (uint i = 0; i < fillStyleCount; ++i) {
 		byte type = bs.getByte();
 		uint32 color;
-		if (shapeType == 3) {
-			color = (bs.getByte() << 16) | (bs.getByte() << 8) | bs.getByte() | (bs.getByte() << 24);
-		} else
-			color = bs.getBits(24) | (0xff << 24);
+		byte r = bs.getByte();
+		byte g = bs.getByte();
+		byte b = bs.getByte();
+		byte a = 0xff;
+
+		if (shapeType == 3)
+			a = bs.getByte();
+
+		color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(a, r, g, b);
+
 		if (type != 0)
 			return false;
 
-		_elements.back()._fillStyles.push_back(flashColorToAGGRGBA8(color));
+		_elements.back()._fillStyles.push_back(color);
 	}
 
 	// Linestyles parsen
@@ -558,12 +550,18 @@
 	for (uint i = 0; i < lineStyleCount; ++i) {
 		double width = bs.getUInt16();
 		uint32 color;
+		byte r = bs.getByte();
+		byte g = bs.getByte();
+		byte b = bs.getByte();
+		byte a = 0xff;
+
 		if (shapeType == 3)
-			color = (bs.getByte() << 16) | (bs.getByte() << 8) | bs.getByte() | (bs.getByte() << 24);
-		else
-			color = bs.getBits(24) | (0xff << 24);
+			a = bs.getByte();
 
-		_elements.back()._lineStyles.push_back(VectorImageElement::LineStyleType(width, flashColorToAGGRGBA8(color)));
+		color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(a, r, g, b);
+
+		debug(0, "color: %08x", color);
+		_elements.back()._lineStyles.push_back(VectorImageElement::LineStyleType(width, color));
 	}
 
 	// Bitbreite f\xFCr die folgenden Styleindizes auslesen
@@ -611,14 +609,8 @@
 
 	// Feststellen, ob das alte Bild im Cache nicht wiederbenutzt werden kann und neu Berechnet werden muss
 	if (!(oldThis == this && oldWidth == width && oldHeight == height)) {
-		float ScaleFactorX = (width == - 1) ? 1 : static_cast<float>(width) / static_cast<float>(getWidth());
-		float ScaleFactorY = (height == - 1) ? 1 : static_cast<float>(height) / static_cast<float>(getHeight());
+		render(width, height);
 
-		uint RenderedWidth;
-		uint RenderedHeight;
-
-		render(ScaleFactorX, ScaleFactorY, RenderedWidth, RenderedHeight);
-
 		oldThis = this;
 		oldHeight = height;
 		oldWidth = width;

Modified: scummvm/trunk/engines/sword25/gfx/image/vectorimage.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/vectorimage.h	2010-10-12 23:34:47 UTC (rev 53315)
+++ scummvm/trunk/engines/sword25/gfx/image/vectorimage.h	2010-10-12 23:35:14 UTC (rev 53316)
@@ -182,7 +182,7 @@
 	}
 	virtual bool fill(const Common::Rect *pFillRect = 0, uint color = BS_RGB(0, 0, 0));
 
-	void render(float scaleFactorX, float scaleFactorY, uint &width, uint &height);
+	void render(int width, int height);
 
 	virtual uint getPixel(int x, int y);
 	virtual bool isBlitSource() const {

Modified: scummvm/trunk/engines/sword25/gfx/image/vectorimagerenderer.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/vectorimagerenderer.cpp	2010-10-12 23:34:47 UTC (rev 53315)
+++ scummvm/trunk/engines/sword25/gfx/image/vectorimagerenderer.cpp	2010-10-12 23:35:14 UTC (rev 53316)
@@ -40,6 +40,7 @@
 #include <libart_lgpl/art_rgb.h>
 
 #include "sword25/gfx/image/vectorimage.h"
+#include "graphics/colormasks.h"
 
 namespace Sword25 {
 
@@ -50,9 +51,8 @@
 	if (r == g && g == b && r == 255) {
 		memset(buf, g, n + n + n + n);
 	} else {
-		art_u32 *alt = (art_u32 *)buf;
-		//art_u32 color = (r << 24) | (g << 16) | (b << 8) | 0xff;
-		art_u32 color = (r << 0) | (g << 8) | (b << 16) | (0xff << 24);
+		uint32 *alt = (uint32 *)buf;
+		uint32 color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(0xff, r, g, b);
 		for (i = 0; i < n; i++)
 			*alt++ = color;
 	}
@@ -215,18 +215,15 @@
 void
 art_rgb_svp_alpha1(const ArtSVP *svp,
                    int x0, int y0, int x1, int y1,
-                   art_u32 rgba,
+                   uint32 color,
                    art_u8 *buf, int rowstride,
                    ArtAlphaGamma *alphagamma) {
 	ArtRgbSVPAlphaData data;
-	int r, g, b, alpha;
+	byte r, g, b, alpha;
 	int i;
 	int a, da;
 
-	r = rgba >> 24;
-	g = (rgba >> 16) & 0xff;
-	b = (rgba >> 8) & 0xff;
-	alpha = rgba & 0xff;
+	Graphics::colorToARGB<Graphics::ColorMasks<8888> >(color, alpha, r, g, b);
 
 	data.r = r;
 	data.g = g;
@@ -251,9 +248,9 @@
 		art_svp_render_aa(svp, x0, y0, x1, y1, art_rgb_svp_alpha_callback1, &data);
 }
 
-void VectorImage::render(float scaleFactorX, float scaleFactorY, uint &width, uint &height) {
-	width = static_cast<uint>(getWidth() * scaleFactorX);
-	height = static_cast<uint>(getHeight() * scaleFactorY);
+void VectorImage::render(int width, int height) {
+	float scaleFactorX = (width == - 1) ? 1 : static_cast<float>(width) / static_cast<float>(getWidth());
+	float scaleFactorY = (height == - 1) ? 1 : static_cast<float>(height) / static_cast<float>(getHeight());
 
 	if (_pixelData)
 		free(_pixelData);


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