Added ARGB optimized case for Mac OS X
authorSam Lantinga
Sun, 21 Dec 2008 08:55:06 +0000
changeset 2899a0c837a16e4c
parent 2898 e40448bc7727
child 2900 3a9636c83849
Added ARGB optimized case for Mac OS X
src/video/SDL_blendline.c
src/video/SDL_blendrect.c
src/video/SDL_blit.h
src/video/SDL_draw.h
     1.1 --- a/src/video/SDL_blendline.c	Sun Dec 21 08:28:25 2008 +0000
     1.2 +++ b/src/video/SDL_blendline.c	Sun Dec 21 08:55:06 2008 +0000
     1.3 @@ -93,6 +93,29 @@
     1.4  }
     1.5  
     1.6  static int
     1.7 +SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
     1.8 +                       int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
     1.9 +{
    1.10 +    unsigned inva = 0xff - a;
    1.11 +
    1.12 +    switch (blendMode) {
    1.13 +    case SDL_BLENDMODE_BLEND:
    1.14 +        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888);
    1.15 +        break;
    1.16 +    case SDL_BLENDMODE_ADD:
    1.17 +        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888);
    1.18 +        break;
    1.19 +    case SDL_BLENDMODE_MOD:
    1.20 +        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888);
    1.21 +        break;
    1.22 +    default:
    1.23 +        BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888);
    1.24 +        break;
    1.25 +    }
    1.26 +    return 0;
    1.27 +}
    1.28 +
    1.29 +static int
    1.30  SDL_BlendLine_RGB(SDL_Surface * dst, int x1, int y1, int x2, int y2,
    1.31                    int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    1.32  {
    1.33 @@ -215,6 +238,9 @@
    1.34              if (!fmt->Amask) {
    1.35                  return SDL_BlendLine_RGB888(dst, x1, y1, x2, y2, blendMode, r,
    1.36                                              g, b, a);
    1.37 +            } else {
    1.38 +                return SDL_BlendLine_ARGB8888(dst, x1, y1, x2, y2, blendMode,
    1.39 +                                              r, g, b, a);
    1.40              }
    1.41              break;
    1.42          }
     2.1 --- a/src/video/SDL_blendrect.c	Sun Dec 21 08:28:25 2008 +0000
     2.2 +++ b/src/video/SDL_blendrect.c	Sun Dec 21 08:55:06 2008 +0000
     2.3 @@ -94,6 +94,29 @@
     2.4  }
     2.5  
     2.6  static int
     2.7 +SDL_BlendRect_ARGB8888(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
     2.8 +                       Uint8 r, Uint8 g, Uint8 b, Uint8 a)
     2.9 +{
    2.10 +    unsigned inva = 0xff - a;
    2.11 +
    2.12 +    switch (blendMode) {
    2.13 +    case SDL_BLENDMODE_BLEND:
    2.14 +        BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
    2.15 +        break;
    2.16 +    case SDL_BLENDMODE_ADD:
    2.17 +        BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
    2.18 +        break;
    2.19 +    case SDL_BLENDMODE_MOD:
    2.20 +        BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
    2.21 +        break;
    2.22 +    default:
    2.23 +        BLENDRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
    2.24 +        break;
    2.25 +    }
    2.26 +    return 0;
    2.27 +}
    2.28 +
    2.29 +static int
    2.30  SDL_BlendRect_RGB(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
    2.31                    Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    2.32  {
    2.33 @@ -217,6 +240,9 @@
    2.34              if (!fmt->Amask) {
    2.35                  return SDL_BlendRect_RGB888(dst, dstrect, blendMode, r, g, b,
    2.36                                              a);
    2.37 +            } else {
    2.38 +                return SDL_BlendRect_ARGB8888(dst, dstrect, blendMode, r, g,
    2.39 +                                              b, a);
    2.40              }
    2.41              break;
    2.42          }
     3.1 --- a/src/video/SDL_blit.h	Sun Dec 21 08:28:25 2008 +0000
     3.2 +++ b/src/video/SDL_blit.h	Sun Dec 21 08:55:06 2008 +0000
     3.3 @@ -236,6 +236,10 @@
     3.4  {									\
     3.5  	Pixel = (r<<16)|(g<<8)|b;					\
     3.6  }
     3.7 +#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a)				\
     3.8 +{									\
     3.9 +	Pixel = (a<<24)|(r<<16)|(g<<8)|b;				\
    3.10 +}
    3.11  #define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) 				\
    3.12  {									\
    3.13  	switch (bpp) {							\
     4.1 --- a/src/video/SDL_draw.h	Sun Dec 21 08:28:25 2008 +0000
     4.2 +++ b/src/video/SDL_draw.h	Sun Dec 21 08:55:06 2008 +0000
     4.3 @@ -165,6 +165,37 @@
     4.4      DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
     4.5  
     4.6  /*
     4.7 + * Define draw operators for ARGB8888
     4.8 + */
     4.9 +
    4.10 +#define DRAW_SETPIXEL_ARGB8888 \
    4.11 +    DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
    4.12 +
    4.13 +#define DRAW_SETPIXEL_BLEND_ARGB8888 \
    4.14 +    DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
    4.15 +                        ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
    4.16 +
    4.17 +#define DRAW_SETPIXEL_ADD_ARGB8888 \
    4.18 +    DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
    4.19 +                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
    4.20 +
    4.21 +#define DRAW_SETPIXEL_MOD_ARGB8888 \
    4.22 +    DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
    4.23 +                      ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
    4.24 +
    4.25 +#define DRAW_SETPIXELXY_ARGB8888(x, y) \
    4.26 +    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
    4.27 +
    4.28 +#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
    4.29 +    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
    4.30 +
    4.31 +#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
    4.32 +    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
    4.33 +
    4.34 +#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
    4.35 +    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
    4.36 +
    4.37 +/*
    4.38   * Define draw operators for general RGB
    4.39   */
    4.40