src/video/SDL_blit.h
changeset 2824 4dba7aa7ea77
parent 2267 c785543d1843
child 2853 6258fa7cd300
     1.1 --- a/src/video/SDL_blit.h	Tue Dec 02 17:10:05 2008 +0000
     1.2 +++ b/src/video/SDL_blit.h	Tue Dec 02 17:14:04 2008 +0000
     1.3 @@ -165,7 +165,7 @@
     1.4  									   \
     1.5  		case 3: {						   \
     1.6  		        Uint8 *B = (Uint8 *)(buf);			   \
     1.7 -			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
     1.8 +			if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
     1.9  			        Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
    1.10  			} else {					   \
    1.11  			        Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
    1.12 @@ -178,38 +178,42 @@
    1.13  		break;							   \
    1.14  									   \
    1.15  		default:						   \
    1.16 -			Pixel = 0; /* appease gcc */			   \
    1.17 +		        Pixel; /* stop gcc complaints */		   \
    1.18  		break;							   \
    1.19  	}								   \
    1.20 -} while(0)
    1.21 +} while (0)
    1.22  
    1.23  #define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)			   \
    1.24  do {									   \
    1.25  	switch (bpp) {							   \
    1.26  		case 2:							   \
    1.27  			Pixel = *((Uint16 *)(buf));			   \
    1.28 +			RGB_FROM_PIXEL(Pixel, fmt, r, g, b);		   \
    1.29  		break;							   \
    1.30  									   \
    1.31 -		case 3: {						   \
    1.32 -		        Uint8 *B = (Uint8 *)buf;			   \
    1.33 -			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
    1.34 -			        Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
    1.35 +		case 3:	{						   \
    1.36 +                        if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
    1.37 +			        r = *((buf)+fmt->Rshift/8);		   \
    1.38 +				g = *((buf)+fmt->Gshift/8);		   \
    1.39 +				b = *((buf)+fmt->Bshift/8);		   \
    1.40  			} else {					   \
    1.41 -			        Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
    1.42 +			        r = *((buf)+2-fmt->Rshift/8);		   \
    1.43 +				g = *((buf)+2-fmt->Gshift/8);		   \
    1.44 +				b = *((buf)+2-fmt->Bshift/8);		   \
    1.45  			}						   \
    1.46  		}							   \
    1.47  		break;							   \
    1.48  									   \
    1.49  		case 4:							   \
    1.50  			Pixel = *((Uint32 *)(buf));			   \
    1.51 +			RGB_FROM_PIXEL(Pixel, fmt, r, g, b);		   \
    1.52  		break;							   \
    1.53  									   \
    1.54 -	        default:						   \
    1.55 -		        Pixel = 0;	/* prevent gcc from complaining */ \
    1.56 +		default:						   \
    1.57 +		        Pixel; /* stop gcc complaints */		   \
    1.58  		break;							   \
    1.59  	}								   \
    1.60 -	RGB_FROM_PIXEL(Pixel, fmt, r, g, b);				   \
    1.61 -} while(0)
    1.62 +} while (0)
    1.63  
    1.64  /* Assemble R-G-B values into a specified pixel format and store them */
    1.65  #define PIXEL_FROM_RGB(Pixel, fmt, r, g, b)				\
    1.66 @@ -242,7 +246,7 @@
    1.67  		break;							\
    1.68  									\
    1.69  		case 3: {						\
    1.70 -                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
    1.71 +                        if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
    1.72  			        *((buf)+fmt->Rshift/8) = r;		\
    1.73  				*((buf)+fmt->Gshift/8) = g;		\
    1.74  				*((buf)+fmt->Bshift/8) = b;		\
    1.75 @@ -277,7 +281,7 @@
    1.76  		break;							\
    1.77  									\
    1.78  		case 3: {						\
    1.79 -                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
    1.80 +                        if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
    1.81  			        *((buf)+fmt->Rshift/8) = r;		\
    1.82  				*((buf)+fmt->Gshift/8) = g;		\
    1.83  				*((buf)+fmt->Bshift/8) = b;		\
    1.84 @@ -342,29 +346,33 @@
    1.85  	switch (bpp) {							   \
    1.86  		case 2:							   \
    1.87  			Pixel = *((Uint16 *)(buf));			   \
    1.88 +			RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a);	   \
    1.89  		break;							   \
    1.90  									   \
    1.91 -		case 3:	{/* FIXME: broken code (no alpha) */		   \
    1.92 -		        Uint8 *b = (Uint8 *)buf;			   \
    1.93 -			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
    1.94 -			        Pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
    1.95 +		case 3:	{						   \
    1.96 +                        if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
    1.97 +			        r = *((buf)+fmt->Rshift/8);		   \
    1.98 +				g = *((buf)+fmt->Gshift/8);		   \
    1.99 +				b = *((buf)+fmt->Bshift/8);		   \
   1.100  			} else {					   \
   1.101 -			        Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
   1.102 +			        r = *((buf)+2-fmt->Rshift/8);		   \
   1.103 +				g = *((buf)+2-fmt->Gshift/8);		   \
   1.104 +				b = *((buf)+2-fmt->Bshift/8);		   \
   1.105  			}						   \
   1.106 +			a = 0xFF;					   \
   1.107  		}							   \
   1.108  		break;							   \
   1.109  									   \
   1.110  		case 4:							   \
   1.111  			Pixel = *((Uint32 *)(buf));			   \
   1.112 +			RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a);	   \
   1.113  		break;							   \
   1.114  									   \
   1.115  		default:						   \
   1.116 -		        Pixel = 0; /* stop gcc complaints */		   \
   1.117 +		        Pixel; /* stop gcc complaints */		   \
   1.118  		break;							   \
   1.119  	}								   \
   1.120 -	RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a);			   \
   1.121 -	Pixel &= ~fmt->Amask;						   \
   1.122 -} while(0)
   1.123 +} while (0)
   1.124  
   1.125  /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
   1.126  #define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a)				\
   1.127 @@ -385,8 +393,8 @@
   1.128  		}							\
   1.129  		break;							\
   1.130  									\
   1.131 -		case 3: { /* FIXME: broken code (no alpha) */		\
   1.132 -                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
   1.133 +		case 3: {						\
   1.134 +                        if (SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
   1.135  			        *((buf)+fmt->Rshift/8) = r;		\
   1.136  				*((buf)+fmt->Gshift/8) = g;		\
   1.137  				*((buf)+fmt->Bshift/8) = b;		\