|
@@ -933,234 +933,6 @@ static void Blit_RGB444_XRGB8888ARMSIMD(SDL_BlitInfo *info)
|
|
|
#define LO 1
|
|
|
#endif
|
|
|
|
|
|
-/* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
|
|
|
-#define RGB888_RGB332(dst, src) \
|
|
|
- { \
|
|
|
- dst = (Uint8)((((src)&0x00E00000) >> 16) | \
|
|
|
- (((src)&0x0000E000) >> 11) | \
|
|
|
- (((src)&0x000000C0) >> 6)); \
|
|
|
- }
|
|
|
-static void Blit_XRGB8888_index8(SDL_BlitInfo *info)
|
|
|
-{
|
|
|
-#ifndef USE_DUFFS_LOOP
|
|
|
- int c;
|
|
|
-#endif
|
|
|
- int width, height;
|
|
|
- Uint32 *src;
|
|
|
- const Uint8 *map;
|
|
|
- Uint8 *dst;
|
|
|
- int srcskip, dstskip;
|
|
|
-
|
|
|
- /* Set up some basic variables */
|
|
|
- width = info->dst_w;
|
|
|
- height = info->dst_h;
|
|
|
- src = (Uint32 *)info->src;
|
|
|
- srcskip = info->src_skip / 4;
|
|
|
- dst = info->dst;
|
|
|
- dstskip = info->dst_skip;
|
|
|
- map = info->table;
|
|
|
-
|
|
|
- if (!map) {
|
|
|
- while (height--) {
|
|
|
-#ifdef USE_DUFFS_LOOP
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- , width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
-#else
|
|
|
- for (c = width / 4; c; --c) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- ++src;
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- }
|
|
|
- switch (width & 3) {
|
|
|
- case 3:
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 2:
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 1:
|
|
|
- RGB888_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- }
|
|
|
-#endif /* USE_DUFFS_LOOP */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- } else {
|
|
|
- int Pixel;
|
|
|
-
|
|
|
- while (height--) {
|
|
|
-#ifdef USE_DUFFS_LOOP
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- , width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
-#else
|
|
|
- for (c = width / 4; c; --c) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- }
|
|
|
- switch (width & 3) {
|
|
|
- case 3:
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 2:
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 1:
|
|
|
- RGB888_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- }
|
|
|
-#endif /* USE_DUFFS_LOOP */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/* Special optimized blit for RGB 10-10-10 --> RGB 3-3-2 */
|
|
|
-#define RGB101010_RGB332(dst, src) \
|
|
|
- { \
|
|
|
- dst = (Uint8)((((src)&0x38000000) >> 22) | \
|
|
|
- (((src)&0x000E0000) >> 15) | \
|
|
|
- (((src)&0x00000300) >> 8)); \
|
|
|
- }
|
|
|
-static void Blit_RGB101010_index8(SDL_BlitInfo *info)
|
|
|
-{
|
|
|
-#ifndef USE_DUFFS_LOOP
|
|
|
- int c;
|
|
|
-#endif
|
|
|
- int width, height;
|
|
|
- Uint32 *src;
|
|
|
- const Uint8 *map;
|
|
|
- Uint8 *dst;
|
|
|
- int srcskip, dstskip;
|
|
|
-
|
|
|
- /* Set up some basic variables */
|
|
|
- width = info->dst_w;
|
|
|
- height = info->dst_h;
|
|
|
- src = (Uint32 *)info->src;
|
|
|
- srcskip = info->src_skip / 4;
|
|
|
- dst = info->dst;
|
|
|
- dstskip = info->dst_skip;
|
|
|
- map = info->table;
|
|
|
-
|
|
|
- if (!map) {
|
|
|
- while (height--) {
|
|
|
-#ifdef USE_DUFFS_LOOP
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- , width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
-#else
|
|
|
- for (c = width / 4; c; --c) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- ++src;
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- }
|
|
|
- switch (width & 3) {
|
|
|
- case 3:
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 2:
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 1:
|
|
|
- RGB101010_RGB332(*dst++, *src);
|
|
|
- ++src;
|
|
|
- }
|
|
|
-#endif /* USE_DUFFS_LOOP */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- } else {
|
|
|
- int Pixel;
|
|
|
-
|
|
|
- while (height--) {
|
|
|
-#ifdef USE_DUFFS_LOOP
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- , width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
-#else
|
|
|
- for (c = width / 4; c; --c) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- }
|
|
|
- switch (width & 3) {
|
|
|
- case 3:
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 2:
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- SDL_FALLTHROUGH;
|
|
|
- case 1:
|
|
|
- RGB101010_RGB332(Pixel, *src);
|
|
|
- *dst++ = map[Pixel];
|
|
|
- ++src;
|
|
|
- }
|
|
|
-#endif /* USE_DUFFS_LOOP */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
/* Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 */
|
|
|
#define RGB888_RGB555(dst, src) \
|
|
|
{ \
|
|
@@ -2072,97 +1844,6 @@ static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void BlitNto1(SDL_BlitInfo *info)
|
|
|
-{
|
|
|
-#ifndef USE_DUFFS_LOOP
|
|
|
- int c;
|
|
|
-#endif
|
|
|
- int width, height;
|
|
|
- Uint8 *src;
|
|
|
- const Uint8 *map;
|
|
|
- Uint8 *dst;
|
|
|
- int srcskip, dstskip;
|
|
|
- int srcbpp;
|
|
|
- Uint32 Pixel;
|
|
|
- int sR, sG, sB;
|
|
|
- const SDL_PixelFormatDetails *srcfmt;
|
|
|
-
|
|
|
- /* Set up some basic variables */
|
|
|
- width = info->dst_w;
|
|
|
- height = info->dst_h;
|
|
|
- src = info->src;
|
|
|
- srcskip = info->src_skip;
|
|
|
- dst = info->dst;
|
|
|
- dstskip = info->dst_skip;
|
|
|
- map = info->table;
|
|
|
- srcfmt = info->src_fmt;
|
|
|
- srcbpp = srcfmt->bytes_per_pixel;
|
|
|
-
|
|
|
- if (!map) {
|
|
|
- while (height--) {
|
|
|
-#ifdef USE_DUFFS_LOOP
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
|
|
- sR, sG, sB);
|
|
|
- if ( 1 ) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- *dst = (Uint8)(((sR>>5)<<(3+2)) | ((sG>>5)<<(2)) | ((sB>>6)<<(0)));
|
|
|
- }
|
|
|
- dst++;
|
|
|
- src += srcbpp;
|
|
|
- , width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
-#else
|
|
|
- for (c = width; c; --c) {
|
|
|
- DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
|
|
- if (1) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- *dst = ((sR >> 5) << (3 + 2)) |
|
|
|
- ((sG >> 5) << (2)) | ((sB >> 6) << (0));
|
|
|
- }
|
|
|
- dst++;
|
|
|
- src += srcbpp;
|
|
|
- }
|
|
|
-#endif
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- } else {
|
|
|
- while (height--) {
|
|
|
-#ifdef USE_DUFFS_LOOP
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
|
|
- sR, sG, sB);
|
|
|
- if ( 1 ) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- *dst = map[((sR>>5)<<(3+2))|
|
|
|
- ((sG>>5)<<(2)) |
|
|
|
- ((sB>>6)<<(0)) ];
|
|
|
- }
|
|
|
- dst++;
|
|
|
- src += srcbpp;
|
|
|
- , width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
-#else
|
|
|
- for (c = width; c; --c) {
|
|
|
- DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
|
|
- if (1) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- *dst = map[((sR >> 5) << (3 + 2)) |
|
|
|
- ((sG >> 5) << (2)) | ((sB >> 6) << (0))];
|
|
|
- }
|
|
|
- dst++;
|
|
|
- src += srcbpp;
|
|
|
- }
|
|
|
-#endif /* USE_DUFFS_LOOP */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
/* blits 32 bit RGB<->RGBA with both surfaces having the same R,G,B fields */
|
|
|
static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
|
|
|
{
|
|
@@ -2474,71 +2155,6 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void BlitNto1Key(SDL_BlitInfo *info)
|
|
|
-{
|
|
|
- int width = info->dst_w;
|
|
|
- int height = info->dst_h;
|
|
|
- Uint8 *src = info->src;
|
|
|
- int srcskip = info->src_skip;
|
|
|
- Uint8 *dst = info->dst;
|
|
|
- int dstskip = info->dst_skip;
|
|
|
- const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
|
|
- const Uint8 *palmap = info->table;
|
|
|
- Uint32 ckey = info->colorkey;
|
|
|
- Uint32 rgbmask = ~srcfmt->Amask;
|
|
|
- int srcbpp;
|
|
|
- Uint32 Pixel;
|
|
|
- unsigned sR, sG, sB;
|
|
|
-
|
|
|
- /* Set up some basic variables */
|
|
|
- srcbpp = srcfmt->bytes_per_pixel;
|
|
|
- ckey &= rgbmask;
|
|
|
-
|
|
|
- if (!palmap) {
|
|
|
- while (height--) {
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- {
|
|
|
- DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
|
|
- sR, sG, sB);
|
|
|
- if ( (Pixel & rgbmask) != ckey ) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- *dst = (Uint8)(((sR>>5)<<(3+2))|
|
|
|
- ((sG>>5)<<(2)) |
|
|
|
- ((sB>>6)<<(0)));
|
|
|
- }
|
|
|
- dst++;
|
|
|
- src += srcbpp;
|
|
|
- },
|
|
|
- width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- } else {
|
|
|
- while (height--) {
|
|
|
- /* *INDENT-OFF* */ /* clang-format off */
|
|
|
- DUFFS_LOOP(
|
|
|
- {
|
|
|
- DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
|
|
- sR, sG, sB);
|
|
|
- if ( (Pixel & rgbmask) != ckey ) {
|
|
|
- /* Pack RGB into 8bit pixel */
|
|
|
- *dst = (Uint8)palmap[((sR>>5)<<(3+2))|
|
|
|
- ((sG>>5)<<(2)) |
|
|
|
- ((sB>>6)<<(0)) ];
|
|
|
- }
|
|
|
- dst++;
|
|
|
- src += srcbpp;
|
|
|
- },
|
|
|
- width);
|
|
|
- /* *INDENT-ON* */ /* clang-format on */
|
|
|
- src += srcskip;
|
|
|
- dst += dstskip;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
static void Blit2to2Key(SDL_BlitInfo *info)
|
|
|
{
|
|
|
int width = info->dst_w;
|
|
@@ -3343,22 +2959,7 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
|
|
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
|
|
case 0:
|
|
|
blitfun = NULL;
|
|
|
- if (dstfmt->bits_per_pixel == 8) {
|
|
|
- if ((srcfmt->bytes_per_pixel == 4) &&
|
|
|
- (srcfmt->Rmask == 0x00FF0000) &&
|
|
|
- (srcfmt->Gmask == 0x0000FF00) &&
|
|
|
- (srcfmt->Bmask == 0x000000FF)) {
|
|
|
- blitfun = Blit_XRGB8888_index8;
|
|
|
- } else if ((srcfmt->bytes_per_pixel == 4) &&
|
|
|
- (srcfmt->Rmask == 0x3FF00000) &&
|
|
|
- (srcfmt->Gmask == 0x000FFC00) &&
|
|
|
- (srcfmt->Bmask == 0x000003FF)) {
|
|
|
- blitfun = Blit_RGB101010_index8;
|
|
|
- } else {
|
|
|
- blitfun = BlitNto1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- /* Now the meat, choose the blitter we want */
|
|
|
+ if (dstfmt->bits_per_pixel > 8) {
|
|
|
Uint32 a_need = NO_ALPHA;
|
|
|
if (dstfmt->Amask) {
|
|
|
a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
|
|
@@ -3418,15 +3019,13 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
|
|
|
|
|
if (srcfmt->bytes_per_pixel == 2 && surface->internal->map.identity != 0) {
|
|
|
return Blit2to2Key;
|
|
|
- } else if (dstfmt->bytes_per_pixel == 1) {
|
|
|
- return BlitNto1Key;
|
|
|
} else {
|
|
|
#ifdef SDL_ALTIVEC_BLITTERS
|
|
|
if ((srcfmt->bytes_per_pixel == 4) && (dstfmt->bytes_per_pixel == 4) && SDL_HasAltiVec()) {
|
|
|
return Blit32to32KeyAltivec;
|
|
|
} else
|
|
|
#endif
|
|
|
- if (srcfmt->Amask && dstfmt->Amask) {
|
|
|
+ if (srcfmt->Amask && dstfmt->Amask) {
|
|
|
return BlitNtoNKeyCopyAlpha;
|
|
|
} else {
|
|
|
return BlitNtoNKey;
|