OpenTTD Source  1.11.0-beta2
40bpp_anim.hpp
1 /* $Id$ */
2 
3 /*
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/>.
8  */
9 
12 #ifndef BLITTER_40BPP_OPTIMIZED_HPP
13 #define BLITTER_40BPP_OPTIMIZED_HPP
14 
15 
16 #include "32bpp_optimized.hpp"
17 #include "../video/video_driver.hpp"
18 
21 public:
22 
23  // void *MoveTo(void *video, int x, int y) override;
24  void SetPixel(void *video, int x, int y, uint8 colour) override;
25  void DrawRect(void *video, int width, int height, uint8 colour) override;
26  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;
27  void CopyFromBuffer(void *video, const void *src, int width, int height) override;
28  void CopyToBuffer(const void *video, void *dst, int width, int height) override;
29  void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;
30  void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
31  void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
32  void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
33  Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
34  int BufferSize(int width, int height) override;
36  bool NeedsAnimationBuffer() override;
37 
38  const char *GetName() override { return "40bpp-anim"; }
39  int GetBytesPerPixel() override { return 5; }
40 
41  template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
42 
43 protected:
44  static inline Colour RealizeBlendedColour(uint8 anim, Colour c)
45  {
46  return anim != 0 ? AdjustBrightness(LookupColourInPalette(anim), GetColourBrightness(c)) : c;
47  }
48 
49 };
50 
53 protected:
54  bool IsUsable() const override
55  {
57  }
58 
59 public:
60  FBlitter_40bppAnim() : BlitterFactory("40bpp-anim", "40bpp Animation Blitter (OpenGL)") {}
61  Blitter *CreateInstance() override { return new Blitter_40bppAnim(); }
62 };
63 
64 #endif /* BLITTER_40BPP_OPTIMIZED_HPP */
VideoDriver::HasAnimBuffer
virtual bool HasAnimBuffer()
Does this video driver support a separate animation buffer in addition to the colour buffer?
Definition: video_driver.hpp:129
FBlitter_40bppAnim::CreateInstance
Blitter * CreateInstance() override
Create an instance of this Blitter-class.
Definition: 40bpp_anim.hpp:61
Blitter_40bppAnim::DrawColourMappingRect
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override
Draw a colourtable to the screen.
Definition: 40bpp_anim.cpp:332
BlitterMode
BlitterMode
The modes of blitting we can do.
Definition: base.hpp:17
Blitter
How all blitters should look like.
Definition: base.hpp:28
BlitterFactory
The base factory, keeping track of all blitters.
Definition: factory.hpp:23
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h: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:409
FBlitter_40bppAnim::IsUsable
bool IsUsable() const override
Is the blitter usable with the current drivers and hardware config?
Definition: 40bpp_anim.hpp:54
Blitter_40bppAnim::GetName
const char * GetName() override
Get the name of the blitter, the same as the Factory-instance returns.
Definition: 40bpp_anim.hpp:38
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:387
Blitter_40bppAnim::BufferSize
int BufferSize(int width, int height) override
Calculate how much memory there is needed for an image of this size in the video-buffer.
Definition: 40bpp_anim.cpp:505
Blitter_40bppAnim::Draw
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draws a sprite to a (screen) buffer.
Definition: 40bpp_anim.cpp:312
32bpp_optimized.hpp
Blitter_40bppAnim::SetPixel
void SetPixel(void *video, int x, int y, uint8 colour) override
Draw a pixel with a given colour on the video-buffer.
Definition: 40bpp_anim.cpp:31
Blitter_32bppBase::LookupColourInPalette
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Definition: 32bpp_base.hpp:38
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:453
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:431
FBlitter_40bppAnim
Factory for the 40 bpp animated blitter (for OpenGL).
Definition: 40bpp_anim.hpp:52
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:168
Blitter_40bppAnim::DrawLine
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
Draw a line with a given colour.
Definition: 40bpp_anim.cpp:68
Colour
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Definition: gfx_type.h:163
Blitter::PaletteAnimation
PaletteAnimation
Types of palette animation.
Definition: base.hpp:49
Blitter_40bppAnim::DrawRect
void DrawRect(void *video, int width, int height, uint8 colour) override
Make a single horizontal line in a single colour on the video-buffer.
Definition: 40bpp_anim.cpp:42
Blitter_40bppAnim::GetBytesPerPixel
int GetBytesPerPixel() override
Get how many bytes are needed to store a pixel.
Definition: 40bpp_anim.hpp:39
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:18
SpriteLoader::Sprite
Structure for passing information from the sprite loader to the blitter.
Definition: spriteloader.hpp:47
Blitter_40bppAnim::Encode
Sprite * Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override
Convert a sprite from the loader to our own format.
Definition: 40bpp_anim.cpp:381
Blitter_40bppAnim::NeedsAnimationBuffer
bool NeedsAnimationBuffer() override
Does this blitter require a separate animation buffer from the video backend?
Definition: 40bpp_anim.cpp:515
Blitter_40bppAnim
The optimized 40 bpp blitter (for OpenGL video driver).
Definition: 40bpp_anim.hpp:20
Blitter::BlitterParams
Parameters related to blitting.
Definition: base.hpp:31
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:510