Lenard Lindstrom avatar Lenard Lindstrom committed 902b988

fix per-pixel alpha bug involving pixel unpacking

Comments (0)

Files changed (5)

     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
     Uint32          tmp;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (!(info->dst_flags & SDL_SRCALPHA && dstfmt->Amask))
     {
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
     Sint32          tmp2;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (!(info->dst_flags & SDL_SRCALPHA && dstfmt->Amask))
     {
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
     Uint32          tmp;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (!(info->dst_flags & SDL_SRCALPHA && dstfmt->Amask))
     {
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             dstbpp = dstfmt->BytesPerPixel;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (!(info->dst_flags & SDL_SRCALPHA && dstfmt->Amask))
     {
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             dstbpp = dstfmt->BytesPerPixel;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (!(info->dst_flags & SDL_SRCALPHA && dstfmt->Amask))
     {
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
     Uint32          tmp;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (srcbpp == 4 && dstbpp == 4 &&
 	srcfmt->Rmask == dstfmt->Rmask &&
 		{
 		    GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
 		LOOP_UNROLLED4(
 		{
 		    GET_PIXEL(pixel, srcbpp, src);
-		    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+		    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
     Sint32          tmp2;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (srcbpp == 4 && dstbpp == 4 &&
 	srcfmt->Rmask == dstfmt->Rmask &&
 		{
 		    GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstfmt);
 		    BLEND_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
     Uint32          tmp;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (srcbpp == 4 && dstbpp == 4 &&
 	srcfmt->Rmask == dstfmt->Rmask &&
 		{
 		    GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
 		LOOP_UNROLLED4(
 		{
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             dstbpp = dstfmt->BytesPerPixel;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (srcbpp == 4 && dstbpp == 4 &&
 	srcfmt->Rmask == dstfmt->Rmask &&
 		{
 		    GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
 		LOOP_UNROLLED4(
 		{
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             dstbpp = dstfmt->BytesPerPixel;
     Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     if (srcbpp == 4 && dstbpp == 4 &&
 	srcfmt->Rmask == dstfmt->Rmask &&
 		{
 		    GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     BLEND_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
 		LOOP_UNROLLED4(
 		{
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
 		    GET_PIXEL (pixel, dstbpp, dst);
-		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+		    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
 		    BLEND_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
 		    dst[offsetR] = dR;
 		    dst[offsetG] = dG;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     BLEND_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             dstbpp = dstfmt->BytesPerPixel;
     int             dR, dG, dB, dA, sR, sG, sB, sA;
     Uint32          pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     /*
     printf ("Alpha blit with %d and %d\n", srcbpp, dstbpp);
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     ALPHA_BLEND (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     ALPHA_BLEND (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     ALPHA_BLEND (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             alpha = srcfmt->alpha;
     Uint32          colorkey = srcfmt->colorkey;
     Uint32          pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     /*
     printf ("Colorkey blit with %d and %d\n", srcbpp, dstbpp);
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     sA = (*src == colorkey) ? 0 : alpha;
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     ALPHA_BLEND (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     sA = (pixel == colorkey) ? 0 : alpha;
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     ALPHA_BLEND (sR, sG, sB, sA, dR, dG, dB, dA);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     sA = (pixel == colorkey) ? 0 : alpha;
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     ALPHA_BLEND (sR, sG, sB, sA, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
     int             dR, dG, dB, dA, sR, sG, sB, sA;
     int             alpha = srcfmt->alpha;
     int             pixel;
+    int             srcppa = (info->src_flags & SDL_SRCALPHA && srcfmt->Amask);
+    int             dstppa = (info->dst_flags & SDL_SRCALPHA && dstfmt->Amask);
 
     /*
     printf ("Solid blit with %d and %d\n", srcbpp, dstbpp);
                 {
                     GET_PIXELVALS_1(sR, sG, sB, sA, src, srcfmt);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     ALPHA_BLEND (sR, sG, sB, alpha, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXELVALS_1(dR, dG, dB, dA, dst, dstfmt);
                     ALPHA_BLEND (sR, sG, sB, alpha, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                 LOOP_UNROLLED4(
                 {
                     GET_PIXEL(pixel, srcbpp, src);
-                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt);
+                    GET_PIXELVALS (sR, sG, sB, sA, pixel, srcfmt, srcppa);
                     GET_PIXEL (pixel, dstbpp, dst);
-                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt);
+                    GET_PIXELVALS (dR, dG, dB, dA, pixel, dstfmt, dstppa);
                     ALPHA_BLEND (sR, sG, sB, alpha, dR, dG, dB, dA);
                     CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
                     src += srcbpp;

src/pixelarray_methods.c

     case 2:
     {
         Uint16 *pixel;
+	int ppa = (surface->flags & SDL_SRCALPHA &&
+		   surface->format->Amask);
         while (posy < array->ylen)
         {
             x = array->xstart;
                 if (distance)
                 {
                     GET_PIXELVALS (r2, g2, b2, a2, (Uint32) *pixel,
-                        surface->format);
+				   surface->format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                         *pixel = (Uint16) rcolor;
         Uint8 *px;
         Uint32 pxcolor;
         SDL_PixelFormat *format = surface->format;
+	int ppa = (surface->flags & SDL_SRCALPHA && format->Amask);
         while (posy < array->ylen)
         {
             x = array->xstart;
                 pxcolor = (px[0]) + (px[1] << 8) + (px[2] << 16);
                 if (distance)
                 {
-                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, surface->format);
+                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                     {
                 pxcolor = (px[2]) + (px[1] << 8) + (px[0] << 16);
                 if (distance)
                 {
-                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, surface->format);
+                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                     {
     default:
     {
         Uint32 *pixel;
+	int ppa = (surface->flags & SDL_SRCALPHA &&
+		   surface->format->Amask);
         while (posy < array->ylen)
         {
             x = array->xstart;
                 pixel = ((Uint32 *) (pixels + y * surface->pitch) + x);
                 if (distance)
                 {
-                    GET_PIXELVALS (r2, g2, b2, a2, *pixel, surface->format);
+                    GET_PIXELVALS (r2, g2, b2, a2, *pixel,
+				   surface->format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                         *pixel = rcolor;
     case 2:
     {
         Uint16 *pixel;
+	int ppa = (surface->flags & SDL_SRCALPHA &&
+		   surface->format->Amask);
         while (posy < newarray->ylen)
         {
             x = newarray->xstart;
                 if (distance)
                 {
                     GET_PIXELVALS (r2, g2, b2, a2, (Uint32) *pixel,
-                        surface->format);
+				   surface->format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                         *pixel = (Uint16) white;
         Uint8 *px;
         Uint32 pxcolor;
         SDL_PixelFormat *format = surface->format;
+	int ppa = (surface->flags & SDL_SRCALPHA && format->Amask);
         while (posy < newarray->ylen)
         {
             x = newarray->xstart;
                 pxcolor = (px[0]) + (px[1] << 8) + (px[2] << 16);
                 if (distance)
                 {
-                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, surface->format);
+                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                     {
                 pxcolor = (px[2]) + (px[1] << 8) + (px[0] << 16);
                 if (distance)
                 {
-                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, surface->format);
+                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor, format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                     {
     default:
     {
         Uint32 *pixel;
+	int ppa = (surface->flags & SDL_SRCALPHA &&
+		   surface->format->Amask);
         while (posy < newarray->ylen)
         {
             x = newarray->xstart;
                 pixel = ((Uint32 *) (pixels + y * surface->pitch) + x);
                 if (distance)
                 {
-                    GET_PIXELVALS (r2, g2, b2, a2, *pixel, surface->format);
+                    GET_PIXELVALS (r2, g2, b2, a2, *pixel,
+				   surface->format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) <=
                         distance)
                         *pixel = white;
     case 2:
     {
         Uint16 *pixel1, *pixel2;
+	int ppa = (surface1->flags & SDL_SRCALPHA &&
+		   surface1->format->Amask);
         while (posy < newarray->ylen)
         {
             vx = array2->xstart;
                 if (distance)
                 {
                     GET_PIXELVALS (r1, g1, b1, a1, (Uint32) *pixel1,
-                        surface1->format);
+				   surface1->format, ppa);
                     GET_PIXELVALS (r2, g2, b2, a2, (Uint32) *pixel2,
-                        surface1->format);
+				   surface1->format, ppa);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) >
                         distance)
                         *pixel1 = (Uint16) white;
         Uint8 *px1, *px2;
         Uint32 pxcolor1, pxcolor2;
         SDL_PixelFormat *format = surface1->format;
+	int ppa1 = (surface1->flags & SDL_SRCALPHA &&
+		    surface1->format->Amask);
+	int ppa2 = (surface2->flags & SDL_SRCALPHA &&
+		    surface2->format->Amask);
         while (posy < newarray->ylen)
         {
             vx = array2->xstart;
                 pxcolor2 = (px2[0]) + (px2[1] << 8) + (px2[2] << 16);
                 if (distance)
                 {
-                    GET_PIXELVALS (r1, g1, b1, a1, pxcolor1, surface1->format);
-                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor2, surface2->format);
+                    GET_PIXELVALS (r1, g1, b1, a1, pxcolor1,
+				   surface1->format, ppa1);
+                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor2,
+				   surface2->format, ppa2);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) >
                         distance)
                     {
                 pxcolor2 = (px2[2]) + (px2[1] << 8) + (px2[0] << 16);
                 if (distance)
                 {
-                    GET_PIXELVALS (r1, g1, b1, a1, pxcolor1, surface1->format);
-                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor2, surface2->format);
+                    GET_PIXELVALS (r1, g1, b1, a1, pxcolor1,
+				   surface1->format, ppa1);
+                    GET_PIXELVALS (r2, g2, b2, a2, pxcolor2,
+				   surface2->format, ppa2);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) >
                         distance)
                     {
         }
         break;
     }
-    default:
+     default:
     {
         Uint32 *pixel1, *pixel2;
+	int ppa1 = (surface1->flags & SDL_SRCALPHA &&
+		    surface1->format->Amask);
+	int ppa2 = (surface2->flags & SDL_SRCALPHA &&
+		    surface2->format->Amask);
         while (posy < newarray->ylen)
         {
             vx = array2->xstart;
                 pixel2 = ((Uint32 *) (pixels2 + vy * surface2->pitch) + vx);
                 if (distance)
                 {
-                    GET_PIXELVALS (r1, g1, b1, a1, *pixel1, surface1->format);
-                    GET_PIXELVALS (r2, g2, b2, a2, *pixel2, surface2->format);
+                    GET_PIXELVALS (r1, g1, b1, a1, *pixel1,
+				   surface1->format, ppa1);
+                    GET_PIXELVALS (r2, g2, b2, a2, *pixel2,
+				   surface2->format, ppa2);
                     if (COLOR_DIFF_RGB (wr, wg, wb, r1, g1, b1, r2, g2, b2) >
                         distance)
                         *pixel1 = white;
     break;                                        \
     }
 
-#define GET_PIXELVALS(_sR, _sG, _sB, _sA, px, fmt)		      \
+#define GET_PIXELVALS(_sR, _sG, _sB, _sA, px, fmt, ppa)		      \
     _sR = ((px & fmt->Rmask) >> fmt->Rshift);                         \
     _sR = (_sR << fmt->Rloss) + (_sR >> (8 - (fmt->Rloss << 1)));     \
     _sG = ((px & fmt->Gmask) >> fmt->Gshift);                         \
     _sG = (_sG << fmt->Gloss) + (_sG >> (8 - (fmt->Gloss << 1)));     \
     _sB = ((px & fmt->Bmask) >> fmt->Bshift);                         \
     _sB = (_sB << fmt->Bloss) + (_sB >> (8 - (fmt->Bloss << 1)));     \
-    if (fmt->Amask)                                                   \
+    if (ppa)							      \
     {                                                                 \
         _sA = ((px & fmt->Amask) >> fmt->Ashift);                     \
         _sA = (_sA << fmt->Aloss) + (_sA >> (8 - (fmt->Aloss << 1))); \

src/surface_fill.c

     int width = rect->w;
     int height = rect->h;
     int skip;
-    int bpp;
+    int bpp = surface->format->BytesPerPixel;
     int n;
-    SDL_PixelFormat *fmt;
+    SDL_PixelFormat *fmt = surface->format;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     Uint32 tmp;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    bpp = surface->format->BytesPerPixel;
-    fmt = surface->format;
     pixels = (Uint8 *) surface->pixels + surface->offset +
         (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
     skip = surface->pitch - width * bpp;
     {
 	size_t offsetR, offsetG, offsetB;
 	SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         while (height--)
         {
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
 		pixels[offsetR] = sR;
 		pixels[offsetG] = sG;
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     int width = rect->w;
     int height = rect->h;
     int skip;
-    int bpp;
+    int bpp = surface->format->BytesPerPixel;
     int n;
-    SDL_PixelFormat *fmt;
+    SDL_PixelFormat *fmt = surface->format;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     Sint32 tmp2;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    bpp = surface->format->BytesPerPixel;
-    fmt = surface->format;
     pixels = (Uint8 *) surface->pixels + surface->offset +
         (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
     skip = surface->pitch - width * bpp;
     {
 	size_t offsetR, offsetG, offsetB;
 	SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         while (height--)
         {
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
 		pixels[offsetR] = sR;
 		pixels[offsetG] = sG;
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     int width = rect->w;
     int height = rect->h;
     int skip;
-    int bpp;
+    int bpp = surface->format->BytesPerPixel;
     int n;
-    SDL_PixelFormat *fmt;
+    SDL_PixelFormat *fmt = surface->format;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    bpp = surface->format->BytesPerPixel;
-    fmt = surface->format;
     pixels = (Uint8 *) surface->pixels + surface->offset +
         (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
     skip = surface->pitch - width * bpp;
     {
 	size_t offsetR, offsetG, offsetB;
 	SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         while (height--)
         {
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
 		pixels[offsetR] = sR;
 		pixels[offsetG] = sG;
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     int width = rect->w;
     int height = rect->h;
     int skip;
-    int bpp;
+    int bpp = surface->format->BytesPerPixel;
     int n;
-    SDL_PixelFormat *fmt;
+    SDL_PixelFormat *fmt = surface->format;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    bpp = surface->format->BytesPerPixel;
-    fmt = surface->format;
     pixels = (Uint8 *) surface->pixels + surface->offset +
         (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
     skip = surface->pitch - width * bpp;
     {
 	size_t offsetR, offsetG, offsetB;
 	SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         while (height--)
         {
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
 		pixels[offsetR] = sR;
 		pixels[offsetG] = sG;
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     int width = rect->w;
     int height = rect->h;
     int skip;
-    int bpp;
+    int bpp = surface->format->BytesPerPixel;
     int n;
-    SDL_PixelFormat *fmt;
+    SDL_PixelFormat *fmt = surface->format;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    bpp = surface->format->BytesPerPixel;
-    fmt = surface->format;
     pixels = (Uint8 *) surface->pixels + surface->offset +
         (Uint16) rect->y * surface->pitch + (Uint16) rect->x * bpp;
     skip = surface->pitch - width * bpp;
     {
 	size_t offsetR, offsetG, offsetB;
 	SET_OFFSETS_24 (offsetR, offsetG, offsetB, fmt);
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         while (height--)
         {
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
 		pixels[offsetR] = sR;
 		pixels[offsetG] = sG;
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     Uint32 pixel;
     Uint32 tmp;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    if (!(surface->flags & SDL_SRCALPHA && fmt->Amask))
+    if (!ppa)
     {
 	return surface_fill_blend_add (surface, rect, color);
     }
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_RGBA_ADD (tmp, cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     Uint32 pixel;
     Sint32 tmp2;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    if (!(surface->flags & SDL_SRCALPHA && fmt->Amask))
+    if (!ppa)
     {
 	return surface_fill_blend_sub (surface, rect, color);
     }
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_RGBA_SUB (tmp2, cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    if (!(surface->flags & SDL_SRCALPHA && fmt->Amask))
+    if (!ppa)
     {
 	return surface_fill_blend_mult (surface, rect, color);
     }
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_RGBA_MULT (cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    if (!(surface->flags & SDL_SRCALPHA && fmt->Amask))
+    if (!ppa)
     {
 	return surface_fill_blend_min (surface, rect, color);
     }
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_RGBA_MIN (cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;
     Uint8 sR, sG, sB, sA, cR, cG, cB, cA;
     Uint32 pixel;
     int result = -1;
+    int ppa = (surface->flags & SDL_SRCALPHA && fmt->Amask);
 
-    if (!(surface->flags & SDL_SRCALPHA && fmt->Amask))
+    if (!ppa)
     {
 	return surface_fill_blend_max (surface, rect, color);
     }
     }
     default:
     {
-        GET_PIXELVALS (cR, cG, cB, cA, color, fmt);
+        GET_PIXELVALS (cR, cG, cB, cA, color, fmt, ppa);
         /*
         printf ("Color: %d, %d, %d, %d, BPP is: %d\n", cR, cG, cB, cA, bpp);
         */
             LOOP_UNROLLED4(
             {
                 GET_PIXEL (pixel, bpp, pixels);
-                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt);
+                GET_PIXELVALS (sR, sG, sB, sA, pixel, fmt, ppa);
                 BLEND_RGBA_MAX (cR, cG, cB, cA, sR, sG, sB, sA);
                 CREATE_PIXEL(pixels, sR, sG, sB, sA, bpp, fmt);
                 pixels += bpp;

test/surface_test.py

                      special_flags=getattr(pygame, blend_name))
             self._assert_surface(dst, p, ", %s" % blend_name)
 
-    def todo_test_GET_PIXELVALS(self):
+    def test_GET_PIXELVALS(self):
         # surface.h GET_PIXELVALS bug regarding whether of not
         # a surface has per-pixel alpha. Looking at the Amask
         # is not enough. The surface's SRCALPHA flag must also
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.