summaryrefslogtreecommitdiff
path: root/src/blitter/32bpp_anim.hpp
diff options
context:
space:
mode:
authorJonathan G Rennison <j.g.rennison@gmail.com>2018-05-23 09:55:04 +0100
committerPeterN <peter@fuzzle.org>2018-05-23 09:55:04 +0100
commit17257b9620a78dc115fadbcfa9a891e5392f09ab (patch)
tree78ba69e935bebbdc3b4ad9996cdc0059e576bf8f /src/blitter/32bpp_anim.hpp
parent306b999cf41307377bebe916048bdfb6fdf8e648 (diff)
downloadopenttd-17257b9620a78dc115fadbcfa9a891e5392f09ab.tar.xz
Add: 32bpp SSE2 blitter palette animator (#6795)
Create a new blitter mode: 32bpp-sse2-anim, which is 32bpp-anim + this. 32bpp-sse2-anim is now used by default where 32bpp-anim would have been. Also use this with the 32bpp-sse4-anim blitter. See issue #6469.
Diffstat (limited to 'src/blitter/32bpp_anim.hpp')
-rw-r--r--src/blitter/32bpp_anim.hpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp
index 1b35c1766..da33ec95b 100644
--- a/src/blitter/32bpp_anim.hpp
+++ b/src/blitter/32bpp_anim.hpp
@@ -18,14 +18,16 @@
class Blitter_32bppAnim : public Blitter_32bppOptimized {
protected:
uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
+ void *anim_alloc; ///< The raw allocated buffer, not necessarily aligned correctly
int anim_buf_width; ///< The width of the animation buffer.
int anim_buf_height; ///< The height of the animation buffer.
- int anim_buf_pitch; ///< The pitch of the animation buffer.
+ int anim_buf_pitch; ///< The pitch of the animation buffer (width rounded up to 16 byte boundary).
Palette palette; ///< The current palette.
public:
Blitter_32bppAnim() :
anim_buf(NULL),
+ anim_alloc(NULL),
anim_buf_width(0),
anim_buf_height(0),
anim_buf_pitch(0)
@@ -58,6 +60,15 @@ public:
return this->palette.palette[index];
}
+ inline int ScreenToAnimOffset(const uint32 *video)
+ {
+ int raw_offset = video - (const uint32 *)_screen.dst_ptr;
+ if (_screen.pitch == this->anim_buf_pitch) return raw_offset;
+ int lines = raw_offset / _screen.pitch;
+ int across = raw_offset % _screen.pitch;
+ return across + (lines * this->anim_buf_pitch);
+ }
+
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
};