[Scummvm-cvs-logs] scummvm master -> 81e1d0963f3c8a9eba0830b02a574ae843b4b575

sev- sev at scummvm.org
Mon Aug 12 14:28:46 CEST 2013


This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0f59009e6e GRAPHICS: Fix VectorRendererSpec for RGBA8888.
1d40dca7a0 GRAPHICS: Add error-checking in blendPixelPtr for invalid BPPs
ece8b7fb65 GRAPHICS: Fix fonts/bdf.cpp to allow for 32bpp to be used
969a33a32d GUI: Allow GUI cursor creation to work with abitrary 2/4Bpp formats.
f545a2f08f GUI: Change name of GUI-renderers to remove "16-bit"
1f1d35bd3d GRAPHICS: Allow VectorRenderer and ThemeEngine to init with 4BPP
81e1d0963f Merge pull request #359 from rundfunk47/32bitguioverlay


Commit: 0f59009e6e57ad58c4bc4f925c0c75361c304544
    https://github.com/scummvm/scummvm/commit/0f59009e6e57ad58c4bc4f925c0c75361c304544
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-08-07T23:27:11-07:00

Commit Message:
GRAPHICS: Fix VectorRendererSpec for RGBA8888.

Formerly values in the gradient and blending code overflowed and thus caused
incorrect colors. Now there's some special case for 32bpp modes, which needs
slightly more operations but assures a correct output.

Changed paths:
    graphics/VectorRendererSpec.cpp



diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 4c5dd33..1fee861 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -317,9 +317,15 @@ setGradientColors(uint8 r1, uint8 g1, uint8 b1, uint8 r2, uint8 g2, uint8 b2) {
 	_gradientEnd = _format.RGBToColor(r2, g2, b2);
 	_gradientStart = _format.RGBToColor(r1, g1, b1);
 
-	_gradientBytes[0] = (_gradientEnd & _redMask) - (_gradientStart & _redMask);
-	_gradientBytes[1] = (_gradientEnd & _greenMask) - (_gradientStart & _greenMask);
-	_gradientBytes[2] = (_gradientEnd & _blueMask) - (_gradientStart & _blueMask);
+	if (sizeof(PixelType) == 4) {
+		_gradientBytes[0] = ((_gradientEnd & _redMask) >> _format.rShift) - ((_gradientStart & _redMask) >> _format.rShift);
+		_gradientBytes[1] = ((_gradientEnd & _greenMask) >> _format.gShift) - ((_gradientStart & _greenMask) >> _format.gShift);
+		_gradientBytes[2] = ((_gradientEnd & _blueMask) >> _format.bShift) - ((_gradientStart & _blueMask) >> _format.bShift);
+	} else {
+		_gradientBytes[0] = (_gradientEnd & _redMask) - (_gradientStart & _redMask);
+		_gradientBytes[1] = (_gradientEnd & _greenMask) - (_gradientStart & _greenMask);
+		_gradientBytes[2] = (_gradientEnd & _blueMask) - (_gradientStart & _blueMask);
+	}
 }
 
 template<typename PixelType>
