summaryrefslogtreecommitdiff
path: root/src/blitter
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-06-18 13:11:02 +0000
committersmatz <smatz@openttd.org>2008-06-18 13:11:02 +0000
commit883ffd168323c34fcc746e292817831ba3e9efc1 (patch)
tree2570ae0300b9343287ed765cd202e0db7ee5642c /src/blitter
parent424a7935adfd22bc9017544c985a8c0e846f3f1b (diff)
downloadopenttd-883ffd168323c34fcc746e292817831ba3e9efc1.tar.xz
(svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
Diffstat (limited to 'src/blitter')
-rw-r--r--src/blitter/32bpp_anim.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index ccbc38af9..28994f86e 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -4,6 +4,7 @@
#include "../stdafx.h"
#include "../core/alloc_func.hpp"
+#include "../core/math_func.hpp"
#include "../gfx_func.h"
#include "../zoom_func.h"
#include "../debug.h"
@@ -291,20 +292,29 @@ int Blitter_32bppAnim::BufferSize(int width, int height)
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
{
assert(!_screen_disable_anim);
- uint8 *anim = this->anim_buf;
+ assert(_screen.width == this->anim_buf_width && _screen.height == this->anim_buf_height);
/* Never repaint the transparency pixel */
- if (start == 0) start++;
+ if (start == 0) {
+ start++;
+ count--;
+ }
+
+ const uint8 *anim = this->anim_buf;
+ uint32 *dst = (uint32 *)_screen.dst_ptr;
/* Let's walk the anim buffer and try to find the pixels */
- for (int y = 0; y < this->anim_buf_height; y++) {
- for (int x = 0; x < this->anim_buf_width; x++) {
- if (*anim >= start && *anim <= start + count) {
+ for (int y = this->anim_buf_height; y != 0 ; y--) {
+ for (int x = this->anim_buf_width; x != 0 ; x--) {
+ uint colour = *anim;
+ if (IsInsideBS(colour, start, count)) {
/* Update this pixel */
- this->SetPixel(_screen.dst_ptr, x, y, *anim);
+ *dst = LookupColourInPalette(colour);
}
+ dst++;
anim++;
}
+ dst += _screen.pitch - _screen.width;
}
/* Make sure the backend redraws the whole screen */