pygame / src / surface_fill.c

Diff from to

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;
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.