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