@@ -328,9 +334,15 @@ calcGradient(uint32 pos, uint32 max) {
 	PixelType output = 0;
 	pos = (MIN(pos * Base::_gradientFactor, max) << 12) / max;
 
-	output |= ((_gradientStart & _redMask) + ((_gradientBytes[0] * pos) >> 12)) & _redMask;
-	output |= ((_gradientStart & _greenMask) + ((_gradientBytes[1] * pos) >> 12)) & _greenMask;
-	output |= ((_gradientStart & _blueMask) + ((_gradientBytes[2] * pos) >> 12)) & _blueMask;
+	if (sizeof(PixelType) == 4) {
+		output |= ((_gradientStart & _redMask) + (((_gradientBytes[0] * pos) >> 12) << _format.rShift)) & _redMask;
+		output |= ((_gradientStart & _greenMask) + (((_gradientBytes[1] * pos) >> 12) << _format.gShift)) & _greenMask;
+		output |= ((_gradientStart & _blueMask) + (((_gradientBytes[2] * pos) >> 12) << _format.bShift)) & _blueMask;
+	} else {
+		output |= ((_gradientStart & _redMask) + ((_gradientBytes[0] * pos) >> 12)) & _redMask;
+		output |= ((_gradientStart & _greenMask) + ((_gradientBytes[1] * pos) >> 12)) & _greenMask;
+		output |= ((_gradientStart & _blueMask) + ((_gradientBytes[2] * pos) >> 12)) & _blueMask;
+	}
 	output |= _alphaMask;
 
 	return output;
@@ -537,20 +549,39 @@ applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) {
 template<typename PixelType>
 inline void VectorRendererSpec<PixelType>::
 blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) {
-	int idst = *ptr;
-	int isrc = color;
-
-	*ptr = (PixelType)(
-		(_redMask & ((idst & _redMask) +
-		((int)(((int)(isrc & _redMask) -
-		(int)(idst & _redMask)) * alpha) >> 8))) |
-		(_greenMask & ((idst & _greenMask) +
-		((int)(((int)(isrc & _greenMask) -
-		(int)(idst & _greenMask)) * alpha) >> 8))) |
-		(_blueMask & ((idst & _blueMask) +
-		((int)(((int)(isrc & _blueMask) -
-		(int)(idst & _blueMask)) * alpha) >> 8))) |
-		(idst & _alphaMask));
+	if (sizeof(PixelType) == 4) {
+		const byte sR = (color & _redMask) >> _format.rShift;
+		const byte sG = (color & _greenMask) >> _format.gShift;
+		const byte sB = (color & _blueMask) >> _format.bShift;
+
+		byte dR = (*ptr & _redMask) >> _format.rShift;
+		byte dG = (*ptr & _greenMask) >> _format.gShift;
+		byte dB = (*ptr & _blueMask) >> _format.bShift;
+
+		dR += ((sR - dR) * alpha) >> 8;
+		dG += ((sG - dG) * alpha) >> 8;
+		dB += ((sB - dB) * alpha) >> 8;
+
+		*ptr = ((dR << _format.rShift) & _redMask)
+		     | ((dG << _format.gShift) & _greenMask)
+		     | ((dB << _format.bShift) & _blueMask)
+		     | (*ptr & _alphaMask);
+	} else {
+		int idst = *ptr;
+		int isrc = color;
+
+		*ptr = (PixelType)(
+			(_redMask & ((idst & _redMask) +
+			((int)(((int)(isrc & _redMask) -
+			(int)(idst & _redMask)) * alpha) >> 8))) |
+			(_greenMask & ((idst & _greenMask) +
+			((int)(((int)(isrc & _greenMask) -
+			(int)(idst & _greenMask)) * alpha) >> 8))) |
+			(_blueMask & ((idst & _blueMask) +
+			((int)(((int)(isrc & _blueMask) -
+			(int)(idst & _blueMask)) * alpha) >> 8))) |
+			(idst & _alphaMask));
+	}
 }
 
 template<typename PixelType>


Commit: 1d40dca7a0446aad81380c7c207461b18b79428d
    https://github.com/scummvm/scummvm/commit/1d40dca7a0446aad81380c7c207461b18b79428d
Author: Narek Mailian (narek.mailian at gmail.com)
Date: 2013-08-07T23:27:11-07:00

Commit Message:
GRAPHICS: Add error-checking in blendPixelPtr for invalid BPPs

Changed paths:
    graphics/VectorRendererSpec.cpp



diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index 1fee861..e594be9 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -566,7 +566,7 @@ blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) {
 		     | ((dG << _format.gShift) & _greenMask)
 		     | ((dB << _format.bShift) & _blueMask)
 		     | (*ptr & _alphaMask);
-	} else {
+	} else if (sizeof(PixelType) == 2) {
 		int idst = *ptr;
 		int isrc = color;
 
@@ -581,6 +581,8 @@ blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) {
 			((int)(((int)(isrc & _blueMask) -
 			(int)(idst & _blueMask)) * alpha) >> 8))) |
 			(idst & _alphaMask));
+	} else {
+		error("Unsupported BPP format: %d", sizeof(PixelType));
 	}
 }
 


Commit: ece8b7fb65402238ab7df896361a9cefe28b8897
    https://github.com/scummvm/scummvm/commit/ece8b7fb65402238ab7df896361a9cefe28b8897
Author: Narek Mailian (narek.mailian at gmail.com)
Date: 2013-08-07T23:27:11-07:00

Commit Message:
GRAPHICS: Fix fonts/bdf.cpp to allow for 32bpp to be used

Changed paths:
    graphics/fonts/bdf.cpp



diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 6d4befa..e523a36 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -102,7 +102,7 @@ void BdfFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const
 	// equal to 50 and the decision of the theme designer?
 	// asserting _data.maxAdvance <= 50: let the theme designer decide what looks best
 	assert(_data.maxAdvance <= 50);
-	assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2);
+	assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4);
 
 	const int idx = mapToIndex(chr);
 	if (idx < 0)
@@ -165,6 +165,8 @@ void BdfFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const
 		drawCharIntern<byte>(ptr, dst->pitch, src, height, originalWidth, xStart, xEnd, color);
 	else if (dst->format.bytesPerPixel == 2)
 		drawCharIntern<uint16>(ptr, dst->pitch, src, height, originalWidth, xStart, xEnd, color);
