OpenTTD
32bpp_anim.cpp
Go to the documentation of this file.
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 #include "../stdafx.h"
13 #include "../video/video_driver.hpp"
14 #include "32bpp_anim.hpp"
15 #include "common.hpp"
16 
17 #include "../table/sprites.h"
18 
19 #include "../safeguards.h"
20 
23 
24 Blitter_32bppAnim::~Blitter_32bppAnim()
25 {
26  free(this->anim_alloc);
27 }
28 
29 template <BlitterMode mode>
30 inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
31 {
32  const SpriteData *src = (const SpriteData *)bp->sprite;
33 
34  const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
35  const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
36 
37  for (uint i = bp->skip_top; i != 0; i--) {
38  src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
39  src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
40  }
41 
42  Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
43  uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
44 
45  const byte *remap = bp->remap; // store so we don't have to access it via bp everytime
46 
47  for (int y = 0; y < bp->height; y++) {
48  Colour *dst_ln = dst + bp->pitch;
49  uint16 *anim_ln = anim + this->anim_buf_pitch;
50 
51  const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
52  src_px++;
53 
54  const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
55  src_n += 2;
56 
57  Colour *dst_end = dst + bp->skip_left;
58 
59  uint n;
60 
61  while (dst < dst_end) {
62  n = *src_n++;
63 
64  if (src_px->a == 0) {
65  dst += n;
66  src_px ++;
67  src_n++;
68 
69  if (dst > dst_end) anim += dst - dst_end;
70  } else {
71  if (dst + n > dst_end) {
72  uint d = dst_end - dst;
73  src_px += d;
74  src_n += d;
75 
76  dst = dst_end - bp->skip_left;
77  dst_end = dst + bp->width;
78 
79  n = min<uint>(n - d, (uint)bp->width);
80  goto draw;
81  }
82  dst += n;
83  src_px += n;
84  src_n += n;
85  }
86  }
87 
88  dst -= bp->skip_left;
89  dst_end -= bp->skip_left;
90 
91  dst_end += bp->width;
92 
93  while (dst < dst_end) {
94  n = min<uint>(*src_n++, (uint)(dst_end - dst));
95 
96  if (src_px->a == 0) {
97  anim += n;
98  dst += n;
99  src_px++;
100  src_n++;
101  continue;
102  }
103 
104  draw:;
105 
106  switch (mode) {
107  case BM_COLOUR_REMAP:
108  if (src_px->a == 255) {
109  do {
110  uint m = *src_n;
111  /* In case the m-channel is zero, do not remap this pixel in any way */
112  if (m == 0) {
113  *dst = src_px->data;
114  *anim = 0;
115  } else {
116  uint r = remap[GB(m, 0, 8)];
117  *anim = r | (m & 0xFF00);
118  if (r != 0) *dst = this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8));
119  }
120  anim++;
121  dst++;
122  src_px++;
123  src_n++;
124  } while (--n != 0);
125  } else {
126  do {
127  uint m = *src_n;
128  if (m == 0) {
129  *dst = ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, *dst);
130  *anim = 0;
131  } else {
132  uint r = remap[GB(m, 0, 8)];
133  *anim = 0;
134  if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8)), src_px->a, *dst);
135  }
136  anim++;
137  dst++;
138  src_px++;
139  src_n++;
140  } while (--n != 0);
141  }
142  break;
143 
144  case BM_CRASH_REMAP:
145  if (src_px->a == 255) {
146  do {
147  uint m = *src_n;
148  if (m == 0) {
149  uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
150  *dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
151  *anim = 0;
152  } else {
153  uint r = remap[GB(m, 0, 8)];
154  *anim = r | (m & 0xFF00);
155  if (r != 0) *dst = this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8));
156  }
157  anim++;
158  dst++;
159  src_px++;
160  src_n++;
161  } while (--n != 0);
162  } else {
163  do {
164  uint m = *src_n;
165  if (m == 0) {
166  if (src_px->a != 0) {
167  uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
168  *dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
169  *anim = 0;
170  }
171  } else {
172  uint r = remap[GB(m, 0, 8)];
173  *anim = 0;
174  if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8)), src_px->a, *dst);
175  }
176  anim++;
177  dst++;
178  src_px++;
179  src_n++;
180  } while (--n != 0);
181  }
182  break;
183 
184 
185  case BM_BLACK_REMAP:
186  do {
187  *dst++ = Colour(0, 0, 0);
188  *anim++ = 0;
189  src_px++;
190  src_n++;
191  } while (--n != 0);
192  break;
193 
194  case BM_TRANSPARENT:
195  /* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
196  * This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
197  * we produce a result the newgrf maker didn't expect ;) */
198 
199  /* Make the current colour a bit more black, so it looks like this image is transparent */
200  src_n += n;
201  if (src_px->a == 255) {
202  src_px += n;
203  do {
204  *dst = MakeTransparent(*dst, 3, 4);
205  *anim = 0;
206  anim++;
207  dst++;
208  } while (--n != 0);
209  } else {
210  do {
211  *dst = MakeTransparent(*dst, (256 * 4 - src_px->a), 256 * 4);
212  *anim = 0;
213  anim++;
214  dst++;
215  src_px++;
216  } while (--n != 0);
217  }
218  break;
219 
220  default:
221  if (src_px->a == 255) {
222  do {
223  /* Compiler assumes pointer aliasing, can't optimise this on its own */
224  uint m = GB(*src_n, 0, 8);
225  /* Above PALETTE_ANIM_START is palette animation */
226  *anim++ = *src_n;
227  *dst++ = (m >= PALETTE_ANIM_START) ? this->AdjustBrightness(this->LookupColourInPalette(m), GB(*src_n, 8, 8)) : src_px->data;
228  src_px++;
229  src_n++;
230  } while (--n != 0);
231  } else {
232  do {
233  uint m = GB(*src_n, 0, 8);
234  *anim++ = 0;
235  if (m >= PALETTE_ANIM_START) {
236  *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(m), GB(*src_n, 8, 8)), src_px->a, *dst);
237  } else {
238  *dst = ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, *dst);
239  }
240  dst++;
241  src_px++;
242  src_n++;
243  } while (--n != 0);
244  }
245  break;
246  }
247  }
248 
249  anim = anim_ln;
250  dst = dst_ln;
251  src_px = src_px_ln;
252  src_n = src_n_ln;
253  }
254 }
255 
257 {
258  if (_screen_disable_anim) {
259  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
260  Blitter_32bppOptimized::Draw(bp, mode, zoom);
261  return;
262  }
263 
264  switch (mode) {
265  default: NOT_REACHED();
266  case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
267  case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
268  case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
269  case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
270  case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP> (bp, zoom); return;
271  }
272 }
273 
274 void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
275 {
276  if (_screen_disable_anim) {
277  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColourMappingRect() */
278  Blitter_32bppOptimized::DrawColourMappingRect(dst, width, height, pal);
279  return;
280  }
281 
282  Colour *udst = (Colour *)dst;
283  uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)dst);
284 
285  if (pal == PALETTE_TO_TRANSPARENT) {
286  do {
287  for (int i = 0; i != width; i++) {
288  *udst = MakeTransparent(*udst, 154);
289  *anim = 0;
290  udst++;
291  anim++;
292  }
293  udst = udst - width + _screen.pitch;
294  anim = anim - width + this->anim_buf_pitch;
295  } while (--height);
296  return;
297  }
298  if (pal == PALETTE_NEWSPAPER) {
299  do {
300  for (int i = 0; i != width; i++) {
301  *udst = MakeGrey(*udst);
302  *anim = 0;
303  udst++;
304  anim++;
305  }
306  udst = udst - width + _screen.pitch;
307  anim = anim - width + this->anim_buf_pitch;
308  } while (--height);
309  return;
310  }
311 
312  DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
313 }
314 
315 void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
316 {
317  *((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
318 
319  /* Set the colour in the anim-buffer too, if we are rendering to the screen */
320  if (_screen_disable_anim) return;
321 
322  this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
323 }
324 
325 void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
326 {
327  const Colour c = LookupColourInPalette(colour);
328 
329  if (_screen_disable_anim) {
330  this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
331  *((Colour *)video + x + y * _screen.pitch) = c;
332  });
333  } else {
334  uint16 * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32 *)video);
335  const uint16 anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
336  this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
337  *((Colour *)video + x + y * _screen.pitch) = c;
338  offset_anim_buf[x + y * this->anim_buf_pitch] = anim_colour;
339  });
340  }
341 }
342 
343 void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
344 {
345  if (_screen_disable_anim) {
346  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
347  Blitter_32bppOptimized::DrawRect(video, width, height, colour);
348  return;
349  }
350 
351  Colour colour32 = LookupColourInPalette(colour);
352  uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf;
353 
354  do {
355  Colour *dst = (Colour *)video;
356  uint16 *anim = anim_line;
357 
358  for (int i = width; i > 0; i--) {
359  *dst = colour32;
360  /* Set the colour in the anim-buffer too */
361  *anim = colour | (DEFAULT_BRIGHTNESS << 8);
362  dst++;
363  anim++;
364  }
365  video = (uint32 *)video + _screen.pitch;
366  anim_line += this->anim_buf_pitch;
367  } while (--height);
368 }
369 
370 void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
371 {
372  assert(!_screen_disable_anim);
373  assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
374  Colour *dst = (Colour *)video;
375  const uint32 *usrc = (const uint32 *)src;
376  uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf;
377 
378  for (; height > 0; height--) {
379  /* We need to keep those for palette animation. */
380  Colour *dst_pal = dst;
381  uint16 *anim_pal = anim_line;
382 
383  memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32));
384  usrc += width;
385  dst += _screen.pitch;
386  /* Copy back the anim-buffer */
387  memcpy(anim_line, usrc, width * sizeof(uint16));
388  usrc = (const uint32 *)((const uint16 *)usrc + width);
389  anim_line += this->anim_buf_pitch;
390 
391  /* Okay, it is *very* likely that the image we stored is using
392  * the wrong palette animated colours. There are two things we
393  * can do to fix this. The first is simply reviewing the whole
394  * screen after we copied the buffer, i.e. run PaletteAnimate,
395  * however that forces a full screen redraw which is expensive
396  * for just the cursor. This just copies the implementation of
397  * palette animation, much cheaper though slightly nastier. */
398  for (int i = 0; i < width; i++) {
399  uint colour = GB(*anim_pal, 0, 8);
400  if (colour >= PALETTE_ANIM_START) {
401  /* Update this pixel */
402  *dst_pal = this->AdjustBrightness(LookupColourInPalette(colour), GB(*anim_pal, 8, 8));
403  }
404  dst_pal++;
405  anim_pal++;
406  }
407  }
408 }
409 
410 void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
411 {
412  assert(!_screen_disable_anim);
413  assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
414  uint32 *udst = (uint32 *)dst;
415  const uint32 *src = (const uint32 *)video;
416 
417  if (this->anim_buf == NULL) return;
418 
419  const uint16 *anim_line = this->ScreenToAnimOffset((const uint32 *)video) + this->anim_buf;
420 
421  for (; height > 0; height--) {
422  memcpy(udst, src, width * sizeof(uint32));
423  src += _screen.pitch;
424  udst += width;
425  /* Copy the anim-buffer */
426  memcpy(udst, anim_line, width * sizeof(uint16));
427  udst = (uint32 *)((uint16 *)udst + width);
428  anim_line += this->anim_buf_pitch;
429  }
430 }
431 
432 void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
433 {
434  assert(!_screen_disable_anim);
435  assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
436  uint16 *dst, *src;
437 
438  /* We need to scroll the anim-buffer too */
439  if (scroll_y > 0) {
440  dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_pitch;
441  src = dst - scroll_y * this->anim_buf_pitch;
442 
443  /* Adjust left & width */
444  if (scroll_x >= 0) {
445  dst += scroll_x;
446  } else {
447  src -= scroll_x;
448  }
449 
450  uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
451  uint th = height - scroll_y;
452  for (; th > 0; th--) {
453  memcpy(dst, src, tw * sizeof(uint16));
454  src -= this->anim_buf_pitch;
455  dst -= this->anim_buf_pitch;
456  }
457  } else {
458  /* Calculate pointers */
459  dst = this->anim_buf + left + top * this->anim_buf_pitch;
460  src = dst - scroll_y * this->anim_buf_pitch;
461 
462  /* Adjust left & width */
463  if (scroll_x >= 0) {
464  dst += scroll_x;
465  } else {
466  src -= scroll_x;
467  }
468 
469  /* the y-displacement may be 0 therefore we have to use memmove,
470  * because source and destination may overlap */
471  uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
472  uint th = height + scroll_y;
473  for (; th > 0; th--) {
474  memmove(dst, src, tw * sizeof(uint16));
475  src += this->anim_buf_pitch;
476  dst += this->anim_buf_pitch;
477  }
478  }
479 
480  Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
481 }
482 
483 int Blitter_32bppAnim::BufferSize(int width, int height)
484 {
485  return width * height * (sizeof(uint32) + sizeof(uint16));
486 }
487 
489 {
490  assert(!_screen_disable_anim);
491 
492  this->palette = palette;
493  /* If first_dirty is 0, it is for 8bpp indication to send the new
494  * palette. However, only the animation colours might possibly change.
495  * Especially when going between toyland and non-toyland. */
496  assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
497 
498  const uint16 *anim = this->anim_buf;
499  Colour *dst = (Colour *)_screen.dst_ptr;
500 
501  /* Let's walk the anim buffer and try to find the pixels */
502  const int width = this->anim_buf_width;
503  const int pitch_offset = _screen.pitch - width;
504  const int anim_pitch_offset = this->anim_buf_pitch - width;
505  for (int y = this->anim_buf_height; y != 0 ; y--) {
506  for (int x = width; x != 0 ; x--) {
507  uint16 value = *anim;
508  uint8 colour = GB(value, 0, 8);
509  if (colour >= PALETTE_ANIM_START) {
510  /* Update this pixel */
511  *dst = this->AdjustBrightness(LookupColourInPalette(colour), GB(value, 8, 8));
512  }
513  dst++;
514  anim++;
515  }
516  dst += pitch_offset;
517  anim += anim_pitch_offset;
518  }
519 
520  /* Make sure the backend redraws the whole screen */
521  VideoDriver::GetInstance()->MakeDirty(0, 0, _screen.width, _screen.height);
522 }
523 
525 {
527 }
528 
530 {
531  if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height ||
532  _screen.pitch != this->anim_buf_pitch) {
533  /* The size of the screen changed; we can assume we can wipe all data from our buffer */
534  free(this->anim_alloc);
535  this->anim_buf_width = _screen.width;
536  this->anim_buf_height = _screen.height;
537  this->anim_buf_pitch = (_screen.width + 7) & ~7;
538  this->anim_alloc = CallocT<uint16>(this->anim_buf_pitch * this->anim_buf_height + 8);
539 
540  /* align buffer to next 16 byte boundary */
541  this->anim_buf = reinterpret_cast<uint16 *>((reinterpret_cast<uintptr_t>(this->anim_alloc) + 0xF) & (~0xF));
542  }
543 }
virtual void MakeDirty(int left, int top, int width, int height)=0
Mark a particular area dirty.
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
static const PaletteID PALETTE_TO_TRANSPARENT
This sets the sprite to transparent.
Definition: sprites.h:1577
Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Definition: 32bpp_anim.hpp:59
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
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
Draw a colourtable to the screen.
Definition: 32bpp_anim.cpp:274
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
uint32 data
Conversion of the channel information to a 32 bit number.
Definition: gfx_type.h:165
int width
The width in pixels that needs to be drawn to dst.
Definition: base.hpp:39
uint8 a
colour channels in LE order
Definition: gfx_type.h:170
void PostResize()
Post resize event.
Definition: 32bpp_anim.cpp:529
uint16 * anim_buf
In this buffer we keep track of the 8bpp indexes so we can do palette animation.
Definition: 32bpp_anim.hpp:20
int BufferSize(int width, int height)
Calculate how much memory there is needed for an image of this size in the video-buffer.
Definition: 32bpp_anim.cpp:483
void * anim_alloc
The raw allocated buffer, not necessarily aligned correctly.
Definition: 32bpp_anim.hpp:21
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
Definition: base.hpp:37
static Colour ComposeColourPANoCheck(Colour colour, uint a, Colour current)
Compose a colour based on Pixel value, alpha value, and the current pixel value.
Definition: 32bpp_base.hpp:76
void DrawRect(void *video, int width, int height, uint8 colour)
Make a single horizontal line in a single colour on the video-buffer.
Definition: 32bpp_base.cpp:36
static FBlitter_32bppAnim iFBlitter_32bppAnim
Instantiation of the 32bpp with animation blitter factory.
Definition: 32bpp_anim.cpp:22
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
Scroll the videobuffer some &#39;x&#39; and &#39;y&#39; value.
Definition: 32bpp_base.cpp:86
void DrawRect(void *video, int width, int height, uint8 colour)
Make a single horizontal line in a single colour on the video-buffer.
Definition: 32bpp_anim.cpp:343
Common functionality for all blitter implementations.
The blitter takes care of the palette animation.
Definition: base.hpp:54
int anim_buf_height
The height of the animation buffer.
Definition: 32bpp_anim.hpp:23
Parameters related to blitting.
Definition: base.hpp:33
int pitch
The pitch of the destination buffer.
Definition: base.hpp:47
int anim_buf_pitch
The pitch of the animation buffer (width rounded up to 16 byte boundary).
Definition: 32bpp_anim.hpp:24
static const PaletteID PALETTE_NEWSPAPER
Recolour sprite for newspaper-greying.
Definition: sprites.h:1579
Perform a crash remapping.
Definition: base.hpp:23
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot) ...
Definition: gfx.cpp:44
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
Draw an image to the screen, given an amount of params defined above.
Definition: 32bpp_anim.cpp:256
int first_dirty
The first dirty element.
Definition: gfx_type.h:311
Perform remapping to a completely blackened sprite.
Definition: base.hpp:24
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
Draw a colourtable to the screen.
#define DEBUG(name, level,...)
Output a line of debugging information.
Definition: debug.h:36
static Colour MakeGrey(Colour colour)
Make a colour grey - based.
Definition: 32bpp_base.hpp:134
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
int anim_buf_width
The width of the animation buffer.
Definition: 32bpp_anim.hpp:22
Palette palette
The current palette.
Definition: 32bpp_anim.hpp:25
const byte * remap
XXX – Temporary storage for remap array.
Definition: base.hpp:35
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Factory for the 32bpp blitter with animation.
Definition: 32bpp_anim.hpp:77
const void * sprite
Pointer to the sprite how ever the encoder stored it.
Definition: base.hpp:34
static uint8 MakeDark(uint8 r, uint8 g, uint8 b)
Make a colour dark grey, for specialized 32bpp remapping.
Definition: 32bpp_base.hpp:123
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void CopyToBuffer(const void *video, void *dst, int width, int height)
Copy from the screen to a buffer.
Definition: 32bpp_anim.cpp:410
Perform a colour remapping.
Definition: base.hpp:21
Blitter::PaletteAnimation UsePaletteAnimation()
Check if the blitter uses palette animation at all.
Definition: 32bpp_anim.cpp:524
A 32 bpp blitter with animation support.
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
Scroll the videobuffer some &#39;x&#39; and &#39;y&#39; value.
Definition: 32bpp_anim.cpp:432
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
Draws a sprite to a (screen) buffer.
void PaletteAnimate(const Palette &palette)
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
Definition: 32bpp_anim.cpp:488
void * dst
Destination buffer.
Definition: base.hpp:46
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Definition: gfx_type.h:164
Perform the simple blitting.
Definition: base.hpp:20
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
BlitterMode
The modes of blitting we can do.
Definition: base.hpp:19
PaletteAnimation
Types of palette animation.
Definition: base.hpp:51
void SetPixel(void *video, int x, int y, uint8 colour)
Draw a pixel with a given colour on the video-buffer.
Definition: 32bpp_anim.cpp:315
static Colour ComposeColourRGBA(uint r, uint g, uint b, uint a, Colour current)
Compose a colour based on RGBA values and the current pixel value.
Definition: 32bpp_base.hpp:65
void CopyFromBuffer(void *video, const void *src, int width, int height)
Copy from a buffer to the screen.
Definition: 32bpp_anim.cpp:370
Index in the _palettes array from which all animations are taking places (table/palettes.h)
Definition: gfx_type.h:278
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
Draw a line with a given colour.
Definition: 32bpp_anim.cpp:325
static Colour MakeTransparent(Colour colour, uint nom, uint denom=256)
Make a pixel looks like it is transparent.
Definition: 32bpp_base.hpp:107
static Colour ComposeColourRGBANoCheck(uint r, uint g, uint b, uint a, Colour current)
Compose a colour based on RGBA values and the current pixel value.
Definition: 32bpp_base.hpp:48