[Scummvm-git-logs] scummvm master -> 253a0519a7d403980d265739741155f3f27ba00d
bluegr
noreply at scummvm.org
Sun Nov 13 04:46:40 UTC 2022
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:
253a0519a7 GRAPHICS: Enable blitting 24bpp sources in managed_surface.cpp
Commit: 253a0519a7d403980d265739741155f3f27ba00d
https://github.com/scummvm/scummvm/commit/253a0519a7d403980d265739741155f3f27ba00d
Author: Greg Kennedy (kennedy.greg at gmail.com)
Date: 2022-11-13T06:46:35+02:00
Commit Message:
GRAPHICS: Enable blitting 24bpp sources in managed_surface.cpp
Function `blitFromInner()` excludes source formats with 3 bytes per pixel. These are commonly returned from opaque full-color image decoders, like JPEG. This change enables blitting with these source images.
- Add `== 3` to the list of acceptable source formats
- Add READ_UINT24 handling for 3-byte source formats
- Add READ_UINT24 and RGBA conversion for 3-byte destination when blending (copying non-opaque source to 24bpp surface)
Changed paths:
graphics/managed_surface.cpp
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index a7ae3b1ad9e..088e088486d 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -291,9 +291,8 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
bool isSameFormat = (destFormat == srcFormat);
if (!isSameFormat) {
// When the pixel format differs, the destination must be non-paletted
- assert(destFormat.bytesPerPixel == 2 || destFormat.bytesPerPixel == 3
- || destFormat.bytesPerPixel == 4);
- assert(srcFormat.bytesPerPixel == 2 || srcFormat.bytesPerPixel == 4
+ assert(destFormat.bytesPerPixel == 2 || destFormat.bytesPerPixel == 3 || destFormat.bytesPerPixel == 4);
+ assert(srcFormat.bytesPerPixel == 2 || srcFormat.bytesPerPixel == 3 || srcFormat.bytesPerPixel == 4
|| (srcFormat.bytesPerPixel == 1 && srcPalette));
}
@@ -350,8 +349,10 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
// Use the src's pixel format to split up the source pixel
if (srcFormat.bytesPerPixel == 2)
col = *reinterpret_cast<const uint16 *>(srcVal);
- else
+ else if (srcFormat.bytesPerPixel == 4)
col = *reinterpret_cast<const uint32 *>(srcVal);
+ else
+ col = READ_UINT24(srcVal);
}
const bool isOpaque = ((col & alphaMask) == alphaMask);
@@ -386,18 +387,15 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
bDest = bSrc;
} else {
// Partially transparent, so calculate new pixel colors
- if (destFormat.bytesPerPixel == 2) {
- uint32 destColor = *reinterpret_cast<uint16 *>(destVal);
- destFormat.colorToARGB(destColor, aDest, rDest, gDest, bDest);
- } else if (format.bytesPerPixel == 4) {
- uint32 destColor = *reinterpret_cast<uint32 *>(destVal);
- destFormat.colorToARGB(destColor, aDest, rDest, gDest, bDest);
- } else {
- aDest = 0xFF;
- rDest = destVal[0];
- gDest = destVal[1];
- bDest = destVal[2];
- }
+ uint32 destColor;
+ if (destFormat.bytesPerPixel == 2)
+ destColor = *reinterpret_cast<uint16 *>(destVal);
+ else if (destFormat.bytesPerPixel == 4)
+ destColor = *reinterpret_cast<uint32 *>(destVal);
+ else
+ destColor = READ_UINT24(destVal);
+
+ destFormat.colorToARGB(destColor, aDest, rDest, gDest, bDest);
if (aDest == 0xff) {
// Opaque target
More information about the Scummvm-git-logs
mailing list