[Scummvm-git-logs] scummvm master -> fd2bc62037f597d628ab45b54995f3c6dd10aee3
criezy
noreply at scummvm.org
Tue Apr 25 20:44:55 UTC 2023
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
facb6852b8 GRAPHICS: Fix incorrect assert in ManagedSurface::blitFromInner
85b832d02e AGS: Fix wrong color when playing CLUT8 video in CLUT8 games
4b61397acd GRAPHICS: Support bliting CLUT8 Surface in non-CLUT8 ManagedSurface
fd2bc62037 AGS: Fix crash when playing CLUT8 video in 16bit or 32bit games
Commit: facb6852b840e5ef956ebcbc99b29d37bef9da4b
https://github.com/scummvm/scummvm/commit/facb6852b840e5ef956ebcbc99b29d37bef9da4b
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-25T21:44:51+01:00
Commit Message:
GRAPHICS: Fix incorrect assert in ManagedSurface::blitFromInner
When blitting from CLUT8 to another format, we need a palette
for the source surface.
Changed paths:
graphics/managed_surface.cpp
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 98f036a3483..c1da5f10312 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -294,7 +294,7 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
assert(srcFormat.bytesPerPixel == 1 || srcFormat.bytesPerPixel == 2 || srcFormat.bytesPerPixel == 3 || srcFormat.bytesPerPixel == 4);
if (srcFormat.bytesPerPixel == 1) {
// When the pixel format differs, the destination must be non-paletted
- assert(!destFormat.isCLUT8() || srcPalette);
+ assert(!destFormat.isCLUT8() && srcPalette);
}
}
Commit: 85b832d02ece680cf131bfd9053f8488b5967d24
https://github.com/scummvm/scummvm/commit/85b832d02ece680cf131bfd9053f8488b5967d24
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-25T21:44:51+01:00
Commit Message:
AGS: Fix wrong color when playing CLUT8 video in CLUT8 games
The palette from the video decoder was ignored, and it was using the
palette from the game instead.
Changed paths:
engines/ags/engine/media/video/video.cpp
diff --git a/engines/ags/engine/media/video/video.cpp b/engines/ags/engine/media/video/video.cpp
index 8a4e41d6934..dd43aeeeaba 100644
--- a/engines/ags/engine/media/video/video.cpp
+++ b/engines/ags/engine/media/video/video.cpp
@@ -74,6 +74,7 @@ static bool play_video(Video::VideoDecoder *decoder, const char *name, int flags
bool stretchVideo = (flags & kVideo_Stretch) != 0;
bool enableVideo = (flags & kVideo_EnableVideo) != 0;
bool enableAudio = (flags & kVideo_EnableAudio) != 0;
+ bool clut8Screen = scr.format.isCLUT8();
if (!enableAudio)
decoder->setVolume(0);
@@ -85,6 +86,8 @@ static bool play_video(Video::VideoDecoder *decoder, const char *name, int flags
if (decoder->needsUpdate()) {
// Get the next video frame and draw onto the screen
const Graphics::Surface *frame = decoder->decodeNextFrame();
+ if (clut8Screen && decoder->hasDirtyPalette())
+ scr.setPalette(decoder->getPalette(), 0, 256);
if (frame && enableVideo) {
Rect dstRect = PlaceInRect(RectWH(0, 0, scr.w, scr.h), RectWH(0, 0, frame->w, frame->h),
Commit: 4b61397acd47a5d01ecc965f5af583f06295f754
https://github.com/scummvm/scummvm/commit/4b61397acd47a5d01ecc965f5af583f06295f754
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-25T21:44:51+01:00
Commit Message:
GRAPHICS: Support bliting CLUT8 Surface in non-CLUT8 ManagedSurface
The inner blitting code already handled that case, but we needed to be able to
pass the Surface palette to that inner code.
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index c1da5f10312..cc3758436f2 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -226,23 +226,23 @@ void ManagedSurface::copyFrom(const Surface &surf) {
memset(_palette, 0, sizeof(_palette));
}
-void ManagedSurface::blitFrom(const Surface &src) {
- blitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Point(0, 0));
+void ManagedSurface::blitFrom(const Surface &src, const byte *srcPalette) {
+ blitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Point(0, 0), srcPalette);
}
-void ManagedSurface::blitFrom(const Surface &src, const Common::Point &destPos) {
- blitFrom(src, Common::Rect(0, 0, src.w, src.h), destPos);
+void ManagedSurface::blitFrom(const Surface &src, const Common::Point &destPos, const byte *srcPalette) {
+ blitFrom(src, Common::Rect(0, 0, src.w, src.h), destPos, srcPalette);
}
void ManagedSurface::blitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Point &destPos) {
+ const Common::Point &destPos, const byte *srcPalette) {
blitFromInner(src, srcRect, Common::Rect(destPos.x, destPos.y, destPos.x + srcRect.width(),
- destPos.y + srcRect.height()), nullptr);
+ destPos.y + srcRect.height()), srcPalette);
}
void ManagedSurface::blitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Rect &destRect) {
- blitFromInner(src, srcRect, destRect, nullptr);
+ const Common::Rect &destRect, const byte *srcPalette) {
+ blitFromInner(src, srcRect, destRect, srcPalette);
}
void ManagedSurface::blitFrom(const ManagedSurface &src) {
@@ -429,40 +429,44 @@ void ManagedSurface::blitFromInner(const Surface &src, const Common::Rect &srcRe
}
void ManagedSurface::transBlitFrom(const Surface &src, uint32 transColor, bool flipped,
- uint32 overrideColor, uint32 srcAlpha) {
+ uint32 overrideColor, uint32 srcAlpha, const byte *srcPalette) {
transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(0, 0, this->w, this->h),
- transColor, flipped, overrideColor, srcAlpha);
+ transColor, flipped, overrideColor, srcAlpha, nullptr, false, srcPalette);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Point &destPos,
- uint32 transColor, bool flipped, uint32 overrideColor, uint32 srcAlpha) {
+ uint32 transColor, bool flipped, uint32 overrideColor, uint32 srcAlpha, const byte *srcPalette) {
transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
- destPos.x + src.w, destPos.y + src.h), transColor, flipped, overrideColor, srcAlpha);
+ destPos.x + src.w, destPos.y + src.h), transColor, flipped, overrideColor, srcAlpha, nullptr, false, srcPalette);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Point &destPos,
- const ManagedSurface &mask) {
+ const ManagedSurface &mask, const byte *srcPalette) {
transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
- destPos.x + src.w, destPos.y + src.h), 0, false, 0, 0xff, &mask._innerSurface, true);
+ destPos.x + src.w, destPos.y + src.h), 0, false, 0, 0xff, &mask._innerSurface, true, srcPalette);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Point &destPos,
- const Surface &mask) {
+ const Surface &mask, const byte *srcPalette) {
transBlitFrom(src, Common::Rect(0, 0, src.w, src.h), Common::Rect(destPos.x, destPos.y,
- destPos.x + src.w, destPos.y + src.h), 0, false, 0, 0xff, &mask, true);
+ destPos.x + src.w, destPos.y + src.h), 0, false, 0, 0xff, &mask, true, srcPalette);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Point &destPos, uint32 transColor, bool flipped, uint32 overrideColor, uint32 srcAlpha) {
+ const Common::Point &destPos, uint32 transColor, bool flipped, uint32 overrideColor, uint32 srcAlpha, const byte *srcPalette) {
transBlitFrom(src, srcRect, Common::Rect(destPos.x, destPos.y,
- destPos.x + srcRect.width(), destPos.y + srcRect.height()), transColor, flipped, overrideColor, srcAlpha);
+ destPos.x + srcRect.width(), destPos.y + srcRect.height()), transColor, flipped, overrideColor, srcAlpha, nullptr, false, srcPalette);
+}
+
+void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const byte *srcPalette) {
+ transBlitFrom(src, srcRect, destRect, 0, false, 0, 0xff, nullptr, false, srcPalette);
}
void ManagedSurface::transBlitFrom(const Surface &src, const Common::Rect &srcRect,
const Common::Rect &destRect, uint32 transColor, bool flipped, uint32 overrideColor, uint32 srcAlpha,
- const Surface *mask, bool maskOnly) {
+ const Surface *mask, bool maskOnly, const byte *srcPalette) {
transBlitFromInner(src, srcRect, destRect, transColor, flipped, overrideColor, srcAlpha,
- nullptr, nullptr, mask, maskOnly);
+ srcPalette, nullptr, mask, maskOnly);
}
void ManagedSurface::transBlitFrom(const ManagedSurface &src, uint32 transColor, bool flipped,
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index 07b92105bc3..dbf4289cf98 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -303,24 +303,24 @@ public:
/**
* Copy another surface into this one.
*/
- void blitFrom(const Surface &src);
+ void blitFrom(const Surface &src, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one at a given destination position.
*/
- void blitFrom(const Surface &src, const Common::Point &destPos);
+ void blitFrom(const Surface &src, const Common::Point &destPos, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one at a given destination position.
*/
void blitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Point &destPos);
+ const Common::Point &destPos, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one at a given destination area and perform the potential scaling.
*/
void blitFrom(const Surface &src, const Common::Rect &srcRect,
- const Common::Rect &destRect);
+ const Common::Rect &destRect, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one at a given destination area and perform the potential scaling.
@@ -353,9 +353,10 @@ public:
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface.
* @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
*/
void transBlitFrom(const Surface &src, uint32 transColor = 0, bool flipped = false,
- uint32 overrideColor = 0, uint32 srcAlpha = 0xff);
+ uint32 overrideColor = 0, uint32 srcAlpha = 0xff, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one, ignoring pixels of a designated transparent color.
@@ -367,9 +368,10 @@ public:
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface.
* @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
*/
void transBlitFrom(const Surface &src, const Common::Point &destPos,
- uint32 transColor = 0, bool flipped = false, uint32 overrideColor = 0, uint32 srcAlpha = 0xff);
+ uint32 transColor = 0, bool flipped = false, uint32 overrideColor = 0, uint32 srcAlpha = 0xff, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one, ignoring pixels of a designated transparent color.
@@ -377,9 +379,10 @@ public:
* @param src Source surface.
* @param destPos Destination position to draw the surface.
* @param mask Mask definition.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
*/
void transBlitFrom(const Surface &src, const Common::Point &destPos,
- const ManagedSurface &mask);
+ const ManagedSurface &mask, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one, ignoring pixels of a designated transparent color.
@@ -387,9 +390,10 @@ public:
* @param src Source surface.
* @param destPos Destination position to draw the surface.
* @param mask Mask definition.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
*/
void transBlitFrom(const Surface &src, const Common::Point &destPos,
- const Surface &mask);
+ const Surface &mask, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one, ignoring pixels of a designated transparent color.
@@ -402,9 +406,21 @@ public:
* @param overrideColor Optional color to use instead of non-transparent pixels from
* the source surface.
* @param srcAlpha Optional additional transparency applied to @p src.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
*/
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos,
- uint32 transColor = 0, bool flipped = false, uint32 overrideColor = 0, uint32 srcAlpha = 0xff);
+ uint32 transColor = 0, bool flipped = false, uint32 overrideColor = 0, uint32 srcAlpha = 0xff, const byte *srcPalette = nullptr);
+
+ /**
+ * Copy another surface into this one, ignoring pixels of a designated transparent color.
+ *
+ * @param src Source surface.
+ * @param srcRect Subsection of the source surface to draw.
+ * @param destRect Destination area to draw the surface in. This can be sized differently
+ * then @p srcRect, allowing for arbitrary scaling of the image.
+ * @param srcPalette Palette for the CLUT8 @p src surface.
+ */
+ void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, const byte *srcPalette);
/**
* Copy another surface into this one, ignoring pixels of a designated transparent color.
@@ -420,10 +436,11 @@ public:
* @param srcAlpha Optional additional transparency applied to @p src.
* @param mask Optional parameter with mask definition.
* @param maskOnly Optional parameter for using mask over @p transColor.
+ * @param srcPalette Optional palette if the @p src surface uses a CLUT8 pixel format.
*/
void transBlitFrom(const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect,
uint32 transColor = 0, bool flipped = false, uint32 overrideColor = 0, uint32 srcAlpha = 0xff,
- const Surface *mask = nullptr, bool maskOnly = false);
+ const Surface *mask = nullptr, bool maskOnly = false, const byte *srcPalette = nullptr);
/**
* Copy another surface into this one, ignoring pixels of a designated transparent color.
Commit: fd2bc62037f597d628ab45b54995f3c6dd10aee3
https://github.com/scummvm/scummvm/commit/fd2bc62037f597d628ab45b54995f3c6dd10aee3
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-25T21:44:51+01:00
Commit Message:
AGS: Fix crash when playing CLUT8 video in 16bit or 32bit games
The blitting code asserted on the palette pointer as it was not
passed to it.
Changed paths:
engines/ags/engine/media/video/video.cpp
diff --git a/engines/ags/engine/media/video/video.cpp b/engines/ags/engine/media/video/video.cpp
index dd43aeeeaba..f98c8654c73 100644
--- a/engines/ags/engine/media/video/video.cpp
+++ b/engines/ags/engine/media/video/video.cpp
@@ -99,9 +99,10 @@ static bool play_video(Video::VideoDecoder *decoder, const char *name, int flags
if (stretchVideo) {
scr.transBlitFrom(*frame, Common::Rect(0, 0, frame->w, frame->h),
- Common::Rect(dstRect.Left, dstRect.Top, dstRect.Right + 1, dstRect.Bottom + 1));
+ Common::Rect(dstRect.Left, dstRect.Top, dstRect.Right + 1, dstRect.Bottom + 1),
+ decoder->getPalette());
} else {
- scr.blitFrom(*frame, Common::Point(dstRect.Left, dstRect.Top));
+ scr.blitFrom(*frame, Common::Point(dstRect.Left, dstRect.Top), decoder->getPalette());
}
}
More information about the Scummvm-git-logs
mailing list