From 725ff24170dd23394b4aa6de075d9ca74a7c9199 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 24 May 2009 12:56:06 +0000 Subject: SCI: re-xlate pixmap when palette revision changed svn-id: r40859 --- engines/sci/gfx/gfx_pixmap_scale.cpp | 2 ++ engines/sci/gfx/gfx_system.h | 1 + engines/sci/gfx/gfx_tools.cpp | 2 ++ engines/sci/gfx/operations.cpp | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index d13c0d143e..52c7b12396 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -646,6 +646,8 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t fi free(pxm->data); } } + if (pxm->palette) + pxm->palette_revision = pxm->palette->getRevision(); } diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index beb23b5db1..d21c28629b 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -201,6 +201,7 @@ struct gfx_pixmap_t { /* gfx_pixmap_t: Pixel map */ */ int color_key; + int palette_revision; // Revision of palette at the time data was generated }; diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 501c972c2e..e1378e14d0 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -112,6 +112,7 @@ gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { clone->index_data = NULL; clone->palette = NULL; clone->data = NULL; + clone->palette_revision = -1; gfx_pixmap_alloc_data(clone, mode); memcpy(clone->data, pxm->data, clone->data_size); @@ -129,6 +130,7 @@ gfx_pixmap_t *gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) { pxm->alpha_map = NULL; pxm->data = NULL; pxm->palette = NULL; + pxm->palette_revision = -1; pxm->index_width = xl; pxm->index_height = yl; diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 2e778e180f..15ee3d3ec5 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -196,8 +196,12 @@ static int _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { if (!driver->mode->palette) return GFX_OK; if (!pxm->palette) return GFX_OK; + pxm->palette->mergeInto(driver->mode->palette); assert(pxm->palette->getParent() == driver->mode->palette); + if (pxm->palette_revision != pxm->palette->getRevision()) + gfx_xlate_pixmap(pxm, driver->mode, GFX_XLATE_FILTER_NONE); + if (!driver->mode->palette->isDirty()) return GFX_OK; // TODO: We probably want to only update the colours used by this pixmap @@ -214,6 +218,7 @@ static int _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { g_system->setPalette(paletteData, 0, paletteSize); driver->mode->palette->markClean(); + return GFX_OK; } -- cgit v1.2.3