diff src/video/SDL_blit.h @ 1047:ffaaf7ecf685

Altivec-optimized blitters! Vast majority of this work is compliments of Bob Ippolito. http://www.devolution.com/pipermail/sdl/2005-February/067466.html and many other posts.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 17 Apr 2005 10:19:22 +0000
parents b8d311d90021
children 2651158f59b8
line wrap: on
line diff
--- a/src/video/SDL_blit.h	Sun Apr 17 10:16:30 2005 +0000
+++ b/src/video/SDL_blit.h	Sun Apr 17 10:19:22 2005 +0000
@@ -374,6 +374,20 @@
 	dB = (((sB-dB)*(A))>>8)+dB;		\
 } while(0)
 
+/* Blend the RGB values of two pixels based on a source alpha value */
+#define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB)	\
+do {						\
+    unsigned tR, tG, tB, tA; \
+    tA = 255 - sA; \
+    tR = 1 + (sR * sA) + (dR * tA); \
+    dR = (tR + (tR >> 8)) >> 8; \
+    tG = 1 + (sG * sA) + (dG * tA); \
+    dG = (tG + (tG >> 8)) >> 8; \
+    tB = 1 + (sB * sA) + (dB * tA); \
+    dB = (tB + (tB >> 8)) >> 8; \
+} while(0)
+
+
 /* This is a very useful loop for optimizing blitters */
 #if defined(_MSC_VER) && (_MSC_VER == 1300)
 /* There's a bug in the Visual C++ 7 optimizer when compiling this code */