Update: Translations from eints
[openttd-github.git] / src / blitter / 40bpp_anim.hpp
blob0174735c3a99c39c58348ce59c3b0c4a54b31450
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file 40bpp_optimized.hpp Optimized 40 bpp blitter. */
10 #ifndef BLITTER_40BPP_OPTIMIZED_HPP
11 #define BLITTER_40BPP_OPTIMIZED_HPP
14 #include "32bpp_optimized.hpp"
15 #include "../video/video_driver.hpp"
17 /** The optimized 40 bpp blitter (for OpenGL video driver). */
18 class Blitter_40bppAnim : public Blitter_32bppOptimized {
19 public:
21 void SetPixel(void *video, int x, int y, uint8_t colour) override;
22 void DrawRect(void *video, int width, int height, uint8_t colour) override;
23 void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override;
24 void CopyFromBuffer(void *video, const void *src, int width, int height) override;
25 void CopyToBuffer(const void *video, void *dst, int width, int height) override;
26 void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
27 void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
28 void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
29 void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
30 Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
31 size_t BufferSize(uint width, uint height) override;
32 Blitter::PaletteAnimation UsePaletteAnimation() override;
33 bool NeedsAnimationBuffer() override;
35 std::string_view GetName() override { return "40bpp-anim"; }
37 template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
39 protected:
40 static inline Colour RealizeBlendedColour(uint8_t anim, Colour c)
42 return anim != 0 ? AdjustBrightness(LookupColourInPalette(anim), GetColourBrightness(c)) : c;
47 /** Factory for the 40 bpp animated blitter (for OpenGL). */
48 class FBlitter_40bppAnim : public BlitterFactory {
49 protected:
50 bool IsUsable() const override
52 return VideoDriver::GetInstance() == nullptr || VideoDriver::GetInstance()->HasAnimBuffer();
55 public:
56 FBlitter_40bppAnim() : BlitterFactory("40bpp-anim", "40bpp Animation Blitter (OpenGL)") {}
57 Blitter *CreateInstance() override { return new Blitter_40bppAnim(); }
60 #endif /* BLITTER_40BPP_OPTIMIZED_HPP */