[Scummvm-git-logs] scummvm master -> 6a1e5bd43a2a3b12b820a9b82c48761cb54a620a

dreammaster dreammaster at scummvm.org
Fri Oct 7 04:01:55 CEST 2016


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:
6a1e5bd43a TITANIC: Cleanup usages of CTransparencySurface


Commit: 6a1e5bd43a2a3b12b820a9b82c48761cb54a620a
    https://github.com/scummvm/scummvm/commit/6a1e5bd43a2a3b12b820a9b82c48761cb54a620a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-10-06T22:01:43-04:00

Commit Message:
TITANIC: Cleanup usages of CTransparencySurface

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



diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index 3983e9f..665ead3 100644
--- a/engines/titanic/support/mouse_cursor.cpp
+++ b/engines/titanic/support/mouse_cursor.cpp
@@ -22,6 +22,7 @@
 
 #include "graphics/cursorman.h"
 #include "titanic/support/mouse_cursor.h"
+#include "titanic/support/transparency_surface.h"
 #include "titanic/support/video_surface.h"
 #include "titanic/titanic.h"
 
@@ -107,12 +108,16 @@ void CMouseCursor::setCursor(CursorId cursorId) {
 
 		Graphics::ManagedSurface surface(CURSOR_SIZE, CURSOR_SIZE, g_system->getScreenFormat());
 		const uint16 *srcP = srcSurface.getPixels();
-		const byte *maskP = (const byte *)ce._transSurface->getPixels();
+		CTransparencySurface transSurface(&ce._transSurface->rawSurface(), TRANS_DEFAULT);
 		uint16 *destP = (uint16 *)surface.getPixels();
 
 		for (int y = 0; y < CURSOR_SIZE; ++y) {
-			for (int x = 0; x < CURSOR_SIZE; ++x, ++srcP, ++maskP, ++destP) {
-				*destP = ((*maskP >> 4) == 0) ? srcSurface.getTransparencyColor() : *srcP;
+			transSurface.setRow(y);
+			transSurface.setCol(0);
+
+			for (int x = 0; x < CURSOR_SIZE; ++x, ++srcP, ++destP) {
+				*destP = transSurface.isPixelTransparent() ? srcSurface.getTransparencyColor() : *srcP;
+				transSurface.moveX();
 			}
 		}
 
diff --git a/engines/titanic/support/transparency_surface.cpp b/engines/titanic/support/transparency_surface.cpp
index f917dfb..5ffa8b9 100644
--- a/engines/titanic/support/transparency_surface.cpp
+++ b/engines/titanic/support/transparency_surface.cpp
@@ -67,17 +67,7 @@ int CTransparencySurface::moveX() {
 
 uint CTransparencySurface::getPixel() const {
 	const byte *pixelP = (const byte *)_surface->getBasePtr(_pos.x, _pos.y);
-	return _flag1 ? 0xFF - *pixelP : *pixelP;
-}
-
-bool CTransparencySurface::isPixelTransparent1() const {
-	const byte *pixelP = (const byte *)_surface->getBasePtr(_pos.x, _pos.y);
-	return _flag1 ? *pixelP == 0xF0 : *pixelP == 0x10;
-}
-
-bool CTransparencySurface::isPixelTransparent2() const {
-	const byte *pixelP = (const byte *)_surface->getBasePtr(_pos.x, _pos.y);
-	return _flag2 ? *pixelP == 0xF0 : *pixelP == 0x10;
+	return *pixelP;
 }
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/transparency_surface.h b/engines/titanic/support/transparency_surface.h
index 5593dfa..06861b6 100644
--- a/engines/titanic/support/transparency_surface.h
+++ b/engines/titanic/support/transparency_surface.h
@@ -43,19 +43,40 @@ private:
 	bool _flag1;
 	bool _flag2;
 public:
+	/**
+	 * Constructor
+	 */
 	CTransparencySurface(const Graphics::Surface *surface, TransparencyMode transMode);
 
+	/**
+	 * Sets the row to get transparencies from
+	 */
 	void setRow(int yp) { _pos.y = yp; }
 
+	/**
+	 * Sets the column to get transparencies from
+	 */
 	void setCol(int xp) { _pos.x = xp; }
 
-	uint getPixel() const;
+	/**
+	 * Moves reading position horizontally by a single pixel
+	 */
+	int moveX();
 
-	bool isPixelTransparent1() const;
+	/**
+	 * Returns a byte from the transparency surface
+	 */
+	uint getPixel() const;
 
-	bool isPixelTransparent2() const;
+	/**
+	 * Returns the alpha value for the pixel (0-31)
+	 */
+	uint getAlpha() const { return getPixel() >> 3; }
 
-	int moveX();
+	/**
+	 * Returns true if the pixel is completely transparent
+	 */
+	bool isPixelTransparent() const { return getAlpha() == 0; }
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 1991d74..79d1f07 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -52,8 +52,7 @@ CVideoSurface::~CVideoSurface() {
 void CVideoSurface::setupPalette(byte palette[32][32], byte val) {
 	for (uint idx1 = 0; idx1 < 32; ++idx1) {
 		for (uint idx2 = 0, base = 0; idx2 < 32; ++idx2, base += idx1) {
-			int64 v = 0x84210843;
-			v *= base;
+			uint v = base / 31;
 			uint v2 = (v >> 36);
 			v = ((v2 >> 31) + v2) & 0xff;
 			palette[idx1][idx2] = v << 3;
@@ -252,15 +251,13 @@ void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVi
 				transSurface.setCol(srcRect.left);
 
 				for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX) {
-					transSurface.moveX();
-
-					if (!transSurface.isPixelTransparent2()) {
-						copyPixel(lineDestP, lineSrcP, transSurface.getPixel() >> 3,
-							is16Bit, isAlpha);
+					if (!transSurface.isPixelTransparent()) {
+						copyPixel(lineDestP, lineSrcP, transSurface.getAlpha(), is16Bit, isAlpha);
 					}
 
 					++lineSrcP;
 					++lineDestP;
+					transSurface.moveX();
 				}
 
 				// Move to next line
@@ -517,7 +514,7 @@ uint16 OSVideoSurface::getPixel(const Common::Point &pt) {
 			transSurface.setRow(_flipVertically ? getHeight() - pt.y - 1 : pt.y);
 			transSurface.setCol(pt.x);
 
-			if (transSurface.isPixelTransparent2())
+			if (transSurface.isPixelTransparent())
 				return getTransparencyColor();
 		}
 





More information about the Scummvm-git-logs mailing list