diff options
Diffstat (limited to 'saga/gfx.cpp')
-rw-r--r-- | saga/gfx.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 121bd7cb19..c18115e7e9 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -182,12 +182,30 @@ void Gfx::setPalette(const PalEntry *pal) { } void Gfx::setPaletteColor(int n, int r, int g, int b) { - _currentPal[4 * n + 0] = r; - _currentPal[4 * n + 1] = g; - _currentPal[4 * n + 2] = b; - _currentPal[4 * n + 3] = 0; + bool update = false; - _system->setPalette(_currentPal, n, 1); + // This function may get called a lot. To avoid forcing full-screen + // updates, only update the palette if the color actually changes. + + if (_currentPal[4 * n + 0] != r) { + _currentPal[4 * n + 0] = r; + update = true; + } + if (_currentPal[4 * n + 1] != g) { + _currentPal[4 * n + 1] = g; + update = true; + } + if (_currentPal[4 * n + 2] != b) { + _currentPal[4 * n + 2] = b; + update = true; + } + if (_currentPal[4 * n + 3] != 0) { + _currentPal[4 * n + 3] = 0; + update = true; + } + + if (update) + _system->setPalette(_currentPal, n, 1); } void Gfx::getCurrentPal(PalEntry *src_pal) { |