[Scummvm-git-logs] scummvm master -> 09ab1ddfb70e2d58defa82b9421f6846d8e26a46

bluegr noreply at scummvm.org
Fri Nov 1 00:34:17 UTC 2024


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

Summary:
68f3c51f2b SCI: Support more pixel formats in GfxScreen::scale2x()
09ab1ddfb7 SCI: Speed up GfxScreen::scale2x() for 2bpp and 4bpp formats


Commit: 68f3c51f2bad5b3836a894d063e0d45c0975a071
    https://github.com/scummvm/scummvm/commit/68f3c51f2bad5b3836a894d063e0d45c0975a071
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-11-01T02:33:51+02:00

Commit Message:
SCI: Support more pixel formats in GfxScreen::scale2x()

Changed paths:
    engines/sci/graphics/screen.cpp


diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 085bd3c3869..54fce227ca4 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -870,7 +870,7 @@ void GfxScreen::debugShowMap(int mapNo) {
 }
 
 void GfxScreen::scale2x(const SciSpan<const byte> &src, SciSpan<byte> &dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
-	assert(bytesPerPixel == 1 || bytesPerPixel == 2);
+	assert(bytesPerPixel == 1 || bytesPerPixel == 2 || bytesPerPixel == 3 || bytesPerPixel == 4);
 	const int newWidth = srcWidth * 2;
 	const int pitch = newWidth * bytesPerPixel;
 	const byte *srcPtr = src.getUnsafeDataAt(0, srcWidth * srcHeight * bytesPerPixel);
@@ -905,6 +905,55 @@ void GfxScreen::scale2x(const SciSpan<const byte> &src, SciSpan<byte> &dst, int1
 			}
 			dstPtr += pitch;
 		}
+	} else if (bytesPerPixel == 3) {
+		for (int y = 0; y < srcHeight; y++) {
+			for (int x = 0; x < srcWidth; x++) {
+				const byte color = *srcPtr++;
+				const byte color2 = *srcPtr++;
+				const byte color3 = *srcPtr++;
+				dstPtr[0] = color;
+				dstPtr[1] = color2;
+				dstPtr[2] = color3;
+				dstPtr[3] = color;
+				dstPtr[4] = color2;
+				dstPtr[5] = color3;
+				dstPtr[pitch] = color;
+				dstPtr[pitch + 1] = color2;
+				dstPtr[pitch + 2] = color3;
+				dstPtr[pitch + 3] = color;
+				dstPtr[pitch + 4] = color2;
+				dstPtr[pitch + 5] = color3;
+				dstPtr += 6;
+			}
+			dstPtr += pitch;
+		}
+	} else if (bytesPerPixel == 4) {
+		for (int y = 0; y < srcHeight; y++) {
+			for (int x = 0; x < srcWidth; x++) {
+				const byte color = *srcPtr++;
+				const byte color2 = *srcPtr++;
+				const byte color3 = *srcPtr++;
+				const byte color4 = *srcPtr++;
+				dstPtr[0] = color;
+				dstPtr[1] = color2;
+				dstPtr[2] = color3;
+				dstPtr[3] = color4;
+				dstPtr[4] = color;
+				dstPtr[5] = color2;
+				dstPtr[6] = color3;
+				dstPtr[7] = color4;
+				dstPtr[pitch] = color;
+				dstPtr[pitch + 1] = color2;
+				dstPtr[pitch + 2] = color3;
+				dstPtr[pitch + 3] = color4;
+				dstPtr[pitch + 4] = color;
+				dstPtr[pitch + 5] = color2;
+				dstPtr[pitch + 6] = color3;
+				dstPtr[pitch + 7] = color4;
+				dstPtr += 8;
+			}
+			dstPtr += pitch;
+		}
 	}
 }
 


Commit: 09ab1ddfb70e2d58defa82b9421f6846d8e26a46
    https://github.com/scummvm/scummvm/commit/09ab1ddfb70e2d58defa82b9421f6846d8e26a46
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-11-01T02:33:51+02:00

Commit Message:
SCI: Speed up GfxScreen::scale2x() for 2bpp and 4bpp formats

Changed paths:
    engines/sci/graphics/screen.cpp


diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 54fce227ca4..a4ba268f020 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -891,16 +891,12 @@ void GfxScreen::scale2x(const SciSpan<const byte> &src, SciSpan<byte> &dst, int1
 	} else if (bytesPerPixel == 2) {
 		for (int y = 0; y < srcHeight; y++) {
 			for (int x = 0; x < srcWidth; x++) {
-				const byte color = *srcPtr++;
-				const byte color2 = *srcPtr++;
-				dstPtr[0] = color;
-				dstPtr[1] = color2;
-				dstPtr[2] = color;
-				dstPtr[3] = color2;
-				dstPtr[pitch] = color;
-				dstPtr[pitch + 1] = color2;
-				dstPtr[pitch + 2] = color;
-				dstPtr[pitch + 3] = color2;
+				const uint16 color = *(const uint16 *)srcPtr;
+				*(uint16 *)(dstPtr + 0) = color;
+				*(uint16 *)(dstPtr + 2) = color;
+				*(uint16 *)(dstPtr + pitch + 0) = color;
+				*(uint16 *)(dstPtr + pitch + 2) = color;
+				srcPtr += 2;
 				dstPtr += 4;
 			}
 			dstPtr += pitch;
@@ -930,26 +926,12 @@ void GfxScreen::scale2x(const SciSpan<const byte> &src, SciSpan<byte> &dst, int1
 	} else if (bytesPerPixel == 4) {
 		for (int y = 0; y < srcHeight; y++) {
 			for (int x = 0; x < srcWidth; x++) {
-				const byte color = *srcPtr++;
-				const byte color2 = *srcPtr++;
-				const byte color3 = *srcPtr++;
-				const byte color4 = *srcPtr++;
-				dstPtr[0] = color;
-				dstPtr[1] = color2;
-				dstPtr[2] = color3;
-				dstPtr[3] = color4;
-				dstPtr[4] = color;
-				dstPtr[5] = color2;
-				dstPtr[6] = color3;
-				dstPtr[7] = color4;
-				dstPtr[pitch] = color;
-				dstPtr[pitch + 1] = color2;
-				dstPtr[pitch + 2] = color3;
-				dstPtr[pitch + 3] = color4;
-				dstPtr[pitch + 4] = color;
-				dstPtr[pitch + 5] = color2;
-				dstPtr[pitch + 6] = color3;
-				dstPtr[pitch + 7] = color4;
+				const uint32 color = *(const uint32 *)srcPtr;
+				*(uint32 *)(dstPtr + 0) = color;
+				*(uint32 *)(dstPtr + 4) = color;
+				*(uint32 *)(dstPtr + pitch + 0) = color;
+				*(uint32 *)(dstPtr + pitch + 4) = color;
+				srcPtr += 4;
 				dstPtr += 8;
 			}
 			dstPtr += pitch;




More information about the Scummvm-git-logs mailing list