diff options
author | truebrain <truebrain@openttd.org> | 2012-01-03 09:46:37 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2012-01-03 09:46:37 +0000 |
commit | 8dbb654e399e6bea2c656d200ba5ee1cf2027bc9 (patch) | |
tree | 54a21d062776ad2a28f5bcd7b849de2aa39132ce | |
parent | 4da7f2b7230b0f199105024b705f3f2fa9b7ec2b (diff) | |
download | openttd-8dbb654e399e6bea2c656d200ba5ee1cf2027bc9.tar.xz |
(svn r23727) -Codechange: speedup the 32bpp palette animation by reducing the amount of compares. This is possible because the function is called with only 2 possible conditions: from 0 to 255 (full palette update, 8bpp only) or from PALETTE_ANIM_START to 255
-rw-r--r-- | src/blitter/32bpp_anim.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index 4d81a538e..bb959524e 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -323,7 +323,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, * palette animation, much cheaper though slightly nastier. */ for (int i = 0; i < width; i++) { uint colour = GB(*anim_pal, 0, 8); - if (IsInsideBS(colour, PALETTE_ANIM_START, PALETTE_ANIM_SIZE)) { + if (colour >= PALETTE_ANIM_START) { /* Update this pixel */ *dst_pal = this->AdjustBrightness(LookupColourInPalette(colour), GB(*anim_pal, 8, 8)); } @@ -417,11 +417,11 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette) assert(!_screen_disable_anim); this->palette = palette; - /* Never repaint the transparency pixel */ - if (this->palette.first_dirty == 0) { - this->palette.first_dirty++; - this->palette.count_dirty--; - } + /* If first_dirty is 0, it is for 8bpp indication to send the new + * palette. As we dont do that for 32bpp, ignore that request + * completely */ + if (this->palette.first_dirty == 0) return; + assert(this->palette.first_dirty == PALETTE_ANIM_START); const uint16 *anim = this->anim_buf; uint32 *dst = (uint32 *)_screen.dst_ptr; @@ -430,7 +430,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette) for (int y = this->anim_buf_height; y != 0 ; y--) { for (int x = this->anim_buf_width; x != 0 ; x--) { uint colour = GB(*anim, 0, 8); - if (IsInsideBS(colour, this->palette.first_dirty, this->palette.count_dirty)) { + if (colour >= PALETTE_ANIM_START) { /* Update this pixel */ *dst = this->AdjustBrightness(LookupColourInPalette(colour), GB(*anim, 8, 8)); } |