src/video/SDL_blit_A.c
changeset 7502 6ff02ff3cf06
parent 6885 700f1b25f77f
child 7640 38284657fc79
     1.1 --- a/src/video/SDL_blit_A.c	Mon Jul 22 02:51:45 2013 -0700
     1.2 +++ b/src/video/SDL_blit_A.c	Tue Jul 23 08:06:49 2013 -0700
     1.3 @@ -39,37 +39,28 @@
     1.4      SDL_PixelFormat *srcfmt = info->src_fmt;
     1.5      SDL_PixelFormat *dstfmt = info->dst_fmt;
     1.6      int srcbpp = srcfmt->BytesPerPixel;
     1.7 -
     1.8 +    Uint32 Pixel;
     1.9 +    unsigned sR, sG, sB;
    1.10 +    unsigned dR, dG, dB;
    1.11      const unsigned A = info->a;
    1.12  
    1.13      while (height--) {
    1.14  	    /* *INDENT-OFF* */
    1.15  	    DUFFS_LOOP4(
    1.16  	    {
    1.17 -		Uint32 Pixel;
    1.18 -		unsigned sR;
    1.19 -		unsigned sG;
    1.20 -		unsigned sB;
    1.21 -		unsigned dR;
    1.22 -		unsigned dG;
    1.23 -		unsigned dB;
    1.24  		DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
    1.25  		dR = dstfmt->palette->colors[*dst].r;
    1.26  		dG = dstfmt->palette->colors[*dst].g;
    1.27  		dB = dstfmt->palette->colors[*dst].b;
    1.28 -		ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
    1.29 +		ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB);
    1.30  		dR &= 0xff;
    1.31  		dG &= 0xff;
    1.32  		dB &= 0xff;
    1.33  		/* Pack RGB into 8bit pixel */
    1.34  		if ( palmap == NULL ) {
    1.35 -		    *dst =((dR>>5)<<(3+2))|
    1.36 -			  ((dG>>5)<<(2))|
    1.37 -			  ((dB>>6)<<(0));
    1.38 +		    *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
    1.39  		} else {
    1.40 -		    *dst = palmap[((dR>>5)<<(3+2))|
    1.41 -				  ((dG>>5)<<(2))  |
    1.42 -				  ((dB>>6)<<(0))];
    1.43 +		    *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
    1.44  		}
    1.45  		dst++;
    1.46  		src += srcbpp;
    1.47 @@ -95,36 +86,27 @@
    1.48      SDL_PixelFormat *srcfmt = info->src_fmt;
    1.49      SDL_PixelFormat *dstfmt = info->dst_fmt;
    1.50      int srcbpp = srcfmt->BytesPerPixel;
    1.51 +    Uint32 Pixel;
    1.52 +    unsigned sR, sG, sB, sA;
    1.53 +    unsigned dR, dG, dB;
    1.54  
    1.55      while (height--) {
    1.56  	    /* *INDENT-OFF* */
    1.57  	    DUFFS_LOOP4(
    1.58  	    {
    1.59 -		Uint32 Pixel;
    1.60 -		unsigned sR;
    1.61 -		unsigned sG;
    1.62 -		unsigned sB;
    1.63 -		unsigned sA;
    1.64 -		unsigned dR;
    1.65 -		unsigned dG;
    1.66 -		unsigned dB;
    1.67  		DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
    1.68  		dR = dstfmt->palette->colors[*dst].r;
    1.69  		dG = dstfmt->palette->colors[*dst].g;
    1.70  		dB = dstfmt->palette->colors[*dst].b;
    1.71 -		ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
    1.72 +		ALPHA_BLEND_RGB(sR, sG, sB, sA, dR, dG, dB);
    1.73  		dR &= 0xff;
    1.74  		dG &= 0xff;
    1.75  		dB &= 0xff;
    1.76  		/* Pack RGB into 8bit pixel */
    1.77  		if ( palmap == NULL ) {
    1.78 -		    *dst =((dR>>5)<<(3+2))|
    1.79 -			  ((dG>>5)<<(2))|
    1.80 -			  ((dB>>6)<<(0));
    1.81 +		    *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
    1.82  		} else {
    1.83 -		    *dst = palmap[((dR>>5)<<(3+2))|
    1.84 -				  ((dG>>5)<<(2))  |
    1.85 -				  ((dB>>6)<<(0))  ];
    1.86 +		    *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
    1.87  		}
    1.88  		dst++;
    1.89  		src += srcbpp;
    1.90 @@ -151,38 +133,29 @@
    1.91      SDL_PixelFormat *dstfmt = info->dst_fmt;
    1.92      int srcbpp = srcfmt->BytesPerPixel;
    1.93      Uint32 ckey = info->colorkey;
    1.94 -
    1.95 -    const int A = info->a;
    1.96 +    Uint32 Pixel;
    1.97 +    unsigned sR, sG, sB;
    1.98 +    unsigned dR, dG, dB;
    1.99 +    const unsigned A = info->a;
   1.100  
   1.101      while (height--) {
   1.102  	    /* *INDENT-OFF* */
   1.103  	    DUFFS_LOOP(
   1.104  	    {
   1.105 -		Uint32 Pixel;
   1.106 -		unsigned sR;
   1.107 -		unsigned sG;
   1.108 -		unsigned sB;
   1.109 -		unsigned dR;
   1.110 -		unsigned dG;
   1.111 -		unsigned dB;
   1.112  		DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
   1.113  		if ( Pixel != ckey ) {
   1.114  		    dR = dstfmt->palette->colors[*dst].r;
   1.115  		    dG = dstfmt->palette->colors[*dst].g;
   1.116  		    dB = dstfmt->palette->colors[*dst].b;
   1.117 -		    ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
   1.118 +		    ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB);
   1.119  		    dR &= 0xff;
   1.120  		    dG &= 0xff;
   1.121  		    dB &= 0xff;
   1.122  		    /* Pack RGB into 8bit pixel */
   1.123  		    if ( palmap == NULL ) {
   1.124 -			*dst =((dR>>5)<<(3+2))|
   1.125 -			      ((dG>>5)<<(2)) |
   1.126 -			      ((dB>>6)<<(0));
   1.127 +                *dst =((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0));
   1.128  		    } else {
   1.129 -			*dst = palmap[((dR>>5)<<(3+2))|
   1.130 -				      ((dG>>5)<<(2))  |
   1.131 -				      ((dB>>6)<<(0))  ];
   1.132 +                *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))];
   1.133  		    }
   1.134  		}
   1.135  		dst++;
   1.136 @@ -417,807 +390,6 @@
   1.137  
   1.138  #endif /* __MMX__ */
   1.139  
   1.140 -#if SDL_ALTIVEC_BLITTERS
   1.141 -#if __MWERKS__
   1.142 -#pragma altivec_model on
   1.143 -#endif
   1.144 -#if HAVE_ALTIVEC_H
   1.145 -#include <altivec.h>
   1.146 -#endif
   1.147 -
   1.148 -#if (defined(__MACOSX__) && (__GNUC__ < 4))
   1.149 -#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
   1.150 -        (vector unsigned char) ( a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p )
   1.151 -#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
   1.152 -        (vector unsigned short) ( a,b,c,d,e,f,g,h )
   1.153 -#else
   1.154 -#define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
   1.155 -        (vector unsigned char) { a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p }
   1.156 -#define VECUINT16_LITERAL(a,b,c,d,e,f,g,h) \
   1.157 -        (vector unsigned short) { a,b,c,d,e,f,g,h }
   1.158 -#endif
   1.159 -
   1.160 -#define UNALIGNED_PTR(x) (((size_t) x) & 0x0000000F)
   1.161 -#define VECPRINT(msg, v) do { \
   1.162 -    vector unsigned int tmpvec = (vector unsigned int)(v); \
   1.163 -    unsigned int *vp = (unsigned int *)&tmpvec; \
   1.164 -    printf("%s = %08X %08X %08X %08X\n", msg, vp[0], vp[1], vp[2], vp[3]); \
   1.165 -} while (0)
   1.166 -
   1.167 -/* the permuation vector that takes the high bytes out of all the appropriate shorts 
   1.168 -    (vector unsigned char)(
   1.169 -        0x00, 0x10, 0x02, 0x12,
   1.170 -        0x04, 0x14, 0x06, 0x16,
   1.171 -        0x08, 0x18, 0x0A, 0x1A,
   1.172 -        0x0C, 0x1C, 0x0E, 0x1E );
   1.173 -*/
   1.174 -#define VEC_MERGE_PERMUTE() (vec_add(vec_lvsl(0, (int*)NULL), (vector unsigned char)vec_splat_u16(0x0F)))
   1.175 -#define VEC_U32_24() (vec_add(vec_splat_u32(12), vec_splat_u32(12)))
   1.176 -#define VEC_ALPHA_MASK() ((vector unsigned char)vec_sl((vector unsigned int)vec_splat_s8(-1), VEC_U32_24()))
   1.177 -#define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \
   1.178 -    ? vec_lvsl(0, src) \
   1.179 -    : vec_add(vec_lvsl(8, src), vec_splat_u8(8)))
   1.180 -
   1.181 -
   1.182 -#define VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1_16, v8_16) do { \
   1.183 -    /* vtemp1 contains source AAGGAAGGAAGGAAGG */ \
   1.184 -    vector unsigned short vtemp1 = vec_mule(vs, valpha); \
   1.185 -    /* vtemp2 contains source RRBBRRBBRRBBRRBB */ \
   1.186 -    vector unsigned short vtemp2 = vec_mulo(vs, valpha); \
   1.187 -    /* valpha2 is 255-alpha */ \
   1.188 -    vector unsigned char valpha2 = vec_nor(valpha, valpha); \
   1.189 -    /* vtemp3 contains dest AAGGAAGGAAGGAAGG */ \
   1.190 -    vector unsigned short vtemp3 = vec_mule(vd, valpha2); \
   1.191 -    /* vtemp4 contains dest RRBBRRBBRRBBRRBB */ \
   1.192 -    vector unsigned short vtemp4 = vec_mulo(vd, valpha2); \
   1.193 -    /* add source and dest */ \
   1.194 -    vtemp1 = vec_add(vtemp1, vtemp3); \
   1.195 -    vtemp2 = vec_add(vtemp2, vtemp4); \
   1.196 -    /* vtemp1 = (vtemp1 + 1) + ((vtemp1 + 1) >> 8) */ \
   1.197 -    vtemp1 = vec_add(vtemp1, v1_16); \
   1.198 -    vtemp3 = vec_sr(vtemp1, v8_16); \
   1.199 -    vtemp1 = vec_add(vtemp1, vtemp3); \
   1.200 -    /* vtemp2 = (vtemp2 + 1) + ((vtemp2 + 1) >> 8) */ \
   1.201 -    vtemp2 = vec_add(vtemp2, v1_16); \
   1.202 -    vtemp4 = vec_sr(vtemp2, v8_16); \
   1.203 -    vtemp2 = vec_add(vtemp2, vtemp4); \
   1.204 -    /* (>>8) and get ARGBARGBARGBARGB */ \
   1.205 -    vd = (vector unsigned char)vec_perm(vtemp1, vtemp2, mergePermute); \
   1.206 -} while (0)
   1.207 -
   1.208 -/* Calculate the permute vector used for 32->32 swizzling */
   1.209 -static vector unsigned char
   1.210 -calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt)
   1.211 -{
   1.212 -    /*
   1.213 -     * We have to assume that the bits that aren't used by other
   1.214 -     *  colors is alpha, and it's one complete byte, since some formats
   1.215 -     *  leave alpha with a zero mask, but we should still swizzle the bits.
   1.216 -     */
   1.217 -    /* ARGB */
   1.218 -    const static struct SDL_PixelFormat default_pixel_format = {
   1.219 -        0, NULL, 0, 0,
   1.220 -        {0, 0},
   1.221 -        0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
   1.222 -        0, 0, 0, 0,
   1.223 -        16, 8, 0, 24,
   1.224 -        0, NULL
   1.225 -    };
   1.226 -    if (!srcfmt) {
   1.227 -        srcfmt = &default_pixel_format;
   1.228 -    }
   1.229 -    if (!dstfmt) {
   1.230 -        dstfmt = &default_pixel_format;
   1.231 -    }
   1.232 -    const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00,
   1.233 -                                                       0x04, 0x04, 0x04, 0x04,
   1.234 -                                                       0x08, 0x08, 0x08, 0x08,
   1.235 -                                                       0x0C, 0x0C, 0x0C,
   1.236 -                                                       0x0C);
   1.237 -    vector unsigned char vswiz;
   1.238 -    vector unsigned int srcvec;
   1.239 -#define RESHIFT(X) (3 - ((X) >> 3))
   1.240 -    Uint32 rmask = RESHIFT(srcfmt->Rshift) << (dstfmt->Rshift);
   1.241 -    Uint32 gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift);
   1.242 -    Uint32 bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift);
   1.243 -    Uint32 amask;
   1.244 -    /* Use zero for alpha if either surface doesn't have alpha */
   1.245 -    if (dstfmt->Amask) {
   1.246 -        amask =
   1.247 -            ((srcfmt->Amask) ? RESHIFT(srcfmt->
   1.248 -                                       Ashift) : 0x10) << (dstfmt->Ashift);
   1.249 -    } else {
   1.250 -        amask =
   1.251 -            0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^
   1.252 -                          0xFFFFFFFF);
   1.253 -    }
   1.254 -#undef RESHIFT
   1.255 -    ((unsigned int *) (char *) &srcvec)[0] = (rmask | gmask | bmask | amask);
   1.256 -    vswiz = vec_add(plus, (vector unsigned char) vec_splat(srcvec, 0));
   1.257 -    return (vswiz);
   1.258 -}
   1.259 -
   1.260 -static void
   1.261 -Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info)
   1.262 -{
   1.263 -    int height = info->dst_h;
   1.264 -    Uint8 *src = (Uint8 *) info->src;
   1.265 -    int srcskip = info->src_skip;
   1.266 -    Uint8 *dst = (Uint8 *) info->dst;
   1.267 -    int dstskip = info->dst_skip;
   1.268 -    SDL_PixelFormat *srcfmt = info->src_fmt;
   1.269 -
   1.270 -    vector unsigned char v0 = vec_splat_u8(0);
   1.271 -    vector unsigned short v8_16 = vec_splat_u16(8);
   1.272 -    vector unsigned short v1_16 = vec_splat_u16(1);
   1.273 -    vector unsigned short v2_16 = vec_splat_u16(2);
   1.274 -    vector unsigned short v3_16 = vec_splat_u16(3);
   1.275 -    vector unsigned int v8_32 = vec_splat_u32(8);
   1.276 -    vector unsigned int v16_32 = vec_add(v8_32, v8_32);
   1.277 -    vector unsigned short v3f =
   1.278 -        VECUINT16_LITERAL(0x003f, 0x003f, 0x003f, 0x003f,
   1.279 -                          0x003f, 0x003f, 0x003f, 0x003f);
   1.280 -    vector unsigned short vfc =
   1.281 -        VECUINT16_LITERAL(0x00fc, 0x00fc, 0x00fc, 0x00fc,
   1.282 -                          0x00fc, 0x00fc, 0x00fc, 0x00fc);
   1.283 -
   1.284 -    /* 
   1.285 -       0x10 - 0x1f is the alpha
   1.286 -       0x00 - 0x0e evens are the red
   1.287 -       0x01 - 0x0f odds are zero
   1.288 -     */
   1.289 -    vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01,
   1.290 -                                                       0x10, 0x02, 0x01, 0x01,
   1.291 -                                                       0x10, 0x04, 0x01, 0x01,
   1.292 -                                                       0x10, 0x06, 0x01,
   1.293 -                                                       0x01);
   1.294 -    vector unsigned char vredalpha2 =
   1.295 -        (vector unsigned char) (vec_add((vector unsigned int) vredalpha1,
   1.296 -                                        vec_sl(v8_32, v16_32))
   1.297 -        );
   1.298 -    /*
   1.299 -       0x00 - 0x0f is ARxx ARxx ARxx ARxx
   1.300 -       0x11 - 0x0f odds are blue
   1.301 -     */
   1.302 -    vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11,
   1.303 -                                                   0x04, 0x05, 0x06, 0x13,
   1.304 -                                                   0x08, 0x09, 0x0a, 0x15,
   1.305 -                                                   0x0c, 0x0d, 0x0e, 0x17);
   1.306 -    vector unsigned char vblue2 =
   1.307 -        (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8_32)
   1.308 -        );
   1.309 -    /*
   1.310 -       0x00 - 0x0f is ARxB ARxB ARxB ARxB
   1.311 -       0x10 - 0x0e evens are green
   1.312 -     */
   1.313 -    vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03,
   1.314 -                                                    0x04, 0x05, 0x12, 0x07,
   1.315 -                                                    0x08, 0x09, 0x14, 0x0b,
   1.316 -                                                    0x0c, 0x0d, 0x16, 0x0f);
   1.317 -    vector unsigned char vgreen2 =
   1.318 -        (vector unsigned
   1.319 -         char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8_32, v8_32))
   1.320 -        );
   1.321 -    vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06,
   1.322 -                                                    0x00, 0x0a, 0x00, 0x0e,
   1.323 -                                                    0x00, 0x12, 0x00, 0x16,
   1.324 -                                                    0x00, 0x1a, 0x00, 0x1e);
   1.325 -    vector unsigned char mergePermute = VEC_MERGE_PERMUTE();
   1.326 -    vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
   1.327 -    vector unsigned char valphaPermute =
   1.328 -        vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC));
   1.329 -
   1.330 -    vector unsigned short vf800 = (vector unsigned short) vec_splat_u8(-7);
   1.331 -    vf800 = vec_sl(vf800, vec_splat_u16(8));
   1.332 -
   1.333 -    while (height--) {
   1.334 -        int extrawidth;
   1.335 -        vector unsigned char valigner;
   1.336 -        vector unsigned char vsrc;
   1.337 -        vector unsigned char voverflow;
   1.338 -        int width = info->dst_w;
   1.339 -
   1.340 -#define ONE_PIXEL_BLEND(condition, widthvar) \
   1.341 -        while (condition) { \
   1.342 -            Uint32 Pixel; \
   1.343 -            unsigned sR, sG, sB, dR, dG, dB, sA; \
   1.344 -            DISEMBLE_RGBA(src, 4, srcfmt, Pixel, sR, sG, sB, sA); \
   1.345 -            if(sA) { \
   1.346 -                unsigned short dstpixel = *((unsigned short *)dst); \
   1.347 -                dR = (dstpixel >> 8) & 0xf8; \
   1.348 -                dG = (dstpixel >> 3) & 0xfc; \
   1.349 -                dB = (dstpixel << 3) & 0xf8; \
   1.350 -                ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
   1.351 -                *((unsigned short *)dst) = ( \
   1.352 -                    ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \
   1.353 -                ); \
   1.354 -            } \
   1.355 -            src += 4; \
   1.356 -            dst += 2; \
   1.357 -            widthvar--; \
   1.358 -        }
   1.359 -        ONE_PIXEL_BLEND((UNALIGNED_PTR(dst)) && (width), width);
   1.360 -        extrawidth = (width % 8);
   1.361 -        valigner = VEC_ALIGNER(src);
   1.362 -        vsrc = (vector unsigned char) vec_ld(0, src);
   1.363 -        width -= extrawidth;
   1.364 -        while (width) {
   1.365 -            vector unsigned char valpha;
   1.366 -            vector unsigned char vsrc1, vsrc2;
   1.367 -            vector unsigned char vdst1, vdst2;
   1.368 -            vector unsigned short vR, vG, vB;
   1.369 -            vector unsigned short vpixel, vrpixel, vgpixel, vbpixel;
   1.370 -
   1.371 -            /* Load 8 pixels from src as ARGB */
   1.372 -            voverflow = (vector unsigned char) vec_ld(15, src);
   1.373 -            vsrc = vec_perm(vsrc, voverflow, valigner);
   1.374 -            vsrc1 = vec_perm(vsrc, vsrc, vpermute);
   1.375 -            src += 16;
   1.376 -            vsrc = (vector unsigned char) vec_ld(15, src);
   1.377 -            voverflow = vec_perm(voverflow, vsrc, valigner);
   1.378 -            vsrc2 = vec_perm(voverflow, voverflow, vpermute);
   1.379 -            src += 16;
   1.380 -
   1.381 -            /* Load 8 pixels from dst as XRGB */
   1.382 -            voverflow = vec_ld(0, dst);
   1.383 -            vR = vec_and((vector unsigned short) voverflow, vf800);
   1.384 -            vB = vec_sl((vector unsigned short) voverflow, v3_16);
   1.385 -            vG = vec_sl(vB, v2_16);
   1.386 -            vdst1 =
   1.387 -                (vector unsigned char) vec_perm((vector unsigned char) vR,
   1.388 -                                                (vector unsigned char) vR,
   1.389 -                                                vredalpha1);
   1.390 -            vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1);
   1.391 -            vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1);
   1.392 -            vdst2 =
   1.393 -                (vector unsigned char) vec_perm((vector unsigned char) vR,
   1.394 -                                                (vector unsigned char) vR,
   1.395 -                                                vredalpha2);
   1.396 -            vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2);
   1.397 -            vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2);
   1.398 -
   1.399 -            /* Alpha blend 8 pixels as ARGB */
   1.400 -            valpha = vec_perm(vsrc1, v0, valphaPermute);
   1.401 -            VEC_MULTIPLY_ALPHA(vsrc1, vdst1, valpha, mergePermute, v1_16,
   1.402 -                               v8_16);
   1.403 -            valpha = vec_perm(vsrc2, v0, valphaPermute);
   1.404 -            VEC_MULTIPLY_ALPHA(vsrc2, vdst2, valpha, mergePermute, v1_16,
   1.405 -                               v8_16);
   1.406 -
   1.407 -            /* Convert 8 pixels to 565 */
   1.408 -            vpixel = (vector unsigned short) vec_packpx((vector unsigned int)
   1.409 -                                                        vdst1,
   1.410 -                                                        (vector unsigned int)
   1.411 -                                                        vdst2);
   1.412 -            vgpixel = (vector unsigned short) vec_perm(vdst1, vdst2, vgmerge);
   1.413 -            vgpixel = vec_and(vgpixel, vfc);
   1.414 -            vgpixel = vec_sl(vgpixel, v3_16);
   1.415 -            vrpixel = vec_sl(vpixel, v1_16);
   1.416 -            vrpixel = vec_and(vrpixel, vf800);
   1.417 -            vbpixel = vec_and(vpixel, v3f);
   1.418 -            vdst1 =
   1.419 -                vec_or((vector unsigned char) vrpixel,
   1.420 -                       (vector unsigned char) vgpixel);
   1.421 -            vdst1 = vec_or(vdst1, (vector unsigned char) vbpixel);
   1.422 -
   1.423 -            /* Store 8 pixels */
   1.424 -            vec_st(vdst1, 0, dst);
   1.425 -
   1.426 -            width -= 8;
   1.427 -            dst += 16;
   1.428 -        }
   1.429 -        ONE_PIXEL_BLEND((extrawidth), extrawidth);
   1.430 -#undef ONE_PIXEL_BLEND
   1.431 -        src += srcskip;
   1.432 -        dst += dstskip;
   1.433 -    }
   1.434 -}
   1.435 -
   1.436 -static void
   1.437 -Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info)
   1.438 -{
   1.439 -    int height = info->dst_h;
   1.440 -    Uint32 *srcp = (Uint32 *) info->src;
   1.441 -    int srcskip = info->src_skip >> 2;
   1.442 -    Uint32 *dstp = (Uint32 *) info->dst;
   1.443 -    int dstskip = info->dst_skip >> 2;
   1.444 -    SDL_PixelFormat *srcfmt = info->src_fmt;
   1.445 -    SDL_PixelFormat *dstfmt = info->dst_fmt;
   1.446 -    unsigned sA = info->a;
   1.447 -    unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
   1.448 -    Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
   1.449 -    Uint32 ckey = info->colorkey;
   1.450 -    vector unsigned char mergePermute;
   1.451 -    vector unsigned char vsrcPermute;
   1.452 -    vector unsigned char vdstPermute;
   1.453 -    vector unsigned char vsdstPermute;
   1.454 -    vector unsigned char valpha;
   1.455 -    vector unsigned char valphamask;
   1.456 -    vector unsigned char vbits;
   1.457 -    vector unsigned char v0;
   1.458 -    vector unsigned short v1;
   1.459 -    vector unsigned short v8;
   1.460 -    vector unsigned int vckey;
   1.461 -    vector unsigned int vrgbmask;
   1.462 -
   1.463 -    mergePermute = VEC_MERGE_PERMUTE();
   1.464 -    v0 = vec_splat_u8(0);
   1.465 -    v1 = vec_splat_u16(1);
   1.466 -    v8 = vec_splat_u16(8);
   1.467 -
   1.468 -    /* set the alpha to 255 on the destination surf */
   1.469 -    valphamask = VEC_ALPHA_MASK();
   1.470 -
   1.471 -    vsrcPermute = calc_swizzle32(srcfmt, NULL);
   1.472 -    vdstPermute = calc_swizzle32(NULL, dstfmt);
   1.473 -    vsdstPermute = calc_swizzle32(dstfmt, NULL);
   1.474 -
   1.475 -    /* set a vector full of alpha and 255-alpha */
   1.476 -    ((unsigned char *) &valpha)[0] = sA;
   1.477 -    valpha = vec_splat(valpha, 0);
   1.478 -    vbits = (vector unsigned char) vec_splat_s8(-1);
   1.479 -
   1.480 -    ckey &= rgbmask;
   1.481 -    ((unsigned int *) (char *) &vckey)[0] = ckey;
   1.482 -    vckey = vec_splat(vckey, 0);
   1.483 -    ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask;
   1.484 -    vrgbmask = vec_splat(vrgbmask, 0);
   1.485 -
   1.486 -    while (height--) {
   1.487 -        int width = info->dst_w;
   1.488 -#define ONE_PIXEL_BLEND(condition, widthvar) \
   1.489 -        while (condition) { \
   1.490 -            Uint32 Pixel; \
   1.491 -            unsigned sR, sG, sB, dR, dG, dB; \
   1.492 -            RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \
   1.493 -            if(sA && Pixel != ckey) { \
   1.494 -                RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
   1.495 -                DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
   1.496 -                ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
   1.497 -                ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
   1.498 -            } \
   1.499 -            dstp++; \
   1.500 -            srcp++; \
   1.501 -            widthvar--; \
   1.502 -        }
   1.503 -        ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
   1.504 -        if (width > 0) {
   1.505 -            int extrawidth = (width % 4);
   1.506 -            vector unsigned char valigner = VEC_ALIGNER(srcp);
   1.507 -            vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp);
   1.508 -            width -= extrawidth;
   1.509 -            while (width) {
   1.510 -                vector unsigned char vsel;
   1.511 -                vector unsigned char voverflow;
   1.512 -                vector unsigned char vd;
   1.513 -                vector unsigned char vd_orig;
   1.514 -
   1.515 -                /* s = *srcp */
   1.516 -                voverflow = (vector unsigned char) vec_ld(15, srcp);
   1.517 -                vs = vec_perm(vs, voverflow, valigner);
   1.518 -
   1.519 -                /* vsel is set for items that match the key */
   1.520 -                vsel =
   1.521 -                    (vector unsigned char) vec_and((vector unsigned int) vs,
   1.522 -                                                   vrgbmask);
   1.523 -                vsel = (vector unsigned char) vec_cmpeq((vector unsigned int)
   1.524 -                                                        vsel, vckey);
   1.525 -
   1.526 -                /* permute to source format */
   1.527 -                vs = vec_perm(vs, valpha, vsrcPermute);
   1.528 -
   1.529 -                /* d = *dstp */
   1.530 -                vd = (vector unsigned char) vec_ld(0, dstp);
   1.531 -                vd_orig = vd = vec_perm(vd, v0, vsdstPermute);
   1.532 -
   1.533 -                VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
   1.534 -
   1.535 -                /* set the alpha channel to full on */
   1.536 -                vd = vec_or(vd, valphamask);
   1.537 -
   1.538 -                /* mask out color key */
   1.539 -                vd = vec_sel(vd, vd_orig, vsel);
   1.540 -
   1.541 -                /* permute to dest format */
   1.542 -                vd = vec_perm(vd, vbits, vdstPermute);
   1.543 -
   1.544 -                /* *dstp = res */
   1.545 -                vec_st((vector unsigned int) vd, 0, dstp);
   1.546 -
   1.547 -                srcp += 4;
   1.548 -                dstp += 4;
   1.549 -                width -= 4;
   1.550 -                vs = voverflow;
   1.551 -            }
   1.552 -            ONE_PIXEL_BLEND((extrawidth), extrawidth);
   1.553 -        }
   1.554 -#undef ONE_PIXEL_BLEND
   1.555 -
   1.556 -        srcp += srcskip;
   1.557 -        dstp += dstskip;
   1.558 -    }
   1.559 -}
   1.560 -
   1.561 -
   1.562 -static void
   1.563 -Blit32to32PixelAlphaAltivec(SDL_BlitInfo * info)
   1.564 -{
   1.565 -    int width = info->dst_w;
   1.566 -    int height = info->dst_h;
   1.567 -    Uint32 *srcp = (Uint32 *) info->src;
   1.568 -    int srcskip = info->src_skip >> 2;
   1.569 -    Uint32 *dstp = (Uint32 *) info->dst;
   1.570 -    int dstskip = info->dst_skip >> 2;
   1.571 -    SDL_PixelFormat *srcfmt = info->src_fmt;
   1.572 -    SDL_PixelFormat *dstfmt = info->dst_fmt;
   1.573 -    vector unsigned char mergePermute;
   1.574 -    vector unsigned char valphaPermute;
   1.575 -    vector unsigned char vsrcPermute;
   1.576 -    vector unsigned char vdstPermute;
   1.577 -    vector unsigned char vsdstPermute;
   1.578 -    vector unsigned char valphamask;
   1.579 -    vector unsigned char vpixelmask;
   1.580 -    vector unsigned char v0;
   1.581 -    vector unsigned short v1;
   1.582 -    vector unsigned short v8;
   1.583 -
   1.584 -    v0 = vec_splat_u8(0);
   1.585 -    v1 = vec_splat_u16(1);
   1.586 -    v8 = vec_splat_u16(8);
   1.587 -    mergePermute = VEC_MERGE_PERMUTE();
   1.588 -    valphamask = VEC_ALPHA_MASK();
   1.589 -    valphaPermute = vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC));
   1.590 -    vpixelmask = vec_nor(valphamask, v0);
   1.591 -    vsrcPermute = calc_swizzle32(srcfmt, NULL);
   1.592 -    vdstPermute = calc_swizzle32(NULL, dstfmt);
   1.593 -    vsdstPermute = calc_swizzle32(dstfmt, NULL);
   1.594 -
   1.595 -    while (height--) {
   1.596 -        width = info->dst_w;
   1.597 -#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
   1.598 -            Uint32 Pixel; \
   1.599 -            unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
   1.600 -            DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \
   1.601 -            if(sA) { \
   1.602 -              DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \
   1.603 -              ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
   1.604 -              ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \
   1.605 -            } \
   1.606 -            ++srcp; \
   1.607 -            ++dstp; \
   1.608 -            widthvar--; \
   1.609 -        }
   1.610 -        ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
   1.611 -        if (width > 0) {
   1.612 -            /* vsrcPermute */
   1.613 -            /* vdstPermute */
   1.614 -            int extrawidth = (width % 4);
   1.615 -            vector unsigned char valigner = VEC_ALIGNER(srcp);
   1.616 -            vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp);
   1.617 -            width -= extrawidth;
   1.618 -            while (width) {
   1.619 -                vector unsigned char voverflow;
   1.620 -                vector unsigned char vd;
   1.621 -                vector unsigned char valpha;
   1.622 -                vector unsigned char vdstalpha;
   1.623 -                /* s = *srcp */
   1.624 -                voverflow = (vector unsigned char) vec_ld(15, srcp);
   1.625 -                vs = vec_perm(vs, voverflow, valigner);
   1.626 -                vs = vec_perm(vs, v0, vsrcPermute);
   1.627 -
   1.628 -                valpha = vec_perm(vs, v0, valphaPermute);
   1.629 -
   1.630 -                /* d = *dstp */
   1.631 -                vd = (vector unsigned char) vec_ld(0, dstp);
   1.632 -                vd = vec_perm(vd, v0, vsdstPermute);
   1.633 -                vdstalpha = vec_and(vd, valphamask);
   1.634 -
   1.635 -                VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
   1.636 -
   1.637 -                /* set the alpha to the dest alpha */
   1.638 -                vd = vec_and(vd, vpixelmask);
   1.639 -                vd = vec_or(vd, vdstalpha);
   1.640 -                vd = vec_perm(vd, v0, vdstPermute);
   1.641 -
   1.642 -                /* *dstp = res */
   1.643 -                vec_st((vector unsigned int) vd, 0, dstp);
   1.644 -
   1.645 -                srcp += 4;
   1.646 -                dstp += 4;
   1.647 -                width -= 4;
   1.648 -                vs = voverflow;
   1.649 -
   1.650 -            }
   1.651 -            ONE_PIXEL_BLEND((extrawidth), extrawidth);
   1.652 -        }
   1.653 -        srcp += srcskip;
   1.654 -        dstp += dstskip;
   1.655 -#undef ONE_PIXEL_BLEND
   1.656 -    }
   1.657 -}
   1.658 -
   1.659 -/* fast ARGB888->(A)RGB888 blending with pixel alpha */
   1.660 -static void
   1.661 -BlitRGBtoRGBPixelAlphaAltivec(SDL_BlitInfo * info)
   1.662 -{
   1.663 -    int width = info->dst_w;
   1.664 -    int height = info->dst_h;
   1.665 -    Uint32 *srcp = (Uint32 *) info->src;
   1.666 -    int srcskip = info->src_skip >> 2;
   1.667 -    Uint32 *dstp = (Uint32 *) info->dst;
   1.668 -    int dstskip = info->dst_skip >> 2;
   1.669 -    vector unsigned char mergePermute;
   1.670 -    vector unsigned char valphaPermute;
   1.671 -    vector unsigned char valphamask;
   1.672 -    vector unsigned char vpixelmask;
   1.673 -    vector unsigned char v0;
   1.674 -    vector unsigned short v1;
   1.675 -    vector unsigned short v8;
   1.676 -    v0 = vec_splat_u8(0);
   1.677 -    v1 = vec_splat_u16(1);
   1.678 -    v8 = vec_splat_u16(8);
   1.679 -    mergePermute = VEC_MERGE_PERMUTE();
   1.680 -    valphamask = VEC_ALPHA_MASK();
   1.681 -    valphaPermute = vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC));
   1.682 -
   1.683 -
   1.684 -    vpixelmask = vec_nor(valphamask, v0);
   1.685 -    while (height--) {
   1.686 -        width = info->dst_w;
   1.687 -#define ONE_PIXEL_BLEND(condition, widthvar) \
   1.688 -        while ((condition)) { \
   1.689 -            Uint32 dalpha; \
   1.690 -            Uint32 d; \
   1.691 -            Uint32 s1; \
   1.692 -            Uint32 d1; \
   1.693 -            Uint32 s = *srcp; \
   1.694 -            Uint32 alpha = s >> 24; \
   1.695 -            if(alpha) { \
   1.696 -              if(alpha == SDL_ALPHA_OPAQUE) { \
   1.697 -                *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000); \
   1.698 -              } else { \
   1.699 -                d = *dstp; \
   1.700 -                dalpha = d & 0xff000000; \
   1.701 -                s1 = s & 0xff00ff; \
   1.702 -                d1 = d & 0xff00ff; \
   1.703 -                d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \
   1.704 -                s &= 0xff00; \
   1.705 -                d &= 0xff00; \
   1.706 -                d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
   1.707 -                *dstp = d1 | d | dalpha; \
   1.708 -              } \
   1.709 -            } \
   1.710 -            ++srcp; \
   1.711 -            ++dstp; \
   1.712 -            widthvar--; \
   1.713 -	    }
   1.714 -        ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
   1.715 -        if (width > 0) {
   1.716 -            int extrawidth = (width % 4);
   1.717 -            vector unsigned char valigner = VEC_ALIGNER(srcp);
   1.718 -            vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp);
   1.719 -            width -= extrawidth;
   1.720 -            while (width) {
   1.721 -                vector unsigned char voverflow;
   1.722 -                vector unsigned char vd;
   1.723 -                vector unsigned char valpha;
   1.724 -                vector unsigned char vdstalpha;
   1.725 -                /* s = *srcp */
   1.726 -                voverflow = (vector unsigned char) vec_ld(15, srcp);
   1.727 -                vs = vec_perm(vs, voverflow, valigner);
   1.728 -
   1.729 -                valpha = vec_perm(vs, v0, valphaPermute);
   1.730 -
   1.731 -                /* d = *dstp */
   1.732 -                vd = (vector unsigned char) vec_ld(0, dstp);
   1.733 -                vdstalpha = vec_and(vd, valphamask);
   1.734 -
   1.735 -                VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
   1.736 -
   1.737 -                /* set the alpha to the dest alpha */
   1.738 -                vd = vec_and(vd, vpixelmask);
   1.739 -                vd = vec_or(vd, vdstalpha);
   1.740 -
   1.741 -                /* *dstp = res */
   1.742 -                vec_st((vector unsigned int) vd, 0, dstp);
   1.743 -
   1.744 -                srcp += 4;
   1.745 -                dstp += 4;
   1.746 -                width -= 4;
   1.747 -                vs = voverflow;
   1.748 -            }
   1.749 -            ONE_PIXEL_BLEND((extrawidth), extrawidth);
   1.750 -        }
   1.751 -        srcp += srcskip;
   1.752 -        dstp += dstskip;
   1.753 -    }
   1.754 -#undef ONE_PIXEL_BLEND
   1.755 -}
   1.756 -
   1.757 -static void
   1.758 -Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
   1.759 -{
   1.760 -    /* XXX : 6 */
   1.761 -    int height = info->dst_h;
   1.762 -    Uint32 *srcp = (Uint32 *) info->src;
   1.763 -    int srcskip = info->src_skip >> 2;
   1.764 -    Uint32 *dstp = (Uint32 *) info->dst;
   1.765 -    int dstskip = info->dst_skip >> 2;
   1.766 -    SDL_PixelFormat *srcfmt = info->src_fmt;
   1.767 -    SDL_PixelFormat *dstfmt = info->dst_fmt;
   1.768 -    unsigned sA = info->a;
   1.769 -    unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
   1.770 -    vector unsigned char mergePermute;
   1.771 -    vector unsigned char vsrcPermute;
   1.772 -    vector unsigned char vdstPermute;
   1.773 -    vector unsigned char vsdstPermute;
   1.774 -    vector unsigned char valpha;
   1.775 -    vector unsigned char valphamask;
   1.776 -    vector unsigned char vbits;
   1.777 -    vector unsigned short v1;
   1.778 -    vector unsigned short v8;
   1.779 -
   1.780 -    mergePermute = VEC_MERGE_PERMUTE();
   1.781 -    v1 = vec_splat_u16(1);
   1.782 -    v8 = vec_splat_u16(8);
   1.783 -
   1.784 -    /* set the alpha to 255 on the destination surf */
   1.785 -    valphamask = VEC_ALPHA_MASK();
   1.786 -
   1.787 -    vsrcPermute = calc_swizzle32(srcfmt, NULL);
   1.788 -    vdstPermute = calc_swizzle32(NULL, dstfmt);
   1.789 -    vsdstPermute = calc_swizzle32(dstfmt, NULL);
   1.790 -
   1.791 -    /* set a vector full of alpha and 255-alpha */
   1.792 -    ((unsigned char *) &valpha)[0] = sA;
   1.793 -    valpha = vec_splat(valpha, 0);
   1.794 -    vbits = (vector unsigned char) vec_splat_s8(-1);
   1.795 -
   1.796 -    while (height--) {
   1.797 -        int width = info->dst_w;
   1.798 -#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
   1.799 -            Uint32 Pixel; \
   1.800 -            unsigned sR, sG, sB, dR, dG, dB; \
   1.801 -            DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \
   1.802 -            DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
   1.803 -            ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
   1.804 -            ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
   1.805 -            ++srcp; \
   1.806 -            ++dstp; \
   1.807 -            widthvar--; \
   1.808 -        }
   1.809 -        ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
   1.810 -        if (width > 0) {
   1.811 -            int extrawidth = (width % 4);
   1.812 -            vector unsigned char valigner = VEC_ALIGNER(srcp);
   1.813 -            vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp);
   1.814 -            width -= extrawidth;
   1.815 -            while (width) {
   1.816 -                vector unsigned char voverflow;
   1.817 -                vector unsigned char vd;
   1.818 -
   1.819 -                /* s = *srcp */
   1.820 -                voverflow = (vector unsigned char) vec_ld(15, srcp);
   1.821 -                vs = vec_perm(vs, voverflow, valigner);
   1.822 -                vs = vec_perm(vs, valpha, vsrcPermute);
   1.823 -
   1.824 -                /* d = *dstp */
   1.825 -                vd = (vector unsigned char) vec_ld(0, dstp);
   1.826 -                vd = vec_perm(vd, vd, vsdstPermute);
   1.827 -
   1.828 -                VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
   1.829 -
   1.830 -                /* set the alpha channel to full on */
   1.831 -                vd = vec_or(vd, valphamask);
   1.832 -                vd = vec_perm(vd, vbits, vdstPermute);
   1.833 -
   1.834 -                /* *dstp = res */
   1.835 -                vec_st((vector unsigned int) vd, 0, dstp);
   1.836 -
   1.837 -                srcp += 4;
   1.838 -                dstp += 4;
   1.839 -                width -= 4;
   1.840 -                vs = voverflow;
   1.841 -            }
   1.842 -            ONE_PIXEL_BLEND((extrawidth), extrawidth);
   1.843 -        }
   1.844 -#undef ONE_PIXEL_BLEND
   1.845 -
   1.846 -        srcp += srcskip;
   1.847 -        dstp += dstskip;
   1.848 -    }
   1.849 -
   1.850 -}
   1.851 -
   1.852 -
   1.853 -/* fast RGB888->(A)RGB888 blending */
   1.854 -static void
   1.855 -BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info)
   1.856 -{
   1.857 -    unsigned alpha = info->a;
   1.858 -    int height = info->dst_h;
   1.859 -    Uint32 *srcp = (Uint32 *) info->src;
   1.860 -    int srcskip = info->src_skip >> 2;
   1.861 -    Uint32 *dstp = (Uint32 *) info->dst;
   1.862 -    int dstskip = info->dst_skip >> 2;
   1.863 -    vector unsigned char mergePermute;
   1.864 -    vector unsigned char valpha;
   1.865 -    vector unsigned char valphamask;
   1.866 -    vector unsigned short v1;
   1.867 -    vector unsigned short v8;
   1.868 -
   1.869 -    mergePermute = VEC_MERGE_PERMUTE();
   1.870 -    v1 = vec_splat_u16(1);
   1.871 -    v8 = vec_splat_u16(8);
   1.872 -
   1.873 -    /* set the alpha to 255 on the destination surf */
   1.874 -    valphamask = VEC_ALPHA_MASK();
   1.875 -
   1.876 -    /* set a vector full of alpha and 255-alpha */
   1.877 -    ((unsigned char *) &valpha)[0] = alpha;
   1.878 -    valpha = vec_splat(valpha, 0);
   1.879 -
   1.880 -    while (height--) {
   1.881 -        int width = info->dst_w;
   1.882 -#define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
   1.883 -            Uint32 s = *srcp; \
   1.884 -            Uint32 d = *dstp; \
   1.885 -            Uint32 s1 = s & 0xff00ff; \
   1.886 -            Uint32 d1 = d & 0xff00ff; \
   1.887 -            d1 = (d1 + ((s1 - d1) * alpha >> 8)) \
   1.888 -                 & 0xff00ff; \
   1.889 -            s &= 0xff00; \
   1.890 -            d &= 0xff00; \
   1.891 -            d = (d + ((s - d) * alpha >> 8)) & 0xff00; \
   1.892 -            *dstp = d1 | d | 0xff000000; \
   1.893 -            ++srcp; \
   1.894 -            ++dstp; \
   1.895 -            widthvar--; \
   1.896 -        }
   1.897 -        ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
   1.898 -        if (width > 0) {
   1.899 -            int extrawidth = (width % 4);
   1.900 -            vector unsigned char valigner = VEC_ALIGNER(srcp);
   1.901 -            vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp);
   1.902 -            width -= extrawidth;
   1.903 -            while (width) {
   1.904 -                vector unsigned char voverflow;
   1.905 -                vector unsigned char vd;
   1.906 -
   1.907 -                /* s = *srcp */
   1.908 -                voverflow = (vector unsigned char) vec_ld(15, srcp);
   1.909 -                vs = vec_perm(vs, voverflow, valigner);
   1.910 -
   1.911 -                /* d = *dstp */
   1.912 -                vd = (vector unsigned char) vec_ld(0, dstp);
   1.913 -
   1.914 -                VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8);
   1.915 -
   1.916 -                /* set the alpha channel to full on */
   1.917 -                vd = vec_or(vd, valphamask);
   1.918 -
   1.919 -                /* *dstp = res */
   1.920 -                vec_st((vector unsigned int) vd, 0, dstp);
   1.921 -
   1.922 -                srcp += 4;
   1.923 -                dstp += 4;
   1.924 -                width -= 4;
   1.925 -                vs = voverflow;
   1.926 -            }
   1.927 -            ONE_PIXEL_BLEND((extrawidth), extrawidth);
   1.928 -        }
   1.929 -#undef ONE_PIXEL_BLEND
   1.930 -
   1.931 -        srcp += srcskip;
   1.932 -        dstp += dstskip;
   1.933 -    }
   1.934 -}
   1.935 -
   1.936 -#if __MWERKS__
   1.937 -#pragma altivec_model off
   1.938 -#endif
   1.939 -#endif /* SDL_ALTIVEC_BLITTERS */
   1.940 -
   1.941  /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
   1.942  static void
   1.943  BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
   1.944 @@ -1984,24 +1156,19 @@
   1.945      SDL_PixelFormat *dstfmt = info->dst_fmt;
   1.946      int srcbpp = srcfmt->BytesPerPixel;
   1.947      int dstbpp = dstfmt->BytesPerPixel;
   1.948 -    unsigned sA = info->a;
   1.949 -    unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
   1.950 +    Uint32 Pixel;
   1.951 +    unsigned sR, sG, sB;
   1.952 +    unsigned dR, dG, dB, dA;
   1.953 +    const unsigned sA = info->a;
   1.954  
   1.955      if (sA) {
   1.956          while (height--) {
   1.957  	    /* *INDENT-OFF* */
   1.958  	    DUFFS_LOOP4(
   1.959  	    {
   1.960 -		Uint32 Pixel;
   1.961 -		unsigned sR;
   1.962 -		unsigned sG;
   1.963 -		unsigned sB;
   1.964 -		unsigned dR;
   1.965 -		unsigned dG;
   1.966 -		unsigned dB;
   1.967  		DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
   1.968 -		DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
   1.969 -		ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
   1.970 +		DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
   1.971 +		ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
   1.972  		ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
   1.973  		src += srcbpp;
   1.974  		dst += dstbpp;
   1.975 @@ -2029,25 +1196,20 @@
   1.976      Uint32 ckey = info->colorkey;
   1.977      int srcbpp = srcfmt->BytesPerPixel;
   1.978      int dstbpp = dstfmt->BytesPerPixel;
   1.979 -    unsigned sA = info->a;
   1.980 -    unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
   1.981 +    Uint32 Pixel;
   1.982 +    unsigned sR, sG, sB;
   1.983 +    unsigned dR, dG, dB, dA;
   1.984 +    const unsigned sA = info->a;
   1.985  
   1.986      while (height--) {
   1.987  	    /* *INDENT-OFF* */
   1.988  	    DUFFS_LOOP4(
   1.989  	    {
   1.990 -		Uint32 Pixel;
   1.991 -		unsigned sR;
   1.992 -		unsigned sG;
   1.993 -		unsigned sB;
   1.994 -		unsigned dR;
   1.995 -		unsigned dG;
   1.996 -		unsigned dB;
   1.997  		RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
   1.998  		if(sA && Pixel != ckey) {
   1.999  		    RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
  1.1000 -		    DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
  1.1001 -		    ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
  1.1002 +		    DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
  1.1003 +		    ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
  1.1004  		    ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
  1.1005  		}
  1.1006  		src += srcbpp;
  1.1007 @@ -2072,9 +1234,11 @@
  1.1008      int dstskip = info->dst_skip;
  1.1009      SDL_PixelFormat *srcfmt = info->src_fmt;
  1.1010      SDL_PixelFormat *dstfmt = info->dst_fmt;
  1.1011 -
  1.1012      int srcbpp;
  1.1013      int dstbpp;
  1.1014 +    Uint32 Pixel;
  1.1015 +    unsigned sR, sG, sB, sA;
  1.1016 +    unsigned dR, dG, dB, dA;
  1.1017  
  1.1018      /* Set up some basic variables */
  1.1019      srcbpp = srcfmt->BytesPerPixel;
  1.1020 @@ -2084,20 +1248,11 @@
  1.1021  	    /* *INDENT-OFF* */
  1.1022  	    DUFFS_LOOP4(
  1.1023  	    {
  1.1024 -		Uint32 Pixel;
  1.1025 -		unsigned sR;
  1.1026 -		unsigned sG;
  1.1027 -		unsigned sB;
  1.1028 -		unsigned dR;
  1.1029 -		unsigned dG;
  1.1030 -		unsigned dB;
  1.1031 -		unsigned sA;
  1.1032 -		unsigned dA;
  1.1033  		DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
  1.1034  		if(sA) {
  1.1035 -		  DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
  1.1036 -		  ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
  1.1037 -		  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
  1.1038 +		    DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
  1.1039 +		    ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA);
  1.1040 +		    ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
  1.1041  		}
  1.1042  		src += srcbpp;
  1.1043  		dst += dstbpp;
  1.1044 @@ -2124,13 +1279,6 @@
  1.1045              return BlitNto1PixelAlpha;
  1.1046  
  1.1047          case 2:
  1.1048 -#if SDL_ALTIVEC_BLITTERS
  1.1049 -            if (sf->BytesPerPixel == 4
  1.1050 -                && df->Gmask == 0x7e0 && df->Bmask == 0x1f
  1.1051 -                && SDL_HasAltiVec())
  1.1052 -                return Blit32to565PixelAlphaAltivec;
  1.1053 -            else
  1.1054 -#endif
  1.1055                  if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
  1.1056                      && sf->Gmask == 0xff00
  1.1057                      && ((sf->Rmask == 0xff && df->Rmask == 0x1f)
  1.1058 @@ -2162,19 +1310,10 @@
  1.1059                  }
  1.1060  #endif /* __MMX__ || __3dNOW__ */
  1.1061                  if (sf->Amask == 0xff000000) {
  1.1062 -#if SDL_ALTIVEC_BLITTERS
  1.1063 -                    if (SDL_HasAltiVec())
  1.1064 -                        return BlitRGBtoRGBPixelAlphaAltivec;
  1.1065 -#endif
  1.1066                      return BlitRGBtoRGBPixelAlpha;
  1.1067                  }
  1.1068              }
  1.1069 -#if SDL_ALTIVEC_BLITTERS
  1.1070 -            if (sf->Amask && sf->BytesPerPixel == 4 && SDL_HasAltiVec())
  1.1071 -                return Blit32to32PixelAlphaAltivec;
  1.1072 -            else
  1.1073 -#endif
  1.1074 -                return BlitNtoNPixelAlpha;
  1.1075 +            return BlitNtoNPixelAlpha;
  1.1076  
  1.1077          case 3:
  1.1078          default:
  1.1079 @@ -2220,19 +1359,10 @@
  1.1080                          return BlitRGBtoRGBSurfaceAlphaMMX;
  1.1081  #endif
  1.1082                      if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) {
  1.1083 -#if SDL_ALTIVEC_BLITTERS
  1.1084 -                        if (SDL_HasAltiVec())
  1.1085 -                            return BlitRGBtoRGBSurfaceAlphaAltivec;
  1.1086 -#endif
  1.1087                          return BlitRGBtoRGBSurfaceAlpha;
  1.1088                      }
  1.1089                  }
  1.1090 -#if SDL_ALTIVEC_BLITTERS
  1.1091 -                if ((sf->BytesPerPixel == 4) && SDL_HasAltiVec())
  1.1092 -                    return Blit32to32SurfaceAlphaAltivec;
  1.1093 -                else
  1.1094 -#endif
  1.1095 -                    return BlitNtoNSurfaceAlpha;
  1.1096 +                return BlitNtoNSurfaceAlpha;
  1.1097  
  1.1098              case 3:
  1.1099              default:
  1.1100 @@ -2243,16 +1373,11 @@
  1.1101  
  1.1102      case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
  1.1103          if (sf->Amask == 0) {
  1.1104 -            if (df->BytesPerPixel == 1)
  1.1105 +            if (df->BytesPerPixel == 1) {
  1.1106                  return BlitNto1SurfaceAlphaKey;
  1.1107 -            else
  1.1108 -#if SDL_ALTIVEC_BLITTERS
  1.1109 -            if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 &&
  1.1110 -                    SDL_HasAltiVec())
  1.1111 -                return Blit32to32SurfaceAlphaKeyAltivec;
  1.1112 -            else
  1.1113 -#endif
  1.1114 +            } else {
  1.1115                  return BlitNtoNSurfaceAlphaKey;
  1.1116 +            }
  1.1117          }
  1.1118          break;
  1.1119      }