src/video/SDL_blit.h
changeset 3035 ff602fdfdedc
parent 2899 a0c837a16e4c
child 3054 8d93bfecb9dc
     1.1 --- a/src/video/SDL_blit.h	Tue Jan 13 03:53:22 2009 +0000
     1.2 +++ b/src/video/SDL_blit.h	Tue Jan 13 07:20:55 2009 +0000
     1.3 @@ -476,48 +476,7 @@
     1.4  	case 3:		pixel_copy_increment;				\
     1.5  	case 2:		pixel_copy_increment;				\
     1.6  	case 1:		pixel_copy_increment;				\
     1.7 -		} while ( --n > 0 );					\
     1.8 -	}								\
     1.9 -}
    1.10 -
    1.11 -/* 2 - times unrolled loop */
    1.12 -#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment,			\
    1.13 -				double_pixel_copy_increment, width)	\
    1.14 -{ int n, w = width;							\
    1.15 -	if( w & 1 ) {							\
    1.16 -	    pixel_copy_increment;					\
    1.17 -	    w--;							\
    1.18 -	}								\
    1.19 -	if ( w > 0 )	{						\
    1.20 -	    n = ( w + 2) / 4;						\
    1.21 -	    switch( w & 2 ) {						\
    1.22 -	    case 0: do {	double_pixel_copy_increment;		\
    1.23 -	    case 2:		double_pixel_copy_increment;		\
    1.24 -		    } while ( --n > 0 );					\
    1.25 -	    }								\
    1.26 -	}								\
    1.27 -}
    1.28 -
    1.29 -/* 2 - times unrolled loop 4 pixels */
    1.30 -#define DUFFS_LOOP_QUATRO2(pixel_copy_increment,			\
    1.31 -				double_pixel_copy_increment,		\
    1.32 -				quatro_pixel_copy_increment, width)	\
    1.33 -{ int n, w = width;								\
    1.34 -        if(w & 1) {							\
    1.35 -	  pixel_copy_increment;						\
    1.36 -	  w--;								\
    1.37 -	}								\
    1.38 -	if(w & 2) {							\
    1.39 -	  double_pixel_copy_increment;					\
    1.40 -	  w -= 2;							\
    1.41 -	}								\
    1.42 -	if ( w > 0 ) {							\
    1.43 -	    n = ( w + 7 ) / 8;						\
    1.44 -	    switch( w & 4 ) {						\
    1.45 -	    case 0: do {	quatro_pixel_copy_increment;		\
    1.46 -	    case 4:		quatro_pixel_copy_increment;		\
    1.47 -		    } while ( --n > 0 );					\
    1.48 -	    }								\
    1.49 +		} while (--n > 0);					\
    1.50  	}								\
    1.51  }
    1.52  
    1.53 @@ -525,40 +484,28 @@
    1.54  #define DUFFS_LOOP(pixel_copy_increment, width)				\
    1.55  	DUFFS_LOOP8(pixel_copy_increment, width)
    1.56  
    1.57 -#else
    1.58 -
    1.59 -/* Don't use Duff's device to unroll loops */
    1.60 -#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment,			\
    1.61 -			 double_pixel_copy_increment, width)		\
    1.62 -{ int n = width;								\
    1.63 -    if( n & 1 ) {							\
    1.64 -	pixel_copy_increment;						\
    1.65 -	n--;								\
    1.66 -    }									\
    1.67 -    n=n>>1;								\
    1.68 -    for(; n > 0; --n) {   						\
    1.69 -	double_pixel_copy_increment;					\
    1.70 -    }									\
    1.71 +/* Special version of Duff's device for even more optimization */
    1.72 +#define DUFFS_LOOP_124(pixel_copy_increment1,				\
    1.73 +                       pixel_copy_increment2,				\
    1.74 +                       pixel_copy_increment4, width)			\
    1.75 +{ int n = width;							\
    1.76 +	if (n & 1) {							\
    1.77 +		pixel_copy_increment1; n -= 1;				\
    1.78 +	}								\
    1.79 +	if (n & 2) {							\
    1.80 +		pixel_copy_increment2; n -= 2;				\
    1.81 +	}								\
    1.82 +	if (n) {							\
    1.83 +		n = (n+7)/ 8;						\
    1.84 +		switch (n & 4) {					\
    1.85 +		case 0: do {	pixel_copy_increment4;			\
    1.86 +		case 4:		pixel_copy_increment4;			\
    1.87 +			} while (--n > 0);				\
    1.88 +		}							\
    1.89 +	}								\
    1.90  }
    1.91  
    1.92 -/* Don't use Duff's device to unroll loops */
    1.93 -#define DUFFS_LOOP_QUATRO2(pixel_copy_increment,			\
    1.94 -				double_pixel_copy_increment,		\
    1.95 -				quatro_pixel_copy_increment, width)	\
    1.96 -{ int n = width;								\
    1.97 -        if(n & 1) {							\
    1.98 -	  pixel_copy_increment;						\
    1.99 -	  n--;								\
   1.100 -	}								\
   1.101 -	if(n & 2) {							\
   1.102 -	  double_pixel_copy_increment;					\
   1.103 -	  n -= 2;							\
   1.104 -	}								\
   1.105 -	n=n>>2;								\
   1.106 -	for(; n > 0; --n) {   						\
   1.107 -	  quatro_pixel_copy_increment;					\
   1.108 -        }								\
   1.109 -}
   1.110 +#else
   1.111  
   1.112  /* Don't use Duff's device to unroll loops */
   1.113  #define DUFFS_LOOP(pixel_copy_increment, width)				\
   1.114 @@ -571,6 +518,10 @@
   1.115  	DUFFS_LOOP(pixel_copy_increment, width)
   1.116  #define DUFFS_LOOP4(pixel_copy_increment, width)			\
   1.117  	DUFFS_LOOP(pixel_copy_increment, width)
   1.118 +#define DUFFS_LOOP_124(pixel_copy_increment1,				\
   1.119 +                       pixel_copy_increment2,				\
   1.120 +                       pixel_copy_increment4, width)			\
   1.121 +	DUFFS_LOOP(pixel_copy_increment1, width)
   1.122  
   1.123  #endif /* USE_DUFFS_LOOP */
   1.124