[Scummvm-git-logs] scummvm master -> 857ddc5f99b4588f46d39863cf0f66de78c5a7ba

sev- noreply at scummvm.org
Sat May 10 19:13:17 UTC 2025


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

Summary:
c0d2fa7a58 QDENGINE: Add 32bpp support to grDispatcher::purSpr_rot(), grDispatcher::putSprMask_rot()
857ddc5f99 QDENGINE: Add 32bpp support to grDispatcher::putSprMask(), not yet tested


Commit: c0d2fa7a58adf144427dcfb4cdabb2ce34dd0eba
    https://github.com/scummvm/scummvm/commit/c0d2fa7a58adf144427dcfb4cdabb2ce34dd0eba
Author: Alikhan Balpykov (luxrage1990 at gmail.com)
Date: 2025-05-11T03:13:12+08:00

Commit Message:
QDENGINE: Add 32bpp support to grDispatcher::purSpr_rot(), grDispatcher::putSprMask_rot()

Changed paths:
    engines/qdengine/system/graphics/gr_dispatcher.h
    engines/qdengine/system/graphics/gr_draw_sprite.cpp


diff --git a/engines/qdengine/system/graphics/gr_dispatcher.h b/engines/qdengine/system/graphics/gr_dispatcher.h
index 2753cd800db..01cefa52e99 100644
--- a/engines/qdengine/system/graphics/gr_dispatcher.h
+++ b/engines/qdengine/system/graphics/gr_dispatcher.h
@@ -269,7 +269,18 @@ public:
 	}
 
 	inline int bytes_per_pixel() const {
-		return 2;
+		switch (_pixel_format) {
+		case GR_ARGB1555:
+		case GR_RGB565:
+			return 2;
+		case GR_RGB888:
+			return 3;
+		case GR_ARGB8888:
+		case GR_RGBA8888:
+			return 4;
+		default:
+			return 0;
+		}
 	}
 
 	enum { // маски для high color режимов
diff --git a/engines/qdengine/system/graphics/gr_draw_sprite.cpp b/engines/qdengine/system/graphics/gr_draw_sprite.cpp
index d3cff68b338..ed86c4428c8 100644
--- a/engines/qdengine/system/graphics/gr_draw_sprite.cpp
+++ b/engines/qdengine/system/graphics/gr_draw_sprite.cpp
@@ -279,11 +279,9 @@ void grDispatcher::putSpr_rot(const Vect2i &pos, const Vect2i &size, const byte
 	int sin_a = round(sn * float(1 << F_PREC));
 	int cos_a = round(cs * float(1 << F_PREC));
 
-	warning("STUB: grDispatcher::putSpr_rot");
-
 	if (has_alpha) {
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + ((size.x + 1 + dx) << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + ((size.y + 1 + dy) << (F_PREC - 1));
@@ -302,22 +300,28 @@ void grDispatcher::putSpr_rot(const Vect2i &pos, const Vect2i &size, const byte
 
 					uint32 a = data_ptr[3];
 					if (a != 255) {
-						if (a)
-							*screen_ptr = alpha_blend_565(make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]), *screen_ptr, a);
-						else
-							*screen_ptr = make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]);
+						if (a) {
+							if (_pixel_format == GR_RGB565) {
+								*(uint16 *)screen_ptr = alpha_blend_565(make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]), *screen_ptr, a);
+							} else if (_pixel_format == GR_RGBA8888) {
+								screen_ptr[1] = data_ptr[0] + ((a * screen_ptr[1]) >> 8);
+								screen_ptr[2] = data_ptr[1] + ((a * screen_ptr[2]) >> 8);
+								screen_ptr[3] = data_ptr[2] + ((a * screen_ptr[3]) >> 8);
+							}
+						} else
+							setPixelFast(screen_ptr, make_rgb(data_ptr[2], data_ptr[1], data_ptr[0]));
 					}
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	} else {
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + ((size.x + 1 + dx) << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + ((size.y + 1 + dy) << (F_PREC - 1));
@@ -334,13 +338,13 @@ void grDispatcher::putSpr_rot(const Vect2i &pos, const Vect2i &size, const byte
 
 					const byte *data_ptr = data + size.x * 3 * yb + xb * 3;
 					if (data_ptr[0] || data_ptr[1] || data_ptr[2])
-						*screen_ptr = make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]);
+						setPixelFast(screen_ptr, make_rgb(data_ptr[2], data_ptr[1], data_ptr[0]));
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	}
@@ -372,11 +376,9 @@ void grDispatcher::putSpr_rot(const Vect2i &pos, const Vect2i &size, const byte
 	Vect2i iscale = Vect2i(scale.x * float(1 << F_PREC), scale.y * float(1 << F_PREC));
 	Vect2i scaled_size = Vect2i(iscale.x * size.x, iscale.y * size.y);
 
-	warning("STUB: grDispatcher::putSpr_rot (scaled)");
-
 	if (has_alpha) {
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + scaled_size.x / 2 + (1 << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + scaled_size.y / 2 + (1 << (F_PREC - 1));
@@ -395,22 +397,28 @@ void grDispatcher::putSpr_rot(const Vect2i &pos, const Vect2i &size, const byte
 
 					uint32 a = data_ptr[3];
 					if (a != 255) {
-						if (a)
-							*screen_ptr = alpha_blend_565(make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]), *screen_ptr, a);
-						else
-							*screen_ptr = make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]);
+						if (a) {
+							if (_pixel_format == GR_RGB565) {
+								*(uint16 *)screen_ptr = alpha_blend_565(make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]), *screen_ptr, a);
+							} else if (_pixel_format == GR_RGBA8888) {
+								screen_ptr[1] = data_ptr[0] + ((a * screen_ptr[1]) >> 8);
+								screen_ptr[2] = data_ptr[1] + ((a * screen_ptr[2]) >> 8);
+								screen_ptr[3] = data_ptr[2] + ((a * screen_ptr[3]) >> 8);
+							}
+						} else
+							setPixelFast(screen_ptr, make_rgb(data_ptr[2], data_ptr[1], data_ptr[0]));
 					}
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	} else {
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + scaled_size.x / 2 + (1 << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + scaled_size.y / 2 + (1 << (F_PREC - 1));
@@ -426,13 +434,13 @@ void grDispatcher::putSpr_rot(const Vect2i &pos, const Vect2i &size, const byte
 						yb = size.y - yb - 1;
 
 					const byte *data_ptr = data + size.x * 3 * yb + xb * 3;
-					*screen_ptr = make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]);
+					setPixelFast(screen_ptr, make_rgb(data_ptr[2], data_ptr[1], data_ptr[0]));
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	}
@@ -461,14 +469,15 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 	int sin_a = round(sn * float(1 << F_PREC));
 	int cos_a = round(cs * float(1 << F_PREC));
 