+	else if (dst->format.bytesPerPixel == 4)
+		drawCharIntern<uint32>(ptr, dst->pitch, src, height, originalWidth, xStart, xEnd, color);
 }
 
 namespace {


Commit: 969a33a32dc331ec8d89da056e584a68974dfeec
    https://github.com/scummvm/scummvm/commit/969a33a32dc331ec8d89da056e584a68974dfeec
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-08-07T23:35:07-07:00

Commit Message:
GUI: Allow GUI cursor creation to work with abitrary 2/4Bpp formats.

Changed paths:
    gui/ThemeEngine.cpp



diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 0f8b449..2ba45a4 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1320,22 +1320,31 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
 	memset(_cursor, 0xFF, sizeof(byte) * _cursorWidth * _cursorHeight);
 
 	// the transparent color is 0xFF00FF
-	const int colTransparent = _overlayFormat.RGBToColor(0xFF, 0, 0xFF);
+	const uint32 colTransparent = _overlayFormat.RGBToColor(0xFF, 0, 0xFF);
 
 	// Now, scan the bitmap. We have to convert it from 16 bit color mode
 	// to 8 bit mode, and have to create a suitable palette on the fly.
 	uint colorsFound = 0;
 	Common::HashMap<int, int> colorToIndex;
-	const OverlayColor *src = (const OverlayColor *)cursor->getPixels();
+	const byte *src = (const byte *)cursor->getPixels();
 	for (uint y = 0; y < _cursorHeight; ++y) {
 		for (uint x = 0; x < _cursorWidth; ++x) {
+			uint32 color = colTransparent;
 			byte r, g, b;
 
+			if (cursor->format.bytesPerPixel == 2) {
+				color = READ_UINT16(src);
+			} else if (cursor->format.bytesPerPixel == 4) {
+				color = READ_UINT32(src);
+			}
+
+			src += cursor->format.bytesPerPixel;
+
 			// Skip transparency
-			if (src[x] == colTransparent)
+			if (color == colTransparent)
 				continue;
 
-			_overlayFormat.colorToRGB(src[x], r, g, b);
+			cursor->format.colorToRGB(color, r, g, b);
 			const int col = (r << 16) | (g << 8) | b;
 
 			// If there is no entry yet for this color in the palette: Add one
@@ -1357,7 +1366,6 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
 			const int index = colorToIndex[col];
 			_cursor[y * _cursorWidth + x] = index;
 		}
-		src += _cursorWidth;
 	}
 
 	_useCursor = true;


Commit: f545a2f08fc8989fa22726ce0b74e03ece099300
    https://github.com/scummvm/scummvm/commit/f545a2f08fc8989fa22726ce0b74e03ece099300
Author: Narek Mailian (narek.mailian at gmail.com)
Date: 2013-08-07T23:35:08-07:00

Commit Message:
GUI: Change name of GUI-renderers to remove "16-bit"

Changed paths:
    graphics/VectorRendererSpec.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h



diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index e594be9..c60d9ca 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -277,15 +277,15 @@ void colorFill(PixelType *first, PixelType *last, PixelType color) {
 
 VectorRenderer *createRenderer(int mode) {
 #ifdef DISABLE_FANCY_THEMES
-	assert(mode == GUI::ThemeEngine::kGfxStandard16bit);
+	assert(mode == GUI::ThemeEngine::kGfxStandard);
 #endif
 
 	PixelFormat format = g_system->getOverlayFormat();
 	switch (mode) {
-	case GUI::ThemeEngine::kGfxStandard16bit:
+	case GUI::ThemeEngine::kGfxStandard:
 		return new VectorRendererSpec<OverlayColor>(format);
 #ifndef DISABLE_FANCY_THEMES
-	case GUI::ThemeEngine::kGfxAntialias16bit:
+	case GUI::ThemeEngine::kGfxAntialias:
 		return new VectorRendererAA<OverlayColor>(format);
 #endif
 	default:
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 2ba45a4..b7199fb 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -343,9 +343,9 @@ ThemeEngine::~ThemeEngine() {
  *********************************************************/
 const ThemeEngine::Renderer ThemeEngine::_rendererModes[] = {
 	{ _s("Disabled GFX"), _sc("Disabled GFX", "lowres"), "none", kGfxDisabled },
-	{ _s("Standard Renderer (16bpp)"), _s("Standard (16bpp)"), "normal_16bpp", kGfxStandard16bit },
+	{ _s("Standard Renderer"), _s("Standard"), "normal", kGfxStandard },
 #ifndef DISABLE_FANCY_THEMES
-	{ _s("Antialiased Renderer (16bpp)"), _s("Antialiased (16bpp)"), "aa_16bpp", kGfxAntialias16bit }
+	{ _s("Antialiased Renderer"), _s("Antialiased"), "antialias", kGfxAntialias }
 #endif
 };
 
@@ -353,9 +353,9 @@ const uint ThemeEngine::_rendererModesSize = ARRAYSIZE(ThemeEngine::_rendererMod
 
 const ThemeEngine::GraphicsMode ThemeEngine::_defaultRendererMode =
 #ifndef DISABLE_FANCY_THEMES
-	ThemeEngine::kGfxAntialias16bit;
+	ThemeEngine::kGfxAntialias;
 #else
-	ThemeEngine::kGfxStandard16bit;
+	ThemeEngine::kGfxStandard;
 #endif
 
 ThemeEngine::GraphicsMode ThemeEngine::findMode(const Common::String &cfg) {
@@ -494,9 +494,9 @@ void ThemeEngine::disable() {
 
 void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
 	switch (mode) {
-	case kGfxStandard16bit:
+	case kGfxStandard:
 #ifndef DISABLE_FANCY_THEMES
-	case kGfxAntialias16bit:
+	case kGfxAntialias:
 #endif
 		_bytesPerPixel = sizeof(uint16);
 		break;
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 160ceb3..c0e47a1 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -250,8 +250,8 @@ public:
 	 */
 	enum GraphicsMode {
 		kGfxDisabled = 0,   ///< No GFX
-		kGfxStandard16bit,  ///< 2BPP with the standard (aliased) renderer.
-		kGfxAntialias16bit  ///< 2BPP with the optimized AA renderer.
+		kGfxStandard,  ///< Standard (aliased) renderer.
+		kGfxAntialias  ///< Optimized AA renderer.
 	};
 
 	/** Constant value to expand dirty rectangles, to make sure they are fully copied */


Commit: 1f1d35bd3d31fe3430b9b5227b6127cfd52e52a2
    https://github.com/scummvm/scummvm/commit/1f1d35bd3d31fe3430b9b5227b6127cfd52e52a2
Author: Narek Mailian (narek.mailian at gmail.com)
Date: 2013-08-07T23:35:08-07:00

Commit Message:
GRAPHICS: Allow VectorRenderer and ThemeEngine to init with 4BPP

Changed paths:
    graphics/VectorRendererSpec.cpp
    gui/ThemeEngine.cpp



diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index c60d9ca..1e01744 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -283,10 +283,16 @@ VectorRenderer *createRenderer(int mode) {
 	PixelFormat format = g_system->getOverlayFormat();
 	switch (mode) {
 	case GUI::ThemeEngine::kGfxStandard:
-		return new VectorRendererSpec<OverlayColor>(format);
+		if (g_system->getOverlayFormat().bytesPerPixel == 4)
+			return new VectorRendererSpec<uint32>(format);
+		else if (g_system->getOverlayFormat().bytesPerPixel == 2)
+			return new VectorRendererSpec<uint16>(format);
 #ifndef DISABLE_FANCY_THEMES
 	case GUI::ThemeEngine::kGfxAntialias:
-		return new VectorRendererAA<OverlayColor>(format);
+		if (g_system->getOverlayFormat().bytesPerPixel == 4)
+			return new VectorRendererAA<uint32>(format);
+		else if (g_system->getOverlayFormat().bytesPerPixel == 2)
+			return new VectorRendererAA<uint16>(format);
 #endif
 	default:
 		break;
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index b7199fb..561c024 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -498,9 +498,13 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
 #ifndef DISABLE_FANCY_THEMES
 	case kGfxAntialias:
 #endif
-		_bytesPerPixel = sizeof(uint16);
-		break;
-
+		if (g_system->getOverlayFormat().bytesPerPixel == 4) {
+			_bytesPerPixel = sizeof(uint32);
+			break;
+		} else if (g_system->getOverlayFormat().bytesPerPixel == 2) {
+			_bytesPerPixel = sizeof(uint16);
+			break;
+		}
 	default:
 		error("Invalid graphics mode");
 	}


Commit: 81e1d0963f3c8a9eba0830b02a574ae843b4b575
    https://github.com/scummvm/scummvm/commit/81e1d0963f3c8a9eba0830b02a574ae843b4b575
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2013-08-12T05:27:44-07:00

Commit Message:
Merge pull request #359 from rundfunk47/32bitguioverlay

GUI: Add option to render GUI in 32-bits

Changed paths:
    graphics/VectorRendererSpec.cpp
    graphics/fonts/bdf.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h









More information about the Scummvm-git-logs mailing list