Anonymous avatar Anonymous committed d05767f

Made sdl.video.PixelFormat.map_rgba/get_rgba comply to SDL.
Minor fix in the DIFF blend macro.
Splitted blend blits.
Fixed path bugs in freetype unit tests.

Comments (0)

Files changed (10)

doc/src/sdlvideo.xml

       <desc>Gets or sets the RGBA value of transparent pixels.</desc>
     </attr>
     <method name="get_rgba">
-      <call>get_rgba (color) -> int, int, int, int</call>
+      <call>get_rgba (color) -> Color</call>
       <desc>
-        Gets the RGBA values for the color.
+        Gets the best matching Color for the color.
 
-        Gets the single RGBA values for a color value, which fit the
-        PixelFormat best. This means that an internal conversion is done
-        on demand to match the passed color to the PixelFormat's
-        supported value ranges. If the PixelFormat does not have alpha
-        transparency support, the last RGBA integer will be set to fully
-        opaque (255).
+        Gets a color value, which fits the PixelFormat best. This means
+        that an internal conversion is done on demand to match the
+        passed color to the PixelFormat's supported value ranges. If the
+        PixelFormat does not have alpha transparency support, the
+        Color's alpha value will be set to fully opaque (255).
       </desc>
     </method>
     <attr name="losses">
       component.</desc>
     </attr>
     <method name="map_rgba">
