Hi
In current code is only alpha == 255 check. This code speedup Alpha
blit by adding alpha == 0 check. This help when you have a lot of
pixels with A == 0 ( full transparent ).
Rafal
-------------- next part --------------
diff -u -r SDL12/src/video/SDL_blit_A.c SDL12a/src/video/SDL_blit_A.c
— SDL12/src/video/SDL_blit_A.c Wed Mar 6 12:23:02 2002
+++ SDL12a/src/video/SDL_blit_A.c Sat Feb 15 19:26:01 2003
@@ -278,9 +278,10 @@
compositioning used (>>8 instead of /255) doesn’t handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
-
if(alpha == SDL_ALPHA_OPAQUE) {
-
if(alpha) {
-
if(alpha == SDL_ALPHA_OPAQUE) { *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000);
-
} else {
-
} else { /* * take out the middle component (green), and process * the other two in parallel. One multiply less.
@@ -294,6 +295,7 @@
d &= 0xff00;
d = (d + ((s - d) * alpha >> 8)) & 0xff00;
*dstp = d1 | d | dalpha;
-
} } ++srcp; ++dstp;
@@ -500,10 +502,11 @@
compositioning used (>>8 instead of /255) doesn’t handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
-
if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
-
if(alpha) {
-
if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { *dstp = (s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f);
-
} else {
-
} else { Uint32 d = *dstp; /* * convert source and destination to G0RAB65565
@@ -515,6 +518,7 @@
d += (s - d) * alpha >> 5;
d &= 0x07e0f81f;
*dstp = d | d >> 16;
-
} } srcp++; dstp++;
@@ -543,10 +547,11 @@
compositioning used (>>8 instead of /255) doesn’t handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
-
if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
-
if(alpha) {
-
if(alpha == (SDL_ALPHA_OPAQUE >> 3)) { *dstp = (s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f);
-
} else {
-
} else { Uint32 d = *dstp; /* * convert source and destination to G0RAB65565
@@ -558,6 +563,7 @@
d += (s - d) * alpha >> 5;
d &= 0x03e07c1f;
*dstp = d | d >> 16;
-
} } srcp++; dstp++;
@@ -583,7 +589,8 @@
unsigned sA = srcfmt->alpha;
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
- while ( height-- ) {
- if(sA) {
-
while ( height-- ) { DUFFS_LOOP4( { Uint32 pixel;
@@ -603,6 +610,7 @@
width);
src += srcskip;
dst += dstskip;
-
}}
}
@@ -634,7 +642,7 @@
unsigned dG;
unsigned dB;
RETRIEVE_RGB_PIXEL(src, srcbpp, pixel);
-
if(pixel != ckey) {
-
if(sA && pixel != ckey) { RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB); DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB); ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
@@ -686,9 +694,11 @@
unsigned sA;
unsigned dA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA);
-
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
-
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
-
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
-
if(sA) {
-
DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
-
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
-
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
-
} src += srcbpp; dst += dstbpp; },