src/video/SDL_blit.h
changeset 1162 2651158f59b8
parent 1047 ffaaf7ecf685
child 1312 c9b51268668f
     1.1 --- a/src/video/SDL_blit.h	Thu Oct 20 06:53:56 2005 +0000
     1.2 +++ b/src/video/SDL_blit.h	Thu Oct 20 06:55:26 2005 +0000
     1.3 @@ -90,112 +90,112 @@
     1.4  
     1.5  /* Load pixel of the specified format from a buffer and get its R-G-B values */
     1.6  /* FIXME: rescale values to 0..255 here? */
     1.7 -#define RGB_FROM_PIXEL(pixel, fmt, r, g, b)				\
     1.8 +#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b)				\
     1.9  {									\
    1.10 -	r = (((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); 		\
    1.11 -	g = (((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); 		\
    1.12 -	b = (((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); 		\
    1.13 +	r = (((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); 		\
    1.14 +	g = (((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); 		\
    1.15 +	b = (((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); 		\
    1.16  }
    1.17 -#define RGB_FROM_RGB565(pixel, r, g, b)					\
    1.18 +#define RGB_FROM_RGB565(Pixel, r, g, b)					\
    1.19  {									\
    1.20 -	r = (((pixel&0xF800)>>11)<<3);		 			\
    1.21 -	g = (((pixel&0x07E0)>>5)<<2); 					\
    1.22 -	b = ((pixel&0x001F)<<3); 					\
    1.23 +	r = (((Pixel&0xF800)>>11)<<3);		 			\
    1.24 +	g = (((Pixel&0x07E0)>>5)<<2); 					\
    1.25 +	b = ((Pixel&0x001F)<<3); 					\
    1.26  }
    1.27 -#define RGB_FROM_RGB555(pixel, r, g, b)					\
    1.28 +#define RGB_FROM_RGB555(Pixel, r, g, b)					\
    1.29  {									\
    1.30 -	r = (((pixel&0x7C00)>>10)<<3);		 			\
    1.31 -	g = (((pixel&0x03E0)>>5)<<3); 					\
    1.32 -	b = ((pixel&0x001F)<<3); 					\
    1.33 +	r = (((Pixel&0x7C00)>>10)<<3);		 			\
    1.34 +	g = (((Pixel&0x03E0)>>5)<<3); 					\
    1.35 +	b = ((Pixel&0x001F)<<3); 					\
    1.36  }
    1.37 -#define RGB_FROM_RGB888(pixel, r, g, b)					\
    1.38 +#define RGB_FROM_RGB888(Pixel, r, g, b)					\
    1.39  {									\
    1.40 -	r = ((pixel&0xFF0000)>>16);		 			\
    1.41 -	g = ((pixel&0xFF00)>>8);		 			\
    1.42 -	b = (pixel&0xFF);			 			\
    1.43 +	r = ((Pixel&0xFF0000)>>16);		 			\
    1.44 +	g = ((Pixel&0xFF00)>>8);		 			\
    1.45 +	b = (Pixel&0xFF);			 			\
    1.46  }
    1.47 -#define RETRIEVE_RGB_PIXEL(buf, bpp, pixel)				   \
    1.48 +#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel)				   \
    1.49  do {									   \
    1.50  	switch (bpp) {							   \
    1.51  		case 2:							   \
    1.52 -			pixel = *((Uint16 *)(buf));			   \
    1.53 +			Pixel = *((Uint16 *)(buf));			   \
    1.54  		break;							   \
    1.55  									   \
    1.56  		case 3: {						   \
    1.57  		        Uint8 *B = (Uint8 *)(buf);			   \
    1.58  			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
    1.59 -			        pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
    1.60 +			        Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
    1.61  			} else {					   \
    1.62 -			        pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
    1.63 +			        Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
    1.64  			}						   \
    1.65  		}							   \
    1.66  		break;							   \
    1.67  									   \
    1.68  		case 4:							   \
    1.69 -			pixel = *((Uint32 *)(buf));			   \
    1.70 +			Pixel = *((Uint32 *)(buf));			   \
    1.71  		break;							   \
    1.72  									   \
    1.73  		default:						   \
    1.74 -			pixel = 0; /* appease gcc */			   \
    1.75 +			Pixel = 0; /* appease gcc */			   \
    1.76  		break;							   \
    1.77  	}								   \
    1.78  } while(0)
    1.79  
    1.80 -#define DISEMBLE_RGB(buf, bpp, fmt, pixel, r, g, b)			   \
    1.81 +#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)			   \
    1.82  do {									   \
    1.83  	switch (bpp) {							   \
    1.84  		case 2:							   \
    1.85 -			pixel = *((Uint16 *)(buf));			   \
    1.86 +			Pixel = *((Uint16 *)(buf));			   \
    1.87  		break;							   \
    1.88  									   \
    1.89  		case 3: {						   \
    1.90  		        Uint8 *B = (Uint8 *)buf;			   \
    1.91  			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
    1.92 -			        pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
    1.93 +			        Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
    1.94  			} else {					   \
    1.95 -			        pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
    1.96 +			        Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
    1.97  			}						   \
    1.98  		}							   \
    1.99  		break;							   \
   1.100  									   \
   1.101  		case 4:							   \
   1.102 -			pixel = *((Uint32 *)(buf));			   \
   1.103 +			Pixel = *((Uint32 *)(buf));			   \
   1.104  		break;							   \
   1.105  									   \
   1.106  	        default:						   \
   1.107 -		        pixel = 0;	/* prevent gcc from complaining */ \
   1.108 +		        Pixel = 0;	/* prevent gcc from complaining */ \
   1.109  		break;							   \
   1.110  	}								   \
   1.111 -	RGB_FROM_PIXEL(pixel, fmt, r, g, b);				   \
   1.112 +	RGB_FROM_PIXEL(Pixel, fmt, r, g, b);				   \
   1.113  } while(0)
   1.114  
   1.115  /* Assemble R-G-B values into a specified pixel format and store them */
   1.116 -#define PIXEL_FROM_RGB(pixel, fmt, r, g, b)				\
   1.117 +#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b)				\
   1.118  {									\
   1.119 -	pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|				\
   1.120 +	Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|				\
   1.121  		((g>>fmt->Gloss)<<fmt->Gshift)|				\
   1.122  		((b>>fmt->Bloss)<<fmt->Bshift);				\
   1.123  }
   1.124 -#define RGB565_FROM_RGB(pixel, r, g, b)					\
   1.125 +#define RGB565_FROM_RGB(Pixel, r, g, b)					\
   1.126  {									\
   1.127 -	pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3);			\
   1.128 +	Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3);			\
   1.129  }
   1.130 -#define RGB555_FROM_RGB(pixel, r, g, b)					\
   1.131 +#define RGB555_FROM_RGB(Pixel, r, g, b)					\
   1.132  {									\
   1.133 -	pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3);			\
   1.134 +	Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3);			\
   1.135  }
   1.136 -#define RGB888_FROM_RGB(pixel, r, g, b)					\
   1.137 +#define RGB888_FROM_RGB(Pixel, r, g, b)					\
   1.138  {									\
   1.139 -	pixel = (r<<16)|(g<<8)|b;					\
   1.140 +	Pixel = (r<<16)|(g<<8)|b;					\
   1.141  }
   1.142  #define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) 				\
   1.143  {									\
   1.144  	switch (bpp) {							\
   1.145  		case 2: {						\
   1.146 -			Uint16 pixel;					\
   1.147 +			Uint16 Pixel;					\
   1.148  									\
   1.149 -			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
   1.150 -			*((Uint16 *)(buf)) = pixel;			\
   1.151 +			PIXEL_FROM_RGB(Pixel, fmt, r, g, b);		\
   1.152 +			*((Uint16 *)(buf)) = Pixel;			\
   1.153  		}							\
   1.154  		break;							\
   1.155  									\
   1.156 @@ -213,10 +213,10 @@
   1.157  		break;							\
   1.158  									\
   1.159  		case 4: {						\
   1.160 -			Uint32 pixel;					\
   1.161 +			Uint32 Pixel;					\
   1.162  									\
   1.163 -			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
   1.164 -			*((Uint32 *)(buf)) = pixel;			\
   1.165 +			PIXEL_FROM_RGB(Pixel, fmt, r, g, b);		\
   1.166 +			*((Uint32 *)(buf)) = Pixel;			\
   1.167  		}							\
   1.168  		break;							\
   1.169  	}								\
   1.170 @@ -226,11 +226,11 @@
   1.171  	switch (bpp) {							\
   1.172  		case 2: {						\
   1.173  			Uint16 *bufp;					\
   1.174 -			Uint16 pixel;					\
   1.175 +			Uint16 Pixel;					\
   1.176  									\
   1.177  			bufp = (Uint16 *)buf;				\
   1.178 -			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
   1.179 -			*bufp = pixel | (*bufp & Amask);		\
   1.180 +			PIXEL_FROM_RGB(Pixel, fmt, r, g, b);		\
   1.181 +			*bufp = Pixel | (*bufp & Amask);		\
   1.182  		}							\
   1.183  		break;							\
   1.184  									\
   1.185 @@ -249,85 +249,85 @@
   1.186  									\
   1.187  		case 4: {						\
   1.188  			Uint32 *bufp;					\
   1.189 -			Uint32 pixel;					\
   1.190 +			Uint32 Pixel;					\
   1.191  									\
   1.192  			bufp = (Uint32 *)buf;				\
   1.193 -			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
   1.194 -			*bufp = pixel | (*bufp & Amask);		\
   1.195 +			PIXEL_FROM_RGB(Pixel, fmt, r, g, b);		\
   1.196 +			*bufp = Pixel | (*bufp & Amask);		\
   1.197  		}							\
   1.198  		break;							\
   1.199  	}								\
   1.200  }
   1.201  
   1.202  /* FIXME: Should we rescale alpha into 0..255 here? */
   1.203 -#define RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a)				\
   1.204 +#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a)				\
   1.205  {									\
   1.206 -	r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; 		\
   1.207 -	g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; 		\
   1.208 -	b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; 		\
   1.209 -	a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss;	 	\
   1.210 +	r = ((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; 		\
   1.211 +	g = ((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; 		\
   1.212 +	b = ((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; 		\
   1.213 +	a = ((Pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss;	 	\
   1.214  }
   1.215 -#define RGBA_FROM_8888(pixel, fmt, r, g, b, a)	\
   1.216 +#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a)	\
   1.217  {						\
   1.218 -	r = (pixel&fmt->Rmask)>>fmt->Rshift;	\
   1.219 -	g = (pixel&fmt->Gmask)>>fmt->Gshift;	\
   1.220 -	b = (pixel&fmt->Bmask)>>fmt->Bshift;	\
   1.221 -	a = (pixel&fmt->Amask)>>fmt->Ashift;	\
   1.222 +	r = (Pixel&fmt->Rmask)>>fmt->Rshift;	\
   1.223 +	g = (Pixel&fmt->Gmask)>>fmt->Gshift;	\
   1.224 +	b = (Pixel&fmt->Bmask)>>fmt->Bshift;	\
   1.225 +	a = (Pixel&fmt->Amask)>>fmt->Ashift;	\
   1.226  }
   1.227 -#define RGBA_FROM_RGBA8888(pixel, r, g, b, a)				\
   1.228 +#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a)				\
   1.229  {									\
   1.230 -	r = (pixel>>24);						\
   1.231 -	g = ((pixel>>16)&0xFF);						\
   1.232 -	b = ((pixel>>8)&0xFF);						\
   1.233 -	a = (pixel&0xFF);						\
   1.234 +	r = (Pixel>>24);						\
   1.235 +	g = ((Pixel>>16)&0xFF);						\
   1.236 +	b = ((Pixel>>8)&0xFF);						\
   1.237 +	a = (Pixel&0xFF);						\
   1.238  }
   1.239 -#define RGBA_FROM_ARGB8888(pixel, r, g, b, a)				\
   1.240 +#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a)				\
   1.241  {									\
   1.242 -	r = ((pixel>>16)&0xFF);						\
   1.243 -	g = ((pixel>>8)&0xFF);						\
   1.244 -	b = (pixel&0xFF);						\
   1.245 -	a = (pixel>>24);						\
   1.246 +	r = ((Pixel>>16)&0xFF);						\
   1.247 +	g = ((Pixel>>8)&0xFF);						\
   1.248 +	b = (Pixel&0xFF);						\
   1.249 +	a = (Pixel>>24);						\
   1.250  }
   1.251 -#define RGBA_FROM_ABGR8888(pixel, r, g, b, a)				\
   1.252 +#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a)				\
   1.253  {									\
   1.254 -	r = (pixel&0xFF);						\
   1.255 -	g = ((pixel>>8)&0xFF);						\
   1.256 -	b = ((pixel>>16)&0xFF);						\
   1.257 -	a = (pixel>>24);						\
   1.258 +	r = (Pixel&0xFF);						\
   1.259 +	g = ((Pixel>>8)&0xFF);						\
   1.260 +	b = ((Pixel>>16)&0xFF);						\
   1.261 +	a = (Pixel>>24);						\
   1.262  }
   1.263 -#define DISEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a)			   \
   1.264 +#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)			   \
   1.265  do {									   \
   1.266  	switch (bpp) {							   \
   1.267  		case 2:							   \
   1.268 -			pixel = *((Uint16 *)(buf));			   \
   1.269 +			Pixel = *((Uint16 *)(buf));			   \
   1.270  		break;							   \
   1.271  									   \
   1.272  		case 3:	{/* FIXME: broken code (no alpha) */		   \
   1.273  		        Uint8 *b = (Uint8 *)buf;			   \
   1.274  			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
   1.275 -			        pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
   1.276 +			        Pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
   1.277  			} else {					   \
   1.278 -			        pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
   1.279 +			        Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
   1.280  			}						   \
   1.281  		}							   \
   1.282  		break;							   \
   1.283  									   \
   1.284  		case 4:							   \
   1.285 -			pixel = *((Uint32 *)(buf));			   \
   1.286 +			Pixel = *((Uint32 *)(buf));			   \
   1.287  		break;							   \
   1.288  									   \
   1.289  		default:						   \
   1.290 -		        pixel = 0; /* stop gcc complaints */		   \
   1.291 +		        Pixel = 0; /* stop gcc complaints */		   \
   1.292  		break;							   \
   1.293  	}								   \
   1.294 -	RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a);			   \
   1.295 -	pixel &= ~fmt->Amask;						   \
   1.296 +	RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a);			   \
   1.297 +	Pixel &= ~fmt->Amask;						   \
   1.298  } while(0)
   1.299  
   1.300  /* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
   1.301 -#define PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a)				\
   1.302 +#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a)				\
   1.303  {									\
   1.304 -	pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|				\
   1.305 +	Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|				\
   1.306  		((g>>fmt->Gloss)<<fmt->Gshift)|				\
   1.307  		((b>>fmt->Bloss)<<fmt->Bshift)|				\
   1.308  		((a>>fmt->Aloss)<<fmt->Ashift);				\
   1.309 @@ -336,10 +336,10 @@
   1.310  {									\
   1.311  	switch (bpp) {							\
   1.312  		case 2: {						\
   1.313 -			Uint16 pixel;					\
   1.314 +			Uint16 Pixel;					\
   1.315  									\
   1.316 -			PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a);	\
   1.317 -			*((Uint16 *)(buf)) = pixel;			\
   1.318 +			PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);	\
   1.319 +			*((Uint16 *)(buf)) = Pixel;			\
   1.320  		}							\
   1.321  		break;							\
   1.322  									\
   1.323 @@ -357,16 +357,16 @@
   1.324  		break;							\
   1.325  									\
   1.326  		case 4: {						\
   1.327 -			Uint32 pixel;					\
   1.328 +			Uint32 Pixel;					\
   1.329  									\
   1.330 -			PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a);	\
   1.331 -			*((Uint32 *)(buf)) = pixel;			\
   1.332 +			PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a);	\
   1.333 +			*((Uint32 *)(buf)) = Pixel;			\
   1.334  		}							\
   1.335  		break;							\
   1.336  	}								\
   1.337  }
   1.338  
   1.339 -/* Blend the RGB values of two pixels based on a source alpha value */
   1.340 +/* Blend the RGB values of two Pixels based on a source alpha value */
   1.341  #define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB)	\
   1.342  do {						\
   1.343  	dR = (((sR-dR)*(A))>>8)+dR;		\
   1.344 @@ -374,7 +374,7 @@
   1.345  	dB = (((sB-dB)*(A))>>8)+dB;		\
   1.346  } while(0)
   1.347  
   1.348 -/* Blend the RGB values of two pixels based on a source alpha value */
   1.349 +/* Blend the RGB values of two Pixels based on a source alpha value */
   1.350  #define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB)	\
   1.351  do {						\
   1.352      unsigned tR, tG, tB, tA; \