Commit c37ad66b authored by Sam Lantinga's avatar Sam Lantinga

Added ARGB optimized case for Mac OS X

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403361
parent d95e51d2
...@@ -92,6 +92,29 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, ...@@ -92,6 +92,29 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
return 0; 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 static int
SDL_BlendLine_RGB(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendLine_RGB(SDL_Surface * dst, int x1, int y1, int x2, int y2,
int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) 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, ...@@ -215,6 +238,9 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
if (!fmt->Amask) { if (!fmt->Amask) {
return SDL_BlendLine_RGB888(dst, x1, y1, x2, y2, blendMode, r, return SDL_BlendLine_RGB888(dst, x1, y1, x2, y2, blendMode, r,
g, b, a); g, b, a);
} else {
return SDL_BlendLine_ARGB8888(dst, x1, y1, x2, y2, blendMode,
r, g, b, a);
} }
break; break;
} }
......
...@@ -93,6 +93,29 @@ SDL_BlendRect_RGB888(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, ...@@ -93,6 +93,29 @@ SDL_BlendRect_RGB888(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
return 0; 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 static int
SDL_BlendRect_RGB(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, SDL_BlendRect_RGB(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode,
Uint8 r, Uint8 g, Uint8 b, Uint8 a) Uint8 r, Uint8 g, Uint8 b, Uint8 a)
...@@ -217,6 +240,9 @@ SDL_BlendRect(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, Uint8 r, ...@@ -217,6 +240,9 @@ SDL_BlendRect(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, Uint8 r,
if (!fmt->Amask) { if (!fmt->Amask) {
return SDL_BlendRect_RGB888(dst, dstrect, blendMode, r, g, b, return SDL_BlendRect_RGB888(dst, dstrect, blendMode, r, g, b,
a); a);
} else {
return SDL_BlendRect_ARGB8888(dst, dstrect, blendMode, r, g,
b, a);
} }
break; break;
} }
......
...@@ -236,6 +236,10 @@ do { \ ...@@ -236,6 +236,10 @@ do { \
{ \ { \
Pixel = (r<<16)|(g<<8)|b; \ 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) \ #define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
{ \ { \
switch (bpp) { \ switch (bpp) { \
......
...@@ -164,6 +164,37 @@ do { \ ...@@ -164,6 +164,37 @@ do { \
#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \ #define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888) 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 * Define draw operators for general RGB
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment