Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added ARGB optimized case for Mac OS X

  • Loading branch information
slouken committed Dec 21, 2008
1 parent 2d2977c commit 1ba19cde07949d7fdacfd31b48fd276495a94d7b
Showing with 87 additions and 0 deletions.
  1. +26 −0 src/video/SDL_blendline.c
  2. +26 −0 src/video/SDL_blendrect.c
  3. +4 −0 src/video/SDL_blit.h
  4. +31 −0 src/video/SDL_draw.h
@@ -92,6 +92,29 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
return 0;
}

static int
SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;

switch (blendMode) {
case SDL_BLENDMODE_BLEND:
BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888);
break;
case SDL_BLENDMODE_ADD:
BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888);
break;
case SDL_BLENDMODE_MOD:
BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888);
break;
default:
BRESENHAM(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888);
break;
}
return 0;
}

static int
SDL_BlendLine_RGB(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
@@ -215,6 +238,9 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
if (!fmt->Amask) {
return SDL_BlendLine_RGB888(dst, x1, y1, x2, y2, blendMode, r,
g, b, a);
} else {
return SDL_BlendLine_ARGB8888(dst, x1, y1, x2, y2, blendMode,
r, g, b, a);
}
break;
}
@@ -93,6 +93,29 @@ SDL_BlendRect_RGB888(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
return 0;
}

static int
SDL_BlendRect_ARGB8888(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
{
unsigned inva = 0xff - a;

switch (blendMode) {
case SDL_BLENDMODE_BLEND:
BLENDRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
break;
case SDL_BLENDMODE_ADD:
BLENDRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
break;
case SDL_BLENDMODE_MOD:
BLENDRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
break;
default:
BLENDRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
break;
}
return 0;
}

static int
SDL_BlendRect_RGB(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
@@ -217,6 +240,9 @@ SDL_BlendRect(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, Uint8 r,
if (!fmt->Amask) {
return SDL_BlendRect_RGB888(dst, dstrect, blendMode, r, g, b,
a);
} else {
return SDL_BlendRect_ARGB8888(dst, dstrect, blendMode, r, g,
b, a);
}
break;
}
@@ -236,6 +236,10 @@ do { \
{ \
Pixel = (r<<16)|(g<<8)|b; \
}
#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \
{ \
Pixel = (a<<24)|(r<<16)|(g<<8)|b; \
}
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
{ \
switch (bpp) { \
@@ -164,6 +164,37 @@ do { \
#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)

/*
* Define draw operators for ARGB8888
*/

#define DRAW_SETPIXEL_ARGB8888 \
DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))

#define DRAW_SETPIXEL_BLEND_ARGB8888 \
DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))

#define DRAW_SETPIXEL_ADD_ARGB8888 \
DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))

#define DRAW_SETPIXEL_MOD_ARGB8888 \
DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))

#define DRAW_SETPIXELXY_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)

#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)

#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)

#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)

/*
* Define draw operators for general RGB
*/

0 comments on commit 1ba19cd

Please sign in to comment.