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