-	warning("STUB: grDispatcher::putSprMask_rot");
-
 	if (has_alpha) {
 		byte mr, mg, mb;
-		split_rgb565u(mask_color, mr, mg, mb);
+		if (bytes_per_pixel() == 2)
+			split_rgb565u(mask_color, mr, mg, mb);
+		else
+			split_rgb888(mask_color, mr, mg, mb);
 
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + (size.x + 1) * (1 << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + (size.y + 1) * (1 << (F_PREC - 1));
@@ -493,22 +502,31 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 						uint32 g = (mg * (255 - a)) >> 8;
 						uint32 b = (mb * (255 - a)) >> 8;
 
-						uint32 cl = make_rgb565u(r, g, b);
+						if (_pixel_format == GR_RGB565) {
+							uint32 cl = make_rgb565u(r, g, b);
 
-						*screen_ptr = alpha_blend_565(cl, *screen_ptr, a);
+							*(uint16 *)screen_ptr = alpha_blend_565(cl, *screen_ptr, a);
+						} else if (_pixel_format == GR_RGBA8888) {
+							screen_ptr[1] = b + ((a * screen_ptr[1]) >> 8);
+							screen_ptr[2] = g + ((a * screen_ptr[2]) >> 8);
+							screen_ptr[3] = r + ((a * screen_ptr[3]) >> 8);
+						}
 					}
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 
 	} else {
 		byte mr, mg, mb;
-		split_rgb565u(mask_color, mr, mg, mb);
+		if (bytes_per_pixel() == 2)
+			split_rgb565u(mask_color, mr, mg, mb);
+		else
+			split_rgb888(mask_color, mr, mg, mb);
 
 		mr = (mr * (255 - mask_alpha)) >> 8;
 		mg = (mg * (255 - mask_alpha)) >> 8;
@@ -517,7 +535,7 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 		uint32 mcl = make_rgb565u(mr, mg, mb);
 
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + (size.x + 1) * (1 << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + (size.y + 1) * (1 << (F_PREC - 1));
@@ -534,14 +552,20 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 
 					const byte *data_ptr = data + size.x * 3 * yb + xb * 3;
 					if (data_ptr[0] || data_ptr[1] || data_ptr[2]) {
-						*screen_ptr = alpha_blend_565(mcl, *screen_ptr, mask_alpha);
+						if (_pixel_format == GR_RGB565) {
+							*(uint16 *)screen_ptr = alpha_blend_565(mcl, *screen_ptr, mask_alpha);
+						} else if (_pixel_format == GR_RGBA8888) {
+							screen_ptr[1] = mb + ((mask_alpha * screen_ptr[1]) >> 8);
+							screen_ptr[2] = mg + ((mask_alpha * screen_ptr[2]) >> 8);
+							screen_ptr[3] = mr + ((mask_alpha * screen_ptr[3]) >> 8);
+						}
 					}
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	}
@@ -573,14 +597,15 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 	Vect2i iscale = Vect2i(scale.x * float(1 << F_PREC), scale.y * float(1 << F_PREC));
 	Vect2i scaled_size = Vect2i(iscale.x * size.x, iscale.y * size.y);
 
-	warning("STUB: grDispatcher::putSprMask_rot (scaled)");
-
 	if (has_alpha) {
 		byte mr, mg, mb;
-		split_rgb565u(mask_color, mr, mg, mb);
+		if (bytes_per_pixel() == 2)
+			split_rgb565u(mask_color, mr, mg, mb);
+		else
+			split_rgb888(mask_color, mr, mg, mb);
 
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + scaled_size.x / 2 + (1 << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + scaled_size.y / 2 + (1 << (F_PREC - 1));
@@ -605,28 +630,37 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 						uint32 g = (mg * (255 - a)) >> 8;
 						uint32 b = (mb * (255 - a)) >> 8;
 
-						uint32 cl = make_rgb565u(r, g, b);
+						if (_pixel_format == GR_RGB565) {
+							uint32 cl = make_rgb565u(r, g, b);
 
-						*screen_ptr = alpha_blend_565(cl, *screen_ptr, a);
+							*(uint16 *)screen_ptr = alpha_blend_565(cl, *screen_ptr, a);
+						} else if (_pixel_format == GR_RGBA8888) {
+							screen_ptr[1] = b + ((a * screen_ptr[1]) >> 8);
+							screen_ptr[2] = g + ((a * screen_ptr[2]) >> 8);
+							screen_ptr[3] = r + ((a * screen_ptr[3]) >> 8);
+						}
 					}
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	} else {
 		byte mr, mg, mb;
-		split_rgb565u(mask_color, mr, mg, mb);
+		if (bytes_per_pixel() == 2)
+			split_rgb565u(mask_color, mr, mg, mb);
+		else
+			split_rgb888(mask_color, mr, mg, mb);
 
 		mr = (mr * (255 - mask_alpha)) >> 8;
 		mg = (mg * (255 - mask_alpha)) >> 8;
 		mb = (mb * (255 - mask_alpha)) >> 8;
 
 		for (int y = 0; y <= sy; y++) {
-			uint16 *screen_ptr = (uint16 *)_screenBuf->getBasePtr(x0, y + y0);
+			byte *screen_ptr = (byte *)_screenBuf->getBasePtr(x0, y + y0);
 
 			int xx = (x0 - xc) * cos_a + (y + y0 - yc) * sin_a + scaled_size.x / 2 + (1 << (F_PREC - 1));
 			int yy = (y + y0 - yc) * cos_a - (x0 - xc) * sin_a + scaled_size.y / 2 + (1 << (F_PREC - 1));
@@ -642,13 +676,13 @@ void grDispatcher::putSprMask_rot(const Vect2i &pos, const Vect2i &size, const b
 						yb = size.y - yb - 1;
 
 					const byte *data_ptr = data + size.x * 3 * yb + xb * 3;
-					*screen_ptr = make_rgb565u(data_ptr[2], data_ptr[1], data_ptr[0]);
+					setPixelFast(screen_ptr, make_rgb(data_ptr[2], data_ptr[1], data_ptr[0]));
 				}
 
 				xx += cos_a;
 				yy -= sin_a;
 
-				screen_ptr++;
+				screen_ptr += bytes_per_pixel();
 			}
 		}
 	}


