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

criezy noreply at scummvm.org
Mon Jul 3 21:11:57 UTC 2023


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:
ff03764f0e AGS: Apply alternative blending to hires fonts in alfont


Commit: ff03764f0ef1dc28dd06da42e4b64b60917b3bd2
    https://github.com/scummvm/scummvm/commit/ff03764f0ef1dc28dd06da42e4b64b60917b3bd2
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-07-03T22:11:54+01:00

Commit Message:
AGS: Apply alternative blending to hires fonts in alfont

When displaying hires fonts, alfont applies an alternative blending mode
which was not implemented, causing hi-res text to display improperly in
multiple games (Mage's Initiation, Starship Quasar and Larry Lotter the
most relevant cases)

Changed paths:
    engines/ags/lib/alfont/alfont.cpp


diff --git a/engines/ags/lib/alfont/alfont.cpp b/engines/ags/lib/alfont/alfont.cpp
index baa113068fc..0c6bf82157b 100644
--- a/engines/ags/lib/alfont/alfont.cpp
+++ b/engines/ags/lib/alfont/alfont.cpp
@@ -178,10 +178,30 @@ uint32_t __preservedalpha_blender_trans24(uint32_t x, uint32_t y, uint32_t n) {
 
 /* replaces set_trans_blender() */
 void set_preservedalpha_trans_blender(int r, int g, int b, int a) {
+	// TODO: The current putpixel() implementation does not support blending in DRAW_MODE_TRANS mode (which is not implemented),
+	// so we can't just call set_blender_mode() here.
+	// The actual blending is done by the apply_trans_blender() function, just before the putpixel() calls
+
 	//set_blender_mode(__skiptranspixels_blender_trans15, __skiptranspixels_blender_trans16, __preservedalpha_blender_trans24, r, g, b, a);
-	set_blender_mode(kAlphaPreservedBlenderMode, r, g, b, a);
+	//set_blender_mode(kAlphaPreservedBlenderMode, r, g, b, a);
 }
 
+/* blends a pixel using the alternative blenders, this is a replacement
+ * for the previous function using set_blender_mode
+ */
+int apply_trans_blender(BITMAP *bmp, int color1, int color2, int alpha) {
+	switch (bitmap_color_depth(bmp)) {
+	case 15:
+		return __skiptranspixels_blender_trans15(color1, color2, alpha);
+	case 16:
+		return __skiptranspixels_blender_trans16(color1, color2, alpha);
+	case 24:
+	case 32:
+		return __preservedalpha_blender_trans24(color1, color2, alpha);
+	default:
+		return color1;
+	}
+}
 
 /* helpers */
 
@@ -1545,13 +1565,15 @@ void alfont_textout_aa_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int
 					for (bmp_y = real_y; bmp_y < max_bmp_y; bmp_y++) {
 						for (bmp_x = real_x; bmp_x < max_bmp_x; bmp_x++) {
 							const int alpha = *bmp_p++;
-
+							const int orig_color = color;
 							if (alpha) {
 								if (alpha >= 255)
 									solid_mode();
 								else {
 									drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
 									set_preservedalpha_trans_blender(0, 0, 0, alpha);
+									// apply blending
+									color = apply_trans_blender(bmp, color, getpixel(bmp, bmp_x, bmp_y), alpha);
 								}
 								if (first_x > bmp_x) first_x = bmp_x;
 								if (final_x < bmp_x) final_x = bmp_x;
@@ -1590,6 +1612,8 @@ void alfont_textout_aa_ex(BITMAP *bmp, ALFONT_FONT *f, const char *s, int x, int
 									putpixel(bmp, bmp_x, bmp_y, color);
 								}
 							}
+							if (color != orig_color) // restore original color
+								color = orig_color;
 						}
 					}
 				} else { //restore original pic




More information about the Scummvm-git-logs mailing list