aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2009-08-13 00:19:26 +0000
committerJohannes Schickel2009-08-13 00:19:26 +0000
commitbc5a2d02e276665409fcc6806c618039495fbd95 (patch)
treee29f3c5069e3999e5b99e61bd285ceaec4baeac5
parent57566ad337415f639cfedbc38a668d75f8272135 (diff)
downloadscummvm-rg350-bc5a2d02e276665409fcc6806c618039495fbd95.tar.gz
scummvm-rg350-bc5a2d02e276665409fcc6806c618039495fbd95.tar.bz2
scummvm-rg350-bc5a2d02e276665409fcc6806c618039495fbd95.zip
Little optimization in Screen::setPaletteIndex, now it only resets the palette, when the color index really changed.
svn-id: r43338
-rw-r--r--engines/kyra/screen.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index bc1ccbb801..52035a49f4 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -658,10 +658,18 @@ int Screen::fadePalStep(const Palette &pal, int diff) {
}
void Screen::setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue) {
- getPalette(0)[index * 3 + 0] = red;
- getPalette(0)[index * 3 + 1] = green;
- getPalette(0)[index * 3 + 2] = blue;
- setScreenPalette(getPalette(0));
+ Palette &pal = getPalette(0);
+
+ const int offset = index * 3;
+
+ if (pal[offset + 0] == red && pal[offset + 1] == green && pal[offset + 2] == blue)
+ return;
+
+ pal[offset + 0] = red;
+ pal[offset + 1] = green;
+ pal[offset + 2] = blue;
+
+ setScreenPalette(pal);
}
void Screen::getRealPalette(int num, uint8 *dst) {