Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_A.c @ 3363:90aec03bf9fd
Fixed bug #627
Increased accuracy of alpha blend calculation
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 10 Oct 2009 07:48:57 +0000 |
parents | ff602fdfdedc |
children | baeff5f3203b |
comparison
equal
deleted
inserted
replaced
3362:4e83cdb58134 | 3363:90aec03bf9fd |
---|---|
627 if(sA) { \ | 627 if(sA) { \ |
628 unsigned short dstpixel = *((unsigned short *)dst); \ | 628 unsigned short dstpixel = *((unsigned short *)dst); \ |
629 dR = (dstpixel >> 8) & 0xf8; \ | 629 dR = (dstpixel >> 8) & 0xf8; \ |
630 dG = (dstpixel >> 3) & 0xfc; \ | 630 dG = (dstpixel >> 3) & 0xfc; \ |
631 dB = (dstpixel << 3) & 0xf8; \ | 631 dB = (dstpixel << 3) & 0xf8; \ |
632 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ | 632 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
633 *((unsigned short *)dst) = ( \ | 633 *((unsigned short *)dst) = ( \ |
634 ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \ | 634 ((dR & 0xf8) << 8) | ((dG & 0xfc) << 3) | (dB >> 3) \ |
635 ); \ | 635 ); \ |
636 } \ | 636 } \ |
637 src += 4; \ | 637 src += 4; \ |
773 unsigned sR, sG, sB, dR, dG, dB; \ | 773 unsigned sR, sG, sB, dR, dG, dB; \ |
774 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \ | 774 RETRIEVE_RGB_PIXEL(((Uint8 *)srcp), 4, Pixel); \ |
775 if(sA && Pixel != ckey) { \ | 775 if(sA && Pixel != ckey) { \ |
776 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \ | 776 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \ |
777 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ | 777 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ |
778 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ | 778 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
779 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ | 779 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ |
780 } \ | 780 } \ |
781 dstp++; \ | 781 dstp++; \ |
782 srcp++; \ | 782 srcp++; \ |
783 widthvar--; \ | 783 widthvar--; \ |
880 Uint32 Pixel; \ | 880 Uint32 Pixel; \ |
881 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \ | 881 unsigned sR, sG, sB, dR, dG, dB, sA, dA; \ |
882 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \ | 882 DISEMBLE_RGBA((Uint8 *)srcp, 4, srcfmt, Pixel, sR, sG, sB, sA); \ |
883 if(sA) { \ | 883 if(sA) { \ |
884 DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \ | 884 DISEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, Pixel, dR, dG, dB, dA); \ |
885 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ | 885 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
886 ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \ | 886 ASSEMBLE_RGBA((Uint8 *)dstp, 4, dstfmt, dR, dG, dB, dA); \ |
887 } \ | 887 } \ |
888 ++srcp; \ | 888 ++srcp; \ |
889 ++dstp; \ | 889 ++dstp; \ |
890 widthvar--; \ | 890 widthvar--; \ |
1080 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ | 1080 #define ONE_PIXEL_BLEND(condition, widthvar) while ((condition)) { \ |
1081 Uint32 Pixel; \ | 1081 Uint32 Pixel; \ |
1082 unsigned sR, sG, sB, dR, dG, dB; \ | 1082 unsigned sR, sG, sB, dR, dG, dB; \ |
1083 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \ | 1083 DISEMBLE_RGB(((Uint8 *)srcp), 4, srcfmt, Pixel, sR, sG, sB); \ |
1084 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ | 1084 DISEMBLE_RGB(((Uint8 *)dstp), 4, dstfmt, Pixel, dR, dG, dB); \ |
1085 ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ | 1085 ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB); \ |
1086 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ | 1086 ASSEMBLE_RGBA(((Uint8 *)dstp), 4, dstfmt, dR, dG, dB, dA); \ |
1087 ++srcp; \ | 1087 ++srcp; \ |
1088 ++dstp; \ | 1088 ++dstp; \ |
1089 widthvar--; \ | 1089 widthvar--; \ |
1090 } | 1090 } |