Commit 47107f28 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Enable altivec blitters on PowerPC Linux, and some fixes for recent

 GCCs versions.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401165
parent dba88d23
......@@ -1910,11 +1910,16 @@ CheckUSBHID()
dnl Check for altivec instruction support using gas syntax
CheckAltivec()
{
AC_MSG_CHECKING(for GCC Altivec instruction support)
have_gcc_altivec=no
dnl FIXME: Theoretically, you might not have altivec.h, we should check
dnl FIXME: that seperately, but I think all major platforms have it
dnl FIXME: at the moment... --ryan.
save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec"
have_gcc_altivec=no
AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
CFLAGS="${save_CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -maltivec"
AC_TRY_COMPILE([
#include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
......@@ -1922,10 +1927,26 @@ CheckAltivec()
],[
have_gcc_altivec=yes
])
AC_MSG_RESULT($have_gcc_altivec)
if test x$have_gcc_altivec = xno; then
AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec"
AC_TRY_COMPILE([
#include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
have_gcc_altivec=yes
])
AC_MSG_RESULT($have_gcc_altivec)
fi
if test x$have_gcc_altivec = xno; then
CFLAGS="${save_CFLAGS}"
fi
AC_MSG_RESULT($have_gcc_altivec)
}
dnl Check for a valid linux/version.h
......
......@@ -90,112 +90,112 @@ extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int complex);
/* Load pixel of the specified format from a buffer and get its R-G-B values */
/* FIXME: rescale values to 0..255 here? */
#define RGB_FROM_PIXEL(pixel, fmt, r, g, b) \
#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \
{ \
r = (((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); \
g = (((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \
b = (((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); \
r = (((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); \
g = (((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \
b = (((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); \
}
#define RGB_FROM_RGB565(pixel, r, g, b) \
#define RGB_FROM_RGB565(Pixel, r, g, b) \
{ \
r = (((pixel&0xF800)>>11)<<3); \
g = (((pixel&0x07E0)>>5)<<2); \
b = ((pixel&0x001F)<<3); \
r = (((Pixel&0xF800)>>11)<<3); \
g = (((Pixel&0x07E0)>>5)<<2); \
b = ((Pixel&0x001F)<<3); \
}
#define RGB_FROM_RGB555(pixel, r, g, b) \
#define RGB_FROM_RGB555(Pixel, r, g, b) \
{ \
r = (((pixel&0x7C00)>>10)<<3); \
g = (((pixel&0x03E0)>>5)<<3); \
b = ((pixel&0x001F)<<3); \
r = (((Pixel&0x7C00)>>10)<<3); \
g = (((Pixel&0x03E0)>>5)<<3); \
b = ((Pixel&0x001F)<<3); \
}
#define RGB_FROM_RGB888(pixel, r, g, b) \
#define RGB_FROM_RGB888(Pixel, r, g, b) \
{ \
r = ((pixel&0xFF0000)>>16); \
g = ((pixel&0xFF00)>>8); \
b = (pixel&0xFF); \
r = ((Pixel&0xFF0000)>>16); \
g = ((Pixel&0xFF00)>>8); \
b = (Pixel&0xFF); \
}
#define RETRIEVE_RGB_PIXEL(buf, bpp, pixel) \
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \
do { \
switch (bpp) { \
case 2: \
pixel = *((Uint16 *)(buf)); \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: { \
Uint8 *B = (Uint8 *)(buf); \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
} else { \
pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \
} \
break; \
\
case 4: \
pixel = *((Uint32 *)(buf)); \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
pixel = 0; /* appease gcc */ \
Pixel = 0; /* appease gcc */ \
break; \
} \
} while(0)
#define DISEMBLE_RGB(buf, bpp, fmt, pixel, r, g, b) \
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
do { \
switch (bpp) { \
case 2: \
pixel = *((Uint16 *)(buf)); \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: { \
Uint8 *B = (Uint8 *)buf; \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
} else { \
pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \
} \
break; \
\
case 4: \
pixel = *((Uint32 *)(buf)); \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
pixel = 0; /* prevent gcc from complaining */ \
Pixel = 0; /* prevent gcc from complaining */ \
break; \
} \
RGB_FROM_PIXEL(pixel, fmt, r, g, b); \
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
} while(0)
/* Assemble R-G-B values into a specified pixel format and store them */
#define PIXEL_FROM_RGB(pixel, fmt, r, g, b) \
#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \
{ \
pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
((g>>fmt->Gloss)<<fmt->Gshift)| \
((b>>fmt->Bloss)<<fmt->Bshift); \
}
#define RGB565_FROM_RGB(pixel, r, g, b) \
#define RGB565_FROM_RGB(Pixel, r, g, b) \
{ \
pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \
Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \
}
#define RGB555_FROM_RGB(pixel, r, g, b) \
#define RGB555_FROM_RGB(Pixel, r, g, b) \
{ \
pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \
Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \
}
#define RGB888_FROM_RGB(pixel, r, g, b) \
#define RGB888_FROM_RGB(Pixel, r, g, b) \
{ \
pixel = (r<<16)|(g<<8)|b; \
Pixel = (r<<16)|(g<<8)|b; \
}
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
{ \
switch (bpp) { \
case 2: { \
Uint16 pixel; \
Uint16 Pixel; \
\
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
......@@ -213,10 +213,10 @@ do { \
break; \
\
case 4: { \
Uint32 pixel; \
Uint32 Pixel; \
\
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = pixel; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = Pixel; \
} \
break; \
} \
......@@ -226,11 +226,11 @@ do { \
switch (bpp) { \
case 2: { \
Uint16 *bufp; \
Uint16 pixel; \
Uint16 Pixel; \
\
bufp = (Uint16 *)buf; \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*bufp = pixel | (*bufp & Amask); \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = Pixel | (*bufp & Amask); \
} \
break; \
\
......@@ -249,85 +249,85 @@ do { \
\
case 4: { \
Uint32 *bufp; \
Uint32 pixel; \
Uint32 Pixel; \
\
bufp = (Uint32 *)buf; \
PIXEL_FROM_RGB(pixel, fmt, r, g, b); \
*bufp = pixel | (*bufp & Amask); \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = Pixel | (*bufp & Amask); \
} \
break; \
} \
}
/* FIXME: Should we rescale alpha into 0..255 here? */
#define RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \
#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \
{ \
r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
r = ((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
g = ((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
b = ((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
a = ((Pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
}
#define RGBA_FROM_8888(pixel, fmt, r, g, b, a) \
#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \
{ \
r = (pixel&fmt->Rmask)>>fmt->Rshift; \
g = (pixel&fmt->Gmask)>>fmt->Gshift; \
b = (pixel&fmt->Bmask)>>fmt->Bshift; \
a = (pixel&fmt->Amask)>>fmt->Ashift; \
r = (Pixel&fmt->Rmask)>>fmt->Rshift; \
g = (Pixel&fmt->Gmask)>>fmt->Gshift; \
b = (Pixel&fmt->Bmask)>>fmt->Bshift; \
a = (Pixel&fmt->Amask)>>fmt->Ashift; \
}
#define RGBA_FROM_RGBA8888(pixel, r, g, b, a) \
#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \
{ \
r = (pixel>>24); \
g = ((pixel>>16)&0xFF); \
b = ((pixel>>8)&0xFF); \
a = (pixel&0xFF); \
r = (Pixel>>24); \
g = ((Pixel>>16)&0xFF); \
b = ((Pixel>>8)&0xFF); \
a = (Pixel&0xFF); \
}
#define RGBA_FROM_ARGB8888(pixel, r, g, b, a) \
#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \
{ \
r = ((pixel>>16)&0xFF); \
g = ((pixel>>8)&0xFF); \
b = (pixel&0xFF); \
a = (pixel>>24); \
r = ((Pixel>>16)&0xFF); \
g = ((Pixel>>8)&0xFF); \
b = (Pixel&0xFF); \
a = (Pixel>>24); \
}
#define RGBA_FROM_ABGR8888(pixel, r, g, b, a) \
#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \
{ \
r = (pixel&0xFF); \
g = ((pixel>>8)&0xFF); \
b = ((pixel>>16)&0xFF); \
a = (pixel>>24); \
r = (Pixel&0xFF); \
g = ((Pixel>>8)&0xFF); \
b = ((Pixel>>16)&0xFF); \
a = (Pixel>>24); \
}
#define DISEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \
do { \
switch (bpp) { \
case 2: \
pixel = *((Uint16 *)(buf)); \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: {/* FIXME: broken code (no alpha) */ \
Uint8 *b = (Uint8 *)buf; \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
Pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
} else { \
pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
} \
} \
break; \
\
case 4: \
pixel = *((Uint32 *)(buf)); \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
pixel = 0; /* stop gcc complaints */ \
Pixel = 0; /* stop gcc complaints */ \
break; \
} \
RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \
pixel &= ~fmt->Amask; \
RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
Pixel &= ~fmt->Amask; \
} while(0)
/* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
#define PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \
#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
{ \
pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
((g>>fmt->Gloss)<<fmt->Gshift)| \
((b>>fmt->Bloss)<<fmt->Bshift)| \
((a>>fmt->Aloss)<<fmt->Ashift); \
......@@ -336,10 +336,10 @@ do { \
{ \
switch (bpp) { \
case 2: { \
Uint16 pixel; \
Uint16 Pixel; \
\
PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
*((Uint16 *)(buf)) = pixel; \
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
......@@ -357,16 +357,16 @@ do { \
break; \
\
case 4: { \
Uint32 pixel; \
Uint32 Pixel; \
\
PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
*((Uint32 *)(buf)) = pixel; \
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint32 *)(buf)) = Pixel; \
} \
break; \
} \
}
/* Blend the RGB values of two pixels based on a source alpha value */
/* Blend the RGB values of two Pixels based on a source alpha value */
#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
do { \
dR = (((sR-dR)*(A))>>8)+dR; \
......@@ -374,7 +374,7 @@ do { \
dB = (((sB-dB)*(A))>>8)+dB; \
} while(0)
/* Blend the RGB values of two pixels based on a source alpha value */
/* Blend the RGB values of two Pixels based on a source alpha value */
#define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB) \
do { \
unsigned tR, tG, tB, tA; \
......
......@@ -62,14 +62,14 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b;
......@@ -114,7 +114,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
......@@ -122,7 +122,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGBA(src,srcbpp,srcfmt,pixel,sR,sG,sB,sA);
DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b;
......@@ -169,15 +169,15 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
if ( pixel != ckey ) {
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
if ( Pixel != ckey ) {
dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b;
......@@ -298,7 +298,7 @@ static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info)
pand_r2r(mm3, mm2); /* 0A0R0G0B -> mm2 */
packuswb_r2r(mm2, mm2); /* ARGBARGB -> mm2 */
por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
movd_r2m(mm2, *dstp);/* mm2 -> pixel */
movd_r2m(mm2, *dstp);/* mm2 -> Pixel */
++srcp;
++dstp;
},{
......@@ -334,7 +334,7 @@ static void BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo *info)
psllq_i2r(32, mm6); /* mm6 << 32 -> mm6 */
por_r2r(mm6, mm2); /* mm6 | mm2 -> mm2 */
por_r2r(mm7, mm2); /* mm7(full alpha) | mm2 -> mm2 */
movq_r2m(mm2, *dstp);/* mm2 -> 2 x pixel */
movq_r2m(mm2, *dstp);/* mm2 -> 2 x Pixel */
srcp += 2;
dstp += 2;
}, width);
......@@ -422,7 +422,21 @@ static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info)
#endif
#ifdef USE_ALTIVEC_BLITTERS
#include <altivec.h>
#include <assert.h>
#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 VECPRINT(msg, v) do { \
vector unsigned int tmpvec = (vector unsigned int)(v); \
......@@ -493,7 +507,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
if (!dstfmt) {
dstfmt = &default_pixel_format;
}
vector unsigned char plus = (vector unsigned char)
vector unsigned char plus = VECUINT8_LITERAL
( 0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x04, 0x04,
0x08, 0x08, 0x08, 0x08,
......@@ -512,7 +526,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF);
}
#undef RESHIFT
((unsigned int *)&srcvec)[0] = (rmask | gmask | bmask | amask);
((unsigned int *)(char*)&srcvec)[0] = (rmask | gmask | bmask | amask);
vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0));
return(vswiz);
}
......@@ -533,10 +547,10 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
vector unsigned short v3_16 = vec_splat_u16(3);
vector unsigned int v8_32 = vec_splat_u32(8);
vector unsigned int v16_32 = vec_add(v8_32, v8_32);
vector unsigned short v3f = (vector unsigned short)(
vector unsigned short v3f = VECUINT16_LITERAL(
0x003f, 0x003f, 0x003f, 0x003f,
0x003f, 0x003f, 0x003f, 0x003f);
vector unsigned short vfc = (vector unsigned short)(
vector unsigned short vfc = VECUINT16_LITERAL(
0x00fc, 0x00fc, 0x00fc, 0x00fc,
0x00fc, 0x00fc, 0x00fc, 0x00fc);
......@@ -545,7 +559,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
0x00 - 0x0e evens are the red
0x01 - 0x0f odds are zero
*/
vector unsigned char vredalpha1 = (vector unsigned char)(
vector unsigned char vredalpha1 = VECUINT8_LITERAL(
0x10, 0x00, 0x01, 0x01,
0x10, 0x02, 0x01, 0x01,
0x10, 0x04, 0x01, 0x01,
......@@ -558,7 +572,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
0x00 - 0x0f is ARxx ARxx ARxx ARxx
0x11 - 0x0f odds are blue
*/
vector unsigned char vblue1 = (vector unsigned char)(
vector unsigned char vblue1 = VECUINT8_LITERAL(
0x00, 0x01, 0x02, 0x11,
0x04, 0x05, 0x06, 0x13,
0x08, 0x09, 0x0a, 0x15,
......@@ -571,7 +585,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
0x00 - 0x0f is ARxB ARxB ARxB ARxB
0x10 - 0x0e evens are green
*/
vector unsigned char vgreen1 = (vector unsigned char)(
vector unsigned char vgreen1 = VECUINT8_LITERAL(
0x00, 0x01, 0x10, 0x03,
0x04, 0x05, 0x12, 0x07,
0x08, 0x09, 0x14, 0x0b,
......@@ -580,7 +594,7 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
vector unsigned char vgreen2 = (vector unsigned char)(
vec_add((vector unsigned int)vgreen1, vec_sl(v8_32, v8_32))
);
vector unsigned char vgmerge = (vector unsigned char)(
vector unsigned char vgmerge = VECUINT8_LITERAL(
0x00, 0x02, 0x00, 0x06,
0x00, 0x0a, 0x00, 0x0e,
0x00, 0x12, 0x00, 0x16,
......@@ -601,9 +615,9 @@ static void Blit32to565PixelAlphaAltivec(SDL_BlitInfo *info)
#define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \
Uint32 pixel; \
Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB, sA; \
DISEMBLE_RGBA(src, 4, srcfmt, pixel, sR, sG, sB, sA); \
DISEMBLE_RGBA(src, 4, srcfmt, Pixel, sR, sG, sB, sA); \
if(sA) { \
unsigned short dstpixel = *((unsigned short *)dst); \
dR = (dstpixel >> 8) & 0xf8; \
......@@ -727,26 +741,26 @@ static void Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo *info)
vbits = (vector unsigned char)vec_splat_s8(-1);
ckey &= rgbmask;
((unsigned int *)&vckey)[0] = ckey;
((unsigned int *)(char*)&vckey)[0] = ckey;
vckey = vec_splat(vckey, 0);
((unsigned int *)&vrgbmask)[0] = rgbmask;
((unsigned int *)(char*)&vrgbmask)[0] = rgbmask;
vrgbmask = vec_splat(vrgbmask, 0);
while(height--) {
int width = info->d_width;
#define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \
Uint32 pixel; \
Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB; \
RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, pixel); \
if(sA && pixel != ckey) { \
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB); \
DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, pixel, dR, dG, dB); \
RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \
if(sA && Pixel != ckey) { \
RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
} \
((Uint8 *)dstp) += 4; \
((Uint8 *)srcp) += 4; \
dstp++; \
srcp++; \
widthvar--; \
}
ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
......@@ -840,11 +854,11 @@ static void Blit32to32PixelAlphaAltivec(SDL_BlitInfo *info)
while ( height-- ) {
width = info->d_width;
#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
Uint32 pixel; \
Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, pixel, sR, sG, sB, sA); \
DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \
if(sA) { \
DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, pixel, dR, dG, dB, dA); \
DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \
ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \
} \
......@@ -1040,10 +1054,10 @@ static void Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo *info)
while(height--) {
int width = info->d_width;
#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
Uint32 pixel; \
Uint32 Pixel; \
unsigned sR, sG, sB, dR, dG, dB; \
DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, pixel, sR, sG, sB); \
DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, pixel, dR, dG, dB); \
DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \
DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
++srcp; \
......@@ -2002,15 +2016,15 @@ static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB);
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
src += srcbpp;
......@@ -2043,17 +2057,17 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
RETRIEVE_RGB_PIXEL(src, srcbpp, pixel);
if(sA && pixel != ckey) {
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB);
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if(sA && Pixel != ckey) {
RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
......@@ -2093,7 +2107,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
......@@ -2102,9 +2116,9 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
unsigned dB;
unsigned sA;
unsigned dA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA);
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
if(sA) {
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
......
......@@ -36,10 +36,11 @@ static char rcsid =
/* Functions to blit from N-bit surfaces to other surfaces */
#ifdef USE_ALTIVEC_BLITTERS
#include <altivec.h>
#include <assert.h>
#include <stdlib.h>
#ifdef MACOSX
#include <sys/sysctl.h>
#include <stdlib.h>
static size_t GetL3CacheSize( void )
{
const char key[] = "hw.l3cachesize";
......@@ -60,6 +61,18 @@ static size_t GetL3CacheSize( void )
}
#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, \
......@@ -112,7 +125,8 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
if (!dstfmt) {
dstfmt = &default_pixel_format;
}
vector unsigned char plus = (vector unsigned char)( 0x00, 0x00, 0x00, 0x00,
vector unsigned char plus = VECUINT8_LITERAL(
0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x04, 0x04,
0x08, 0x08, 0x08, 0x08,
0x0C, 0x0C, 0x0C, 0x0C );
......@@ -130,7 +144,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ 0xFFFFFFFF);
}
#undef RESHIFT
((unsigned int *)&srcvec)[0] = (rmask | gmask | bmask | amask);
((unsigned int *)(char*)&srcvec)[0] = (rmask | gmask | bmask | amask);
vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0));
return(vswiz);
}
......@@ -145,17 +159,17 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) {
SDL_PixelFormat *srcfmt = info->src;
vector unsigned char valpha = vec_splat_u8(0);
vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
vector unsigned char vgmerge = (vector unsigned char)(
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 = (vector unsigned short)(
vector unsigned short v3f = VECUINT16_LITERAL(
0x003f, 0x003f, 0x003f, 0x003f,
0x003f, 0x003f, 0x003f, 0x003f);
vector unsigned short vfc = (vector unsigned short)(
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);
......@@ -172,9 +186,9 @@ static void Blit_RGB888_RGB565Altivec(SDL_BlitInfo *info) {
/* do scalar until we can align... */
#define ONE_PIXEL_BLEND(condition, widthvar) \
while (condition) { \
Uint32 pixel; \
Uint32 Pixel; \
unsigned sR, sG, sB, sA; \
DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, pixel, \
DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, Pixel, \
sR, sG, sB, sA); \
*(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \
((sG << 3) & 0x000007E0) | \
......@@ -259,20 +273,20 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0e evens are the red
0x01 - 0x0f odds are zero
*/
vector unsigned char vredalpha1 = (vector unsigned char)(
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)(
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 = (vector unsigned char)(
vector unsigned char vblue1 = VECUINT8_LITERAL(
0x00, 0x01, 0x02, 0x11,
0x04, 0x05, 0x06, 0x13,
0x08, 0x09, 0x0a, 0x15,
......@@ -285,7 +299,7 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0f is ARxB ARxB ARxB ARxB
0x10 - 0x0e evens are green
*/
vector unsigned char vgreen1 = (vector unsigned char)(
vector unsigned char vgreen1 = VECUINT8_LITERAL(
0x00, 0x01, 0x10, 0x03,
0x04, 0x05, 0x12, 0x07,
0x08, 0x09, 0x14, 0x0b,
......@@ -323,10 +337,10 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) {
#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; \
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; \
......@@ -404,7 +418,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0e evens are the red
0x01 - 0x0f odds are zero
*/
vector unsigned char vredalpha1 = (vector unsigned char)(
vector unsigned char vredalpha1 = VECUINT8_LITERAL(
0x10, 0x00, 0x01, 0x01,
0x10, 0x02, 0x01, 0x01,
0x10, 0x04, 0x01, 0x01,
......@@ -417,7 +431,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0f is ARxx ARxx ARxx ARxx
0x11 - 0x0f odds are blue
*/
vector unsigned char vblue1 = (vector unsigned char)(
vector unsigned char vblue1 = VECUINT8_LITERAL(
0x00, 0x01, 0x02, 0x11,
0x04, 0x05, 0x06, 0x13,
0x08, 0x09, 0x0a, 0x15,
......@@ -430,7 +444,7 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
0x00 - 0x0f is ARxB ARxB ARxB ARxB
0x10 - 0x0e evens are green
*/
vector unsigned char vgreen1 = (vector unsigned char)(
vector unsigned char vgreen1 = VECUINT8_LITERAL(
0x00, 0x01, 0x10, 0x03,
0x04, 0x05, 0x12, 0x07,
0x08, 0x09, 0x14, 0x0b,
......@@ -468,10 +482,10 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) {
#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; \
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; \
......@@ -565,39 +579,39 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info)
valpha = (vector unsigned int)vzero;
}
ckey &= rgbmask;
((unsigned int *)&vckey)[0] = ckey;
((unsigned int *)(char*)&vckey)[0] = ckey;
vckey = vec_splat(vckey, 0);
((unsigned int *)&vrgbmask)[0] = rgbmask;
((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; \
Uint32 Pixel; \
unsigned sR, sG, sB, sA; \
DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, pixel, \
DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, Pixel, \
sR, sG, sB, sA); \
if ( (pixel & rgbmask) != ckey ) { \
if ( (Pixel & rgbmask) != ckey ) { \
ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \
sR, sG, sB, sA); \
} \
((Uint8 *)dstp) += dstbpp; \
((Uint8 *)srcp) += srcbpp; \
dstp = (Uint32 *) (((Uint8 *) dstp) + dstbpp); \
srcp = (Uint32 *) (((Uint8 *) srcp) + srcbpp); \
widthvar--; \
} \
} else { \
while (condition) { \
Uint32 pixel; \
Uint32 Pixel; \
unsigned sR, sG, sB; \
RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, pixel); \
if ( pixel != ckey ) { \
RGB_FROM_PIXEL(pixel, srcfmt, 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); \
} \
((Uint8 *)dstp) += dstbpp; \
((Uint8 *)srcp) += srcbpp; \
dstp = (Uint32 *) (((Uint8 *)dstp) + dstbpp); \
srcp = (Uint32 *) (((Uint8 *)srcp) + srcbpp); \
widthvar--; \
} \
}
......@@ -819,6 +833,7 @@ static Uint32 GetBlitFeatures( void )
/* 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)
);
}
......@@ -911,43 +926,43 @@ static void Blit_RGB888_index8(SDL_BlitInfo *info)
dst += dstskip;
}
} else {
int pixel;
int Pixel;
while ( height-- ) {
#ifdef USE_DUFFS_LOOP
DUFFS_LOOP(
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
, width);
#else
for ( c=width/4; c; --c ) {
/* Pack RGB into 8bit pixel */
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
switch ( width & 3 ) {
case 3:
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 2:
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 1:
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
#endif /* USE_DUFFS_LOOP */
......@@ -1820,7 +1835,7 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
#ifndef USE_DUFFS_LOOP
int c;
#endif
int pixel;
int Pixel;
int width, height;
Uint32 *src;
const Uint8 *map;
......@@ -1839,8 +1854,8 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
#ifdef USE_DUFFS_LOOP
while ( height-- ) {
DUFFS_LOOP(
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
, width);
src += srcskip;
......@@ -1850,31 +1865,31 @@ static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
while ( height-- ) {
for ( c=width/4; c; --c ) {
/* Pack RGB into 8bit pixel */
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
switch ( width & 3 ) {
case 3:
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 2:
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
case 1:
RGB888_RGB332(pixel, *src);
*dst++ = map[pixel];
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
}
src += srcskip;
......@@ -1893,7 +1908,7 @@ static void BlitNto1(SDL_BlitInfo *info)
Uint8 *dst;
int srcskip, dstskip;
int srcbpp;
Uint32 pixel;
Uint32 Pixel;
int sR, sG, sB;
SDL_PixelFormat *srcfmt;
......@@ -1912,7 +1927,7 @@ static void BlitNto1(SDL_BlitInfo *info)
while ( height-- ) {
#ifdef USE_DUFFS_LOOP
DUFFS_LOOP(
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
......@@ -1925,7 +1940,7 @@ static void BlitNto1(SDL_BlitInfo *info)
, width);
#else
for ( c=width; c; --c ) {
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
......@@ -1944,7 +1959,7 @@ static void BlitNto1(SDL_BlitInfo *info)
while ( height-- ) {
#ifdef USE_DUFFS_LOOP
DUFFS_LOOP(
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
......@@ -1957,7 +1972,7 @@ static void BlitNto1(SDL_BlitInfo *info)
, width);
#else
for ( c=width; c; --c ) {
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( 1 ) {
/* Pack RGB into 8bit pixel */
......@@ -1991,11 +2006,11 @@ static void BlitNtoN(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
dst += dstbpp;
src += srcbpp;
......@@ -2023,9 +2038,9 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
/* FIXME: should map alpha to [0..255] correctly! */
while ( height-- ) {
for ( c=width; c; --c ) {
Uint32 pixel;
Uint32 Pixel;
unsigned sR, sG, sB, sA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel,
sR, sG, sB, sA);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
sR, sG, sB, sA);
......@@ -2050,7 +2065,7 @@ static void BlitNto1Key(SDL_BlitInfo *info)
Uint32 ckey = srcfmt->colorkey;
Uint32 rgbmask = ~srcfmt->Amask;
int srcbpp;
Uint32 pixel;
Uint32 Pixel;
Uint8 sR, sG, sB;
/* Set up some basic variables */
......@@ -2061,9 +2076,9 @@ static void BlitNto1Key(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP(
{
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( (pixel & rgbmask) != ckey ) {
if ( (Pixel & rgbmask) != ckey ) {
/* Pack RGB into 8bit pixel */
*dst = ((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
......@@ -2080,9 +2095,9 @@ static void BlitNto1Key(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP(
{
DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
sR, sG, sB);
if ( (pixel & rgbmask) != ckey ) {
if ( (Pixel & rgbmask) != ckey ) {
/* Pack RGB into 8bit pixel */
*dst = palmap[((sR>>5)<<(3+2))|
((sG>>5)<<(2)) |
......@@ -2147,13 +2162,13 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP(
{
Uint32 pixel;
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
RETRIEVE_RGB_PIXEL(src, srcbpp, pixel);
if ( pixel != ckey ) {
RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB);
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if ( Pixel != ckey ) {
RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
sR, sG, sB, alpha);
}
......@@ -2181,7 +2196,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
Uint8 srcbpp;
Uint8 dstbpp;
Uint32 pixel;
Uint32 Pixel;
Uint8 sR, sG, sB, sA;
/* Set up some basic variables */
......@@ -2193,9 +2208,9 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
while ( height-- ) {
DUFFS_LOOP(
{
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel,
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel,
sR, sG, sB, sA);
if ( (pixel & rgbmask) != ckey ) {
if ( (Pixel & rgbmask) != ckey ) {
ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
sR, sG, sB, sA);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment