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