diff options
author | Martin Kiewitz | 2010-02-07 12:13:34 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-02-07 12:13:34 +0000 |
commit | ed2a3f1f1604d032ad2d37357ce025b3fcbf088e (patch) | |
tree | 7161ffe9772ec0d75e9c39d57c5aaa26123ab916 /engines/sci | |
parent | 97c2543b0eaea6a0b10560b4a1e61aef40e26b20 (diff) | |
download | scummvm-rg350-ed2a3f1f1604d032ad2d37357ce025b3fcbf088e.tar.gz scummvm-rg350-ed2a3f1f1604d032ad2d37357ce025b3fcbf088e.tar.bz2 scummvm-rg350-ed2a3f1f1604d032ad2d37357ce025b3fcbf088e.zip |
SCI: set screen palette only when it got changed during merge (performance only change)
svn-id: r47955
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/graphics/palette.cpp | 29 | ||||
-rw-r--r-- | engines/sci/graphics/palette.h | 2 |
2 files changed, 21 insertions, 10 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index f8b12d4eca..07eb7d7df1 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -187,26 +187,32 @@ void GfxPalette::setEGA() { void GfxPalette::set(Palette *sciPal, bool force, bool forceRealMerge) { uint32 systime = _sysPalette.timestamp; + bool paletteChanged; + if (force || sciPal->timestamp != systime) { - merge(sciPal, &_sysPalette, force, forceRealMerge); + paletteChanged = merge(sciPal, &_sysPalette, force, forceRealMerge); sciPal->timestamp = _sysPalette.timestamp; - if (_screen->_picNotValid == 0 && systime != _sysPalette.timestamp) + if (paletteChanged && _screen->_picNotValid == 0 && systime != _sysPalette.timestamp) setOnScreen(); } } -void GfxPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge) { +bool GfxPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge) { uint16 res; int i,j; + bool paletteChanged = false; if ((!forceRealMerge) && (getSciVersion() >= SCI_VERSION_1_1)) { // SCI1.1+ doesnt do real merging anymore, but simply copying over the used colors from other palettes for (i = 1; i < 255; i++) { if (pFrom->colors[i].used) { + if ((pFrom->colors[i].r != pTo->colors[i].r) || (pFrom->colors[i].g != pTo->colors[i].g) || (pFrom->colors[i].b != pTo->colors[i].b)) { + pTo->colors[i].r = pFrom->colors[i].r; + pTo->colors[i].g = pFrom->colors[i].g; + pTo->colors[i].b = pFrom->colors[i].b; + paletteChanged = true; + } pTo->colors[i].used = pFrom->colors[i].used; - pTo->colors[i].r = pFrom->colors[i].r; - pTo->colors[i].g = pFrom->colors[i].g; - pTo->colors[i].b = pFrom->colors[i].b; pFrom->mapping[i] = i; } } @@ -218,9 +224,12 @@ void GfxPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealM // forced palette merging or dest color is not used yet if (force || (!pTo->colors[i].used)) { pTo->colors[i].used = pFrom->colors[i].used; - pTo->colors[i].r = pFrom->colors[i].r; - pTo->colors[i].g = pFrom->colors[i].g; - pTo->colors[i].b = pFrom->colors[i].b; + if ((pFrom->colors[i].r != pTo->colors[i].r) || (pFrom->colors[i].g != pTo->colors[i].g) || (pFrom->colors[i].b != pTo->colors[i].b)) { + pTo->colors[i].r = pFrom->colors[i].r; + pTo->colors[i].g = pFrom->colors[i].g; + pTo->colors[i].b = pFrom->colors[i].b; + paletteChanged = true; + } pFrom->mapping[i] = i; continue; } @@ -245,6 +254,7 @@ void GfxPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealM pTo->colors[j].g = pFrom->colors[i].g; pTo->colors[j].b = pFrom->colors[i].b; pFrom->mapping[i] = j; + paletteChanged = true; break; } // if still no luck - set an approximate color @@ -255,6 +265,7 @@ void GfxPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealM } } pTo->timestamp = g_system->getMillis() * 60 / 1000; + return paletteChanged; } uint16 GfxPalette::matchColor(Palette *pPal, byte r, byte g, byte b) { diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h index 16b4d375d3..224c03965b 100644 --- a/engines/sci/graphics/palette.h +++ b/engines/sci/graphics/palette.h @@ -44,7 +44,7 @@ public: void modifyAmigaPalette(byte *data); void setEGA(); void set(Palette *sciPal, bool force, bool forceRealMerge = false); - void merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge); + bool merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge); uint16 matchColor(Palette *pPal, byte r, byte g, byte b); void getSys(Palette *pal); |