[Scummvm-git-logs] scummvm master -> e514f882dd876879f1c056541b98e8d968e60ce1
sev-
noreply at scummvm.org
Sat Jan 28 23:03:28 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:
e514f882dd DIRECTOR: Force a widget refresh for bitmaps with custom palettes
Commit: e514f882dd876879f1c056541b98e8d968e60ce1
https://github.com/scummvm/scummvm/commit/e514f882dd876879f1c056541b98e8d968e60ce1
Author: Scott Percival (code at moral.net.au)
Date: 2023-01-29T00:03:23+01:00
Commit Message:
DIRECTOR: Force a widget refresh for bitmaps with custom palettes
If a bitmap cast member has a custom palette, createWidget() has a
routine to dither the image to the current score palette. However, this
needs to be done every time there is a change in palette, as the
dithering might not match, or not be necessary due to a matching
score palette.
Fixes the menu screen in the Mac version of Majestic Part 1.
Changed paths:
engines/director/castmember.cpp
engines/director/castmember.h
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 2d94a0159f8..8ac132a71ff 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -103,6 +103,7 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
_flags2 = 0;
_regX = _regY = 0;
_clut = 0;
+ _ditheredTargetClut = 0;
_bitsPerPixel = 0;
if (version < kFileVer400) {
@@ -211,6 +212,7 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Image::ImageDecode
_img = img;
_ditheredImg = nullptr;
_clut = -1;
+ _ditheredTargetClut = 0;
_initialRect = Common::Rect(0, 0, img->getSurface()->w, img->getSurface()->h);
_pitch = img->getSurface()->pitch;
_bitsPerPixel = img->getSurface()->format.bytesPerPixel * 8;
@@ -253,6 +255,7 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
_ditheredImg->free();
delete _ditheredImg;
_ditheredImg = nullptr;
+ _ditheredTargetClut = 0;
}
if (dstBpp == 1) {
@@ -278,8 +281,10 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
if (!currentPaletteId)
currentPaletteId = cast->_defaultPalette;
PaletteV4 *currentPalette = g_director->getPalette(currentPaletteId);
- if (!currentPalette)
- currentPalette = g_director->getPalette(kClutSystemMac);
+ if (!currentPalette) {
+ currentPaletteId = kClutSystemMac;
+ currentPalette = g_director->getPalette(currentPaletteId);
+ }
int castPaletteId = score->resolvePaletteId(_clut);
if (!castPaletteId)
castPaletteId = cast->_defaultPalette;
@@ -323,9 +328,12 @@ Graphics::MacWidget *BitmapCastMember::createWidget(Common::Rect &bbox, Channel
break;
}
- // Finally, the first and last colours in the palette are special. No matter what the palette remap
- // does, we need to scrub those to be the same.
if (_ditheredImg) {
+ // Save the palette ID so we can check if a redraw is required
+ _ditheredTargetClut = currentPaletteId;
+
+ // Finally, the first and last colours in the palette are special. No matter what the palette remap
+ // does, we need to scrub those to be the same.
const Graphics::Surface *src = _img->getSurface();
for (int y = 0; y < src->h; y++) {
for (int x = 0; x < src->w; x++) {
@@ -395,6 +403,37 @@ void BitmapCastMember::copyStretchImg(Graphics::Surface *surface, const Common::
}
}
+bool BitmapCastMember::isModified() {
+ // Check for palette changes.
+ // If a bitmap has a custom palette assigned to it, createWidget()
+ // will dither the image so that it fits within the current palette.
+ // When the score palette changes, we need to flag that the widget needs
+ // to be recreated.
+ if (_clut) {
+ Movie *movie = g_director->getCurrentMovie();
+ Cast *cast = movie->getCast();
+ Score *score = movie->getScore();
+ int currentPaletteId = score->resolvePaletteId(score->getCurrentPalette());
+ if (!currentPaletteId)
+ currentPaletteId = cast->_defaultPalette;
+ PaletteV4 *currentPalette = g_director->getPalette(currentPaletteId);
+ if (!currentPalette) {
+ currentPaletteId = kClutSystemMac;
+ currentPalette = g_director->getPalette(currentPaletteId);
+ }
+ int castPaletteId = score->resolvePaletteId(_clut);
+ if (!castPaletteId)
+ castPaletteId = cast->_defaultPalette;
+
+ if (currentPaletteId == castPaletteId) {
+ return _ditheredTargetClut != 0;
+ } else {
+ return _ditheredTargetClut != currentPaletteId;
+ }
+ }
+ return false;
+}
+
void BitmapCastMember::createMatte(Common::Rect &bbox) {
// Like background trans, but all white pixels NOT ENCLOSED by coloured pixels
// are transparent
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index 7f83f44afd7..67a6f149d18 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -125,6 +125,7 @@ public:
~BitmapCastMember();
Graphics::MacWidget *createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) override;
+ bool isModified() override;
void createMatte(Common::Rect &bbox);
Graphics::Surface *getMatte(Common::Rect &bbox);
void copyStretchImg(Graphics::Surface *surface, const Common::Rect &bbox, const byte *pal = 0);
@@ -145,6 +146,7 @@ public:
uint16 _flags2;
uint16 _bytes;
int _clut;
+ int _ditheredTargetClut;
uint16 _bitsPerPixel;
More information about the Scummvm-git-logs
mailing list