[Scummvm-git-logs] scummvm master -> 09561bd36c9add746b6e426088ac67faaa069dfc

dreammaster dreammaster at scummvm.org
Sat Oct 1 03:54:12 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:
09561bd36c TITANIC: Use CRawSurface in video surface getPixel


Commit: 09561bd36c9add746b6e426088ac67faaa069dfc
    https://github.com/scummvm/scummvm/commit/09561bd36c9add746b6e426088ac67faaa069dfc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-30T21:54:03-04:00

Commit Message:
TITANIC: Use CRawSurface in video surface getPixel

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



diff --git a/engines/titanic/support/raw_surface.cpp b/engines/titanic/support/raw_surface.cpp
index 044bdb5..8328ad1 100644
--- a/engines/titanic/support/raw_surface.cpp
+++ b/engines/titanic/support/raw_surface.cpp
@@ -25,32 +25,32 @@
 
 namespace Titanic {
 
-CRawSurface::CRawSurface(Graphics::Surface *surface, TransparencyMode transMode) {
+CRawSurface::CRawSurface(const Graphics::Surface *surface, TransparencyMode transMode) {
 	_width = surface->w;
 	_pixelsBaseP = (byte *)surface->getPixels();
 	_pixelsP = nullptr;
 	_pitch = 0;
-	_fieldC = 0;
-	_field10 = false;
-	_field18 = 0;
-	_field1C = 0xFF;
+	_runLength = 0;
+	_flag = false;
+	_flag1 = false;
+	_flag2 = true;
 
 	switch (transMode) {
 	case TRANS_MASK0:
 	case TRANS_ALPHA0:
-		_field1C = 0;
-		_field18 = 0xFF;
+		_flag2 = false;
+		_flag1 = true;
 		break;
 	case TRANS_MASK255:
 	case TRANS_ALPHA255:
-		_field1C = 0xFF;
-		_field18 = 0;
+		_flag2 = true;
+		_flag1 = false;
 		break;
 	case TRANS_DEFAULT:
 		if ((_pixelsBaseP[0] == 0 && _pixelsBaseP[2] < 0x80) ||
 				(_pixelsBaseP[0] != 0 && _pixelsBaseP[1] < 0x80)) {
-			_field18 = 0xFF;
-			_field1C = 0;
+			_flag1 = true;
+			_flag2 = false;
 		}
 		break;
 	default:
@@ -75,55 +75,55 @@ void CRawSurface::skipPitch() {
 }
 
 int CRawSurface::moveX(int xp) {
-	if (_fieldC) {
-		if (!_field10) {
-			--_fieldC;
+	if (_runLength) {
+		if (!_flag) {
+			--_runLength;
 			--_pitch;
 			++_pixelsP;
 			return 1;
 		}
 	} else {
 		while (!*_pixelsBaseP) {
-			_fieldC = *++_pixelsBaseP;
+			_runLength = *++_pixelsBaseP;
 			++_pixelsBaseP;
 
-			if (_fieldC) {
+			if (_runLength) {
 				_pixelsP = _pixelsBaseP;
-				_pixelsBaseP += _fieldC;
-				if (_fieldC & 1)
+				_pixelsBaseP += _runLength;
+				if (_runLength & 1)
 					++_pixelsBaseP;
 
-				_field10 = 0;
+				_flag = false;
 				--_pitch;
-				--_fieldC;
+				--_runLength;
 				return 1;
 			}
 		}
 
-		_fieldC = *_pixelsBaseP++;
+		_runLength = *_pixelsBaseP++;
 		++_pixelsBaseP;
-		_field10 = true;
+		_flag = true;
 	}
 
 	if (xp < 0 || xp > _pitch)
 		xp = _pitch;
 
-	int len = MIN(_fieldC, xp);
+	int len = MIN(_runLength, xp);
 	_pitch -= len;
-	_fieldC -= len;
+	_runLength -= len;
 	return len;
 }
 
 uint CRawSurface::getPixel() const {
-	return _field18 ? 0xFF - *_pixelsP : *_pixelsP;
+	return _flag1 ? 0xFF - *_pixelsP : *_pixelsP;
 }
 
 bool CRawSurface::isPixelTransparent1() const {
-	return _field18 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
+	return _flag1 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
 }
 
 bool CRawSurface::isPixelTransparent2() const {
-	return _field18 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
+	return _flag2 ? *_pixelsP == 0xF0 : *_pixelsP == 0x10;
 }
 
 void CRawSurface::resetPitch() {
diff --git a/engines/titanic/support/raw_surface.h b/engines/titanic/support/raw_surface.h
index c0d98ad..69efc1e 100644
--- a/engines/titanic/support/raw_surface.h
+++ b/engines/titanic/support/raw_surface.h
@@ -34,18 +34,16 @@ enum TransparencyMode {
 
 class CRawSurface {
 private:
-	byte *_pixelsBaseP;
-	byte *_pixelsP;
+	const byte *_pixelsBaseP;
+	const byte *_pixelsP;
 	int _pitch;
-	int _fieldC;
-	bool _field10;
+	int _runLength;
+	bool _flag;
 	int _width;
-	int _field18;
-	int _field1C;
-private:
-	int moveX(int xp);
+	bool _flag1;
+	bool _flag2;
 public:
-	CRawSurface(Graphics::Surface *surface, TransparencyMode transMode);
+	CRawSurface(const Graphics::Surface *surface, TransparencyMode transMode);
 
 	void setRow(int yp);
 
@@ -60,6 +58,8 @@ public:
 	bool isPixelTransparent2() const;
 
 	void resetPitch();
+
+	int moveX(int xp);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 63ad782..166a954 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -22,6 +22,7 @@
 
 #include "titanic/support/video_surface.h"
 #include "titanic/support/image_decoders.h"
+#include "titanic/support/raw_surface.h"
 #include "titanic/support/screen_manager.h"
 #include "titanic/titanic.h"
 
@@ -408,8 +409,13 @@ uint16 OSVideoSurface::getPixel(const Common::Point &pt) {
 
 	if (pt.x >= 0 && pt.y >= 0 && pt.x < getWidth() && pt.y < getHeight()) {
 		if (_transparencySurface) {
-			const byte *pixelP = (const byte *)_transparencySurface->getBasePtr(pt.x, pt.y);
-			if (*pixelP != 0xF0)
+			CRawSurface rawSurface(&_transparencySurface->rawSurface(), _transparencyMode);
+			rawSurface.setRow(_transBlitFlag ? pt.y : getHeight() - pt.y - 1);
+			rawSurface.resetPitch();
+			rawSurface.setCol(pt.x);
+			rawSurface.moveX(0);
+
+			if (rawSurface.isPixelTransparent2())
 				return getTransparencyColor();
 		}
 





More information about the Scummvm-git-logs mailing list