OpenTTD
base.hpp
Go to the documentation of this file.
1 /* $Id: base.hpp 26969 2014-10-06 18:45:51Z rubidium $ */
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_BASE_HPP
13 #define BLITTER_BASE_HPP
14 
15 #include "../spritecache.h"
16 #include "../spriteloader/spriteloader.hpp"
17 
25 };
26 
30 class Blitter {
31 public:
33  struct BlitterParams {
34  const void *sprite;
35  const byte *remap;
36 
37  int skip_left;
38  int skip_top;
39  int width;
40  int height;
43  int left;
44  int top;
45 
46  void *dst;
47  int pitch;
48  };
49 
55  };
56 
61  virtual uint8 GetScreenDepth() = 0;
62 
66  virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0;
67 
77  virtual void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) = 0;
78 
82  virtual Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) = 0;
83 
92  virtual void *MoveTo(void *video, int x, int y) = 0;
93 
101  virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
102 
110  virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0;
111 
125  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 = 0);
126 
135  virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0;
136 
145  virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0;
146 
155  virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0;
156 
167  virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0;
168 
175  virtual int BufferSize(int width, int height) = 0;
176 
182  virtual void PaletteAnimate(const Palette &palette) = 0;
183 
189 
193  virtual const char *GetName() = 0;
194 
198  virtual int GetBytesPerPixel() = 0;
199 
203  virtual void PostResize() { };
204 
205  virtual ~Blitter() { }
206 };
207 
208 #endif /* BLITTER_BASE_HPP */
int left
The left offset in the &#39;dst&#39; in pixels to start drawing.
Definition: base.hpp:43
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:20
int sprite_width
Real width of the sprite.
Definition: base.hpp:41
Information about the currently used palette.
Definition: gfx_type.h:309
int height
The height in pixels that needs to be drawn to dst.
Definition: base.hpp:40
Perform transparency colour remapping.
Definition: base.hpp:22
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
Definition: base.hpp:38
Data structure describing a sprite.
Definition: spritecache.h:18
int sprite_height
Real height of the sprite.
Definition: base.hpp:42
virtual void SetPixel(void *video, int x, int y, uint8 colour)=0
Draw a pixel with a given colour on the video-buffer.
int width
The width in pixels that needs to be drawn to dst.
Definition: base.hpp:39
No palette animation.
Definition: base.hpp:52
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
Definition: base.hpp:37
virtual Sprite * Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)=0
Convert a sprite from the loader to our own format.
How all blitters should look like.
Definition: base.hpp:30
virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)=0
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp...
virtual const char * GetName()=0
Get the name of the blitter, the same as the Factory-instance returns.
virtual void PostResize()
Post resize event.
Definition: base.hpp:203
virtual int GetBytesPerPixel()=0
Get how many bytes are needed to store a pixel.
Palette animation should be done by video backend (8bpp only!)
Definition: base.hpp:53
The blitter takes care of the palette animation.
Definition: base.hpp:54
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=0)
Draw a line with a given colour.
Definition: base.cpp:18
Parameters related to blitting.
Definition: base.hpp:33
virtual void PaletteAnimate(const Palette &palette)=0
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
int pitch
The pitch of the destination buffer.
Definition: base.hpp:47
virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)=0
Draw an image to the screen, given an amount of params defined above.
Perform a crash remapping.
Definition: base.hpp:23
Structure for passing information from the sprite loader to the blitter.
Perform remapping to a completely blackened sprite.
Definition: base.hpp:24
virtual void CopyToBuffer(const void *video, void *dst, int width, int height)=0
Copy from the screen to a buffer.
virtual Blitter::PaletteAnimation UsePaletteAnimation()=0
Check if the blitter uses palette animation at all.
virtual int BufferSize(int width, int height)=0
Calculate how much memory there is needed for an image of this size in the video-buffer.
virtual void DrawRect(void *video, int width, int height, uint8 colour)=0
Make a single horizontal line in a single colour on the video-buffer.
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:21
int top
The top offset in the &#39;dst&#39; in pixels to start drawing.
Definition: base.hpp:44
const byte * remap
XXX – Temporary storage for remap array.
Definition: base.hpp:35
virtual void CopyFromBuffer(void *video, const void *src, int width, int height)=0
Copy from a buffer to the screen.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
Definition: base.hpp:34
Perform a colour remapping.
Definition: base.hpp:21
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
void * dst
Destination buffer.
Definition: base.hpp:46
Perform the simple blitting.
Definition: base.hpp:20
virtual uint8 GetScreenDepth()=0
Get the screen depth this blitter works for.
BlitterMode
The modes of blitting we can do.
Definition: base.hpp:19
PaletteAnimation
Types of palette animation.
Definition: base.hpp:51
virtual void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)=0
Draw a colourtable to the screen.
virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)=0
Scroll the videobuffer some &#39;x&#39; and &#39;y&#39; value.