4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file 32bpp_anim.hpp A 32 bpp blitter with animation support. */
12 #ifndef BLITTER_32BPP_ANIM_HPP
13 #define BLITTER_32BPP_ANIM_HPP
15 #include "32bpp_optimized.hpp"
17 /** The optimised 32 bpp blitter with palette animation. */
18 class Blitter_32bppAnim
: public Blitter_32bppOptimized
{
20 uint16
*anim_buf
; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
21 int anim_buf_width
; ///< The width of the animation buffer.
22 int anim_buf_height
; ///< The height of the animation buffer.
23 int anim_buf_pitch
; ///< The pitch of the animation buffer.
24 Palette palette
; ///< The current palette.
33 this->palette
= _cur_palette
;
38 /* virtual */ void Draw(Blitter::BlitterParams
*bp
, BlitterMode mode
, ZoomLevel zoom
);
39 /* virtual */ void DrawColourMappingRect(void *dst
, int width
, int height
, PaletteID pal
);
40 /* virtual */ void SetPixel(void *video
, int x
, int y
, uint8 colour
);
41 /* virtual */ void DrawLine(void *video
, int x
, int y
, int x2
, int y2
, int screen_width
, int screen_height
, uint8 colour
, int width
, int dash
);
42 /* virtual */ void SetLine(void *video
, int x
, int y
, uint8
*colours
, uint width
);
43 /* virtual */ void SetLine32(void *video
, int x
, int y
, uint32
*colours
, uint width
);
44 /* virtual */ void DrawRect(void *video
, int width
, int height
, uint8 colour
);
45 /* virtual */ void CopyFromBuffer(void *video
, const void *src
, int width
, int height
);
46 /* virtual */ void CopyToBuffer(const void *video
, void *dst
, int width
, int height
);
47 /* virtual */ void ScrollBuffer(void *video
, int &left
, int &top
, int &width
, int &height
, int scroll_x
, int scroll_y
);
48 /* virtual */ int BufferSize(int width
, int height
);
49 /* virtual */ void PaletteAnimate(const Palette
&palette
);
50 /* virtual */ Blitter::PaletteAnimation
UsePaletteAnimation();
52 /* virtual */ const char *GetName() { return "32bpp-anim"; }
53 /* virtual */ int GetBytesPerPixel() { return 6; }
54 /* virtual */ void PostResize();
57 * Look up the colour in the current palette.
59 inline Colour
LookupColourInPalette(uint index
)
61 return this->palette
.palette
[index
];
64 inline int ScreenToAnimOffset(const uint32
*video
)
66 int raw_offset
= video
- (const uint32
*)_screen
.dst_ptr
;
67 if (_screen
.pitch
== this->anim_buf_pitch
) return raw_offset
;
68 int lines
= raw_offset
/ _screen
.pitch
;
69 int across
= raw_offset
% _screen
.pitch
;
70 return across
+ (lines
* this->anim_buf_pitch
);
73 template <BlitterMode mode
, bool no_anim_translucent
> void Draw(const Blitter::BlitterParams
*bp
, ZoomLevel zoom
);
76 /** Factory for the 32bpp blitter with animation. */
77 class FBlitter_32bppAnim
: public BlitterFactory
{
79 FBlitter_32bppAnim() : BlitterFactory("32bpp-anim", "32bpp Animation Blitter (palette animation)") {}
80 /* virtual */ Blitter
*CreateInstance() { return new Blitter_32bppAnim(); }
83 #endif /* BLITTER_32BPP_ANIM_HPP */