comparison src/video/SDL_blit_A.c @ 4293:63b54ddd38ea SDL-1.2

Fixed bug #627 Increased accuracy of alpha blend calculation
author Sam Lantinga <slouken@libsdl.org>
date Sat, 10 Oct 2009 07:48:15 +0000
parents 800f3cb78e45
children
comparison
equal deleted inserted replaced
4292:464126f4c7db 4293:63b54ddd38ea
859 if(sA) { \ 859 if(sA) { \
860 unsigned short dstpixel = *((unsigned short *)dst); \ 860 unsigned short dstpixel = *((unsigned short *)dst); \
861 dR = (dstpixel >> 8) & 0xf8; \ 861 dR = (dstpixel >> 8) & 0xf8; \
862 dG = (dstpixel >> 3) & 0xfc; \ 862 dG = (dstpixel >> 3) & 0xfc; \
863 dB = (dstpixel << 3) & 0xf8; \ 863 dB = (dstpixel << 3) & 0xf8; \
864 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ 864 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
865 *((unsigned short *)dst) = ( \ 865 *((unsigned short *)dst) = ( \
866 ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \ 866 ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \
867 ); \ 867 ); \
868 } \ 868 } \
869 src += 4; \ 869 src += 4; \
992 unsigned sR, sG, sB, dR, dG, dB; \ 992 unsigned sR, sG, sB, dR, dG, dB; \
993 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \ 993 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \
994 if(sA && Pixel != ckey) { \ 994 if(sA && Pixel != ckey) { \
995 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \ 995 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \
996 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ 996 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
997 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ 997 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
998 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ 998 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
999 } \ 999 } \
1000 dstp++; \ 1000 dstp++; \
1001 srcp++; \ 1001 srcp++; \
1002 widthvar--; \ 1002 widthvar--; \
1095 Uint32 Pixel; \ 1095 Uint32 Pixel; \
1096 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \ 1096 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \
1097 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \ 1097 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \
1098 if(sA) { \ 1098 if(sA) { \
1099 DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \ 1099 DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \
1100 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ 1100 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
1101 ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \ 1101 ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \
1102 } \ 1102 } \
1103 ++srcp; \ 1103 ++srcp; \
1104 ++dstp; \ 1104 ++dstp; \
1105 widthvar--; \ 1105 widthvar--; \
1294 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ 1294 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \
1295 Uint32 Pixel; \ 1295 Uint32 Pixel; \
1296 unsigned sR, sG, sB, dR, dG, dB; \ 1296 unsigned sR, sG, sB, dR, dG, dB; \
1297 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \ 1297 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \
1298 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ 1298 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \
1299 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ 1299 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \
1300 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ 1300 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \
1301 ++srcp; \ 1301 ++srcp; \
1302 ++dstp; \ 1302 ++dstp; \
1303 widthvar--; \ 1303 widthvar--; \
1304 } 1304 }