/project/jni/sdl-1.3/src/video/SDL_blit_N.c
https://github.com/aichunyu/FFPlayer · C · 2514 lines · 2155 code · 165 blank · 194 comment · 208 complexity · d4b695a71205fc371eeb8f9b6ca443d1 MD5 · raw file
Large files are truncated click here to view the full file
- /*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
- */
- #include "SDL_config.h"
- #include "SDL_video.h"
- #include "SDL_endian.h"
- #include "SDL_cpuinfo.h"
- #include "SDL_blit.h"
- #include "SDL_assert.h"
- /* Functions to blit from N-bit surfaces to other surfaces */
- #if SDL_ALTIVEC_BLITTERS
- #ifdef HAVE_ALTIVEC_H
- #include <altivec.h>
- #endif
- #ifdef __MACOSX__
- #include <sys/sysctl.h>
- static size_t
- GetL3CacheSize(void)
- {
- const char key[] = "hw.l3cachesize";
- u_int64_t result = 0;
- size_t typeSize = sizeof(result);
- int err = sysctlbyname(key, &result, &typeSize, NULL, 0);
- if (0 != err)
- return 0;
- return result;
- }
- #else
- static size_t
- GetL3CacheSize(void)
- {
- /* XXX: Just guess G4 */
- return 2097152;
- }
- #endif /* __MACOSX__ */
- #if (defined(__MACOSX__) && (__GNUC__ < 4))
- #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
- (vector unsigned char) ( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p )
- #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
- (vector unsigned short) ( a,b,c,d,e,f,g,h )
- #else
- #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
- (vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p }
- #define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
- (vector unsigned short) { a,b,c,d,e,f,g,h }
- #endif
- #define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F)
- #define VSWIZZLE32(a,b,c,d) (vector unsigned char) \
- ( 0x00+a, 0x00+b, 0x00+c, 0x00+d, \
- 0x04+a, 0x04+b, 0x04+c, 0x04+d, \
- 0x08+a, 0x08+b, 0x08+c, 0x08+d, \
- 0x0C+a, 0x0C+b, 0x0C+c, 0x0C+d )
- #define MAKE8888(dstfmt, r, g, b, a) \
- ( ((r<<dstfmt->Rshift)&dstfmt->Rmask) | \
- ((g<<dstfmt->Gshift)&dstfmt->Gmask) | \
- ((b<<dstfmt->Bshift)&dstfmt->Bmask) | \
- ((a<<dstfmt->Ashift)&dstfmt->Amask) )
- /*
- * Data Stream Touch...Altivec cache prefetching.
- *
- * Don't use this on a G5...however, the speed boost is very significant
- * on a G4.
- */
- #define DST_CHAN_SRC 1
- #define DST_CHAN_DEST 2
- /* macro to set DST control word value... */
- #define DST_CTRL(size, count, stride) \
- (((size) << 24) | ((count) << 16) | (stride))
- #define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \
- ? vec_lvsl(0, src) \
- : vec_add(vec_lvsl(8, src), vec_splat_u8(8)))
- /* Calculate the permute vector used for 32->32 swizzling */
- static vector unsigned char
- calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt)
- {
- /*
- * We have to assume that the bits that aren't used by other
- * colors is alpha, and it's one complete byte, since some formats
- * leave alpha with a zero mask, but we should still swizzle the bits.
- */
- /* ARGB */
- const static const struct SDL_PixelFormat default_pixel_format = {
- 0, NULL, 0, 0,
- {0, 0},
- 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
- 0, 0, 0, 0,
- 16, 8, 0, 24,
- 0, NULL
- };
- if (!srcfmt) {
- srcfmt = &default_pixel_format;
- }
- if (!dstfmt) {
- dstfmt = &default_pixel_format;
- }
- const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00,
- 0x04, 0x04, 0x04, 0x04,
- 0x08, 0x08, 0x08, 0x08,
- 0x0C, 0x0C, 0x0C,
- 0x0C);
- vector unsigned char vswiz;
- vector unsigned int srcvec;
- #define RESHIFT(X) (3 - ((X) >> 3))
- Uint32 rmask = RESHIFT(srcfmt->Rshift) << (dstfmt->Rshift);
- Uint32 gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift);
- Uint32 bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift);
- Uint32 amask;
- /* Use zero for alpha if either surface doesn't have alpha */
- if (dstfmt->Amask) {
- amask =
- ((srcfmt->Amask) ? RESHIFT(srcfmt->
- Ashift) : 0x10) << (dstfmt->Ashift);
- } else {
- amask =
- 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^
- 0xFFFFFFFF);
- }
- #undef RESHIFT
- ((unsigned int *) (char *) &srcvec)[0] = (rmask | gmask | bmask | amask);
- vswiz = vec_add(plus, (vector unsigned char) vec_splat(srcvec, 0));
- return (vswiz);
- }
- static void Blit_RGB888_RGB565(SDL_BlitInfo * info);
- static void
- Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info)
- {
- int height = info->dst_h;
- Uint8 *src = (Uint8 *) info->src;
- int srcskip = info->src_skip;
- Uint8 *dst = (Uint8 *) info->dst;
- int dstskip = info->dst_skip;
- SDL_PixelFormat *srcfmt = info->src_fmt;
- vector unsigned char valpha = vec_splat_u8(0);
- vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
- vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06,
- 0x00, 0x0a, 0x00, 0x0e,
- 0x00, 0x12, 0x00, 0x16,
- 0x00, 0x1a, 0x00, 0x1e);
- vector unsigned short v1 = vec_splat_u16(1);
- vector unsigned short v3 = vec_splat_u16(3);
- vector unsigned short v3f =
- VECUINT16_LITERAL(0x003f, 0x003f, 0x003f, 0x003f,
- 0x003f, 0x003f, 0x003f, 0x003f);
- vector unsigned short vfc =
- VECUINT16_LITERAL(0x00fc, 0x00fc, 0x00fc, 0x00fc,
- 0x00fc, 0x00fc, 0x00fc, 0x00fc);
- vector unsigned short vf800 = (vector unsigned short) vec_splat_u8(-7);
- vf800 = vec_sl(vf800, vec_splat_u16(8));
- while (height--) {
- vector unsigned char valigner;
- vector unsigned char voverflow;
- vector unsigned char vsrc;
- int width = info->dst_w;
- int extrawidth;
- /* do scalar until we can align... */
- #define ONE_PIXEL_BLEND(condition, widthvar) \
- while (condition) { \
- Uint32 Pixel; \
- unsigned sR, sG, sB, sA; \
- DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, Pixel, \
- sR, sG, sB, sA); \
- *(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \
- ((sG << 3) & 0x000007E0) | \
- ((sB >> 3) & 0x0000001F)); \
- dst += 2; \
- src += 4; \
- widthvar--; \
- }
- ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width);
- /* After all that work, here's the vector part! */
- extrawidth = (width % 8); /* trailing unaligned stores */
- width -= extrawidth;
- vsrc = vec_ld(0, src);
- valigner = VEC_ALIGNER(src);
- while (width) {
- vector unsigned short vpixel, vrpixel, vgpixel, vbpixel;
- vector unsigned int vsrc1, vsrc2;
- vector unsigned char vdst;
- voverflow = vec_ld(15, src);
- vsrc = vec_perm(vsrc, voverflow, valigner);
- vsrc1 = (vector unsigned int) vec_perm(vsrc, valpha, vpermute);
- src += 16;
- vsrc = voverflow;
- voverflow = vec_ld(15, src);
- vsrc = vec_perm(vsrc, voverflow, valigner);
- vsrc2 = (vector unsigned int) vec_perm(vsrc, valpha, vpermute);
- /* 1555 */
- vpixel = (vector unsigned short) vec_packpx(vsrc1, vsrc2);
- vgpixel = (vector unsigned short) vec_perm(vsrc1, vsrc2, vgmerge);
- vgpixel = vec_and(vgpixel, vfc);
- vgpixel = vec_sl(vgpixel, v3);
- vrpixel = vec_sl(vpixel, v1);
- vrpixel = vec_and(vrpixel, vf800);
- vbpixel = vec_and(vpixel, v3f);
- vdst =
- vec_or((vector unsigned char) vrpixel,
- (vector unsigned char) vgpixel);
- /* 565 */
- vdst = vec_or(vdst, (vector unsigned char) vbpixel);
- vec_st(vdst, 0, dst);
- width -= 8;
- src += 16;
- dst += 16;
- vsrc = voverflow;
- }
- SDL_assert(width == 0);
- /* do scalar until we can align... */
- ONE_PIXEL_BLEND((extrawidth), extrawidth);
- #undef ONE_PIXEL_BLEND
- src += srcskip; /* move to next row, accounting for pitch. */
- dst += dstskip;
- }
- }
- static void
- Blit_RGB565_32Altivec(SDL_BlitInfo * info)
- {
- int height = info->dst_h;
- Uint8 *src = (Uint8 *) info->src;
- int srcskip = info->src_skip;
- Uint8 *dst = (Uint8 *) info->dst;
- int dstskip = info->dst_skip;
- SDL_PixelFormat *srcfmt = info->src_fmt;
- SDL_PixelFormat *dstfmt = info->dst_fmt;
- unsigned alpha;
- vector unsigned char valpha;
- vector unsigned char vpermute;
- vector unsigned short vf800;
- vector unsigned int v8 = vec_splat_u32(8);
- vector unsigned int v16 = vec_add(v8, v8);
- vector unsigned short v2 = vec_splat_u16(2);
- vector unsigned short v3 = vec_splat_u16(3);
- /*
- 0x10 - 0x1f is the alpha
- 0x00 - 0x0e evens are the red
- 0x01 - 0x0f odds are zero
- */
- vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01,
- 0x10, 0x02, 0x01, 0x01,
- 0x10, 0x04, 0x01, 0x01,
- 0x10, 0x06, 0x01,
- 0x01);
- vector unsigned char vredalpha2 =
- (vector unsigned
- char) (vec_add((vector unsigned int) vredalpha1, vec_sl(v8, v16))
- );
- /*
- 0x00 - 0x0f is ARxx ARxx ARxx ARxx
- 0x11 - 0x0f odds are blue
- */
- vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11,
- 0x04, 0x05, 0x06, 0x13,
- 0x08, 0x09, 0x0a, 0x15,
- 0x0c, 0x0d, 0x0e, 0x17);
- vector unsigned char vblue2 =
- (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8)
- );
- /*
- 0x00 - 0x0f is ARxB ARxB ARxB ARxB
- 0x10 - 0x0e evens are green
- */
- vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03,
- 0x04, 0x05, 0x12, 0x07,
- 0x08, 0x09, 0x14, 0x0b,
- 0x0c, 0x0d, 0x16, 0x0f);
- vector unsigned char vgreen2 =
- (vector unsigned
- char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8))
- );
- SDL_assert(srcfmt->BytesPerPixel == 2);
- SDL_assert(dstfmt->BytesPerPixel == 4);
- vf800 = (vector unsigned short) vec_splat_u8(-7);
- vf800 = vec_sl(vf800, vec_splat_u16(8));
- if (dstfmt->Amask && info->a) {
- ((unsigned char *) &valpha)[0] = alpha = info->a;
- valpha = vec_splat(valpha, 0);
- } else {
- alpha = 0;
- valpha = vec_splat_u8(0);
- }
- vpermute = calc_swizzle32(NULL, dstfmt);
- while (height--) {
- vector unsigned char valigner;
- vector unsigned char voverflow;
- vector unsigned char vsrc;
- int width = info->dst_w;
- int extrawidth;
- /* do scalar until we can align... */
- #define ONE_PIXEL_BLEND(condition, widthvar) \
- while (condition) { \
- unsigned sR, sG, sB; \
- unsigned short Pixel = *((unsigned short *)src); \
- sR = (Pixel >> 8) & 0xf8; \
- sG = (Pixel >> 3) & 0xfc; \
- sB = (Pixel << 3) & 0xf8; \
- ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \
- src += 2; \
- dst += 4; \
- widthvar--; \
- }
- ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width);
- /* After all that work, here's the vector part! */
- extrawidth = (width % 8); /* trailing unaligned stores */
- width -= extrawidth;
- vsrc = vec_ld(0, src);
- valigner = VEC_ALIGNER(src);
- while (width) {
- vector unsigned short vR, vG, vB;
- vector unsigned char vdst1, vdst2;
- voverflow = vec_ld(15, src);
- vsrc = vec_perm(vsrc, voverflow, valigner);
- vR = vec_and((vector unsigned short) vsrc, vf800);
- vB = vec_sl((vector unsigned short) vsrc, v3);
- vG = vec_sl(vB, v2);
- vdst1 =
- (vector unsigned char) vec_perm((vector unsigned char) vR,
- valpha, vredalpha1);
- vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1);
- vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1);
- vdst1 = vec_perm(vdst1, valpha, vpermute);
- vec_st(vdst1, 0, dst);
- vdst2 =
- (vector unsigned char) vec_perm((vector unsigned char) vR,
- valpha, vredalpha2);
- vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2);
- vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2);
- vdst2 = vec_perm(vdst2, valpha, vpermute);
- vec_st(vdst2, 16, dst);
- width -= 8;
- dst += 32;
- src += 16;
- vsrc = voverflow;
- }
- SDL_assert(width == 0);
- /* do scalar until we can align... */
- ONE_PIXEL_BLEND((extrawidth), extrawidth);
- #undef ONE_PIXEL_BLEND
- src += srcskip; /* move to next row, accounting for pitch. */
- dst += dstskip;
- }
- }
- static void
- Blit_RGB555_32Altivec(SDL_BlitInfo * info)
- {
- int height = info->dst_h;
- Uint8 *src = (Uint8 *) info->src;
- int srcskip = info->src_skip;
- Uint8 *dst = (Uint8 *) info->dst;
- int dstskip = info->dst_skip;
- SDL_PixelFormat *srcfmt = info->src_fmt;
- SDL_PixelFormat *dstfmt = info->dst_fmt;
- unsigned alpha;
- vector unsigned char valpha;
- vector unsigned char vpermute;
- vector unsigned short vf800;
- vector unsigned int v8 = vec_splat_u32(8);
- vector unsigned int v16 = vec_add(v8, v8);
- vector unsigned short v1 = vec_splat_u16(1);
- vector unsigned short v3 = vec_splat_u16(3);
- /*
- 0x10 - 0x1f is the alpha
- 0x00 - 0x0e evens are the red
- 0x01 - 0x0f odds are zero
- */
- vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01,
- 0x10, 0x02, 0x01, 0x01,
- 0x10, 0x04, 0x01, 0x01,
- 0x10, 0x06, 0x01,
- 0x01);
- vector unsigned char vredalpha2 =
- (vector unsigned
- char) (vec_add((vector unsigned int) vredalpha1, vec_sl(v8, v16))
- );
- /*
- 0x00 - 0x0f is ARxx ARxx ARxx ARxx
- 0x11 - 0x0f odds are blue
- */
- vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11,
- 0x04, 0x05, 0x06, 0x13,
- 0x08, 0x09, 0x0a, 0x15,
- 0x0c, 0x0d, 0x0e, 0x17);
- vector unsigned char vblue2 =
- (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8)
- );
- /*
- 0x00 - 0x0f is ARxB ARxB ARxB ARxB
- 0x10 - 0x0e evens are green
- */
- vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03,
- 0x04, 0x05, 0x12, 0x07,
- 0x08, 0x09, 0x14, 0x0b,
- 0x0c, 0x0d, 0x16, 0x0f);
- vector unsigned char vgreen2 =
- (vector unsigned
- char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8))
- );
- SDL_assert(srcfmt->BytesPerPixel == 2);
- SDL_assert(dstfmt->BytesPerPixel == 4);
- vf800 = (vector unsigned short) vec_splat_u8(-7);
- vf800 = vec_sl(vf800, vec_splat_u16(8));
- if (dstfmt->Amask && info->a) {
- ((unsigned char *) &valpha)[0] = alpha = info->a;
- valpha = vec_splat(valpha, 0);
- } else {
- alpha = 0;
- valpha = vec_splat_u8(0);
- }
- vpermute = calc_swizzle32(NULL, dstfmt);
- while (height--) {
- vector unsigned char valigner;
- vector unsigned char voverflow;
- vector unsigned char vsrc;
- int width = info->dst_w;
- int extrawidth;
- /* do scalar until we can align... */
- #define ONE_PIXEL_BLEND(condition, widthvar) \
- while (condition) { \
- unsigned sR, sG, sB; \
- unsigned short Pixel = *((unsigned short *)src); \
- sR = (Pixel >> 7) & 0xf8; \
- sG = (Pixel >> 2) & 0xf8; \
- sB = (Pixel << 3) & 0xf8; \
- ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \
- src += 2; \
- dst += 4; \
- widthvar--; \
- }
- ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width);
- /* After all that work, here's the vector part! */
- extrawidth = (width % 8); /* trailing unaligned stores */
- width -= extrawidth;
- vsrc = vec_ld(0, src);
- valigner = VEC_ALIGNER(src);
- while (width) {
- vector unsigned short vR, vG, vB;
- vector unsigned char vdst1, vdst2;
- voverflow = vec_ld(15, src);
- vsrc = vec_perm(vsrc, voverflow, valigner);
- vR = vec_and(vec_sl((vector unsigned short) vsrc, v1), vf800);
- vB = vec_sl((vector unsigned short) vsrc, v3);
- vG = vec_sl(vB, v3);
- vdst1 =
- (vector unsigned char) vec_perm((vector unsigned char) vR,
- valpha, vredalpha1);
- vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1);
- vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1);
- vdst1 = vec_perm(vdst1, valpha, vpermute);
- vec_st(vdst1, 0, dst);
- vdst2 =
- (vector unsigned char) vec_perm((vector unsigned char) vR,
- valpha, vredalpha2);
- vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2);
- vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2);
- vdst2 = vec_perm(vdst2, valpha, vpermute);
- vec_st(vdst2, 16, dst);
- width -= 8;
- dst += 32;
- src += 16;
- vsrc = voverflow;
- }
- SDL_assert(width == 0);
- /* do scalar until we can align... */
- ONE_PIXEL_BLEND((extrawidth), extrawidth);
- #undef ONE_PIXEL_BLEND
- src += srcskip; /* move to next row, accounting for pitch. */
- dst += dstskip;
- }
- }
- static void BlitNtoNKey(SDL_BlitInfo * info);
- static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info);
- static void
- Blit32to32KeyAltivec(SDL_BlitInfo * info)
- {
- int height = info->dst_h;
- Uint32 *srcp = (Uint32 *) info->src;
- int srcskip = info->src_skip / 4;
- Uint32 *dstp = (Uint32 *) info->dst;
- int dstskip = info->dst_skip / 4;
- SDL_PixelFormat *srcfmt = info->src_fmt;
- int srcbpp = srcfmt->BytesPerPixel;
- SDL_PixelFormat *dstfmt = info->dst_fmt;
- int dstbpp = dstfmt->BytesPerPixel;
- int copy_alpha = (srcfmt->Amask && dstfmt->Amask);
- unsigned alpha = dstfmt->Amask ? info->a : 0;
- Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
- Uint32 ckey = info->colorkey;
- vector unsigned int valpha;
- vector unsigned char vpermute;
- vector unsigned char vzero;
- vector unsigned int vckey;
- vector unsigned int vrgbmask;
- vpermute = calc_swizzle32(srcfmt, dstfmt);
- if (info->dst_w < 16) {
- if (copy_alpha) {
- BlitNtoNKeyCopyAlpha(info);
- } else {
- BlitNtoNKey(info);
- }
- return;
- }
- vzero = vec_splat_u8(0);
- if (alpha) {
- ((unsigned char *) &valpha)[0] = (unsigned char) alpha;
- valpha =
- (vector unsigned int) vec_splat((vector unsigned char) valpha, 0);
- } else {
- valpha = (vector unsigned int) vzero;
- }
- ckey &= rgbmask;
- ((unsigned int *) (char *) &vckey)[0] = ckey;
- vckey = vec_splat(vckey, 0);
- ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask;
- vrgbmask = vec_splat(vrgbmask, 0);
- while (height--) {
- #define ONE_PIXEL_BLEND(condition, widthvar) \
- if (copy_alpha) { \
- while (condition) { \
- Uint32 Pixel; \
- unsigned sR, sG, sB, sA; \
- DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, Pixel, \
- sR, sG, sB, sA); \
- if ( (Pixel & rgbmask) != ckey ) { \
- ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \
- sR, sG, sB, sA); \
- } \
- dstp = (Uint32 *) (((Uint8 *) dstp) + dstbpp); \
- srcp = (Uint32 *) (((Uint8 *) srcp) + srcbpp); \
- widthvar--; \
- } \
- } else { \
- while (condition) { \
- Uint32 Pixel; \
- unsigned sR, sG, sB; \
- RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, Pixel); \
- if ( Pixel != ckey ) { \
- RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
- ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \
- sR, sG, sB, alpha); \
- } \
- dstp = (Uint32 *) (((Uint8 *)dstp) + dstbpp); \
- srcp = (Uint32 *) (((Uint8 *)srcp) + srcbpp); \
- widthvar--; \
- } \
- }
- int width = info->dst_w;
- ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
- SDL_assert(width > 0);
- if (width > 0) {
- int extrawidth = (width % 4);
- vector unsigned char valigner = VEC_ALIGNER(srcp);
- vector unsigned int vs = vec_ld(0, srcp);
- width -= extrawidth;
- SDL_assert(width >= 4);
- while (width) {
- vector unsigned char vsel;
- vector unsigned int vd;
- vector unsigned int voverflow = vec_ld(15, srcp);
- /* load the source vec */
- vs = vec_perm(vs, voverflow, valigner);
- /* vsel is set for items that match the key */
- vsel = (vector unsigned char) vec_and(vs, vrgbmask);
- vsel = (vector unsigned char) vec_cmpeq(vs, vckey);
- /* permute the src vec to the dest format */
- vs = vec_perm(vs, valpha, vpermute);
- /* load the destination vec */
- vd = vec_ld(0, dstp);
- /* select the source and dest into vs */
- vd = (vector unsigned int) vec_sel((vector unsigned char) vs,
- (vector unsigned char) vd,
- vsel);
- vec_st(vd, 0, dstp);
- srcp += 4;
- width -= 4;
- dstp += 4;
- vs = voverflow;
- }
- ONE_PIXEL_BLEND((extrawidth), extrawidth);
- #undef ONE_PIXEL_BLEND
- srcp += srcskip;
- dstp += dstskip;
- }
- }
- }
- /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */
- /* Use this on a G5 */
- static void
- ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info)
- {
- int height = info->dst_h;
- Uint32 *src = (Uint32 *) info->src;
- int srcskip = info->src_skip / 4;
- Uint32 *dst = (Uint32 *) info->dst;
- int dstskip = info->dst_skip / 4;
- SDL_PixelFormat *srcfmt = info->src_fmt;
- SDL_PixelFormat *dstfmt = info->dst_fmt;
- vector unsigned int vzero = vec_splat_u32(0);
- vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
- if (dstfmt->Amask && !srcfmt->Amask) {
- if (info->a) {
- vector unsigned char valpha;
- ((unsigned char *) &valpha)[0] = info->a;
- vzero = (vector unsigned int) vec_splat(valpha, 0);
- }
- }
- SDL_assert(srcfmt->BytesPerPixel == 4);
- SDL_assert(dstfmt->BytesPerPixel == 4);
- while (height--) {
- vector unsigned char valigner;
- vector unsigned int vbits;
- vector unsigned int voverflow;
- Uint32 bits;
- Uint8 r, g, b, a;
- int width = info->dst_w;
- int extrawidth;
- /* do scalar until we can align... */
- while ((UNALIGNED_PTR(dst)) && (width)) {
- bits = *(src++);
- RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
- if(!srcfmt->Amask)
- a = info->a;
- *(dst++) = MAKE8888(dstfmt, r, g, b, a);
- width--;
- }
- /* After all that work, here's the vector part! */
- extrawidth = (width % 4);
- width -= extrawidth;
- valigner = VEC_ALIGNER(src);
- vbits = vec_ld(0, src);
- while (width) {
- voverflow = vec_ld(15, src);
- src += 4;
- width -= 4;
- vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */
- vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */
- vec_st(vbits, 0, dst); /* store it back out. */
- dst += 4;
- vbits = voverflow;
- }
- SDL_assert(width == 0);
- /* cover pixels at the end of the row that didn't fit in 16 bytes. */
- while (extrawidth) {
- bits = *(src++); /* max 7 pixels, don't bother with prefetch. */
- RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
- if(!srcfmt->Amask)
- a = info->a;
- *(dst++) = MAKE8888(dstfmt, r, g, b, a);
- extrawidth--;
- }
- src += srcskip;
- dst += dstskip;
- }
- }
- /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */
- /* Use this on a G4 */
- static void
- ConvertAltivec32to32_prefetch(SDL_BlitInfo * info)
- {
- const int scalar_dst_lead = sizeof(Uint32) * 4;
- const int vector_dst_lead = sizeof(Uint32) * 16;
- int height = info->dst_h;
- Uint32 *src = (Uint32 *) info->src;
- int srcskip = info->src_skip / 4;
- Uint32 *dst = (Uint32 *) info->dst;
- int dstskip = info->dst_skip / 4;
- SDL_PixelFormat *srcfmt = info->src_fmt;
- SDL_PixelFormat *dstfmt = info->dst_fmt;
- vector unsigned int vzero = vec_splat_u32(0);
- vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
- if (dstfmt->Amask && !srcfmt->Amask) {
- if (info->a) {
- vector unsigned char valpha;
- ((unsigned char *) &valpha)[0] = info->a;
- vzero = (vector unsigned int) vec_splat(valpha, 0);
- }
- }
- SDL_assert(srcfmt->BytesPerPixel == 4);
- SDL_assert(dstfmt->BytesPerPixel == 4);
- while (height--) {
- vector unsigned char valigner;
- vector unsigned int vbits;
- vector unsigned int voverflow;
- Uint32 bits;
- Uint8 r, g, b, a;
- int width = info->dst_w;
- int extrawidth;
- /* do scalar until we can align... */
- while ((UNALIGNED_PTR(dst)) && (width)) {
- vec_dstt(src + scalar_dst_lead, DST_CTRL(2, 32, 1024),
- DST_CHAN_SRC);
- vec_dstst(dst + scalar_dst_lead, DST_CTRL(2, 32, 1024),
- DST_CHAN_DEST);
- bits = *(src++);
- RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
- if(!srcfmt->Amask)
- a = info->a;
- *(dst++) = MAKE8888(dstfmt, r, g, b, a);
- width--;
- }
- /* After all that work, here's the vector part! */
- extrawidth = (width % 4);
- width -= extrawidth;
- valigner = VEC_ALIGNER(src);
- vbits = vec_ld(0, src);
- while (width) {
- vec_dstt(src + vector_dst_lead, DST_CTRL(2, 32, 1024),
- DST_CHAN_SRC);
- vec_dstst(dst + vector_dst_lead, DST_CTRL(2, 32, 1024),
- DST_CHAN_DEST);
- voverflow = vec_ld(15, src);
- src += 4;
- width -= 4;
- vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */
- vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */
- vec_st(vbits, 0, dst); /* store it back out. */
- dst += 4;
- vbits = voverflow;
- }
- SDL_assert(width == 0);
- /* cover pixels at the end of the row that didn't fit in 16 bytes. */
- while (extrawidth) {
- bits = *(src++); /* max 7 pixels, don't bother with prefetch. */
- RGBA_FROM_8888(bits, srcfmt, r, g, b, a);
- if(!srcfmt->Amask)
- a = info->a;
- *(dst++) = MAKE8888(dstfmt, r, g, b, a);
- extrawidth--;
- }
- src += srcskip;
- dst += dstskip;
- }
- vec_dss(DST_CHAN_SRC);
- vec_dss(DST_CHAN_DEST);
- }
- static Uint32
- GetBlitFeatures(void)
- {
- static Uint32 features = 0xffffffff;
- if (features == 0xffffffff) {
- /* Provide an override for testing .. */
- char *override = SDL_getenv("SDL_ALTIVEC_BLIT_FEATURES");
- if (override) {
- features = 0;
- SDL_sscanf(override, "%u", &features);
- } else {
- features = (0
- /* Feature 1 is has-MMX */
- | ((SDL_HasMMX())? 1 : 0)
- /* Feature 2 is has-AltiVec */
- | ((SDL_HasAltiVec())? 2 : 0)
- /* Feature 4 is dont-use-prefetch */
- /* !!!! FIXME: Check for G5 or later, not the cache size! Always prefetch on a G4. */
- | ((GetL3CacheSize() == 0) ? 4 : 0)
- );
- }
- }
- return features;
- }
- #if __MWERKS__
- #pragma altivec_model off
- #endif
- #else
- /* Feature 1 is has-MMX */
- #define GetBlitFeatures() ((Uint32)(SDL_HasMMX() ? 1 : 0))
- #endif
- /* This is now endian dependent */
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
- #define HI 1
- #define LO 0
- #else /* SDL_BYTEORDER == SDL_BIG_ENDIAN */
- #define HI 0
- #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_RGB888_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 == NULL) {
- while (height--) {
- #ifdef USE_DUFFS_LOOP
- /* *INDENT-OFF* */
- DUFFS_LOOP(
- RGB888_RGB332(*dst++, *src);
- , width);
- /* *INDENT-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;
- case 2:
- RGB888_RGB332(*dst++, *src);
- ++src;
- 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* */
- DUFFS_LOOP(
- RGB888_RGB332(Pixel, *src);
- *dst++ = map[Pixel];
- ++src;
- , width);
- /* *INDENT-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;
- case 2:
- RGB888_RGB332(Pixel, *src);
- *dst++ = map[Pixel];
- ++src;
- case 1:
- RGB888_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) { \
- *(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>9)| \
- (((*src)&0x0000F800)>>6)| \
- (((*src)&0x000000F8)>>3)); \
- }
- #define RGB888_RGB555_TWO(dst, src) { \
- *(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>9)| \
- (((src[HI])&0x0000F800)>>6)| \
- (((src[HI])&0x000000F8)>>3))<<16)| \
- (((src[LO])&0x00F80000)>>9)| \
- (((src[LO])&0x0000F800)>>6)| \
- (((src[LO])&0x000000F8)>>3); \
- }
- static void
- Blit_RGB888_RGB555(SDL_BlitInfo * info)
- {
- #ifndef USE_DUFFS_LOOP
- int c;
- #endif
- int width, height;
- Uint32 *src;
- Uint16 *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 = (Uint16 *) info->dst;
- dstskip = info->dst_skip / 2;
- #ifdef USE_DUFFS_LOOP
- while (height--) {
- /* *INDENT-OFF* */
- DUFFS_LOOP(
- RGB888_RGB555(dst, src);
- ++src;
- ++dst;
- , width);
- /* *INDENT-ON* */
- src += srcskip;
- dst += dstskip;
- }
- #else
- /* Memory align at 4-byte boundary, if necessary */
- if ((long) dst & 0x03) {
- /* Don't do anything if width is 0 */
- if (width == 0) {
- return;
- }
- --width;
- while (height--) {
- /* Perform copy alignment */
- RGB888_RGB555(dst, src);
- ++src;
- ++dst;
- /* Copy in 4 pixel chunks */
- for (c = width / 4; c; --c) {
- RGB888_RGB555_TWO(dst, src);
- src += 2;
- dst += 2;
- RGB888_RGB555_TWO(dst, src);
- src += 2;
- dst += 2;
- }
- /* Get any leftovers */
- switch (width & 3) {
- case 3:
- RGB888_RGB555(dst, src);
- ++src;
- ++dst;
- case 2:
- RGB888_RGB555_TWO(dst, src);
- src += 2;
- dst += 2;
- break;
- case 1:
- RGB888_RGB555(dst, src);
- ++src;
- ++dst;
- break;
- }
- src += srcskip;
- dst += dstskip;
- }
- } else {
- while (height--) {
- /* Copy in 4 pixel chunks */
- for (c = width / 4; c; --c) {
- RGB888_RGB555_TWO(dst, src);
- src += 2;
- dst += 2;
- RGB888_RGB555_TWO(dst, src);
- src += 2;
- dst += 2;
- }
- /* Get any leftovers */
- switch (width & 3) {
- case 3:
- RGB888_RGB555(dst, src);
- ++src;
- ++dst;
- case 2:
- RGB888_RGB555_TWO(dst, src);
- src += 2;
- dst += 2;
- break;
- case 1:
- RGB888_RGB555(dst, src);
- ++src;
- ++dst;
- break;
- }
- src += srcskip;
- dst += dstskip;
- }
- }
- #endif /* USE_DUFFS_LOOP */
- }
- /* Special optimized blit for RGB 8-8-8 --> RGB 5-6-5 */
- #define RGB888_RGB565(dst, src) { \
- *(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>8)| \
- (((*src)&0x0000FC00)>>5)| \
- (((*src)&0x000000F8)>>3)); \
- }
- #define RGB888_RGB565_TWO(dst, src) { \
- *(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>8)| \
- (((src[HI])&0x0000FC00)>>5)| \
- (((src[HI])&0x000000F8)>>3))<<16)| \
- (((src[LO])&0x00F80000)>>8)| \
- (((src[LO])&0x0000FC00)>>5)| \
- (((src[LO])&0x000000F8)>>3); \
- }
- static void
- Blit_RGB888_RGB565(SDL_BlitInfo * info)
- {
- #ifndef USE_DUFFS_LOOP
- int c;
- #endif
- int width, height;
- Uint32 *src;
- Uint16 *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 = (Uint16 *) info->dst;
- dstskip = info->dst_skip / 2;
- #ifdef USE_DUFFS_LOOP
- while (height--) {
- /* *INDENT-OFF* */
- DUFFS_LOOP(
- RGB888_RGB565(dst, src);
- ++src;
- ++dst;
- , width);
- /* *INDENT-ON* */
- src += srcskip;
- dst += dstskip;
- }
- #else
- /* Memory align at 4-byte boundary, if necessary */
- if ((long) dst & 0x03) {
- /* Don't do anything if width is 0 */
- if (width == 0) {
- return;
- }
- --width;
- while (height--) {
- /* Perform copy alignment */
- RGB888_RGB565(dst, src);
- ++src;
- ++dst;
- /* Copy in 4 pixel chunks */
- for (c = width / 4; c; --c) {
- RGB888_RGB565_TWO(dst, src);
- src += 2;
- dst += 2;
- RGB888_RGB565_TWO(dst, src);
- src += 2;
- dst += 2;
- }
- /* Get any leftovers */
- switch (width & 3) {
- case 3:
- RGB888_RGB565(dst, src);
- ++src;
- ++dst;
- case 2:
- RGB888_RGB565_TWO(dst, src);
- src += 2;
- dst += 2;
- break;
- case 1:
- RGB888_RGB565(dst, src);
- ++src;
- ++dst;
- break;
- }
- src += srcskip;
- dst += dstskip;
- }
- } else {
- while (height--) {
- /* Copy in 4 pixel chunks */
- for (c = width / 4; c; --c) {
- RGB888_RGB565_TWO(dst, src);
- src += 2;
- dst += 2;
- RGB888_RGB565_TWO(dst, src);
- src += 2;
- dst += 2;
- }
- /* Get any leftovers */
- switch (width & 3) {
- case 3:
- RGB888_RGB565(dst, src);
- ++src;
- ++dst;
- case 2:
- RGB888_RGB565_TWO(dst, src);
- src += 2;
- dst += 2;
- break;
- case 1:
- RGB888_RGB565(dst, src);
- ++src;
- ++dst;
- break;
- }
- src += srcskip;
- dst += dstskip;
- }
- }
- #endif /* USE_DUFFS_LOOP */
- }
- /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */
- #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1])
- static void
- Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map)
- {
- #ifndef USE_DUFFS_LOOP
- int c;
- #endif
- int width, height;
- Uint8 *src;
- Uint32 *dst;
- int srcskip, dstskip;
- /* Set up some basic variables */
- width = info->dst_w;
- height = info->dst_h;
- src = (Uint8 *) info->src;
- srcskip = info->src_skip;
- dst = (Uint32 *) info->dst;
- dstskip = info->dst_skip / 4;
- #ifdef USE_DUFFS_LOOP
- while (height--) {
- /* *INDENT-OFF* */
- DUFFS_LOOP(
- {
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- },
- width);
- /* *INDENT-ON* */
- src += srcskip;
- dst += dstskip;
- }
- #else
- while (height--) {
- /* Copy in 4 pixel chunks */
- for (c = width / 4; c; --c) {
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- }
- /* Get any leftovers */
- switch (width & 3) {
- case 3:
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- case 2:
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- case 1:
- *dst++ = RGB565_32(dst, src, map);
- src += 2;
- break;
- }
- src += srcskip;
- dst += dstskip;
- }
- #endif /* USE_DUFFS_LOOP */
- }
- /* Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 */
- static const Uint32 RGB565_ARGB8888_LUT[512] = {
- 0x00000000, 0xff000000, 0x00000008, 0xff002000,
- 0x00000010, 0xff004000, 0x00000018, 0xff006100,
- 0x00000020, 0xff008100, 0x00000029, 0xff00a100,
- 0x00000031, 0xff00c200, 0x00000039, 0xff00e200,
- 0x00000041, 0xff080000, 0x0000004a, 0xff082000,
- 0x00000052, 0xff084000, 0x0000005a, 0xff086100,
- 0x00000062, 0xff088100, 0x0000006a, 0xff08a100,
- 0x00000073, 0xff08c200, 0x0000007b, 0xff08e200,
- 0x00000083, 0xff100000, 0x0000008b, 0xff102000,
- 0x00000094, 0xff104000, 0x0000009c, 0xff106100,
- 0x000000a4, 0xff108100, 0x000000ac, 0xff10a100,
- 0x000000b4, 0xff10c200, 0x000000bd, 0xff10e200,
- 0x000000c5, 0xff180000, 0x000000cd, 0xff182000,
- 0x000000d5, 0xff184000, 0x000000de, 0xff186100,
- 0x000000e6, 0xff188100, 0x000000ee, 0xff18a100,
- 0x000000f6, 0xff18c200, 0x000000ff, 0xff18e200,
- 0x00000400, 0xff200000, 0x00000408, 0xff202000,
- 0x00000410, 0xff204000, 0x00000418, 0xff206100,
- 0x00000420, 0xff208100, 0x00000429, 0xff20a100,
- 0x00000431, 0xff20c200, 0x00000439, 0xff20e200,
- 0x00000441, 0xff290000, 0x0000044a, 0xff292000,
- 0x00000452, 0xff294000, 0x0000045a, 0xff296100,
- 0x00000462, 0xff298100, 0x0000046a, 0xff29a100,
- 0x00000473, 0xff29c200, 0x0000047b, 0xff29e200,
- 0x00000483, 0xff310000, 0x0000048b, 0xff312000,
- 0x00000494, 0xff314000, 0x0000049c, 0xff316100,
- 0x000004a4, 0xff318100, 0x000004ac, 0xff31a100,
- 0x000004b4, 0xff31c200, 0x000004bd, 0xff31e200,
- 0x000004c5, 0xff390000, 0x000004cd, 0xff392000,
- 0x000004d5, 0xff394000, 0x000004de, 0xff396100,
- 0x000004e6, 0xff398100, 0x000004ee, 0xff39a100,
- 0x000004f6, 0xff39c200, 0x000004ff, 0xff39e200,
- 0x00000800, 0xff410000, 0x00000808, 0xff412000,
- 0x00000810, 0xff414000, 0x00000818, 0xff416100,
- 0x00000820, 0xff418100, 0x00000829, 0xff41a100,
- 0x00000831, 0xff41c200, 0x00000839, 0xff41e200,
- 0x00000841, 0xff4a0000, 0x0000084a, 0xff4a2000,
- 0x00000852, 0xff4a4000, 0x0000085a, 0xff4a6100,
- 0x00000862, 0xff4a8100, 0x0000086a, 0xff4aa100,
- 0x00000873, 0xff4ac200, 0x0000087b, 0xff4ae200,
- 0x00000883, 0xff520000, 0x0000088b, 0xff522000,
- 0x00000894, 0xff524000, 0x0000089c, 0xff526100,
- 0x000008a4, 0xff528100, 0x000008ac, 0xff52a100,
- 0x000008b4, 0xff52c200, 0x000008bd, 0xff52e200,
- 0x000008c5, 0xff5a0000, 0x000008cd, 0xff5a2000,
- 0x000008d5, 0xff5a4000, 0x000008de, 0xff5a6100,
- 0x000008e6, 0xff5a8100, 0x000008ee, 0xff5aa100,
- 0x000008f6, 0xff5ac200, 0x000008ff, 0xff5ae200,
- 0x00000c00, 0xff620000, 0x00000c08, 0xff622000,
- 0x00000c10, 0xff624000, 0x00000c18, 0xff626100,
- 0x00000c20, 0xff628100, 0x00000c29, 0xff62a100,
- 0x00000c31, 0xff62c200, 0x00000c39, 0xff62e200,
- 0x00000c41, 0xff6a0000, 0x00000c4a, 0xff6a2000,
- 0x00000c52, 0xff6a4000, 0x00000c5a, 0xff6a6100,
- 0x00000c62, 0xff6a8100, 0x00000c6a, 0xff6aa100,
- 0x00000c73, 0xff6ac200, 0x00000c7b, 0xff6ae200,
- 0x00000c83, 0xff730000, 0x00000c8b, 0xff732000,
- 0x00000c94, 0xff734000, 0x00000c9c, 0xff736100,
- 0x00000ca4, 0xff738100, 0x00000cac, 0xff73a100,
- 0x00000cb4, 0xff73c200, 0x00000cbd, 0xff73e200,
- 0x00000cc5, 0xff7b0000, 0x00000ccd, 0xff7b2000,
- 0x00000cd5, 0xff7b4000, 0x00000cde, 0xff7b6100,
- 0x00000ce6, 0xff7b8100, 0x00000cee, 0xff7ba100,
- 0x00000cf6, 0xff7bc200, 0x00000cff, 0xff7be200,
- 0x00001000, 0xff830000, 0x00001008, 0xff832000,
- 0x00001010, 0xff834000, 0x00001018, 0xff836100,
- 0x00001020, 0xff838100, 0x00001029, 0xff83a100,
- 0x00001031, 0xff83c200, 0x00001039, 0xff83e200,
- 0x00001041, 0xff8b0000, 0x0000104a, 0xff8b2000,
- 0x00001052, 0xff8b4000, 0x0000105a, 0xff8b6100,
- 0x00001062, 0xff8b8100, 0x0000106a, 0xff8ba100,
- 0x00001073, 0xff8bc200, 0x0000107b, 0xff8be200,
- 0x00001083, 0xff940000, 0x0000108b, 0xff942000,
- 0x00001094, 0xff944000, 0x0000109c, 0xff946100,
- 0x000010a4, 0xff948100, 0x000010ac, 0xff94a100,
- 0x000010b4, 0xff94c200, 0x000010bd, 0xff94e200,
- 0x000010c5, 0xff9c0000, 0x000010cd, 0xff9c2000,
- 0x000010d5, 0xff9c4000, 0x000010de, 0xff9c6100,
- 0x000010e6, 0xff9c8100, 0x000010ee, 0xff9ca100,
- 0x000010f6, 0xff9cc200, 0x000010ff, 0xff9ce200,
- 0x00001400, 0xffa40000, 0x00001408, 0xffa42000,
- 0x00001410, 0xffa44000, 0x00001418, 0xffa46100,
- 0x00001420, 0xffa48100, 0x00001429, 0xffa4a100,
- 0x00001431, 0xffa4c200, 0x00001439, 0xffa4e200,
- 0x00001441, 0xffac0000, 0x0000144a, 0xffac2000,
- 0x00001452, 0xffac4000, 0x0000145a, 0xffac6100,
- 0x00001462, 0xffac8100, 0x0000146a, 0xffaca100,
- 0x00001473, 0xffacc200, 0x0000147b, 0xfface200,
- 0x00001483, 0xffb40000, 0x0000148b, 0xffb42000,
- 0x00001494, 0xffb44000, 0x0000149c, 0xffb46100,
- 0x000014a4, 0xffb48100, 0x000014ac, 0xffb4a100,
- 0x000014b4, 0xffb4c200, 0x000014bd, 0xffb4e200,
- 0x000014c5, 0xffbd0000, 0x000014cd, 0xffbd2000,
- 0x000014d5, 0xffbd4000, 0x000014de, 0xffbd6100,
- 0x000014e6, 0xffbd8100, 0x000014ee, 0xffbda100,
- 0x000014f6, 0xffbdc200, 0x000014ff, 0xffbde200,
- 0x00001800, 0xffc50000, 0x00001808, 0xffc52000,
- 0x00001810, 0xffc54000, 0x00001818, 0xffc56100,
- 0x00001820, 0xffc58100, 0x00001829, 0xffc5a100,
- 0x00001831, 0xffc5c200, 0x00001839, 0xffc5e200,
- 0x00001841, 0xffcd0000, 0x0000184a, 0xffcd2000,
- 0x00001852, 0xffcd4000, 0x0000185a, 0xffcd6100,
- 0x00001862, 0xffcd8100, 0x0000186a, 0xffcda100,
- 0x00001873, 0xffcdc200, 0x0000187b, 0xffcde200,
- 0x00001883, 0xffd50000, 0x0000188b, 0xffd52000,
- 0x00001894, 0xffd54000, 0x0000189c, 0xffd56100,
- 0x000018a4, 0xffd58100, 0x000018ac, 0xffd5a100,
- 0x000018b4, 0xffd5c200, 0x000018bd, 0xffd5e200,
- 0x000018c5, 0xffde0000, 0x000018cd, 0xffde2000,
- 0x000018d5, 0xffde4000, 0x000018de, 0xffde6100,
- 0x000018e6, 0xffde8100, 0x000018ee, 0xffdea100,
- 0x000018f6, 0xffdec200, 0x000018ff, 0xffdee200,
- 0x00001c00, 0xffe60000, 0x00001c08, 0xffe62000,
- 0x00001c10, 0xffe64000, 0x00001c18, 0xffe66100,
- 0x00001c20, 0xffe68100, 0x00001c29, 0xffe6a100,
- 0x00001c31, 0xffe6c200, 0x00001c39, 0xffe6e200,
- 0x00001c41, 0xffee0000, 0x00001c4a, 0xffee2000,
- 0x00001c52, 0xffee4000, 0x00001c5a, 0xffee6100,
- 0x00001c62, 0xffee8100, 0x00001c6a, 0xffeea100,
- 0x00001c73, 0xffeec200, 0x00001c7b, 0xffeee200,
- 0x00001c83, 0xfff60000, 0x00001c8b, 0xfff62000,
- 0x00001c94, 0xfff64000, 0x00001c9c, 0xfff66100,
- 0x00001ca4, 0xfff68100, 0x00001cac, 0xfff6a100,
- 0x00001cb4, 0xfff6c200, 0x00001cbd, 0xfff6e200,
- 0x00001cc5, 0xffff0000, 0x00001ccd, 0xffff2000,
- 0x00001cd5, 0xffff4000, 0x00001cde, 0xffff6100,
- 0x00001ce6, 0xffff8100, 0x00001cee, 0xffffa100,
- 0x00001cf6, 0xffffc200, 0x00001cff, 0xffffe200
- };
- static void
- Blit_RGB565_ARGB8888(SDL_BlitInfo * info)
- {
- Blit_RGB565_32(info, RGB565_ARGB8888_LUT);
- }
- /* Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 */
- static const Uint32 RGB565_ABGR8888_LUT[512] = {
- 0xff000000, 0x00000000, 0xff080000, 0x00002000,
- 0xff100000, 0x00004000, 0xff180000, 0x00006100,
- 0xff200000, 0x00008100, 0xff290000, 0x0000a100,
- 0xff310000, 0x0000c200, 0xff390000, 0x0000e200,
- 0xff410000, 0x00000008, 0xff4a0000, 0x00002008,
- 0xff520000, 0x00004008, 0xff5a0000, 0x00006108,
- 0xff620000, 0x00008108, 0xff6a0000, 0x0000a108,
- 0xff730000, 0x0000c208, 0xff7b0000, 0x0000e208,
- 0xff830000, 0x00000010, 0xff8b0000, 0x00002010,
- 0xff940000, 0x00004010, 0xff9c0000, 0x00006110,
- 0xffa40000, 0x00008110, 0xffac0000, 0x0000a110,
- 0xffb40000, 0x0000c210, 0xffbd0000, 0x0000e210,
- 0xffc50000, 0x00000018, 0xffcd0000, 0x00002018,
- 0xffd50000, 0x00004018, 0xffde0000, 0x00006118,
- 0xffe60000, 0x00008118, 0xffee0000, 0x0000a118,
- 0xfff60000, 0x0000c218, 0xffff0000, 0x0000e…