author | rubidium |
Wed, 09 Jan 2008 18:11:12 +0000 | |
branch | noai |
changeset 9723 | eee46cb39750 |
parent 9629 | 66dde6412125 |
child 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
9628 | 1 |
/* $Id$ */ |
2 |
||
3 |
#ifndef BLITTER_BASE_HPP |
|
4 |
#define BLITTER_BASE_HPP |
|
5 |
||
6 |
#include "../spritecache.h" |
|
7 |
#include "../spriteloader/spriteloader.hpp" |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9629
diff
changeset
|
8 |
#include "../zoom_type.h" |
9628 | 9 |
|
10 |
enum BlitterMode { |
|
11 |
BM_NORMAL, |
|
12 |
BM_COLOUR_REMAP, |
|
13 |
BM_TRANSPARENT, |
|
14 |
}; |
|
15 |
||
16 |
/** |
|
17 |
* How all blitters should look like. Extend this class to make your own. |
|
18 |
*/ |
|
19 |
class Blitter { |
|
20 |
public: |
|
21 |
struct BlitterParams { |
|
22 |
const void *sprite; ///< Pointer to the sprite how ever the encoder stored it |
|
23 |
const byte *remap; ///< XXX -- Temporary storage for remap array |
|
24 |
||
25 |
int skip_left, skip_top; ///< How much pixels of the source to skip on the left and top (based on zoom of dst) |
|
26 |
int width, height; ///< The width and height in pixels that needs to be drawn to dst |
|
27 |
int sprite_width; ///< Real width of the sprite |
|
28 |
int sprite_height; ///< Real height of the sprite |
|
29 |
int left, top; ///< The offset in the 'dst' in pixels to start drawing |
|
30 |
||
31 |
void *dst; ///< Destination buffer |
|
32 |
int pitch; ///< The pitch of the destination buffer |
|
33 |
}; |
|
34 |
||
9629 | 35 |
enum PaletteAnimation { |
36 |
PALETTE_ANIMATION_NONE, ///< No palette animation |
|
37 |
PALETTE_ANIMATION_VIDEO_BACKEND, ///< Palette animation should be done by video backend (8bpp only!) |
|
38 |
PALETTE_ANIMATION_BLITTER, ///< The blitter takes care of the palette animation |
|
39 |
}; |
|
40 |
||
9628 | 41 |
typedef void *AllocatorProc(size_t size); |
42 |
||
43 |
/** |
|
44 |
* Get the screen depth this blitter works for. |
|
45 |
* This is either: 8, 16, 24 or 32. |
|
46 |
*/ |
|
47 |
virtual uint8 GetScreenDepth() = 0; |
|
48 |
||
49 |
/** |
|
50 |
* Draw an image to the screen, given an amount of params defined above. |
|
51 |
*/ |
|
52 |
virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0; |
|
53 |
||
54 |
/** |
|
55 |
* Draw a colortable to the screen. This is: the color of the screen is read |
|
56 |
* and is looked-up in the palette to match a new color, which then is put |
|
57 |
* on the screen again. |
|
58 |
* @param dst the destination pointer (video-buffer). |
|
59 |
* @param width the width of the buffer. |
|
60 |
* @param height the height of the buffer. |
|
61 |
* @param pal the palette to use. |
|
62 |
*/ |
|
63 |
virtual void DrawColorMappingRect(void *dst, int width, int height, int pal) = 0; |
|
64 |
||
65 |
/** |
|
66 |
* Convert a sprite from the loader to our own format. |
|
67 |
*/ |
|
68 |
virtual Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) = 0; |
|
69 |
||
70 |
/** |
|
71 |
* Move the destination pointer the requested amount x and y, keeping in mind |
|
72 |
* any pitch and bpp of the renderer. |
|
73 |
* @param video The destination pointer (video-buffer) to scroll. |
|
74 |
* @param x How much you want to scroll to the right. |
|
75 |
* @param y How much you want to scroll to the bottom. |
|
76 |
* @return A new destination pointer moved the the requested place. |
|
77 |
*/ |
|
78 |
virtual void *MoveTo(const void *video, int x, int y) = 0; |
|
79 |
||
80 |
/** |
|
81 |
* Draw a pixel with a given color on the video-buffer. |
|
82 |
* @param video The destination pointer (video-buffer). |
|
83 |
* @param x The x position within video-buffer. |
|
84 |
* @param y The y position within video-buffer. |
|
85 |
* @param color A 8bpp mapping color. |
|
86 |
*/ |
|
87 |
virtual void SetPixel(void *video, int x, int y, uint8 color) = 0; |
|
88 |
||
89 |
/** |
|
90 |
* Draw a pixel with a given color on the video-buffer if there is currently a black pixel. |
|
91 |
* @param video The destination pointer (video-buffer). |
|
92 |
* @param x The x position within video-buffer. |
|
93 |
* @param y The y position within video-buffer. |
|
94 |
* @param color A 8bpp mapping color. |
|
95 |
*/ |
|
96 |
virtual void SetPixelIfEmpty(void *video, int x, int y, uint8 color) = 0; |
|
97 |
||
98 |
/** |
|
99 |
* Make a single horizontal line in a single color on the video-buffer. |
|
100 |
* @param video The destination pointer (video-buffer). |
|
101 |
* @param width The lenght of the line. |
|
102 |
* @param color A 8bpp mapping color. |
|
103 |
*/ |
|
9629 | 104 |
virtual void DrawRect(void *video, int width, int height, uint8 color) = 0; |
105 |
||
106 |
/** |
|
107 |
* Draw a line with a given color. |
|
108 |
* @param video The destination pointer (video-buffer). |
|
109 |
* @param x The x coordinate from where the line starts. |
|
110 |
* @param y The y coordinate from where the line starts. |
|
111 |
* @param x2 The x coordinate to where the line goes. |
|
112 |
* @param y2 The y coordinate to where the lines goes. |
|
113 |
* @param screen_width The width of the screen you are drawing in (to avoid buffer-overflows). |
|
114 |
* @param screen_height The height of the screen you are drawing in (to avoid buffer-overflows). |
|
115 |
* @param color A 8bpp mapping color. |
|
116 |
*/ |
|
117 |
virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color) = 0; |
|
9628 | 118 |
|
119 |
/** |
|
120 |
* Copy from a buffer to the screen. |
|
121 |
* @param video The destionation pointer (video-buffer). |
|
122 |
* @param src The buffer from which the data will be read. |
|
123 |
* @param width The width of the buffer. |
|
124 |
* @param height The height of the buffer. |
|
9629 | 125 |
* @note You can not do anything with the content of the buffer, as the blitter can store non-pixel data in it too! |
9628 | 126 |
*/ |
9629 | 127 |
virtual void CopyFromBuffer(void *video, const void *src, int width, int height) = 0; |
9628 | 128 |
|
129 |
/** |
|
130 |
* Copy from the screen to a buffer. |
|
131 |
* @param video The destination pointer (video-buffer). |
|
132 |
* @param dst The buffer in which the data will be stored. |
|
133 |
* @param width The width of the buffer. |
|
134 |
* @param height The height of the buffer. |
|
9629 | 135 |
* @note You can not do anything with the content of the buffer, as the blitter can store non-pixel data in it too! |
9628 | 136 |
*/ |
9629 | 137 |
virtual void CopyToBuffer(const void *video, void *dst, int width, int height) = 0; |
9628 | 138 |
|
139 |
/** |
|
9629 | 140 |
* Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp. |
141 |
* @param video The destination pointer (video-buffer). |
|
142 |
* @param dst The buffer in which the data will be stored. |
|
143 |
* @param width The width of the buffer. |
|
144 |
* @param height The height of the buffer. |
|
145 |
* @param dst_pitch The pitch (byte per line) of the destination buffer. |
|
9628 | 146 |
*/ |
9629 | 147 |
virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) = 0; |
148 |
||
149 |
/** |
|
150 |
* Scroll the videobuffer some 'x' and 'y' value. |
|
151 |
* @param video The buffer to scroll into. |
|
152 |
* @param left The left value of the screen to scroll. |
|
153 |
* @param top The top value of the screen to scroll. |
|
154 |
* @param width The width of the screen to scroll. |
|
155 |
* @param height The height of the screen to scroll. |
|
156 |
* @param scroll_x How much to scroll in X. |
|
157 |
* @param scroll_y How much to scroll in Y. |
|
158 |
*/ |
|
159 |
virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) = 0; |
|
9628 | 160 |
|
161 |
/** |
|
162 |
* Calculate how much memory there is needed for an image of this size in the video-buffer. |
|
163 |
* @param width The width of the buffer-to-be. |
|
164 |
* @param height The height of the buffer-to-be. |
|
165 |
* @return The size needed for the buffer. |
|
166 |
*/ |
|
167 |
virtual int BufferSize(int width, int height) = 0; |
|
168 |
||
9629 | 169 |
/** |
170 |
* Called when the 8bpp palette is changed; you should redraw all pixels on the screen that |
|
171 |
* are equal to the 8bpp palette indexes 'start' to 'start + count'. |
|
172 |
* @param start The start index in the 8bpp palette. |
|
173 |
* @param count The amount of indexes that are (possible) changed. |
|
174 |
*/ |
|
175 |
virtual void PaletteAnimate(uint start, uint count) = 0; |
|
176 |
||
177 |
/** |
|
178 |
* Check if the blitter uses palette animation at all. |
|
179 |
* @return True if it uses palette animation. |
|
180 |
*/ |
|
181 |
virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0; |
|
182 |
||
183 |
/** |
|
184 |
* Get the naem of the blitter, the same as the Factory-instance returns. |
|
185 |
*/ |
|
186 |
virtual const char *GetName() = 0; |
|
187 |
||
9628 | 188 |
virtual ~Blitter() { } |
189 |
}; |
|
190 |
||
191 |
#endif /* BLITTER_BASE_HPP */ |