OpenTTD Source 20260304-master-g1baaa74679
32bpp_sse_func.hpp
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
16
17#ifndef BLITTER_32BPP_SSE_FUNC_HPP
18#define BLITTER_32BPP_SSE_FUNC_HPP
19
21#define INTERNAL_LINKAGE static
22
23#ifdef WITH_SSE
24
25GNU_TARGET(SSE_TARGET)
26INTERNAL_LINKAGE inline void InsertFirstUint32(const uint32_t value, __m128i &into)
27{
28#if (SSE_VERSION >= 4)
29 into = _mm_insert_epi32(into, value, 0);
30#else
31 into = _mm_insert_epi16(into, value, 0);
32 into = _mm_insert_epi16(into, value >> 16, 1);
33#endif
34}
35
36GNU_TARGET(SSE_TARGET)
37INTERNAL_LINKAGE inline void InsertSecondUint32(const uint32_t value, __m128i &into)
38{
39#if (SSE_VERSION >= 4)
40 into = _mm_insert_epi32(into, value, 1);
41#else
42 into = _mm_insert_epi16(into, value, 2);
43 into = _mm_insert_epi16(into, value >> 16, 3);
44#endif
45}
46
47GNU_TARGET(SSE_TARGET)
48INTERNAL_LINKAGE inline void LoadUint64(const uint64_t value, __m128i &into)
49{
50#ifdef POINTER_IS_64BIT
51 into = _mm_cvtsi64_si128(value);
52#else
53 #if (SSE_VERSION >= 4)
54 into = _mm_cvtsi32_si128(value);
55 InsertSecondUint32(value >> 32, into);
56 #else
57 (*(um128i*) &into).m128i_u64[0] = value;
58 #endif
59#endif
60}
61
62GNU_TARGET(SSE_TARGET)
63INTERNAL_LINKAGE inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
64{
65#if (SSE_VERSION == 2)
66 from = _mm_and_si128(from, mask); // PAND, wipe high bytes to keep low bytes when packing
67 return _mm_packus_epi16(from, from); // PACKUSWB, pack 2 colours (with saturation)
68#else
69 return _mm_shuffle_epi8(from, mask);
70#endif
71}
72
73GNU_TARGET(SSE_TARGET)
74INTERNAL_LINKAGE inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
75{
76#if (SSE_VERSION == 2)
77 __m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1
78 alphaAB = _mm_shufflehi_epi16(alphaAB, 0x3F); // PSHUFHW, put alpha2 in front of each rgb2
79 return _mm_andnot_si128(mask, alphaAB); // PANDN, set alpha fields to 0
80#else
81 return _mm_shuffle_epi8(from, mask);
82#endif
83}
84
85GNU_TARGET(SSE_TARGET)
86INTERNAL_LINKAGE inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
87{
88 __m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16
89 __m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
90
91 __m128i alphaMaskAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW (alpha > 0) ? 0xFFFF : 0
92 __m128i alphaAB = _mm_sub_epi16(srcAB, alphaMaskAB); // if (alpha > 0) a++;
93 alphaAB = DistributeAlpha(alphaAB, distribution_mask);
94
95 srcAB = _mm_sub_epi16(srcAB, dstAB); // PSUBW, (r - Cr)
96 srcAB = _mm_mullo_epi16(srcAB, alphaAB); // PMULLW, a*(r - Cr)
97 srcAB = _mm_srli_epi16(srcAB, 8); // PSRLW, a*(r - Cr)/256
98 srcAB = _mm_add_epi16(srcAB, dstAB); // PADDW, a*(r - Cr)/256 + Cr
99
100 alphaMaskAB = _mm_and_si128(alphaMaskAB, alpha_mask); // PAND, set non alpha fields to 0
101 srcAB = _mm_or_si128(srcAB, alphaMaskAB); // POR, set alpha fields to 0xFFFF is src alpha was > 0
102
103 return PackUnsaturated(srcAB, pack_mask);
104}
105
106/* Darken 2 pixels.
107 * rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
108 */
109GNU_TARGET(SSE_TARGET)
110INTERNAL_LINKAGE inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
111{
112 __m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
113 __m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
114 __m128i alphaAB = DistributeAlpha(srcAB, distribution_mask);
115 alphaAB = _mm_srli_epi16(alphaAB, 2); // Reduce to 64 levels of shades so the max value fits in 16 bits.
116 __m128i nom = _mm_sub_epi16(tr_nom_base, alphaAB);
117 dstAB = _mm_mullo_epi16(dstAB, nom);
118 dstAB = _mm_srli_epi16(dstAB, 8);
119 return _mm_packus_epi16(dstAB, dstAB);
120}
121
122GNU_TARGET(SSE_TARGET)
123INTERNAL_LINKAGE Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
124{
125 uint64_t c16 = colour.b | (uint64_t) colour.g << 16 | (uint64_t) colour.r << 32;
126 c16 *= brightness;
127 uint64_t c16_ob = c16; // Helps out of order execution.
128 c16 /= DEFAULT_BRIGHTNESS;
129 c16 &= 0x01FF01FF01FFULL;
130
131 /* Sum overbright (maximum for each rgb is 508, 9 bits, -255 is changed in -256 so we just have to take the 8 lower bits into account). */
132 c16_ob = (((c16_ob >> (8 + 7)) & 0x0100010001ULL) * 0xFF) & c16;
133 const uint ob = ((uint16_t) c16_ob + (uint16_t) (c16_ob >> 16) + (uint16_t) (c16_ob >> 32)) / 2;
134
135 const uint32_t alpha32 = colour.data & 0xFF000000;
136 __m128i ret;
137 LoadUint64(c16, ret);
138 if (ob != 0) {
139 __m128i ob128 = _mm_cvtsi32_si128(ob);
140 ob128 = _mm_shufflelo_epi16(ob128, 0xC0);
141 __m128i white = OVERBRIGHT_VALUE_MASK;
142 __m128i c128 = ret;
143 ret = _mm_subs_epu16(white, c128); // PSUBUSW, (255 - rgb)
144 ret = _mm_mullo_epi16(ret, ob128); // PMULLW, ob*(255 - rgb)
145 ret = _mm_srli_epi16(ret, 8); // PSRLW, ob*(255 - rgb)/256
146 ret = _mm_add_epi16(ret, c128); // PADDW, ob*(255 - rgb)/256 + rgb
147 }
148
149 ret = _mm_packus_epi16(ret, ret); // PACKUSWB, saturate and pack.
150 return alpha32 | _mm_cvtsi128_si32(ret);
151}
152
156INTERNAL_LINKAGE inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
157{
158 /* Shortcut for normal brightness. */
159 if (brightness == DEFAULT_BRIGHTNESS) return colour;
160
161 return ReallyAdjustBrightness(colour, brightness);
162}
163
164GNU_TARGET(SSE_TARGET)
165INTERNAL_LINKAGE inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
166{
167#if (SSE_VERSION < 3)
168 NOT_REACHED();
169#else
170 /* The following dataflow differs from the one of AdjustBrightness() only for alpha.
171 * In order to keep alpha in colAB, insert a 1 in a unused brightness byte (a*1->a).
172 * OK, not a 1 but DEFAULT_BRIGHTNESS to compensate the div.
173 */
174 brightness &= 0xFF00FF00;
175 brightness += DEFAULT_BRIGHTNESS;
176
177 __m128i colAB = _mm_unpacklo_epi8(from, _mm_setzero_si128());
178 __m128i briAB = _mm_cvtsi32_si128(brightness);
179 briAB = _mm_shuffle_epi8(briAB, BRIGHTNESS_LOW_CONTROL_MASK); // DEFAULT_BRIGHTNESS in 0, 0x00 in 2.
180 colAB = _mm_mullo_epi16(colAB, briAB);
181 __m128i colAB_ob = _mm_srli_epi16(colAB, 8 + 7);
182 colAB = _mm_srli_epi16(colAB, 7);
183
184 /* Sum overbright.
185 * Maximum for each rgb is 508 => 9 bits. The highest bit tells if there is overbright.
186 * -255 is changed in -256 so we just have to take the 8 lower bits into account.
187 */
188 colAB = _mm_and_si128(colAB, BRIGHTNESS_DIV_CLEANER);
189 colAB_ob = _mm_and_si128(colAB_ob, OVERBRIGHT_PRESENCE_MASK);
190 colAB_ob = _mm_mullo_epi16(colAB_ob, OVERBRIGHT_VALUE_MASK);
191 colAB_ob = _mm_and_si128(colAB_ob, colAB);
192 __m128i obAB = _mm_hadd_epi16(_mm_hadd_epi16(colAB_ob, _mm_setzero_si128()), _mm_setzero_si128());
193
194 obAB = _mm_srli_epi16(obAB, 1); // Reduce overbright strength.
195 obAB = _mm_shuffle_epi8(obAB, OVERBRIGHT_CONTROL_MASK);
196 __m128i retAB = OVERBRIGHT_VALUE_MASK; // ob_mask is equal to white.
197 retAB = _mm_subs_epu16(retAB, colAB); // (255 - rgb)
198 retAB = _mm_mullo_epi16(retAB, obAB); // ob*(255 - rgb)
199 retAB = _mm_srli_epi16(retAB, 8); // ob*(255 - rgb)/256
200 retAB = _mm_add_epi16(retAB, colAB); // ob*(255 - rgb)/256 + rgb
201
202 return _mm_packus_epi16(retAB, retAB);
203#endif
204}
205
206#if FULL_ANIMATION == 0
214template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last, bool translucent>
215GNU_TARGET(SSE_TARGET)
216#if (SSE_VERSION == 2)
217inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
218#elif (SSE_VERSION == 3)
219inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
220#elif (SSE_VERSION == 4)
221inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
222#endif
223{
224 const uint8_t * const remap = bp->remap;
225 Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
226 int effective_width = bp->width;
227
228 /* Find where to start reading in the source sprite. */
229 const SpriteData * const sd = (const SpriteData *) bp->sprite;
230 const SpriteInfo * const si = &sd->infos[zoom];
231 const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
232 const Colour *src_rgba_line = (const Colour *) ((const uint8_t *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
233
234 if (read_mode != RM_WITH_MARGIN) {
235 src_rgba_line += bp->skip_left;
236 src_mv_line += bp->skip_left;
237 }
238 const MapValue *src_mv = src_mv_line;
239
240 /* Load these variables into register before loop. */
241 const __m128i alpha_and = ALPHA_AND_MASK;
242 #define ALPHA_BLEND_PARAM_3 alpha_and
243#if (SSE_VERSION == 2)
244 const __m128i clear_hi = CLEAR_HIGH_BYTE_MASK;
245 #define ALPHA_BLEND_PARAM_1 alpha_and
246 #define ALPHA_BLEND_PARAM_2 clear_hi
247 #define DARKEN_PARAM_1 tr_nom_base
248 #define DARKEN_PARAM_2 tr_nom_base
249#else
250 const __m128i a_cm = ALPHA_CONTROL_MASK;
251 const __m128i pack_low_cm = PACK_LOW_CONTROL_MASK;
252 #define ALPHA_BLEND_PARAM_1 a_cm
253 #define ALPHA_BLEND_PARAM_2 pack_low_cm
254 #define DARKEN_PARAM_1 a_cm
255 #define DARKEN_PARAM_2 tr_nom_base
256#endif
257 const __m128i tr_nom_base = TRANSPARENT_NOM_BASE;
258
259 for (int y = bp->height; y != 0; y--) {
260 Colour *dst = dst_line;
261 const Colour *src = src_rgba_line + META_LENGTH;
262 if (mode == BlitterMode::ColourRemap || mode == BlitterMode::CrashRemap) src_mv = src_mv_line;
263
264 if (read_mode == RM_WITH_MARGIN) {
265 assert(bt_last == BT_NONE); // or you must ensure block type is preserved
266 src += src_rgba_line[0].data;
267 dst += src_rgba_line[0].data;
268 if (mode == BlitterMode::ColourRemap || mode == BlitterMode::CrashRemap) src_mv += src_rgba_line[0].data;
269 const int width_diff = si->sprite_width - bp->width;
270 effective_width = bp->width - (int) src_rgba_line[0].data;
271 const int delta_diff = (int) src_rgba_line[1].data - width_diff;
272 const int new_width = effective_width - delta_diff;
273 effective_width = delta_diff > 0 ? new_width : effective_width;
274 if (effective_width <= 0) goto next_line;
275 }
276
277 switch (mode) {
278 default:
279 if (!translucent) {
280 for (uint x = (uint) effective_width; x > 0; x--) {
281 if (src->a) *dst = *src;
282 src++;
283 dst++;
284 }
285 break;
286 }
287
288 for (uint x = (uint) effective_width / 2; x > 0; x--) {
289 __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
290 __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
291 _mm_storel_epi64((__m128i*) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3));
292 src += 2;
293 dst += 2;
294 }
295
296 if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
297 __m128i srcABCD = _mm_cvtsi32_si128(src->data);
298 __m128i dstABCD = _mm_cvtsi32_si128(dst->data);
299 dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3));
300 }
301 break;
302
304#if (SSE_VERSION >= 3)
305 for (uint x = (uint) effective_width / 2; x > 0; x--) {
306 __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
307 __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
308 uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
309
310 /* Remap colours. */
311 if (mvX2 & 0x00FF00FF) {
312 /* Written so the compiler uses CMOV. */
313 #define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
314 Colour m_colour = m_colour_init; \
315 { \
316 const Colour srcm = (Colour) (m_src); \
317 const uint m = (uint8_t) (m_m); \
318 const uint r = remap[m]; \
319 const Colour cmap = (this->LookupColourInPalette(r).data & 0x00FFFFFF) | (srcm.data & 0xFF000000); \
320 m_colour = r == 0 ? m_colour : cmap; \
321 m_colour = m != 0 ? m_colour : srcm; \
322 }
323#ifdef POINTER_IS_64BIT
324 uint64_t srcs = _mm_cvtsi128_si64(srcABCD);
325 uint64_t remapped_src = 0;
326 CMOV_REMAP(c0, 0, srcs, mvX2);
327 remapped_src = c0.data;
328 CMOV_REMAP(c1, 0, srcs >> 32, mvX2 >> 16);
329 remapped_src |= (uint64_t) c1.data << 32;
330 srcABCD = _mm_cvtsi64_si128(remapped_src);
331#else
332 Colour remapped_src[2];
333 CMOV_REMAP(c0, 0, _mm_cvtsi128_si32(srcABCD), mvX2);
334 remapped_src[0] = c0.data;
335 CMOV_REMAP(c1, 0, src[1], mvX2 >> 16);
336 remapped_src[1] = c1.data;
337 srcABCD = _mm_loadl_epi64((__m128i*) &remapped_src);
338#endif
339
340 if ((mvX2 & 0xFF00FF00) != 0x80008000) srcABCD = AdjustBrightnessOfTwoPixels(srcABCD, mvX2);
341 }
342
343 /* Blend colours. */
344 _mm_storel_epi64((__m128i *) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3));
345 dst += 2;
346 src += 2;
347 src_mv += 2;
348 }
349
350 if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
351#else
352 for (uint x = (uint) effective_width; x > 0; x--) {
353#endif
354 /* In case the m-channel is zero, do not remap this pixel in any way. */
355 __m128i srcABCD;
356 if (src_mv->m) {
357 const uint r = remap[src_mv->m];
358 if (r != 0) {
359 Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), src_mv->v);
360 if (src->a == 255) {
361 *dst = remapped_colour;
362 } else {
363 remapped_colour.a = src->a;
364 srcABCD = _mm_cvtsi32_si128(remapped_colour.data);
365 goto bmcr_alpha_blend_single;
366 }
367 }
368 } else {
369 srcABCD = _mm_cvtsi32_si128(src->data);
370 if (src->a < 255) {
371bmcr_alpha_blend_single:
372 __m128i dstABCD = _mm_cvtsi32_si128(dst->data);
373 srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3);
374 }
375 dst->data = _mm_cvtsi128_si32(srcABCD);
376 }
377#if (SSE_VERSION == 2)
378 src_mv++;
379 dst++;
380 src++;
381#endif
382 }
383 break;
384
386 /* Make the current colour a bit more black, so it looks like this image is transparent. */
387 for (uint x = (uint) bp->width / 2; x > 0; x--) {
388 __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
389 __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
390 _mm_storel_epi64((__m128i *) dst, DarkenTwoPixels(srcABCD, dstABCD, DARKEN_PARAM_1, DARKEN_PARAM_2));
391 src += 2;
392 dst += 2;
393 }
394
395 if ((bt_last == BT_NONE && bp->width & 1) || bt_last == BT_ODD) {
396 __m128i srcABCD = _mm_cvtsi32_si128(src->data);
397 __m128i dstABCD = _mm_cvtsi32_si128(dst->data);
398 dst->data = _mm_cvtsi128_si32(DarkenTwoPixels(srcABCD, dstABCD, DARKEN_PARAM_1, DARKEN_PARAM_2));
399 }
400 break;
401
403 /* Apply custom transparency remap. */
404 for (uint x = (uint) bp->width; x > 0; x--) {
405 if (src->a != 0) {
406 *dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
407 }
408 src_mv++;
409 dst++;
410 src++;
411 }
412 break;
413
415 for (uint x = (uint) bp->width; x > 0; x--) {
416 if (src_mv->m == 0) {
417 if (src->a != 0) {
418 uint8_t g = MakeDark(src->r, src->g, src->b);
419 *dst = ComposeColourRGBA(g, g, g, src->a, *dst);
420 }
421 } else {
422 uint r = remap[src_mv->m];
423 if (r != 0) *dst = ComposeColourPANoCheck(AdjustBrightness(this->LookupColourInPalette(r), src_mv->v), src->a, *dst);
424 }
425 src_mv++;
426 dst++;
427 src++;
428 }
429 break;
430
432 for (uint x = (uint) bp->width; x > 0; x--) {
433 if (src->a != 0) {
434 *dst = Colour(0, 0, 0);
435 }
436 src_mv++;
437 dst++;
438 src++;
439 }
440 break;
441 }
442
443next_line:
444 if (mode == BlitterMode::ColourRemap || mode == BlitterMode::CrashRemap) src_mv_line += si->sprite_width;
445 src_rgba_line = (const Colour*) ((const uint8_t*) src_rgba_line + si->sprite_line_size);
446 dst_line += bp->pitch;
447 }
448}
449
457#if (SSE_VERSION == 2)
458void Blitter_32bppSSE2::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
459#elif (SSE_VERSION == 3)
460void Blitter_32bppSSSE3::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
461#elif (SSE_VERSION == 4)
462void Blitter_32bppSSE4::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
463#endif
464{
465 switch (mode) {
466 default: {
467 if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
468bm_normal:
469 const BlockType bt_last = (BlockType) (bp->width & 1);
470 switch (bt_last) {
471 default: Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_EVEN, true>(bp, zoom); return;
472 case BT_ODD: Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_ODD, true>(bp, zoom); return;
473 }
474 } else {
475 if (((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags.Test(SpriteFlag::Translucent)) {
476 Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true>(bp, zoom);
477 } else {
478 Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, false>(bp, zoom);
479 }
480 return;
481 }
482 break;
483 }
485 if (((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags.Test(SpriteFlag::NoRemap)) goto bm_normal;
486 if (bp->skip_left != 0 || bp->width <= MARGIN_REMAP_THRESHOLD) {
487 Draw<BlitterMode::ColourRemap, RM_WITH_SKIP, BT_NONE, true>(bp, zoom); return;
488 } else {
489 Draw<BlitterMode::ColourRemap, RM_WITH_MARGIN, BT_NONE, true>(bp, zoom); return;
490 }
491 case BlitterMode::Transparent: Draw<BlitterMode::Transparent, RM_NONE, BT_NONE, true>(bp, zoom); return;
492 case BlitterMode::TransparentRemap: Draw<BlitterMode::TransparentRemap, RM_NONE, BT_NONE, true>(bp, zoom); return;
493 case BlitterMode::CrashRemap: Draw<BlitterMode::CrashRemap, RM_NONE, BT_NONE, true>(bp, zoom); return;
494 case BlitterMode::BlackRemap: Draw<BlitterMode::BlackRemap, RM_NONE, BT_NONE, true>(bp, zoom); return;
495 }
496}
497#endif /* FULL_ANIMATION */
498
499#endif /* WITH_SSE */
500#endif /* BLITTER_32BPP_SSE_FUNC_HPP */
#define INTERNAL_LINKAGE
Prefix all things in this file wiht this specifier to make them linked internally only.
BlitterMode
The modes of blitting we can do.
Definition base.hpp:17
@ Transparent
Perform transparency darkening remapping.
Definition base.hpp:20
@ CrashRemap
Perform a crash remapping.
Definition base.hpp:22
@ BlackRemap
Perform remapping to a completely blackened sprite.
Definition base.hpp:23
@ TransparentRemap
Perform transparency colour remapping.
Definition base.hpp:21
@ ColourRemap
Perform a colour remapping.
Definition base.hpp:19
Colour ReallyAdjustBrightness(Colour colour, int brightness)
Adjust brightness of colour.
Definition palette.cpp:182
uint8_t GetNearestColourIndex(uint8_t r, uint8_t g, uint8_t b)
Get nearest colour palette index from an RGB colour.
Definition palette.cpp:156
Parameters related to blitting.
Definition base.hpp:32
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst).
Definition base.hpp:37
void * dst
Destination buffer.
Definition base.hpp:45
int left
The left offset in the 'dst' in pixels to start drawing.
Definition base.hpp:42
int pitch
The pitch of the destination buffer.
Definition base.hpp:46
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst).
Definition base.hpp:36
int height
The height in pixels that needs to be drawn to dst.
Definition base.hpp:39
const uint8_t * remap
XXX – Temporary storage for remap array.
Definition base.hpp:34
int width
The width in pixels that needs to be drawn to dst.
Definition base.hpp:38
const void * sprite
Pointer to the sprite how ever the encoder stored it.
Definition base.hpp:33
int top
The top offset in the 'dst' in pixels to start drawing.
Definition base.hpp:43
ZoomLevel
All zoom levels we know.
Definition zoom_type.h:20