OpenTTD Source  20240919-master-gdf0233f4c2
40bpp_anim.hpp
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  */
7 
10 #ifndef BLITTER_40BPP_OPTIMIZED_HPP
11 #define BLITTER_40BPP_OPTIMIZED_HPP
12 
13 
14 #include "32bpp_optimized.hpp"
15 #include "../video/video_driver.hpp"
16 
19 public:
20 
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;
33  bool NeedsAnimationBuffer() override;
34 
35  std::string_view GetName() override { return "40bpp-anim"; }
36 
37  template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
38 
39 protected:
40  static inline Colour RealizeBlendedColour(uint8_t anim, Colour c)
41  {
42  return anim != 0 ? AdjustBrightness(LookupColourInPalette(anim), GetColourBrightness(c)) : c;
43  }
44 
45 };
46 
49 protected:
50  bool IsUsable() const override
51  {
53  }
54 
55 public:
56  FBlitter_40bppAnim() : BlitterFactory("40bpp-anim", "40bpp Animation Blitter (OpenGL)") {}
57  Blitter *CreateInstance() override { return new Blitter_40bppAnim(); }
58 };
59 
60 #endif /* BLITTER_40BPP_OPTIMIZED_HPP */
Blitter_40bppAnim::BufferSize
size_t BufferSize(uint width, uint height) override
Calculate how much memory there is needed for an image of this size in the video-buffer.
Definition: 40bpp_anim.cpp:524
VideoDriver::HasAnimBuffer
virtual bool HasAnimBuffer()
Does this video driver support a separate animation buffer in addition to the colour buffer?
Definition: video_driver.hpp:135
FBlitter_40bppAnim::CreateInstance
Blitter * CreateInstance() override
Create an instance of this Blitter-class.
Definition: 40bpp_anim.hpp:57
Blitter_40bppAnim::DrawColourMappingRect
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override
Draw a colourtable to the screen.
Definition: 40bpp_anim.cpp:351
BlitterMode
BlitterMode
The modes of blitting we can do.
Definition: base.hpp:17
Blitter
How all blitters should look like.
Definition: base.hpp:29
BlitterFactory
The base factory, keeping track of all blitters.
Definition: factory.hpp:21
Blitter_40bppAnim::CopyToBuffer
void CopyToBuffer(const void *video, void *dst, int width, int height) override
Copy from the screen to a buffer.
Definition: 40bpp_anim.cpp:428
FBlitter_40bppAnim::IsUsable
bool IsUsable() const override
Is the blitter usable with the current drivers and hardware config?
Definition: 40bpp_anim.hpp:50
Blitter_40bppAnim::GetName
std::string_view GetName() override
Get the name of the blitter, the same as the Factory-instance returns.
Definition: 40bpp_anim.hpp:35
PaletteID
uint32_t PaletteID
The number of the palette.
Definition: gfx_type.h:19
Blitter_40bppAnim::DrawLine
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
Draw a line with a given colour.
Definition: 40bpp_anim.cpp:68
SpriteAllocator
Interface for something that can allocate memory for a sprite.
Definition: spriteloader.hpp:88
SpriteLoader::SpriteCollection
std::array< Sprite, ZOOM_LVL_END > SpriteCollection
Type defining a collection of sprites, one for each zoom level.
Definition: spriteloader.hpp:70
Blitter_40bppAnim::CopyFromBuffer
void CopyFromBuffer(void *video, const void *src, int width, int height) override
Copy from a buffer to the screen.
Definition: 40bpp_anim.cpp:406
Blitter_40bppAnim::SetPixel
void SetPixel(void *video, int x, int y, uint8_t colour) override
Draw a pixel with a given colour on the video-buffer.
Definition: 40bpp_anim.cpp:30
Blitter_40bppAnim::Draw
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draws a sprite to a (screen) buffer.
Definition: 40bpp_anim.cpp:330
Blitter_40bppAnim::Encode
Sprite * Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override
Convert a sprite from the loader to our own format.
Definition: 40bpp_anim.cpp:400
32bpp_optimized.hpp
Blitter_40bppAnim::DrawRect
void DrawRect(void *video, int width, int height, uint8_t colour) override
Make a single horizontal line in a single colour on the video-buffer.
Definition: 40bpp_anim.cpp:42
Blitter_32bppBase::LookupColourInPalette
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Definition: 32bpp_base.hpp:37
Blitter_40bppAnim::ScrollBuffer
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override
Scroll the videobuffer some 'x' and 'y' value.
Definition: 40bpp_anim.cpp:472
Blitter_40bppAnim::CopyImageToBuffer
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
Definition: 40bpp_anim.cpp:450
FBlitter_40bppAnim
Factory for the 40 bpp animated blitter (for OpenGL).
Definition: 40bpp_anim.hpp:48
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:201
Colour
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Definition: gfx_type.h:165
Blitter::PaletteAnimation
PaletteAnimation
Types of palette animation.
Definition: base.hpp:50
Blitter_40bppAnim::NeedsAnimationBuffer
bool NeedsAnimationBuffer() override
Does this blitter require a separate animation buffer from the video backend?
Definition: 40bpp_anim.cpp:534
Blitter_40bppAnim
The optimized 40 bpp blitter (for OpenGL video driver).
Definition: 40bpp_anim.hpp:18
Blitter::BlitterParams
Parameters related to blitting.
Definition: base.hpp:32
Sprite
Data structure describing a sprite.
Definition: spritecache.h:17
Blitter_32bppOptimized
The optimised 32 bpp blitter (without palette animation).
Definition: 32bpp_optimized.hpp:16
Blitter_40bppAnim::UsePaletteAnimation
Blitter::PaletteAnimation UsePaletteAnimation() override
Check if the blitter uses palette animation at all.
Definition: 40bpp_anim.cpp:529
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:16