[Scummvm-git-logs] scummvm master -> 61a55bd4150cd53a41d7ff0c9ac2438bfb5185a7
sev-
noreply at scummvm.org
Tue Feb 7 23:09:49 UTC 2023
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8f85390b4c GRAPHICS: Add hasPalette and grabPalette to ManagedSurface
079713e7a8 GUI: Simplify palette code
71a8f4262d MTROPOLIS: Simplify palette code
3e019c1d94 NANCY: Simplify palette code
6c0fda035e PRIVATE: Simplify palette code
01e0459f05 ULTIMA: NUVIE: Simplify palette code
4c3424bf55 ULTIMA: ULTIMA4: Simplify palette code
61a55bd415 GRAPHICS: Remove or deprecate RGBA palette functions in ManagedSurface
Commit: 8f85390b4c8ba8349039fb1f46a440cf197ce212
https://github.com/scummvm/scummvm/commit/8f85390b4c8ba8349039fb1f46a440cf197ce212
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
GRAPHICS: Add hasPalette and grabPalette to ManagedSurface
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 09aa393acd2..0fa51cf682b 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -748,6 +748,18 @@ void ManagedSurface::clear(uint32 color) {
fillRect(getBounds(), color);
}
+void ManagedSurface::grabPalette(byte *colors, uint start, uint num) const {
+ assert(start < 256 && (start + num) <= 256);
+ const uint32 *src = &_palette[start];
+
+ for (; num > 0; --num, colors += 3) {
+ uint32 p = *src++;
+ colors[0] = p & 0xff;
+ colors[1] = (p >> 8) & 0xff;
+ colors[2] = (p >> 16) & 0xff;
+ }
+}
+
void ManagedSurface::setPalette(const byte *colors, uint start, uint num) {
assert(start < 256 && (start + num) <= 256);
uint32 *dest = &_palette[start];
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index b1ea4e0b6c8..a067fadaa1b 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -668,6 +668,18 @@ public:
_paletteSet = false;
}
+ /**
+ * Return true if a palette has been set.
+ */
+ bool hasPalette() const {
+ return _paletteSet;
+ }
+
+ /**
+ * Grab the palette using RGB tuples.
+ */
+ void grabPalette(byte *colors, uint start, uint num) const;
+
/**
* Get the palette array.
*/
Commit: 079713e7a8d1910736480630a6cb973c91dad465
https://github.com/scummvm/scummvm/commit/079713e7a8d1910736480630a6cb973c91dad465
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
GUI: Simplify palette code
Changed paths:
gui/options.cpp
diff --git a/gui/options.cpp b/gui/options.cpp
index 081cfdf7f3d..b1c5129b3a8 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -3781,14 +3781,7 @@ bool OptionsDialog::testGraphicsSettings() {
Graphics::ManagedSurface *pm5544 = Graphics::renderPM5544(xres, yres);
byte palette[768];
- const uint32 *p = pm5544->getPalette();
-
- for (int i = 0; i < 256; i++) {
- palette[i * 3 + 0] = p[i] & 0xff;
- palette[i * 3 + 1] = (p[i] >> 8) & 0xff;
- palette[i * 3 + 2] = (p[i] >> 16) & 0xff;
- }
-
+ pm5544->grabPalette(palette, 0, 256);
g_system->getPaletteManager()->setPalette(palette, 0, 256);
g_system->copyRectToScreen(pm5544->surfacePtr()->getPixels(), pm5544->surfacePtr()->pitch, 0, 0, xres, yres);
Commit: 71a8f4262dd3a4a51a4d308c70e4ed758d127fbe
https://github.com/scummvm/scummvm/commit/71a8f4262dd3a4a51a4d308c70e4ed758d127fbe
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
MTROPOLIS: Simplify palette code
Changed paths:
engines/mtropolis/elements.cpp
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 92d1f2cf890..2b1cb4c8b2a 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -1091,11 +1091,10 @@ void ImageElement::render(Window *window) {
if (optimized->format.bytesPerPixel == 1) {
// FIXME: Pass palette to blit functions instead
if (_cachedImage->getOriginalColorDepth() == kColorDepthMode1Bit) {
- const Graphics::PixelFormat &fmt = window->getPixelFormat();
- uint32 blackColor = fmt.RGBToColor(0, 0, 0);
- uint32 whiteColor = fmt.RGBToColor(255, 255, 255);
-
- const uint32 bwPalette[2] = {whiteColor, blackColor};
+ const uint8 bwPalette[2 * 3] = {
+ 255, 255, 255,
+ 0, 0, 0
+ };
optimized->setPalette(bwPalette, 0, 2);
} else {
const Palette *palette = getPalette().get();
@@ -1939,8 +1938,10 @@ void TextLabelElement::render(Window *window) {
// TODO: Need to handle more modes
const ColorRGB8 &color = _renderProps.getForeColor();
- const uint32 opaqueColor = target->format.RGBToColor(color.r, color.g, color.b);
- const uint32 drawPalette[2] = {0, opaqueColor};
+ const uint8 drawPalette[2 * 3] = {
+ 0, 0, 0,
+ color.r, color.g, color.b
+ };
if (_renderedText) {
_renderedText->setPalette(drawPalette, 0, 2);
Commit: 3e019c1d948d5050a065600e22ab93bba82995d3
https://github.com/scummvm/scummvm/commit/3e019c1d948d5050a065600e22ab93bba82995d3
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
NANCY: Simplify palette code
Changed paths:
engines/nancy/cursor.cpp
engines/nancy/font.cpp
engines/nancy/graphics.cpp
engines/nancy/ui/inventorybox.cpp
engines/nancy/ui/viewport.cpp
diff --git a/engines/nancy/cursor.cpp b/engines/nancy/cursor.cpp
index 38d904b95c2..1f5e113d585 100644
--- a/engines/nancy/cursor.cpp
+++ b/engines/nancy/cursor.cpp
@@ -124,12 +124,9 @@ void CursorManager::setCursor(CursorType type, int16 itemID) {
// Convert the trans color from the original format to the screen format
uint transColor;
if (g_nancy->getGameType() == kGameTypeVampire) {
- uint8 r, g, b;
- uint32 input = surf->getPalette()[1];
- r = input & 0xFF;
- g = (input & 0xFF00) >> 8;
- b = (input & 0xFF0000) >> 16;
- transColor = temp.format.RGBToColor(r, g, b);
+ uint8 palette[1 * 3];
+ surf->grabPalette(palette, 1, 1);
+ transColor = temp.format.RGBToColor(palette[0], palette[1], palette[2]);
} else {
uint8 r, g, b;
surf->format.colorToRGB(g_nancy->_graphicsManager->getTransColor(), r, g, b);
diff --git a/engines/nancy/font.cpp b/engines/nancy/font.cpp
index 4cbd7bf48f0..b8e4da1fda7 100644
--- a/engines/nancy/font.cpp
+++ b/engines/nancy/font.cpp
@@ -107,12 +107,9 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
byte colorID = *(const byte *)_image.getBasePtr(srcRect.left + curX, srcRect.top + curY);
if (colorID != _transColor) {
- uint8 r, g, b;
- uint curColor = _image.getPalette()[colorID];
- r = curColor & 0xFF;
- g = (curColor & 0xFF00) >> 8;
- b = (curColor & 0xFF0000) >> 16;
- *(uint16 *)dst->getBasePtr(x + curX, y + yOffset + curY) = dst->format.RGBToColor(r, g, b);
+ uint8 palette[1 * 3];
+ _image.grabPalette(palette, colorID, 1);
+ *(uint16 *)dst->getBasePtr(x + curX, y + yOffset + curY) = dst->format.RGBToColor(palette[0], palette[1], palette[2]);
}
break;
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 94449091b0b..56c908b7f0f 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -141,13 +141,17 @@ void GraphicsManager::loadSurfacePalette(Graphics::ManagedSurface &inSurf, const
void GraphicsManager::copyToManaged(const Graphics::Surface &src, Graphics::ManagedSurface &dst, bool verticalFlip, bool doubleSize) {
if (dst.w != (doubleSize ? src.w * 2 : src.w) || dst.h != (doubleSize ? src.h * 2 : src.h)) {
- const uint32 *palette = dst.getPalette();
+ uint8 palette[256 * 3];
+ bool hasPalette = dst.hasPalette();
bool hasTransColor = dst.hasTransparentColor();
+
+ if (hasPalette && g_nancy->getGameType() == kGameTypeVampire) {
+ dst.grabPalette(palette, 0, 256);
+ }
+
dst.create(doubleSize ? src.w * 2 : src.w, doubleSize ? src.h * 2 : src.h, src.format);
- if (palette && g_nancy->getGameType() == kGameTypeVampire) {
- // free() clears the _hasPalette flag but doesn't clear the palette itself, so
- // we just set it to itself; hopefully this doesn't cause any issues
+ if (hasPalette && g_nancy->getGameType() == kGameTypeVampire) {
dst.setPalette(palette, 0, 256);
}
diff --git a/engines/nancy/ui/inventorybox.cpp b/engines/nancy/ui/inventorybox.cpp
index 6f24b326592..20e52eaae40 100644
--- a/engines/nancy/ui/inventorybox.cpp
+++ b/engines/nancy/ui/inventorybox.cpp
@@ -232,7 +232,9 @@ void InventoryBox::Curtains::init() {
_drawSurface.create(bounds.width(), bounds.height(), g_nancy->_graphicsManager->getInputPixelFormat());
if (g_nancy->getGameType() == kGameTypeVampire) {
- _drawSurface.setPalette(g_nancy->_graphicsManager->_object0.getPalette(), 0, 256);
+ uint8 palette[256 * 3];
+ g_nancy->_graphicsManager->_object0.grabPalette(palette, 0, 256);
+ _drawSurface.setPalette(palette, 0, 256);
}
_screenPosition = _parent->getScreenPosition();
diff --git a/engines/nancy/ui/viewport.cpp b/engines/nancy/ui/viewport.cpp
index b97e7e23bb3..c3c819177dd 100644
--- a/engines/nancy/ui/viewport.cpp
+++ b/engines/nancy/ui/viewport.cpp
@@ -198,7 +198,9 @@ void Viewport::loadVideo(const Common::String &filename, uint frameNr, uint vert
if (palette.size()) {
GraphicsManager::loadSurfacePalette(_drawSurface, palette);
- _fullFrame.setPalette(_drawSurface.getPalette(), 0, 256);
+ uint8 pal[256 * 3];
+ _drawSurface.grabPalette(pal, 0, 256);
+ _fullFrame.setPalette(pal, 0, 256);
}
_movementLastFrame = 0;
@@ -208,13 +210,17 @@ void Viewport::loadVideo(const Common::String &filename, uint frameNr, uint vert
void Viewport::setPalette(const Common::String &paletteName) {
GraphicsManager::loadSurfacePalette(_drawSurface, paletteName);
- _fullFrame.setPalette(_drawSurface.getPalette(), 0, 256);
+ uint8 pal[256 * 3];
+ _drawSurface.grabPalette(pal, 0, 256);
+ _fullFrame.setPalette(pal, 0, 256);
_needsRedraw = true;
}
void Viewport::setPalette(const Common::String &paletteName, uint paletteStart, uint paletteSize) {
GraphicsManager::loadSurfacePalette(_drawSurface, paletteName, paletteStart, paletteSize);
- _fullFrame.setPalette(_drawSurface.getPalette(), 0, 256);
+ uint8 pal[256 * 3];
+ _drawSurface.grabPalette(pal, 0, 256);
+ _fullFrame.setPalette(pal, 0, 256);
_needsRedraw = true;
}
Commit: 6c0fda035efa40c0a261a1def74ef1aad1ac91f5
https://github.com/scummvm/scummvm/commit/6c0fda035efa40c0a261a1def74ef1aad1ac91f5
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
PRIVATE: Simplify palette code
Changed paths:
engines/private/private.cpp
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 1af9b947e7e..15a27a8dd30 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -1404,14 +1404,8 @@ void PrivateEngine::drawScreen() {
// No use of _compositeSurface, we write the frame directly to the screen in the expected position
g_system->copyRectToScreen(frame->getPixels(), frame->pitch, center.x, center.y, frame->w, frame->h);
} else {
- const byte *cPalette = (const byte *) _compositeSurface->getPalette();
-
- byte newPalette[768];
- for (int c = 0; c < 256; c++) { // This avoids any endianness issues
- uint32 y = READ_UINT32(&cPalette[c * 4]) & 0x00FFFFFF;
- WRITE_LE_UINT24(&newPalette[c * 3], y);
- }
-
+ byte newPalette[256 * 3];
+ _compositeSurface->grabPalette(newPalette, 0, 256);
g_system->getPaletteManager()->setPalette(newPalette, 0, 256);
if (_mode == 1) {
Commit: 01e0459f05f13d2a847d7d9e6af4b707aecde568
https://github.com/scummvm/scummvm/commit/01e0459f05f13d2a847d7d9e6af4b707aecde568
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
ULTIMA: NUVIE: Simplify palette code
Changed paths:
engines/ultima/nuvie/gui/gui_font.cpp
engines/ultima/nuvie/misc/sdl_compat.cpp
engines/ultima/nuvie/misc/sdl_compat.h
engines/ultima/nuvie/screen/screen.cpp
diff --git a/engines/ultima/nuvie/gui/gui_font.cpp b/engines/ultima/nuvie/gui/gui_font.cpp
index 59c11c9367c..3f5b29bc438 100644
--- a/engines/ultima/nuvie/gui/gui_font.cpp
+++ b/engines/ultima/nuvie/gui/gui_font.cpp
@@ -106,14 +106,20 @@ void GUI_Font::setTransparency(bool on) {
/* determine foreground and background color values RGB*/
void GUI_Font::setColoring(uint8 fr, uint8 fg, uint8 fb, uint8 br, uint8 bg, uint8 bb) {
- const SDL_Color colors[2] = { MAKE_COLOR(br, bg, bb), MAKE_COLOR(fr, fg, fb) };
- SDL_SetColors(_fontStore, colors, 0, 2);
+ const uint8 colors[2 * 3] = {
+ br, bg, bb,
+ fr, fg, fb
+ };
+ _fontStore->setPalette(colors, 0, 2);
}
void GUI_Font::setColoring(uint8 fr, uint8 fg, uint8 fb, uint8 fr1, uint8 fg1, uint8 fb1, uint8 br, uint8 bg, uint8 bb) {
- const SDL_Color colors[3] = {
- MAKE_COLOR(br, bg, bb), MAKE_COLOR(fr, fg, fb), MAKE_COLOR(fr1, fg1, fb1) };
- SDL_SetColors(_fontStore, colors, 0, 3);
+ const uint8 colors[3 * 3] = {
+ br, bg, bb,
+ fr, fg, fb,
+ fr1, fg1, fb1
+ };
+ _fontStore->setPalette(colors, 0, 3);
}
/* put the text onto the given surface using the preset mode and colors */
diff --git a/engines/ultima/nuvie/misc/sdl_compat.cpp b/engines/ultima/nuvie/misc/sdl_compat.cpp
index f3f8d1db43c..8fcbf8aff16 100644
--- a/engines/ultima/nuvie/misc/sdl_compat.cpp
+++ b/engines/ultima/nuvie/misc/sdl_compat.cpp
@@ -107,11 +107,6 @@ int SDL_SetColorKey(Graphics::ManagedSurface *surface, int flag, uint32 key) {
return 0;
}
-int SDL_SetColors(Graphics::ManagedSurface *surface, const SDL_Color *colors, int firstcolor, int ncolors) {
- surface->setPalette(colors, firstcolor, ncolors);
- return 0;
-}
-
int SDL_WaitEvent(Common::Event *event) {
while (!Events::get()->pollEvent(*event))
g_system->delayMillis(5);
diff --git a/engines/ultima/nuvie/misc/sdl_compat.h b/engines/ultima/nuvie/misc/sdl_compat.h
index b303e72cc85..eca7864ff0f 100644
--- a/engines/ultima/nuvie/misc/sdl_compat.h
+++ b/engines/ultima/nuvie/misc/sdl_compat.h
@@ -33,9 +33,6 @@ namespace Nuvie {
#define SDL_SWSURFACE 0
-typedef uint32 SDL_Color;
-#define MAKE_COLOR(r, g, b) (((uint32)r) | (((uint32)g) << 8) | (((uint32)b) << 16) | (((uint32)0xff) << 24))
-
extern uint32 SDL_GetTicks();
extern void SDL_FreeSurface(Graphics::ManagedSurface *&s);
extern void SDL_ShowCursor(bool show);
@@ -47,7 +44,6 @@ extern void SDL_UpdateRect(Graphics::ManagedSurface *surf, int x, int y, int w,
extern void SDL_UpdateRects(Graphics::ManagedSurface *surf, int count, Common::Rect *rects);
extern Graphics::ManagedSurface *SDL_LoadBMP(const char *filename);
extern int SDL_SetColorKey(Graphics::ManagedSurface *surface, int flag, uint32 key);
-extern int SDL_SetColors(Graphics::ManagedSurface *surface, const SDL_Color *colors, int firstcolor, int ncolors);
extern int SDL_WaitEvent(Common::Event *event);
extern int SDL_PollEvent(Common::Event *event);
extern int SDL_LockSurface(Graphics::ManagedSurface *surface);
diff --git a/engines/ultima/nuvie/screen/screen.cpp b/engines/ultima/nuvie/screen/screen.cpp
index 618010edec9..65aa564935e 100644
--- a/engines/ultima/nuvie/screen/screen.cpp
+++ b/engines/ultima/nuvie/screen/screen.cpp
@@ -135,7 +135,6 @@ bool Screen::set_palette(uint8 *p) {
if (_renderSurface == NULL || p == NULL)
return false;
-//SDL_SetColors(scaled_surface,palette,0,256);
for (int i = 0; i < 256; ++i) {
uint32 r = p[i * 3];
uint32 g = p[i * 3 + 1];
Commit: 4c3424bf55f5c969e2c8b5d6613721d7fd21f668
https://github.com/scummvm/scummvm/commit/4c3424bf55f5c969e2c8b5d6613721d7fd21f668
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
ULTIMA: ULTIMA4: Simplify palette code
Changed paths:
engines/ultima/ultima4/gfx/image.cpp
engines/ultima/ultima4/gfx/image.h
engines/ultima/ultima4/gfx/imagemgr.cpp
diff --git a/engines/ultima/ultima4/gfx/image.cpp b/engines/ultima/ultima4/gfx/image.cpp
index ecdb229d950..f299d5a9575 100644
--- a/engines/ultima/ultima4/gfx/image.cpp
+++ b/engines/ultima/ultima4/gfx/image.cpp
@@ -108,7 +108,8 @@ void Image::setPalette(const RGBA *colors, unsigned n_colors) {
void Image::setPaletteFromImage(const Image *src) {
assertMsg(_paletted && src->_paletted, "imageSetPaletteFromImage called on non-indexed image");
- const uint32 *srcPal = src->_surface->getPalette();
+ uint8 srcPal[PALETTE_COUNT * 3];
+ src->_surface->grabPalette(srcPal, 0, PALETTE_COUNT);
_surface->setPalette(srcPal, 0, PALETTE_COUNT);
}
@@ -116,32 +117,17 @@ RGBA Image::getPaletteColor(int index) {
RGBA color = RGBA(0, 0, 0, 0);
if (_paletted) {
- uint32 pal = _surface->getPalette()[index];
- color.r = (pal & 0xff);
- color.g = (pal >> 8) & 0xff;
- color.b = (pal >> 16) & 0xff;
+ uint8 pal[1 * 3];
+ _surface->grabPalette(pal, index, 1);
+ color.r = pal[0];
+ color.g = pal[1];
+ color.b = pal[2];
color.a = IM_OPAQUE;
}
return color;
}
-int Image::getPaletteIndex(RGBA color) {
- if (!_paletted)
- return -1;
-
- const uint32 *pal = _surface->getPalette();
- uint32 color32 = color;
-
- for (int i = 0; i < PALETTE_COUNT; ++i, ++pal) {
- if (*pal == color32)
- return i;
- }
-
- // return the proper palette index for the specified color
- return -1;
-}
-
RGBA Image::setColor(uint8 r, uint8 g, uint8 b, uint8 a) {
RGBA color = RGBA(r, g, b, a);
return color;
@@ -156,39 +142,39 @@ bool Image::setFontColor(ColorFG fg, ColorBG bg) {
bool Image::setFontColorFG(ColorFG fg) {
switch (fg) {
case FG_GREY:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(153, 153, 153))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(102, 102, 102))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(51, 51, 51))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 153, 153, 153)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 102, 102, 102)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 51, 51, 51)) return false;
break;
case FG_BLUE:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(102, 102, 255))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(51, 51, 204))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(51, 51, 51))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 102, 102, 255)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 51, 51, 204)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 51, 51, 51)) return false;
break;
case FG_PURPLE:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(255, 102, 255))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(204, 51, 204))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(51, 51, 51))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 255, 102, 255)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 204, 51, 204)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 51, 51, 51)) return false;
break;
case FG_GREEN:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(102, 255, 102))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(0, 153, 0))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(51, 51, 51))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 102, 255, 102)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 0, 153, 0)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 51, 51, 51)) return false;
break;
case FG_RED:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(255, 102, 102))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(204, 51, 51))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(51, 51, 51))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 255, 102, 102)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 204, 51, 51)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 51, 51, 51)) return false;
break;
case FG_YELLOW:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(255, 255, 51))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(204, 153, 51))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(51, 51, 51))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 255, 255, 51)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 204, 153, 51)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 51, 51, 51)) return false;
break;
default:
- if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, setColor(255, 255, 255))) return false;
- if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, setColor(204, 204, 204))) return false;
- if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, setColor(68, 68, 68))) return false;
+ if (!setPaletteIndex(TEXT_FG_PRIMARY_INDEX, 255, 255, 255)) return false;
+ if (!setPaletteIndex(TEXT_FG_SECONDARY_INDEX, 204, 204, 204)) return false;
+ if (!setPaletteIndex(TEXT_FG_SHADOW_INDEX, 68, 68, 68)) return false;
}
return true;
}
@@ -196,22 +182,24 @@ bool Image::setFontColorFG(ColorFG fg) {
bool Image::setFontColorBG(ColorBG bg) {
switch (bg) {
case BG_BRIGHT:
- if (!setPaletteIndex(TEXT_BG_INDEX, setColor(0, 0, 102)))
+ if (!setPaletteIndex(TEXT_BG_INDEX, 0, 0, 102))
return false;
break;
default:
- if (!setPaletteIndex(TEXT_BG_INDEX, setColor(0, 0, 0)))
+ if (!setPaletteIndex(TEXT_BG_INDEX, 0, 0, 0))
return false;
}
return true;
}
-bool Image::setPaletteIndex(uint index, RGBA color) {
+bool Image::setPaletteIndex(uint index, uint8 r, uint8 g, uint8 b) {
if (!_paletted)
return false;
- uint32 color32 = color;
- _surface->setPalette(&color32, index, 1);
+ const uint8 palette[1 * 3] = {
+ r, g, b
+ };
+ _surface->setPalette(palette, index, 1);
// success
return true;
@@ -253,11 +241,12 @@ uint Image::getColor(byte r, byte g, byte b, byte a) {
uint color;
if (_surface->format.bytesPerPixel == 1) {
- const uint32 *pal = _surface->getPalette();
- for (color = 0; color <= 0xfe; ++color, ++pal) {
- byte rv = *pal & 0xff;
- byte gv = (*pal >> 8) & 0xff;
- byte bv = (*pal >> 16) & 0xff;
+ uint8 pal[256 * 3];
+ _surface->grabPalette(pal, 0, 256);
+ for (color = 0; color <= 0xfe; ++color) {
+ byte rv = pal[(color * 3) + 0];
+ byte gv = pal[(color * 3) + 1] & 0xff;
+ byte bv = pal[(color * 3) + 2] & 0xff;
if (r == rv && g == gv && b == bv)
break;
}
@@ -379,11 +368,12 @@ void Image::getPixel(int x, int y, uint &r, uint &g, uint &b, uint &a) const {
getPixelIndex(x, y, index);
if (_surface->format.bytesPerPixel == 1) {
- uint32 col = _surface->getPalette()[index];
- r = col & 0xff;
- g = (col >> 8) & 0xff;
- b = (col >> 16) & 0xff;
- a = (col >> 24) & 0xff;
+ uint8 pal[1 * 3];
+ _surface->grabPalette(pal, index, 1);
+ r = pal[0];
+ g = pal[1];
+ b = pal[2];
+ a = IM_OPAQUE;
} else {
_surface->format.colorToARGB(index, a1, r1, g1, b1);
r = r1;
diff --git a/engines/ultima/ultima4/gfx/image.h b/engines/ultima/ultima4/gfx/image.h
index 67b1b344c9c..ad382a99300 100644
--- a/engines/ultima/ultima4/gfx/image.h
+++ b/engines/ultima/ultima4/gfx/image.h
@@ -146,12 +146,8 @@ public:
/**
* Sets the specified palette index to the specified RGB color
*/
- bool setPaletteIndex(uint index, RGBA color);
+ bool setPaletteIndex(uint index, uint8 r, uint8 g, uint8 b);
- /**
- * Returns the palette index of the specified RGB color
- */
- int getPaletteIndex(RGBA color);
RGBA setColor(uint8 r, uint8 g, uint8 b, uint8 a = IM_OPAQUE);
diff --git a/engines/ultima/ultima4/gfx/imagemgr.cpp b/engines/ultima/ultima4/gfx/imagemgr.cpp
index 7f2df8c53dc..50dba67a549 100644
--- a/engines/ultima/ultima4/gfx/imagemgr.cpp
+++ b/engines/ultima/ultima4/gfx/imagemgr.cpp
@@ -331,10 +331,10 @@ void ImageMgr::fixupIntro(Image *im, int prescale) {
im->setPaletteFromImage(borderInfo->_image);
// update the color of "and" and "present"
- (void)im->setPaletteIndex(15, im->setColor(226, 226, 255));
+ (void)im->setPaletteIndex(15, 226, 226, 255);
// update the color of "Origin Systems, Inc."
- (void)im->setPaletteIndex(9, im->setColor(129, 129, 255));
+ (void)im->setPaletteIndex(9, 129, 129, 255);
#ifdef TODO
borderInfo->_image->save("border.png");
Commit: 61a55bd4150cd53a41d7ff0c9ac2438bfb5185a7
https://github.com/scummvm/scummvm/commit/61a55bd4150cd53a41d7ff0c9ac2438bfb5185a7
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-08T00:09:39+01:00
Commit Message:
GRAPHICS: Remove or deprecate RGBA palette functions in ManagedSurface
Changed paths:
graphics/managed_surface.cpp
graphics/managed_surface.h
diff --git a/graphics/managed_surface.cpp b/graphics/managed_surface.cpp
index 0fa51cf682b..e797505ad9e 100644
--- a/graphics/managed_surface.cpp
+++ b/graphics/managed_surface.cpp
@@ -774,13 +774,4 @@ void ManagedSurface::setPalette(const byte *colors, uint start, uint num) {
_owner->setPalette(colors, start, num);
}
-void ManagedSurface::setPalette(const uint32 *colors, uint start, uint num) {
- assert(start < 256 && (start + num) <= 256);
- Common::copy(colors, colors + num, &_palette[start]);
- _paletteSet = true;
-
- if (_owner)
- _owner->setPalette(colors, start, num);
-}
-
} // End of namespace Graphics
diff --git a/graphics/managed_surface.h b/graphics/managed_surface.h
index a067fadaa1b..0145685a45a 100644
--- a/graphics/managed_surface.h
+++ b/graphics/managed_surface.h
@@ -683,6 +683,7 @@ public:
/**
* Get the palette array.
*/
+ WARN_DEPRECATED("Use grabPalette instead")
const uint32 *getPalette() const {
return _palette;
}
@@ -691,11 +692,6 @@ public:
* Set the palette using RGB tuples.
*/
void setPalette(const byte *colors, uint start, uint num);
-
- /**
- * Set the palette using RGBA values.
- */
- void setPalette(const uint32 *colors, uint start, uint num);
};
/** @} */
} // End of namespace Graphics
More information about the Scummvm-git-logs
mailing list