OpenTTD Source  20240919-master-gdf0233f4c2
40bpp_anim.cpp
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 "../zoom_func.h"
12 #include "../settings_type.h"
13 #include "../video/video_driver.hpp"
14 #include "../palette_func.h"
15 #include "40bpp_anim.hpp"
16 #include "common.hpp"
17 
18 #include "../table/sprites.h"
19 
20 #include "../safeguards.h"
21 
22 
24 static FBlitter_40bppAnim iFBlitter_40bppAnim;
25 
27 static const Colour _black_colour(0, 0, 0);
28 
29 
30 void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
31 {
33  Blitter_32bppOptimized::SetPixel(video, x, y, colour);
34  } else {
35  size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
36  *((Colour *)video + x + y_offset) = _black_colour;
37 
38  VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = colour;
39  }
40 }
41 
42 void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8_t colour)
43 {
45  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
46  Blitter_32bppOptimized::DrawRect(video, width, height, colour);
47  return;
48  }
49 
50  assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
51  uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
52 
53  do {
54  Colour *dst = (Colour *)video;
55  uint8_t *anim = anim_line;
56 
57  for (int i = width; i > 0; i--) {
58  *dst = _black_colour;
59  *anim = colour;
60  dst++;
61  anim++;
62  }
63  video = (uint32_t *)video + _screen.pitch;
64  anim_line += _screen.pitch;
65  } while (--height);
66 }
67 
68 void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
69 {
71  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
72  Blitter_32bppOptimized::DrawLine(video, x, y, x2, y2, screen_width, screen_height, colour, width, dash);
73  return;
74  }
75 
76  assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
77  uint8_t *anim = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
78 
79  this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
80  *((Colour *)video + x + y * _screen.pitch) = _black_colour;
81  *(anim + x + y * _screen.pitch) = colour;
82  });
83 }
84 
92 template <BlitterMode mode>
94 {
95  const SpriteData *src = (const SpriteData *)bp->sprite;
96 
97  /* src_px : each line begins with uint32_t n = 'number of bytes in this line',
98  * then n times is the Colour struct for this line */
99  const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
100  /* src_n : each line begins with uint32_t n = 'number of bytes in this line',
101  * then interleaved stream of 'm' and 'n' channels. 'm' is remap,
102  * 'n' is number of bytes with the same alpha channel class */
103  const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
104 
105  /* skip upper lines in src_px and src_n */
106  for (uint i = bp->skip_top; i != 0; i--) {
107  src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
108  src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
109  }
110 
111  /* skip lines in dst */
112  Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
113  assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
114  uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)bp->dst - (uint32_t *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
115 
116  /* store so we don't have to access it via bp everytime (compiler assumes pointer aliasing) */
117  const uint8_t *remap = bp->remap;
118 
119  for (int y = 0; y < bp->height; y++) {
120  /* next dst line begins here */
121  Colour *dst_ln = dst + bp->pitch;
122  uint8_t *anim_ln = anim + bp->pitch;
123 
124  /* next src line begins here */
125  const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
126  src_px++;
127 
128  /* next src_n line begins here */
129  const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
130  src_n += 2;
131 
132  /* we will end this line when we reach this point */
133  Colour *dst_end = dst + bp->skip_left;
134 
135  /* number of pixels with the same alpha channel class */
136  uint n;
137 
138  while (dst < dst_end) {
139  n = *src_n++;
140 
141  if (src_px->a == 0) {
142  dst += n;
143  src_px++;
144  src_n++;
145 
146  if (dst > dst_end) anim += dst - dst_end;
147  } else {
148  if (dst + n > dst_end) {
149  uint d = dst_end - dst;
150  src_px += d;
151  src_n += d;
152 
153  dst = dst_end - bp->skip_left;
154  dst_end = dst + bp->width;
155 
156  n = std::min<uint>(n - d, (uint)bp->width);
157  goto draw;
158  }
159  dst += n;
160  src_px += n;
161  src_n += n;
162  }
163  }
164 
165  dst -= bp->skip_left;
166  dst_end -= bp->skip_left;
167 
168  dst_end += bp->width;
169 
170  while (dst < dst_end) {
171  n = std::min<uint>(*src_n++, (uint)(dst_end - dst));
172 
173  if (src_px->a == 0) {
174  anim += n;
175  dst += n;
176  src_px++;
177  src_n++;
178  continue;
179  }
180 
181  draw:;
182 
183  switch (mode) {
184  case BM_COLOUR_REMAP:
185  case BM_CRASH_REMAP:
186  if (src_px->a == 255) {
187  do {
188  uint8_t m = GB(*src_n, 0, 8);
189  /* In case the m-channel is zero, only apply the crash remap by darkening the RGB colour. */
190  if (m == 0) {
191  *dst = mode == BM_CRASH_REMAP ? this->MakeDark(*src_px) : *src_px;
192  *anim = 0;
193  } else {
194  uint r = remap[m];
195  if (r != 0) {
196  *dst = src_px->data;
197  *anim = r;
198  }
199  }
200  anim++;
201  dst++;
202  src_px++;
203  src_n++;
204  } while (--n != 0);
205  } else {
206  do {
207  uint8_t m = GB(*src_n, 0, 8);
208  Colour b = this->RealizeBlendedColour(*anim, *dst);
209  if (m == 0) {
210  Colour c = mode == BM_CRASH_REMAP ? this->MakeDark(*src_px) : *src_px;
211  *dst = this->ComposeColourRGBANoCheck(c.r, c.g, c.b, src_px->a, b);
212  *anim = 0;
213  } else {
214  uint r = remap[m];
215  if (r != 0) {
216  *dst = this->ComposeColourPANoCheck(this->LookupColourInPalette(r), src_px->a, b);
217  *anim = 0; // Animation colours don't work with alpha-blending.
218  }
219  }
220  anim++;
221  dst++;
222  src_px++;
223  src_n++;
224  } while (--n != 0);
225  }
226  break;
227 
228  case BM_BLACK_REMAP:
229  do {
230  *anim++ = 0;
231  *dst++ = _black_colour;
232  src_px++;
233  src_n++;
234  } while (--n != 0);
235  break;
236 
237  case BM_TRANSPARENT:
238  /* Make the current colour a bit more black, so it looks like this image is transparent */
239  src_n += n;
240  if (src_px->a == 255) {
241  src_px += n;
242  do {
243  /* If the anim buffer contains a color value, the image composition will
244  * only look at the RGB brightness value. As such, we can simply darken the
245  * RGB value to darken the anim color. */
246  Colour b = *anim != 0 ? Colour(this->GetColourBrightness(*dst), 0, 0) : *dst;
247  *dst = this->MakeTransparent(b, 3, 4);
248  anim++;
249  dst++;
250  } while (--n != 0);
251  } else {
252  do {
253  Colour b = this->RealizeBlendedColour(*anim, *dst);
254  *dst = this->MakeTransparent(b, (256 * 4 - src_px->a), 256 * 4);
255  *anim = 0; // Animation colours don't work with alpha-blending.
256  anim++;
257  dst++;
258  src_px++;
259  } while (--n != 0);
260  }
261  break;
262 
264  /* Apply custom transparency remap. */
265  src_n += n;
266  if (src_px->a != 0) {
267  src_px += n;
268  do {
269  if (*anim != 0) {
270  *anim = remap[*anim];
271  } else {
272  *dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
273  *anim = 0;
274  }
275  anim++;
276  dst++;
277  } while (--n != 0);
278  } else {
279  dst += n;
280  anim += n;
281  src_px += n;
282  }
283  break;
284 
285  default:
286  if (src_px->a == 255) {
287  do {
288  *anim++ = GB(*src_n, 0, 8);
289  *dst++ = src_px->data;
290  src_px++;
291  src_n++;
292  } while (--n != 0);
293  break;
294  } else {
295  do {
296  uint8_t m = GB(*src_n, 0, 8);
297  Colour b = this->RealizeBlendedColour(*anim, *dst);
298 
299  if (m == 0) {
300  *dst = this->ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, b);
301  *anim = 0;
302  } else {
303  *dst = this->ComposeColourPANoCheck(this->LookupColourInPalette(m), src_px->a, b);
304  *anim = m;
305  }
306 
307  anim++;
308  dst++;
309  src_px++;
310  src_n++;
311  } while (--n != 0);
312  }
313  }
314  }
315 
316  dst = dst_ln;
317  anim = anim_ln;
318  src_px = src_px_ln;
319  src_n = src_n_ln;
320  }
321 }
322 
331 {
332  assert(_screen.dst_ptr != nullptr);
333 
334  if (_screen_disable_anim || VideoDriver::GetInstance()->GetAnimBuffer() == nullptr) {
335  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
336  Blitter_32bppOptimized::Draw<true>(bp, mode, zoom);
337  return;
338  }
339 
340  switch (mode) {
341  default: NOT_REACHED();
342  case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
343  case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
344  case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
345  case BM_TRANSPARENT_REMAP: Draw<BM_TRANSPARENT_REMAP>(bp, zoom); return;
346  case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
347  case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP> (bp, zoom); return;
348  }
349 }
350 
351 void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
352 {
353  if (_screen_disable_anim) {
354  /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColourMappingRect() */
355  Blitter_32bppOptimized::DrawColourMappingRect(dst, width, height, pal);
356  return;
357  }
358 
359  Colour *udst = (Colour *)dst;
360  uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr);
361 
362  if (pal == PALETTE_TO_TRANSPARENT) {
363  /* If the anim buffer contains a color value, the image composition will
364  * only look at the RGB brightness value. As such, we can simply darken the
365  * RGB value to darken the anim color. */
366  do {
367  for (int i = 0; i != width; i++) {
368  Colour b = *anim != 0 ? Colour(this->GetColourBrightness(*udst), 0, 0) : *udst;
369  *udst = MakeTransparent(b, 154);
370  udst++;
371  anim++;
372  }
373  udst = udst - width + _screen.pitch;
374  anim = anim - width + _screen.pitch;
375  } while (--height);
376  } else if (pal == PALETTE_NEWSPAPER) {
377  const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
378  do {
379  for (int i = 0; i != width; i++) {
380  if (*anim == 0) *udst = MakeGrey(*udst);
381  *anim = remap[*anim];
382  udst++;
383  anim++;
384  }
385  udst = udst - width + _screen.pitch;
386  anim = anim - width + _screen.pitch;
387  } while (--height);
388  } else {
389  const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1;
390  do {
391  for (int i = 0; i != width; i++) {
392  *anim = remap[*anim];
393  anim++;
394  }
395  anim = anim - width + _screen.pitch;
396  } while (--height);
397  }
398 }
399 
401 {
402  return this->EncodeInternal<false>(sprite, allocator);
403 }
404 
405 
406 void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
407 {
408  assert(!_screen_disable_anim);
409  assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
410  uint32_t *dst = (uint32_t *)video;
411  const uint32_t *usrc = (const uint32_t *)src;
412 
413  uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
414  if (anim_buf == nullptr) return;
415  uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
416 
417  for (; height > 0; height--) {
418  memcpy(dst, usrc, width * sizeof(uint32_t));
419  usrc += width;
420  dst += _screen.pitch;
421  /* Copy back the anim-buffer */
422  memcpy(anim_line, usrc, width * sizeof(uint8_t));
423  usrc = (const uint32_t *)((const uint8_t *)usrc + width);
424  anim_line += _screen.pitch;
425  }
426 }
427 
428 void Blitter_40bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
429 {
430  assert(!_screen_disable_anim);
431  assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
432  uint32_t *udst = (uint32_t *)dst;
433  const uint32_t *src = (const uint32_t *)video;
434 
435  uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
436  if (anim_buf == nullptr) return;
437  const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
438 
439  for (; height > 0; height--) {
440  memcpy(udst, src, width * sizeof(uint32_t));
441  src += _screen.pitch;
442  udst += width;
443  /* Copy the anim-buffer */
444  memcpy(udst, anim_line, width * sizeof(uint8_t));
445  udst = (uint32_t *)((uint8_t *)udst + width);
446  anim_line += _screen.pitch;
447  }
448 }
449 
450 void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
451 {
452  uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
453  if (anim_buf == nullptr) {
454  Blitter_32bppOptimized::CopyImageToBuffer(video, dst, width, height, dst_pitch);
455  return;
456  }
457 
458  uint32_t *udst = (uint32_t *)dst;
459  const uint32_t *src = (const uint32_t *)video;
460  const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
461 
462  for (; height > 0; height--) {
463  for (int x = 0; x < width; x++) {
464  udst[x] = this->RealizeBlendedColour(anim_line[x], src[x]).data;
465  }
466  src += _screen.pitch;
467  anim_line += _screen.pitch;
468  udst += dst_pitch;
469  }
470 }
471 
472 void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
473 {
474  assert(!_screen_disable_anim);
475  assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
476  uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
477  uint8_t *dst, *src;
478 
479  /* We need to scroll the anim-buffer too */
480  if (scroll_y > 0) {
481  dst = anim_buf + left + (top + height - 1) * _screen.pitch;
482  src = dst - scroll_y * _screen.pitch;
483 
484  /* Adjust left & width */
485  if (scroll_x >= 0) {
486  dst += scroll_x;
487  } else {
488  src -= scroll_x;
489  }
490 
491  uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
492  uint th = height - scroll_y;
493  for (; th > 0; th--) {
494  memcpy(dst, src, tw * sizeof(uint8_t));
495  src -= _screen.pitch;
496  dst -= _screen.pitch;
497  }
498  } else {
499  /* Calculate pointers */
500  dst = anim_buf + left + top * _screen.pitch;
501  src = dst - scroll_y * _screen.pitch;
502 
503  /* Adjust left & width */
504  if (scroll_x >= 0) {
505  dst += scroll_x;
506  } else {
507  src -= scroll_x;
508  }
509 
510  /* the y-displacement may be 0 therefore we have to use memmove,
511  * because source and destination may overlap */
512  uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
513  uint th = height + scroll_y;
514  for (; th > 0; th--) {
515  memmove(dst, src, tw * sizeof(uint8_t));
516  src += _screen.pitch;
517  dst += _screen.pitch;
518  }
519  }
520 
521  Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
522 }
523 
524 size_t Blitter_40bppAnim::BufferSize(uint width, uint height)
525 {
526  return (sizeof(uint32_t) + sizeof(uint8_t)) * width * height;
527 }
528 
530 {
532 }
533 
535 {
536  return true;
537 }
Blitter_40bppAnim::BufferSize
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: 40bpp_anim.cpp:524
SpriteType::Recolour
@ Recolour
Recolour sprite.
Blitter::BlitterParams::top
int top
The top offset in the 'dst' in pixels to start drawing.
Definition: base.hpp:43
BM_TRANSPARENT
@ BM_TRANSPARENT
Perform transparency darkening 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:36
Blitter_40bppAnim::DrawColourMappingRect
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override
Draw a colourtable to the screen.
Definition: 40bpp_anim.cpp:351
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:38
Blitter_32bppBase::SetPixel
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_base.cpp:21
Blitter::BlitterParams::remap
const uint8_t * remap
XXX – Temporary storage for remap array.
Definition: base.hpp:34
GB
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.
Definition: bitmath_func.hpp:32
common.hpp
Blitter::BlitterParams::dst
void * dst
Destination buffer.
Definition: base.hpp:45
PALETTE_TO_TRANSPARENT
static const PaletteID PALETTE_TO_TRANSPARENT
This sets the sprite to transparent.
Definition: sprites.h:1607
Blitter_32bppBase::DrawLine
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_base.cpp:26
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:73
Blitter_32bppOptimized::SpriteData::data
uint8_t data[]
Data, all zoomlevels.
Definition: 32bpp_optimized.hpp:21
Blitter::BlitterParams::pitch
int pitch
The pitch of the destination buffer.
Definition: base.hpp:46
Blitter_40bppAnim::CopyToBuffer
void CopyToBuffer(const void *video, void *dst, int width, int height) override
Copy from the screen to a buffer.
Definition: 40bpp_anim.cpp:428
PaletteID
uint32_t PaletteID
The number of the palette.
Definition: gfx_type.h:19
Blitter_40bppAnim::DrawLine
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: 40bpp_anim.cpp:68
SpriteAllocator
Interface for something that can allocate memory for a sprite.
Definition: spriteloader.hpp:88
SpriteLoader::SpriteCollection
std::array< Sprite, ZOOM_LVL_END > SpriteCollection
Type defining a collection of sprites, one for each zoom level.
Definition: spriteloader.hpp:70
Blitter_40bppAnim::CopyFromBuffer
void CopyFromBuffer(void *video, const void *src, int width, int height) override
Copy from a buffer to the screen.
Definition: 40bpp_anim.cpp:406
BM_NORMAL
@ BM_NORMAL
Perform the simple blitting.
Definition: base.hpp:18
Blitter_40bppAnim::SetPixel
void SetPixel(void *video, int x, int y, uint8_t colour) override
Draw a pixel with a given colour on the video-buffer.
Definition: 40bpp_anim.cpp:30
Blitter_40bppAnim::Draw
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override
Draws a sprite to a (screen) buffer.
Definition: 40bpp_anim.cpp:330
Blitter_40bppAnim::Encode
Sprite * Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override
Convert a sprite from the loader to our own format.
Definition: 40bpp_anim.cpp:400
Blitter::BlitterParams::sprite
const void * sprite
Pointer to the sprite how ever the encoder stored it.
Definition: base.hpp:33
Blitter_32bppBase::MakeGrey
static Colour MakeGrey(Colour colour)
Make a colour grey - based.
Definition: 32bpp_base.hpp:143
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
Blitter_40bppAnim::DrawRect
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: 40bpp_anim.cpp:42
_screen_disable_anim
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
Definition: gfx.cpp:46
BM_COLOUR_REMAP
@ BM_COLOUR_REMAP
Perform a colour remapping.
Definition: base.hpp:19
PALETTE_NEWSPAPER
static const PaletteID PALETTE_NEWSPAPER
Recolour sprite for newspaper-greying.
Definition: sprites.h:1609
VideoDriver::GetAnimBuffer
virtual uint8_t * GetAnimBuffer()
Get a pointer to the animation buffer of the video back-end.
Definition: video_driver.hpp:144
BM_CRASH_REMAP
@ BM_CRASH_REMAP
Perform a crash remapping.
Definition: base.hpp:22
Blitter_32bppBase::LookupColourInPalette
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
Definition: 32bpp_base.hpp:37
Blitter_32bppSimple::DrawColourMappingRect
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override
Draw a colourtable to the screen.
Definition: 32bpp_simple.cpp:90
Blitter_40bppAnim::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: 40bpp_anim.cpp:472
BM_BLACK_REMAP
@ BM_BLACK_REMAP
Perform remapping to a completely blackened sprite.
Definition: base.hpp:23
Blitter_40bppAnim::CopyImageToBuffer
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
Definition: 40bpp_anim.cpp:450
FBlitter_40bppAnim
Factory for the 40 bpp animated blitter (for OpenGL).
Definition: 40bpp_anim.hpp:48
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:201
Colour::data
uint32_t data
Conversion of the channel information to a 32 bit number.
Definition: gfx_type.h:166
Colour
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Definition: gfx_type.h:165
Blitter::PaletteAnimation
PaletteAnimation
Types of palette animation.
Definition: base.hpp:50
Blitter_32bppBase::MakeDark
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
GetNearestColourIndex
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
Blitter_32bppOptimized::SpriteData::offset
uint32_t offset[ZOOM_LVL_END][2]
Offsets (from .data) to streams for different zoom levels, and the normal and remap image information...
Definition: 32bpp_optimized.hpp:20
Blitter_32bppBase::DrawRect
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
Blitter::BlitterParams::left
int left
The left offset in the 'dst' in pixels to start drawing.
Definition: base.hpp:42
Blitter::PALETTE_ANIMATION_VIDEO_BACKEND
@ PALETTE_ANIMATION_VIDEO_BACKEND
Palette animation should be done by video backend (8bpp only!)
Definition: base.hpp:52
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:45
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:104
Blitter_40bppAnim::NeedsAnimationBuffer
bool NeedsAnimationBuffer() override
Does this blitter require a separate animation buffer from the video backend?
Definition: 40bpp_anim.cpp:534
Blitter::BlitterParams
Parameters related to blitting.
Definition: base.hpp:32
Blitter::BlitterParams::height
int height
The height in pixels that needs to be drawn to dst.
Definition: base.hpp:39
Blitter_32bppOptimized::SpriteData
Data stored about a (single) sprite.
Definition: 32bpp_optimized.hpp:19
Blitter_32bppBase::CopyImageToBuffer
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
Definition: 32bpp_base.cpp:72
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:37
Sprite
Data structure describing a sprite.
Definition: spritecache.h:17
BM_TRANSPARENT_REMAP
@ BM_TRANSPARENT_REMAP
Perform transparency colour remapping.
Definition: base.hpp:21
Colour::a
uint8_t a
colour channels in LE order
Definition: gfx_type.h:173
Blitter_40bppAnim::UsePaletteAnimation
Blitter::PaletteAnimation UsePaletteAnimation() override
Check if the blitter uses palette animation at all.
Definition: 40bpp_anim.cpp:529
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:16