Fixed alpha composition when destination alpha is transparent.
authorSam Lantinga <slouken@libsdl.org>
Fri, 16 Aug 2013 09:20:33 -0700
changeset 76410cd36d20df2b
parent 7640 38284657fc79
child 7642 303214c66577
Fixed alpha composition when destination alpha is transparent.

Jianyu Guan

I found I make a big mistake that when dstA==0, I just simply let *dstp=*srcp and forgot to make dstRGB = srcRGB*srcA.

The if consition "(*dstp & amask) == 0" in BlitRGBtoRGBPixelAlphaMMX and BlitRGBtoRGBPixelAlphaMMX3dNow should be removed.
src/video/SDL_blit_A.c
     1.1 --- a/src/video/SDL_blit_A.c	Fri Aug 16 06:59:19 2013 -0700
     1.2 +++ b/src/video/SDL_blit_A.c	Fri Aug 16 09:20:33 2013 -0700
     1.3 @@ -352,7 +352,7 @@
     1.4  		Uint32 alpha = *srcp & amask;
     1.5  		if (alpha == 0) {
     1.6  			/* do nothing */
     1.7 -		} else if (alpha == amask || (*dstp & amask) == 0) {
     1.8 +		} else if (alpha == amask) {
     1.9  			*dstp = *srcp;
    1.10  		} else {
    1.11  			src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/
    1.12 @@ -545,7 +545,7 @@
    1.13  		alpha = *srcp & amask;
    1.14  		if (alpha == 0) {
    1.15  			/* do nothing */
    1.16 -		} else if (alpha == amask || (*dstp & amask) == 0) {
    1.17 +		} else if (alpha == amask) {
    1.18  			*dstp = *srcp;
    1.19  		} else {
    1.20  			src1 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src1 (0000ARGB)*/