Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added ARGB optimized case for Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 21, 2008
1 parent 2d2977c commit 1ba19cd
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/video/SDL_blendline.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
26 changes: 26 additions & 0 deletions src/video/SDL_blendrect.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/video/SDL_blit.h
Expand Up @@ -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) { \
Expand Down
31 changes: 31 additions & 0 deletions src/video/SDL_draw.h
Expand Up @@ -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
*/
Expand Down

0 comments on commit 1ba19cd

Please sign in to comment.