2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file 32bpp_anim.hpp A 32 bpp blitter with animation support. */
|
2007-06-19 17:43:30 +00:00
|
|
|
|
|
|
|
#ifndef BLITTER_32BPP_ANIM_HPP
|
|
|
|
#define BLITTER_32BPP_ANIM_HPP
|
|
|
|
|
2007-09-09 23:16:01 +00:00
|
|
|
#include "32bpp_optimized.hpp"
|
2007-06-19 17:43:30 +00:00
|
|
|
|
2011-05-01 10:15:33 +00:00
|
|
|
/** The optimised 32 bpp blitter with palette animation. */
|
2014-01-02 23:52:13 +00:00
|
|
|
class Blitter_32bppAnim : public Blitter_32bppOptimized {
|
|
|
|
protected:
|
2011-12-24 23:33:45 +00:00
|
|
|
uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
|
2015-12-17 20:45:33 +00:00
|
|
|
void *anim_alloc; ///< The raw allocated buffer, not necessarily aligned correctly
|
2011-05-01 10:15:33 +00:00
|
|
|
int anim_buf_width; ///< The width of the animation buffer.
|
2015-12-17 20:45:33 +00:00
|
|
|
int anim_buf_pitch; ///< The pitch of the animation buffer (width rounded up to 16 byte boundary).
|
2011-05-01 10:15:33 +00:00
|
|
|
int anim_buf_height; ///< The height of the animation buffer.
|
2011-12-08 19:37:33 +00:00
|
|
|
Palette palette; ///< The current palette.
|
2007-06-19 17:43:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Blitter_32bppAnim() :
|
2019-04-10 21:07:06 +00:00
|
|
|
anim_buf(nullptr),
|
|
|
|
anim_alloc(nullptr),
|
2007-06-19 17:43:30 +00:00
|
|
|
anim_buf_width(0),
|
2015-12-17 20:45:33 +00:00
|
|
|
anim_buf_pitch(0),
|
2007-06-19 17:43:30 +00:00
|
|
|
anim_buf_height(0)
|
2017-03-07 23:37:06 +00:00
|
|
|
{
|
|
|
|
this->palette = _cur_palette;
|
|
|
|
}
|
2007-06-19 17:43:30 +00:00
|
|
|
|
2015-12-17 20:45:33 +00:00
|
|
|
~Blitter_32bppAnim();
|
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
|
|
|
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
|
|
|
void SetPixel(void *video, int x, int y, uint8 colour) override;
|
2022-05-18 23:08:15 +00:00
|
|
|
void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override;
|
2019-03-03 22:25:13 +00:00
|
|
|
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
|
2020-10-01 22:11:15 +00:00
|
|
|
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
|
|
|
|
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override;
|
2019-03-03 22:25:13 +00:00
|
|
|
void DrawRect(void *video, int width, int height, uint8 colour) override;
|
2023-01-17 22:18:02 +00:00
|
|
|
void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override;
|
2019-03-03 22:25:13 +00:00
|
|
|
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
|
|
|
|
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
|
2020-02-09 00:34:47 +00:00
|
|
|
void ScrollBuffer(void *video, int left, int top, int width, int height, int scroll_x, int scroll_y) override;
|
2023-01-02 20:30:02 +00:00
|
|
|
size_t BufferSize(uint width, uint height) override;
|
2019-03-03 22:25:13 +00:00
|
|
|
void PaletteAnimate(const Palette &palette) override;
|
|
|
|
Blitter::PaletteAnimation UsePaletteAnimation() override;
|
2007-06-21 13:56:59 +00:00
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
const char *GetName() override { return "32bpp-anim"; }
|
|
|
|
int GetBytesPerPixel() override { return 6; }
|
|
|
|
void PostResize() override;
|
2008-06-26 15:46:19 +00:00
|
|
|
|
2011-12-08 19:37:33 +00:00
|
|
|
/**
|
|
|
|
* Look up the colour in the current palette.
|
|
|
|
*/
|
2012-04-10 20:16:51 +00:00
|
|
|
inline Colour LookupColourInPalette(uint index)
|
2011-12-08 19:37:33 +00:00
|
|
|
{
|
2012-04-10 20:16:51 +00:00
|
|
|
return this->palette.palette[index];
|
2011-12-08 19:37:33 +00:00
|
|
|
}
|
|
|
|
|
2015-12-17 20:45:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-01-19 23:24:09 +00:00
|
|
|
template <BlitterMode mode, bool no_anim_translucent> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
2007-06-19 17:43:30 +00:00
|
|
|
};
|
|
|
|
|
2011-05-01 10:15:33 +00:00
|
|
|
/** Factory for the 32bpp blitter with animation. */
|
2014-01-02 22:41:58 +00:00
|
|
|
class FBlitter_32bppAnim : public BlitterFactory {
|
2007-06-19 17:43:30 +00:00
|
|
|
public:
|
2014-01-02 22:41:58 +00:00
|
|
|
FBlitter_32bppAnim() : BlitterFactory("32bpp-anim", "32bpp Animation Blitter (palette animation)") {}
|
2019-03-03 22:25:13 +00:00
|
|
|
Blitter *CreateInstance() override { return new Blitter_32bppAnim(); }
|
2007-06-19 17:43:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* BLITTER_32BPP_ANIM_HPP */
|