Commit: 857ddc5f99b4588f46d39863cf0f66de78c5a7ba
    https://github.com/scummvm/scummvm/commit/857ddc5f99b4588f46d39863cf0f66de78c5a7ba
Author: Alikhan Balpykov (luxrage1990 at gmail.com)
Date: 2025-05-11T03:13:12+08:00

Commit Message:
QDENGINE: Add 32bpp support to grDispatcher::putSprMask(), not yet tested

Changed paths:
    engines/qdengine/system/graphics/gr_draw_sprite.cpp


diff --git a/engines/qdengine/system/graphics/gr_draw_sprite.cpp b/engines/qdengine/system/graphics/gr_draw_sprite.cpp
index ed86c4428c8..44154f27746 100644
--- a/engines/qdengine/system/graphics/gr_draw_sprite.cpp
+++ b/engines/qdengine/system/graphics/gr_draw_sprite.cpp
@@ -1144,14 +1144,17 @@ void grDispatcher::putSprMask(int x, int y, int sx, int sy, const byte *p, uint3
 	int psy = sy;
 
 	if (!clip_rectangle(x, y, px, py, psx, psy)) return;
-	int dx = -1;
+	int dx = -2;
 	int dy = -1;
 
 	if (mode & GR_FLIP_HORIZONTAL) {
 		x += psx - 1;
 		px = sx - px - psx;
 	} else
-		dx = 1;
+		dx = 2;
+
+	if (_pixel_format == GR_RGBA8888)
+		dx *= 2;
 
 	if (mode & GR_FLIP_VERTICAL) {
 		y += psy - 1;
@@ -1165,7 +1168,10 @@ void grDispatcher::putSprMask(int x, int y, int sx, int sy, const byte *p, uint3
 	const byte *data_ptr = p + py * sx + px;
 
 	byte mr, mg, mb;
-	split_rgb565u(mask_color, mr, mg, mb);
+	if (bytes_per_pixel() == 2)
+		split_rgb565u(mask_color, mr, mg, mb);
+	else
+		split_rgb888(mask_color, mr, mg, mb);
 
 	mr = (mr * (255 - mask_alpha)) >> 8;
 	mg = (mg * (255 - mask_alpha)) >> 8;
@@ -1175,12 +1181,19 @@ void grDispatcher::putSprMask(int x, int y, int sx, int sy, const byte *p, uint3
 
 	warning("STUB: grDispatcher::putSprMask");
 	for (int i = 0; i < psy; i++) {
-		uint16 *scr_buf = (uint16 *)(_screenBuf->getBasePtr(x, y));
+		byte *scr_buf = (byte *)(_screenBuf->getBasePtr(x, y));
 		const byte *data_line = data_ptr;
 
 		for (int j = 0; j < psx; j++) {
-			if (data_line[0] || data_line[1] || data_line[2])
-				*scr_buf = alpha_blend_565(mcl, *scr_buf, mask_alpha);
+			if (data_line[0] || data_line[1] || data_line[2]) {
+				if (_pixel_format == GR_RGB565) {
+					*(uint16 *)scr_buf = alpha_blend_565(mcl, *scr_buf, mask_alpha);
+				} else if (_pixel_format == GR_RGBA8888) {
+					scr_buf[1] = mb + ((mask_alpha * scr_buf[1]) >> 8);
+					scr_buf[2] = mg + ((mask_alpha * scr_buf[2]) >> 8);
+					scr_buf[3] = mr + ((mask_alpha * scr_buf[3]) >> 8);
+				}
+			}
 			scr_buf += dx;
 			data_line += 3;
 		}
@@ -1224,7 +1237,10 @@ void grDispatcher::putSprMask(int x, int y, int sx, int sy, const byte *p, uint3
 	}
 
 	byte mr, mg, mb;
-	split_rgb565u(mask_color, mr, mg, mb);
+	if (bytes_per_pixel() == 2)
+		split_rgb565u(mask_color, mr, mg, mb);
+	else
+		split_rgb888(mask_color, mr, mg, mb);
 
 	mr = (mr * (255 - mask_alpha)) >> 8;
 	mg = (mg * (255 - mask_alpha)) >> 8;
@@ -1245,9 +1261,18 @@ void grDispatcher::putSprMask(int x, int y, int sx, int sy, const byte *p, uint3
 		for (int j = x0; j != x1; j += ix) {
 			const byte *src_data = line_src + (fx >> 16) * 3;
 			if (src_data[0] || src_data[1] || src_data[2]) {
-				uint16 scl;
-				getPixel(x + j, y + i, scl);
-				setPixel(x + j, y + i, alpha_blend_565(mcl, scl, mask_alpha));
+				if (_pixel_format == GR_RGB565) {
+					uint16 scl;
+					getPixel(x + j, y + i, scl);
+					setPixel(x + j, y + i, alpha_blend_565(mcl, scl, mask_alpha));
+				} else if (_pixel_format == GR_RGBA8888) {
+					byte r, g, b;
+					b = mb + ((mask_alpha * src_data[0]) >> 8);
+					g = mg + ((mask_alpha * src_data[1]) >> 8);
+					r = mr + ((mask_alpha * src_data[2]) >> 8);
+
+					setPixel(x + j, y + i, r, g, b);
+				}
 			}
 			fx += dx;
 		}




More information about the Scummvm-git-logs mailing list