[Scummvm-git-logs] scummvm master -> d2bb119824562e9c8de8af4a6b818774ccb7747a

criezy criezy at scummvm.org
Tue Feb 23 17:14:53 UTC 2021


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:
d2bb119824 AGS: Fix drawing tinted sprites


Commit: d2bb119824562e9c8de8af4a6b818774ccb7747a
    https://github.com/scummvm/scummvm/commit/d2bb119824562e9c8de8af4a6b818774ccb7747a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-02-23T17:13:26Z

Commit Message:
AGS: Fix drawing tinted sprites

Changed paths:
    engines/ags/lib/allegro/gfx.cpp
    engines/ags/lib/allegro/surface.cpp
    engines/ags/lib/allegro/surface.h


diff --git a/engines/ags/lib/allegro/gfx.cpp b/engines/ags/lib/allegro/gfx.cpp
index 80b91cbe0f..f592352aaf 100644
--- a/engines/ags/lib/allegro/gfx.cpp
+++ b/engines/ags/lib/allegro/gfx.cpp
@@ -156,7 +156,7 @@ void draw_trans_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y) {
 void draw_lit_sprite(BITMAP *bmp, const BITMAP *sprite, int x, int y, int color) {
 	bmp->draw(sprite, Common::Rect(0, 0, sprite->w, sprite->h),
 		Common::Rect(x, y, x + sprite->w, y + sprite->h),
-		false, false, true, color);
+		false, false, true, color, trans_blend_red, trans_blend_green, trans_blend_blue);
 }
 
 void draw_sprite_h_flip(BITMAP *bmp, const BITMAP *sprite, int x, int y) {
diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
index 782d547fe1..9ff1f3f0dd 100644
--- a/engines/ags/lib/allegro/surface.cpp
+++ b/engines/ags/lib/allegro/surface.cpp
@@ -96,7 +96,8 @@ const int SCALE_THRESHOLD = 0x100;
 
 void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
 		const Common::Rect &destRect, bool horizFlip, bool vertFlip,
-		bool skipTrans, int srcAlpha) {
+		bool skipTrans, int srcAlpha, int tintRed, int tintGreen,
+		int tintBlue) {
 	assert(format.bytesPerPixel == 2 || format.bytesPerPixel == 4 ||
 		(format.bytesPerPixel == 1 && srcBitmap->format.bytesPerPixel == 1));
 
@@ -107,6 +108,7 @@ void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
 	const int scaleY = SCALE_THRESHOLD * srcRect.height() / destRect.height();
 	const int xDir = horizFlip ? -1 : 1;
 	bool isScreenDest = dynamic_cast<Graphics::Screen *>(_owner);
+	bool useTint = (tintRed >= 0 && tintGreen >= 0 && tintBlue >= 0);
 
 	byte rSrc, gSrc, bSrc, aSrc;
 	byte rDest = 0, gDest = 0, bDest = 0, aDest = 0;
@@ -164,18 +166,25 @@ void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
 				aSrc = 0xff;
 
 			if (aSrc != 0xff) {
-				// Get the pixel at the destination, to check if it's transparent.
-				// Transparent pixels can be considered to be 0 alph
-				format.colorToARGB(format.bytesPerPixel == 2 ?
-					*(uint16 *)destVal : *(uint32 *)destVal, aDest, rDest, gDest, bDest);
-				if (IS_TRANSPARENT(rDest, gDest, bDest))
-					aDest = 0;
+				if (useTint) {
+					aDest = 0xff;
+					rDest = static_cast<uint8>(tintRed);
+					gDest = static_cast<uint8>(tintGreen);
+					bDest = static_cast<uint8>(tintBlue);
+				} else {
+					// Get the pixel at the destination, to check if it's transparent.
+					// Transparent pixels can be considered to be 0 alpha
+					format.colorToARGB(format.bytesPerPixel == 2 ?
+						*(uint16 *)destVal : *(uint32 *)destVal, aDest, rDest, gDest, bDest);
+					if (IS_TRANSPARENT(rDest, gDest, bDest))
+						aDest = 0;
+				}
 			} else {
 				// Source is opaque, so just treat destination as transparent
 				aDest = 0;
 			}
 
-			if (aDest != 0 && (aSrc != 0xff || srcAlpha != -1)) {
+			if (aDest != 0 && aSrc != 0xff) {
 				// Alpha blender
 				double sAlpha = (double)aSrc / 255.0;
 				double dAlpha = (double)aDest / 255.0;
diff --git a/engines/ags/lib/allegro/surface.h b/engines/ags/lib/allegro/surface.h
index 257ecc91db..7c7dc1b536 100644
--- a/engines/ags/lib/allegro/surface.h
+++ b/engines/ags/lib/allegro/surface.h
@@ -100,7 +100,8 @@ public:
 	 */
 	void draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
 		const Common::Rect &destRect, bool horizFlip, bool vertFlip,
-		bool skipTrans, int srcAlpha);
+		bool skipTrans, int srcAlpha, int tintRed = -1, int tintGreen = -1,
+		int tintBlue = -1);
 };
 
 /**




More information about the Scummvm-git-logs mailing list