OpenTTD Source: src/blitter/32bpp_anim.cpp Source File

OpenTTD Source 15.0-RC2

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