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