[Scummvm-git-logs] scummvm master -> 1b10678898142b797242fd6ac735244fd0ce5b8a

dreammaster dreammaster at scummvm.org
Sat May 20 23:27:39 CEST 2017


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

Summary:
1b10678898 TITANIC: Fix blitting of game objects with a transparency surface


Commit: 1b10678898142b797242fd6ac735244fd0ce5b8a
    https://github.com/scummvm/scummvm/commit/1b10678898142b797242fd6ac735244fd0ce5b8a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-05-20T17:27:23-04:00

Commit Message:
TITANIC: Fix blitting of game objects with a transparency surface

Changed paths:
    engines/titanic/support/transparency_surface.cpp
    engines/titanic/support/transparency_surface.h
    engines/titanic/support/video_surface.cpp


diff --git a/engines/titanic/support/transparency_surface.cpp b/engines/titanic/support/transparency_surface.cpp
index 8b5cbec..505cd1f 100644
--- a/engines/titanic/support/transparency_surface.cpp
+++ b/engines/titanic/support/transparency_surface.cpp
@@ -31,24 +31,25 @@ CTransparencySurface::CTransparencySurface(const Graphics::Surface *surface,
 	_pitch = 0;
 	_runLength = 0;
 	_flag = false;
-	_flag1 = false;
-	_flag2 = true;
+	_opaqueColor = 0;
+	_transparentColor = 0xff;
 
 	switch (transMode) {
 	case TRANS_MASK0:
 	case TRANS_ALPHA0:
-		_flag2 = false;
-		_flag1 = true;
+		_transparentColor = 0;
+		_opaqueColor = 0xff;
 		break;
 	case TRANS_MASK255:
 	case TRANS_ALPHA255:
-		_flag2 = true;
-		_flag1 = false;
+		_transparentColor = 0xff;
+		_opaqueColor = 0;
 		break;
 	case TRANS_DEFAULT:
+		// If top left pixel is low, then 0 is the transparent color
 		if (*(const byte *)surface->getPixels() < 0x80) {
-			_flag1 = true;
-			_flag2 = false;
+			_opaqueColor = 0xff;
+			_transparentColor = 0;
 		}
 		break;
 	default:
@@ -72,11 +73,23 @@ uint CTransparencySurface::getPixel() const {
 
 uint CTransparencySurface::getAlpha() const {
 	byte pixel = getPixel();
-	return _flag1 ? 0xFF - pixel : pixel;
+	return _opaqueColor ? 0xFF - pixel : pixel;
 }
 
-bool CTransparencySurface::isPixelTransparent() {
-	return getAlpha() == 0xff;
+bool CTransparencySurface::isPixelOpaque() const {
+	byte pixel = getPixel();
+	if (_opaqueColor)
+		return pixel >= 0xf0;
+	else
+		return pixel < 0x10;
+}
+
+bool CTransparencySurface::isPixelTransparent() const {
+	byte pixel = getPixel();
+	if (_transparentColor)
+		return pixel >= 0xf0;
+	else
+		return pixel < 0x10;
 }
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/transparency_surface.h b/engines/titanic/support/transparency_surface.h
index 1b4587a..0970de4 100644
--- a/engines/titanic/support/transparency_surface.h
+++ b/engines/titanic/support/transparency_surface.h
@@ -40,8 +40,8 @@ private:
 	int _pitch;
 	int _runLength;
 	bool _flag;
-	bool _flag1;
-	bool _flag2;
+	byte _transparentColor;
+	byte _opaqueColor;
 private:
 	/**
 	* Returns a a pixel from the transparency surface
@@ -74,9 +74,14 @@ public:
 	uint getAlpha() const;
 
 	/**
+	 * Returns true if the pixel is opaque
+	 */
+	bool isPixelOpaque() const;
+
+	/**
 	 * Returns true if the pixel is completely transparent
 	 */
-	bool isPixelTransparent();
+	bool isPixelTransparent() const;
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 4f84834..5715ef7 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -224,7 +224,9 @@ void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVi
 				transSurface.setCol(srcRect.left);
 
 				for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX) {
-					if (*lineSrcP != transColor)
+					if (transSurface.isPixelOpaque())
+						*lineDestP = *lineSrcP;
+					else if (!transSurface.isPixelTransparent())
 						copyPixel(lineDestP, lineSrcP, transSurface.getAlpha() >> 3, srcSurface->format, isAlpha);
 
 					++lineSrcP;





More information about the Scummvm-git-logs mailing list