# HG changeset patch # User Sam Lantinga # Date 1229849706 0 # Node ID a0c837a16e4c19ff845240bfa731f60a40f50b7c # Parent e40448bc77275a4a06386fc428e89294d5860303 Added ARGB optimized case for Mac OS X diff -r e40448bc7727 -r a0c837a16e4c src/video/SDL_blendline.c --- a/src/video/SDL_blendline.c Sun Dec 21 08:28:25 2008 +0000 +++ b/src/video/SDL_blendline.c Sun Dec 21 08:55:06 2008 +0000 @@ -93,6 +93,29 @@ } 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 @@ 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; } diff -r e40448bc7727 -r a0c837a16e4c src/video/SDL_blendrect.c --- a/src/video/SDL_blendrect.c Sun Dec 21 08:28:25 2008 +0000 +++ b/src/video/SDL_blendrect.c Sun Dec 21 08:55:06 2008 +0000 @@ -94,6 +94,29 @@ } 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 @@ 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; } diff -r e40448bc7727 -r a0c837a16e4c src/video/SDL_blit.h --- a/src/video/SDL_blit.h Sun Dec 21 08:28:25 2008 +0000 +++ b/src/video/SDL_blit.h Sun Dec 21 08:55:06 2008 +0000 @@ -236,6 +236,10 @@ { \ 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) { \ diff -r e40448bc7727 -r a0c837a16e4c src/video/SDL_draw.h --- a/src/video/SDL_draw.h Sun Dec 21 08:28:25 2008 +0000 +++ b/src/video/SDL_draw.h Sun Dec 21 08:55:06 2008 +0000 @@ -165,6 +165,37 @@ 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 */