-      <call>map_rgba (r, g, b[, a]) -> Color
-        map_rgba (color) -> Color
+      <call>map_rgba (r, g, b[, a]) -> long
+        map_rgba (color) -> long
       </call>
       <desc>
         Converts a color to the best value matching the format.
         sources = [
             "src/sdl/pixelformat.c",
             "src/sdl/surface_blit.c",
+            "src/sdl/surface_blit_rgb.c",
+            "src/sdl/surface_blit_rgba.c",
             "src/sdl/surface_fill.c",
             "src/sdl/surface_save.c",
             "src/sdl/surface.c",

src/sdl/pixelformat.c

 _pixelformat_maprgba (PyObject *self, PyObject *args)
 {
     PyObject *color = NULL;
-    Uint8 r, g, b, a;
+    Uint8 r, g, b, a = 0;
     
     int _a = -1;
     Uint32 val;
      * and an alpha value was requested.
      */
     if (((PyPixelFormat*)self)->format->Amask != 0 && _a != -1)
-    {
         val = SDL_MapRGBA (((PyPixelFormat*)self)->format, r, g, b, a);
-        SDL_GetRGBA (val, ((PyPixelFormat*)self)->format, &r, &g, &b, &a);
-    }
     else
-    {
         val = SDL_MapRGB (((PyPixelFormat*)self)->format, r, g, b);
-        a = 255; /* Set the alpha portion fully opaque. */
-        GET_RGB_VALS (val, ((PyPixelFormat*)self)->format, r, g, b, a);
-    }
-    return PyColor_NewFromRGBA ((pgbyte)r, (pgbyte)g, (pgbyte)b, (pgbyte)a);
+
+    return PyLong_FromUnsignedLong ((unsigned long) val);
 }
 
 static PyObject*
 _pixelformat_getrgba (PyObject *self, PyObject *args)
 {
     PyObject *color = NULL;
-    Uint8 r, g, b, a;
+    Uint8 r = 0, g = 0, b = 0, a = 255;
     Uint32 val;
 
     if (!PyArg_ParseTuple (args, "O:get_rgba", &color))
 
     if (!Uint32FromObj (color, &val))
         return NULL;
+    if (PyColor_Check (color))
+    {
+        ARGB2FORMAT (val, ((PyPixelFormat*)self)->format);
+    }
 
-    SDL_GetRGBA (val, ((PyPixelFormat*)self)->format, &r, &g, &b, &a);
-    
-    return Py_BuildValue ("(iiii)", r, g, b, a);
+    if (((PyPixelFormat*)self)->format->Amask != 0)
+        SDL_GetRGBA (val, ((PyPixelFormat*)self)->format, &r, &g, &b, &a);
+    else
+        SDL_GetRGB (val, ((PyPixelFormat*)self)->format, &r, &g, &b);
+
+    return PyColor_NewFromRGBA ((pgbyte)r, (pgbyte)g, (pgbyte)b, (pgbyte)a);
 }
 
 /* C API */

src/sdl/surface.h

     dB = MIN (255, MAX(sB | dB, 0));
 
 #define D_BLEND_RGB_DIFF(sR, sG, sB, dR, dG, dB)    \
-    dR = ABS((int)sR - (int)dR);                    \
-    dG = ABS((int)sG - (int)dG);                    \
-    dB = ABS((int)sB - (int)dB);
+    dR = ABS((int)dR - (int)sR);                    \
+    dG = ABS((int)dG - (int)sG);                    \
+    dB = ABS((int)dB - (int)sB);
 
 #define D_BLEND_RGB_SCREEN(sR, sG, sB, dR, dG, dB)  \
     dR = 255 - ((255 - sR) * (255 - dR) >> 8);      \

src/sdl/surface_blit.c

 /*
   pygame - Python Game Library
   Copyright (C) 2000-2001  Pete Shinners, 2006 Rene Dudfield,
-                2007 Marcus von Appen
+                2007-2009 Marcus von Appen
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
 
 */
 
-#include "surface.h"
-
-/* The structure passed to the low level blit functions */
-typedef struct
-{
-    Uint8          *s_pixels;
-    int             s_width;
-    int             s_height;
-    int             s_skip;
-    Uint8          *d_pixels;
-    int             d_width;
-    int             d_height;
-    int             d_skip;
-    void           *aux_data;
-    SDL_PixelFormat *src;
-    Uint8          *table;
-    SDL_PixelFormat *dst;
-} SDL_BlitInfo;
-
-static void blit_blend_rgba_add (SDL_BlitInfo* info);
-static void blit_blend_rgba_sub (SDL_BlitInfo* info);
-static void blit_blend_rgba_mul (SDL_BlitInfo* info);
-static void blit_blend_rgba_min (SDL_BlitInfo* info);
-static void blit_blend_rgba_max (SDL_BlitInfo* info);
-
-static void blit_blend_add (SDL_BlitInfo* info);
-static void blit_blend_sub (SDL_BlitInfo* info);
-static void blit_blend_mul (SDL_BlitInfo* info);
-static void blit_blend_min (SDL_BlitInfo* info);
-static void blit_blend_max (SDL_BlitInfo* info);
-static void blit_blend_and (SDL_BlitInfo* info);
-static void blit_blend_or (SDL_BlitInfo* info);
-static void blit_blend_xor (SDL_BlitInfo* info);
-static void blit_blend_diff (SDL_BlitInfo* info);
-static void blit_blend_screen (SDL_BlitInfo* info);
-static void blit_blend_avg (SDL_BlitInfo* info);
+#include "surface_blit.h"
 
 static void alphablit_alpha (SDL_BlitInfo* info);
 static void alphablit_colorkey (SDL_BlitInfo* info);
 static void alphablit_solid (SDL_BlitInfo* info);
 
-static void
-blit_blend_rgba_add (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-    Uint32          tmp;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_ADD (tmp, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_rgba_sub (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-    Sint32          tmp2;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_SUB (tmp2, sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_rgba_mul (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MULT (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_rgba_min (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MIN (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_rgba_max (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGBA_MAX (sR, sG, sB, sA, dR, dG, dB, dA);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_add (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-    Uint32          tmp;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    /*
-                    printf ("VAL: %d %d %d || %d %d %d || 0x%.8x || 0x%.8x \n",
-                        sR, sG, sB, dR, dG, dB, *((Uint16*)dst),
-                        ((Uint16)SDL_MapRGB(dstfmt, dR, dG, dB)));
-                    */
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_sub (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-    Sint32          tmp2;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_SUB (tmp2, sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SUB (tmp2, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SUB (tmp2, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SUB (tmp2, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SUB (tmp2, sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_mul (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_MULT (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MULT (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MULT (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MULT (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MULT (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_min (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_MIN (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MIN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MIN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MIN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MIN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_max (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcfmt->BytesPerPixel == 4 && dstfmt->BytesPerPixel == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_MAX (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MAX (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MAX (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MAX (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_MAX (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_xor (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_XOR (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_XOR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_XOR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_XOR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_XOR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_and (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_AND (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AND (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AND (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AND (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AND (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_or (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_OR (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_OR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_OR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_OR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_OR (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_diff (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_DIFF (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_DIFF (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_DIFF (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_DIFF (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_DIFF (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_screen (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_SCREEN (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SCREEN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SCREEN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SCREEN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_SCREEN (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
-static void
-blit_blend_avg (SDL_BlitInfo * info)
-{
-    int             n;
-    int             width = info->d_width;
-    int             height = info->d_height;
-    Uint8          *src = info->s_pixels;
-    int             srcskip = info->s_skip;
-    Uint8          *dst = info->d_pixels;
-    int             dstskip = info->d_skip;
-    SDL_PixelFormat *srcfmt = info->src;
-    SDL_PixelFormat *dstfmt = info->dst;
-    int             srcbpp = srcfmt->BytesPerPixel;
-    int             dstbpp = dstfmt->BytesPerPixel;
-    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
-    Uint32          pixel;
-
-    if (srcbpp == 4 && dstbpp == 4)
-    {
-        while (height--)
-        {
-            LOOP_UNROLLED4(
-            {
-                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
-                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
-                D_BLEND_RGB_AVG (sR, sG, sB, dR, dG, dB);
-                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                src += srcbpp;
-                dst += dstbpp;
-            }, n, width);
-            src += srcskip;
-            dst += dstskip;
-        }
-        return;
-    }
-
-    if (srcbpp == 1)
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AVG (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AVG (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-    else /* srcbpp > 1 */
-    {
-        if (dstbpp == 1)
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AVG (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-
-        }
-        else /* dstbpp > 1 */
-        {
-            while (height--)
-            {
-                LOOP_UNROLLED4(
-                {
-                    GET_PIXEL(pixel, srcbpp, src);
-                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
-                    GET_PIXEL (pixel, dstbpp, dst);
-                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
-                    D_BLEND_RGB_AVG (sR, sG, sB, dR, dG, dB);
-                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
-                    src += srcbpp;
-                    dst += dstbpp;
-                }, n, width);
-                src += srcskip;
-                dst += dstskip;
-            }
-        }
-    }
-}
-
 static void 
 alphablit_alpha (SDL_BlitInfo * info)
 {

src/sdl/surface_blit.h

+/*
+  pygame - Python Game Library
+  Copyright (C) 2009 Marcus von Appen
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public
+  License along with this library; if not, write to the Free
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "surface.h"
+
+/* The structure passed to the low level blit functions */
+typedef struct
+{
+    Uint8          *s_pixels;
+    int             s_width;
+    int             s_height;
+    int             s_skip;
+    Uint8          *d_pixels;
+    int             d_width;
+    int             d_height;
+    int             d_skip;
+    void           *aux_data;
+    SDL_PixelFormat *src;
+    Uint8          *table;
+    SDL_PixelFormat *dst;
+} SDL_BlitInfo;
+
+void blit_blend_add (SDL_BlitInfo* info);
+void blit_blend_sub (SDL_BlitInfo* info);
+void blit_blend_mul (SDL_BlitInfo* info);
+void blit_blend_min (SDL_BlitInfo* info);
+void blit_blend_max (SDL_BlitInfo* info);
+void blit_blend_and (SDL_BlitInfo* info);
+void blit_blend_or (SDL_BlitInfo* info);
+void blit_blend_xor (SDL_BlitInfo* info);
+void blit_blend_diff (SDL_BlitInfo* info);
+void blit_blend_screen (SDL_BlitInfo* info);
+void blit_blend_avg (SDL_BlitInfo* info);
+
+void blit_blend_rgba_add (SDL_BlitInfo* info);
+void blit_blend_rgba_sub (SDL_BlitInfo* info);
+void blit_blend_rgba_mul (SDL_BlitInfo* info);
+void blit_blend_rgba_min (SDL_BlitInfo* info);
+void blit_blend_rgba_max (SDL_BlitInfo* info);

src/sdl/surface_blit_rgb.c

+/*
+  pygame - Python Game Library
+  Copyright (C) 2000-2001  Pete Shinners, 2006 Rene Dudfield,
+                2007-2009 Marcus von Appen
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public
+  License along with this library; if not, write to the Free
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+#include "surface_blit.h"
+
+void
+blit_blend_add (SDL_BlitInfo * info)
+{
+    int             n;
+    int             width = info->d_width;
+    int             height = info->d_height;
+    Uint8          *src = info->s_pixels;
+    int             srcskip = info->s_skip;
+    Uint8          *dst = info->d_pixels;
+    int             dstskip = info->d_skip;
+    SDL_PixelFormat *srcfmt = info->src;
+    SDL_PixelFormat *dstfmt = info->dst;
+    int             srcbpp = srcfmt->BytesPerPixel;
+    int             dstbpp = dstfmt->BytesPerPixel;
+    Uint8           dR, dG, dB, dA, sR, sG, sB, sA;
+    Uint32          pixel;
+    Uint32          tmp;
+
+    if (srcbpp == 4 && dstbpp == 4)
+    {
+        while (height--)
+        {
+            LOOP_UNROLLED4(
+            {
+                GET_RGB_VALS ((*(Uint32*)src), srcfmt, sR, sG, sB, sA);
+                GET_RGB_VALS ((*(Uint32*)dst), dstfmt, dR, dG, dB, dA);
+                D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
+                CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
+                src += srcbpp;
+                dst += dstbpp;
+            }, n, width);
+            src += srcskip;
+            dst += dstskip;
+        }
+        return;
+    }
+
+    if (srcbpp == 1)
+    {
+        if (dstbpp == 1)
+        {
+            while (height--)
+            {
+                LOOP_UNROLLED4(
+                {
+                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
+                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
+                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
+                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
+                    src += srcbpp;
+                    dst += dstbpp;
+                }, n, width);
+                src += srcskip;
+                dst += dstskip;
+            }
+        }
+        else /* dstbpp > 1 */
+        {
+            while (height--)
+            {
+                LOOP_UNROLLED4(
+                {
+                    GET_PALETTE_VALS(src, srcfmt, sR, sG, sB, sA);
+                    GET_PIXEL (pixel, dstbpp, dst);
+                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
+                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
+                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
+                    src += srcbpp;
+                    dst += dstbpp;
+                }, n, width);
+                src += srcskip;
+                dst += dstskip;
+            }
+        }
+    }
+    else /* srcbpp > 1 */
+    {
+        if (dstbpp == 1)
+        {
+            while (height--)
+            {
+                LOOP_UNROLLED4(
+                {
+                    GET_PIXEL(pixel, srcbpp, src);
+                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
+                    GET_PALETTE_VALS(dst, dstfmt, dR, dG, dB, dA);
+                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
+                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
+                    src += srcbpp;
+                    dst += dstbpp;
+                }, n, width);
+                src += srcskip;
+                dst += dstskip;
+            }
+
+        }
+        else /* dstbpp > 1 */
+        {
+            while (height--)
+            {
+                LOOP_UNROLLED4(
+                {
+                    GET_PIXEL(pixel, srcbpp, src);
+                    GET_RGB_VALS (pixel, srcfmt, sR, sG, sB, sA);
+                    GET_PIXEL (pixel, dstbpp, dst);
+                    GET_RGB_VALS (pixel, dstfmt, dR, dG, dB, dA);
+                    D_BLEND_RGB_ADD (tmp, sR, sG, sB, dR, dG, dB);
+                    CREATE_PIXEL(dst, dR, dG, dB, dA, dstbpp, dstfmt);
+                    /*
+                    printf ("VAL: %d %d %d || %d %d %d || 0x%.8x || 0x%.8x \n",
+                        sR, sG, sB, dR, dG, dB, *((Uint16*)dst),
+                        ((Uint16)SDL_MapRGB(dstfmt, dR, dG, dB)));
+                    */
+                    src += srcbpp;
+                    dst += dstbpp;
+                }, n, width);