src/video/SDL_blit_N.c
changeset 91 e85e03f195b4
parent 0 74212992fb08
child 252 e8157fcb3114
     1.1 --- a/src/video/SDL_blit_N.c	Sat Jul 07 08:08:42 2001 +0000
     1.2 +++ b/src/video/SDL_blit_N.c	Sat Jul 07 20:20:17 2001 +0000
     1.3 @@ -78,7 +78,8 @@
     1.4  #endif
     1.5  	int width, height;
     1.6  	Uint32 *src;
     1.7 -	Uint8 *map, *dst;
     1.8 +	const Uint8 *map;
     1.9 +	Uint8 *dst;
    1.10  	int srcskip, dstskip;
    1.11  
    1.12  	/* Set up some basic variables */
    1.13 @@ -107,7 +108,7 @@
    1.14  				RGB888_RGB332(*dst++, *src);
    1.15  				++src;
    1.16  			}
    1.17 -			switch ( width % 4 ) {
    1.18 +			switch ( width & 3 ) {
    1.19  				case 3:
    1.20  					RGB888_RGB332(*dst++, *src);
    1.21  					++src;
    1.22 @@ -148,7 +149,7 @@
    1.23  				*dst++ = map[pixel];
    1.24  				++src;
    1.25  			}
    1.26 -			switch ( width % 4 ) {
    1.27 +			switch ( width & 3 ) {
    1.28  				case 3:
    1.29  					RGB888_RGB332(pixel, *src);
    1.30  					*dst++ = map[pixel];
    1.31 @@ -235,7 +236,7 @@
    1.32  				dst += 2;
    1.33  			}
    1.34  			/* Get any leftovers */
    1.35 -			switch (width % 4) {
    1.36 +			switch (width & 3) {
    1.37  				case 3:
    1.38  					RGB888_RGB555(dst, src);
    1.39  					++src;
    1.40 @@ -266,7 +267,7 @@
    1.41  				dst += 2;
    1.42  			}
    1.43  			/* Get any leftovers */
    1.44 -			switch (width % 4) {
    1.45 +			switch (width & 3) {
    1.46  				case 3:
    1.47  					RGB888_RGB555(dst, src);
    1.48  					++src;
    1.49 @@ -355,7 +356,7 @@
    1.50  				dst += 2;
    1.51  			}
    1.52  			/* Get any leftovers */
    1.53 -			switch (width % 4) {
    1.54 +			switch (width & 3) {
    1.55  				case 3:
    1.56  					RGB888_RGB565(dst, src);
    1.57  					++src;
    1.58 @@ -386,7 +387,7 @@
    1.59  				dst += 2;
    1.60  			}
    1.61  			/* Get any leftovers */
    1.62 -			switch (width % 4) {
    1.63 +			switch (width & 3) {
    1.64  				case 3:
    1.65  					RGB888_RGB565(dst, src);
    1.66  					++src;
    1.67 @@ -418,7 +419,7 @@
    1.68  #else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
    1.69  #define RGB565_32(dst, src, map) (map[src[1]*2] + map[src[0]*2+1])
    1.70  #endif
    1.71 -static void Blit_RGB565_32(SDL_BlitInfo *info, Uint32 *map)
    1.72 +static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map)
    1.73  {
    1.74  #ifndef USE_DUFFS_LOOP
    1.75  	int c;
    1.76 @@ -461,7 +462,7 @@
    1.77  			src += 2;
    1.78  		}
    1.79  		/* Get any leftovers */
    1.80 -		switch (width % 4) {
    1.81 +		switch (width & 3) {
    1.82  			case 3:
    1.83  				*dst++ = RGB565_32(dst, src, map);
    1.84  				src += 2;
    1.85 @@ -480,7 +481,7 @@
    1.86  }
    1.87  
    1.88  /* Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 */
    1.89 -static Uint32 RGB565_ARGB8888_LUT[512] = {
    1.90 +static const Uint32 RGB565_ARGB8888_LUT[512] = {
    1.91  		0x00000000, 0xff000000, 0x00000008, 0xff002000,
    1.92  		0x00000010, 0xff004000, 0x00000018, 0xff006100,
    1.93  		0x00000020, 0xff008100, 0x00000029, 0xff00a100,
    1.94 @@ -616,7 +617,7 @@
    1.95  }
    1.96  
    1.97  /* Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 */
    1.98 -static Uint32 RGB565_ABGR8888_LUT[512] = {
    1.99 +static const Uint32 RGB565_ABGR8888_LUT[512] = {
   1.100  		0xff000000, 0x00000000, 0xff080000, 0x00002000,
   1.101  		0xff100000, 0x00004000, 0xff180000, 0x00006100,
   1.102  		0xff200000, 0x00008100, 0xff290000, 0x0000a100,
   1.103 @@ -752,7 +753,7 @@
   1.104  }
   1.105  
   1.106  /* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */
   1.107 -static Uint32 RGB565_RGBA8888_LUT[512] = {
   1.108 +static const Uint32 RGB565_RGBA8888_LUT[512] = {
   1.109  		0x000000ff, 0x00000000, 0x000008ff, 0x00200000,
   1.110  		0x000010ff, 0x00400000, 0x000018ff, 0x00610000,
   1.111  		0x000020ff, 0x00810000, 0x000029ff, 0x00a10000,
   1.112 @@ -888,7 +889,7 @@
   1.113  }
   1.114  
   1.115  /* Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 */
   1.116 -static Uint32 RGB565_BGRA8888_LUT[512] = {
   1.117 +static const Uint32 RGB565_BGRA8888_LUT[512] = {
   1.118  		0x00000000, 0x000000ff, 0x08000000, 0x002000ff,
   1.119  		0x10000000, 0x004000ff, 0x18000000, 0x006100ff,
   1.120  		0x20000000, 0x008100ff, 0x29000000, 0x00a100ff,
   1.121 @@ -1039,7 +1040,8 @@
   1.122  	int pixel;
   1.123  	int width, height;
   1.124  	Uint32 *src;
   1.125 -	Uint8 *map, *dst;
   1.126 +	const Uint8 *map;
   1.127 +	Uint8 *dst;
   1.128  	int srcskip, dstskip;
   1.129  
   1.130  	/* Set up some basic variables */
   1.131 @@ -1078,7 +1080,7 @@
   1.132  			*dst++ = map[pixel];
   1.133  			++src;
   1.134  		}
   1.135 -		switch ( width % 4 ) {
   1.136 +		switch ( width & 3 ) {
   1.137  			case 3:
   1.138  				RGB888_RGB332(pixel, *src);
   1.139  				*dst++ = map[pixel];
   1.140 @@ -1103,7 +1105,9 @@
   1.141  	int c;
   1.142  #endif
   1.143  	int width, height;
   1.144 -	Uint8 *src, *map, *dst;
   1.145 +	Uint8 *src;
   1.146 +	const Uint8 *map;
   1.147 +	Uint8 *dst;
   1.148  	int srcskip, dstskip;
   1.149  	int srcbpp;
   1.150  	Uint32 pixel;
   1.151 @@ -1259,7 +1263,7 @@
   1.152  	Uint8 *dst = info->d_pixels;
   1.153  	int dstskip = info->d_skip;
   1.154  	SDL_PixelFormat *srcfmt = info->src;
   1.155 -	Uint8 *palmap = info->table;
   1.156 +	const Uint8 *palmap = info->table;
   1.157  	Uint32 ckey = srcfmt->colorkey;
   1.158  	Uint32 rgbmask = ~srcfmt->Amask;
   1.159  	int srcbpp;
   1.160 @@ -1431,11 +1435,11 @@
   1.161  	SDL_loblit blitfunc;
   1.162          enum { NO_ALPHA, SET_ALPHA, COPY_ALPHA } alpha;
   1.163  };
   1.164 -static struct blit_table normal_blit_1[] = {
   1.165 +static const struct blit_table normal_blit_1[] = {
   1.166  	/* Default for 8-bit RGB source, an invalid combination */
   1.167  	{ 0,0,0, 0, 0,0,0, 0, NULL, NULL },
   1.168  };
   1.169 -static struct blit_table normal_blit_2[] = {
   1.170 +static const struct blit_table normal_blit_2[] = {
   1.171  #ifdef USE_ASMBLIT
   1.172      { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000007E0,0x0000F800,
   1.173        0, ConvertX86p16_16BGR565, ConvertX86, NO_ALPHA },
   1.174 @@ -1456,11 +1460,11 @@
   1.175      /* Default for 16-bit RGB source, used if no other blitter matches */
   1.176      { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
   1.177  };
   1.178 -static struct blit_table normal_blit_3[] = {
   1.179 +static const struct blit_table normal_blit_3[] = {
   1.180  	/* Default for 24-bit RGB source, never optimized */
   1.181      { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
   1.182  };
   1.183 -static struct blit_table normal_blit_4[] = {
   1.184 +static const struct blit_table normal_blit_4[] = {
   1.185  #ifdef USE_ASMBLIT
   1.186      { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
   1.187        MMX_CPU, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
   1.188 @@ -1497,7 +1501,7 @@
   1.189  	/* Default for 32-bit RGB source, used if no other blitter matches */
   1.190  	{ 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
   1.191  };
   1.192 -static struct blit_table *normal_blit[] = {
   1.193 +static const struct blit_table *normal_blit[] = {
   1.194  	normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4
   1.195  };
   1.196  
   1.197 @@ -1506,7 +1510,7 @@
   1.198  	struct private_swaccel *sdata;
   1.199  	SDL_PixelFormat *srcfmt;
   1.200  	SDL_PixelFormat *dstfmt;
   1.201 -	struct blit_table *table;
   1.202 +	const struct blit_table *table;
   1.203  	int which;
   1.204  	SDL_loblit blitfun;
   1.205