New surface alpha blend code

Hi all

Could someone test it for me ?
I get strenge time results.

Rafal----------------------------------------------------------------------
Biznesowy portal INTERIA.PL >>> http://link.interia.pl/f170c
-------------- next part --------------
diff -u -r SDL12/src/video/SDL_blit_A.c SDL12b/src/video/SDL_blit_A.c
ā€” SDL12/src/video/SDL_blit_A.c Wed Mar 6 12:23:02 2002
+++ SDL12b/src/video/SDL_blit_A.c Wed Apr 2 16:24:10 2003
@@ -216,7 +216,7 @@
dstp += dstskip;
}
}

+#if 0
/* fast RGB888->(A)RGB888 blending with surface alpha */
static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
{
@@ -256,6 +256,119 @@
}
}

+#else
+
+#ifdef USE_DUFFS_LOOP
+
+/* 2 - times unrolled loop */
+#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \

  •   		double_pixel_copy_increment, width)	\
    

+{ int n; \

  • if( width & 1 ) { \
  •   pixel_copy_increment;					\
    
  •   n = (( width - 1 ) + 2) / 4;				\
    
  • } else { \
  •   n = ( width + 2 ) / 4;					\
    
  • } \
  • if ( width > 1 ) \
  •   switch( width & 2 ) {					\
    
  •   case 0: do {	double_pixel_copy_increment;		\
    
  •   case 1:		double_pixel_copy_increment;		\
    
  •       } while ( --n > 0 );				\
    
  •   }								\
    

+}
+
+#else
+
+#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \

  •   	 double_pixel_copy_increment, width)		\
    

+{ int n = width; \

  • if( n & 1 ) { \
  • pixel_copy_increment; \
  • nā€“; \
  • } \
  • for(; n > 0; --n) { \
  • double_pixel_copy_increment; \
  • }
    +}

+#endif
+
+/* fast RGB888->(A)RGB888 blending with surface alpha */
+static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
+{

  • unsigned alpha = info->src->alpha;
  • if(alpha == 128) {
  •   BlitRGBtoRGBSurfaceAlpha128(info);
    
  • } else {
  •   int width = info->d_width;
    
  •   int height = info->d_height;
    
  •   Uint32 *srcp = (Uint32 *)info->s_pixels;
    
  •   int srcskip = info->s_skip >> 2;
    
  •   Uint32 *dstp = (Uint32 *)info->d_pixels;
    
  •   int dstskip = info->d_skip >> 2;
    
  •   while(height--) {
    
  •   	DUFFS_LOOP_DOUBLE2({
    
  •   		/* One Pixel Blend */
    
  •   		Uint32 s;
    
  •   		Uint32 d;
    
  •   		Uint32 s1;
    
  •   		Uint32 d1;
    
  •   		s = *srcp;
    
  •   		d = *dstp;
    
  •   		s1 = s & 0xff00ff;
    
  •   		d1 = d & 0xff00ff;
    
  •   		d1 = (d1 + ((s1 - d1) * alpha >> 8))
    
  •   		     & 0xff00ff;
    
  •   		s &= 0xff00;
    
  •   		d &= 0xff00;
    
  •   		d = (d + ((s - d) * alpha >> 8)) & 0xff00;
    
  •   		*dstp = d1 | d | 0xff000000;
    
  •   		++srcp;
    
  •   		++dstp;
    
  •   	},{
    
  •   	        /* Two Pixels Blend */
    
  •   		Uint32 s;
    
  •   		Uint32 d;
    
  •   		Uint32 s1;
    
  •   		Uint32 d1;
    
  •   		s = *srcp;
    
  •   		d = *dstp;
    
  •   		s1 = s & 0xff00ff;
    
  •   		d1 = d & 0xff00ff;
    
  •   		d1 += (s1 - d1) * alpha >> 8;
    
  •   		d1 &= 0xff00ff;
    
  •   		s = ((s & 0xff00) >> 8) | 
    
  •   			((srcp[1] & 0xff00) << 8);
    
  •   		d = ((d & 0xff00) >> 8) |
    
  •   			((dstp[1] & 0xff00) << 8);
    
  •   		d += (s - d) * alpha >> 8;
    
  •   		d &= 0x00ff00ff;
    
  •   		*dstp++ = d1 | ((d << 8) & 0xff00) | 0xff000000;
    
  •   		++srcp;
    
  •   		s1 = srcp[0] & 0xff00ff;
    
  •   		d1 = dstp[0] & 0xff00ff;
    
  •   		d1 += (s1 - d1) * alpha >> 8;
    
  •   		d1 &= 0xff00ff;
    
  •   		*dstp = d1 | ((d >> 8) & 0xff00) | 0xff000000;
    
  •   		++srcp;
    
  •   		++dstp;
    
  •   	}, width);
    
  •   	srcp += srcskip;
    
  •   	dstp += dstskip;
    
  •   }
    
  • }
    +}

+#endif
+
/* fast ARGB888->(A)RGB888 blending with pixel alpha */
static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
{