Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_1.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
26 #include "SDL_sysvideo.h" | 26 #include "SDL_sysvideo.h" |
27 #include "SDL_endian.h" | 27 #include "SDL_endian.h" |
28 | 28 |
29 /* Functions to blit from 8-bit surfaces to other surfaces */ | 29 /* Functions to blit from 8-bit surfaces to other surfaces */ |
30 | 30 |
31 static void Blit1to1(SDL_BlitInfo *info) | 31 static void |
32 Blit1to1 (SDL_BlitInfo * info) | |
32 { | 33 { |
33 #ifndef USE_DUFFS_LOOP | 34 #ifndef USE_DUFFS_LOOP |
34 int c; | 35 int c; |
35 #endif | 36 #endif |
36 int width, height; | 37 int width, height; |
37 Uint8 *src, *map, *dst; | 38 Uint8 *src, *map, *dst; |
38 int srcskip, dstskip; | 39 int srcskip, dstskip; |
39 | 40 |
40 /* Set up some basic variables */ | 41 /* Set up some basic variables */ |
41 width = info->d_width; | 42 width = info->d_width; |
42 height = info->d_height; | 43 height = info->d_height; |
43 src = info->s_pixels; | 44 src = info->s_pixels; |
44 srcskip = info->s_skip; | 45 srcskip = info->s_skip; |
45 dst = info->d_pixels; | 46 dst = info->d_pixels; |
46 dstskip = info->d_skip; | 47 dstskip = info->d_skip; |
47 map = info->table; | 48 map = info->table; |
48 | 49 |
49 while ( height-- ) { | 50 while (height--) { |
50 #ifdef USE_DUFFS_LOOP | 51 #ifdef USE_DUFFS_LOOP |
52 /* *INDENT-OFF* */ | |
51 DUFFS_LOOP( | 53 DUFFS_LOOP( |
52 { | 54 { |
53 *dst = map[*src]; | 55 *dst = map[*src]; |
54 } | 56 } |
55 dst++; | 57 dst++; |
56 src++; | 58 src++; |
57 , width); | 59 , width); |
60 /* *INDENT-ON* */ | |
58 #else | 61 #else |
59 for ( c=width; c; --c ) { | 62 for (c = width; c; --c) { |
60 *dst = map[*src]; | 63 *dst = map[*src]; |
61 dst++; | 64 dst++; |
62 src++; | 65 src++; |
63 } | 66 } |
64 #endif | 67 #endif |
65 src += srcskip; | 68 src += srcskip; |
66 dst += dstskip; | 69 dst += dstskip; |
67 } | 70 } |
68 } | 71 } |
72 | |
69 /* This is now endian dependent */ | 73 /* This is now endian dependent */ |
70 #if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) | 74 #if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) |
71 #define HI 1 | 75 #define HI 1 |
72 #define LO 0 | 76 #define LO 0 |
73 #else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */ | 77 #else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */ |
74 #define HI 0 | 78 #define HI 0 |
75 #define LO 1 | 79 #define LO 1 |
76 #endif | 80 #endif |
77 static void Blit1to2(SDL_BlitInfo *info) | 81 static void |
82 Blit1to2 (SDL_BlitInfo * info) | |
78 { | 83 { |
79 #ifndef USE_DUFFS_LOOP | 84 #ifndef USE_DUFFS_LOOP |
80 int c; | 85 int c; |
81 #endif | 86 #endif |
82 int width, height; | 87 int width, height; |
83 Uint8 *src, *dst; | 88 Uint8 *src, *dst; |
84 Uint16 *map; | 89 Uint16 *map; |
85 int srcskip, dstskip; | 90 int srcskip, dstskip; |
86 | 91 |
87 /* Set up some basic variables */ | 92 /* Set up some basic variables */ |
88 width = info->d_width; | 93 width = info->d_width; |
89 height = info->d_height; | 94 height = info->d_height; |
90 src = info->s_pixels; | 95 src = info->s_pixels; |
91 srcskip = info->s_skip; | 96 srcskip = info->s_skip; |
92 dst = info->d_pixels; | 97 dst = info->d_pixels; |
93 dstskip = info->d_skip; | 98 dstskip = info->d_skip; |
94 map = (Uint16 *)info->table; | 99 map = (Uint16 *) info->table; |
95 | 100 |
96 #ifdef USE_DUFFS_LOOP | 101 #ifdef USE_DUFFS_LOOP |
97 while ( height-- ) { | 102 while (height--) { |
103 /* *INDENT-OFF* */ | |
98 DUFFS_LOOP( | 104 DUFFS_LOOP( |
99 { | 105 { |
100 *(Uint16 *)dst = map[*src++]; | 106 *(Uint16 *)dst = map[*src++]; |
101 dst += 2; | 107 dst += 2; |
102 }, | 108 }, |
103 width); | 109 width); |
104 src += srcskip; | 110 /* *INDENT-ON* */ |
105 dst += dstskip; | 111 src += srcskip; |
106 } | 112 dst += dstskip; |
113 } | |
107 #else | 114 #else |
108 /* Memory align at 4-byte boundary, if necessary */ | 115 /* Memory align at 4-byte boundary, if necessary */ |
109 if ( (long)dst & 0x03 ) { | 116 if ((long) dst & 0x03) { |
110 /* Don't do anything if width is 0 */ | 117 /* Don't do anything if width is 0 */ |
111 if ( width == 0 ) { | 118 if (width == 0) { |
112 return; | 119 return; |
113 } | 120 } |
114 --width; | 121 --width; |
115 | 122 |
116 while ( height-- ) { | 123 while (height--) { |
117 /* Perform copy alignment */ | 124 /* Perform copy alignment */ |
118 *(Uint16 *)dst = map[*src++]; | 125 *(Uint16 *) dst = map[*src++]; |
119 dst += 2; | 126 dst += 2; |
120 | 127 |
121 /* Copy in 4 pixel chunks */ | 128 /* Copy in 4 pixel chunks */ |
122 for ( c=width/4; c; --c ) { | 129 for (c = width / 4; c; --c) { |
123 *(Uint32 *)dst = | 130 *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); |
124 (map[src[HI]]<<16)|(map[src[LO]]); | 131 src += 2; |
125 src += 2; | 132 dst += 4; |
126 dst += 4; | 133 *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); |
127 *(Uint32 *)dst = | 134 src += 2; |
128 (map[src[HI]]<<16)|(map[src[LO]]); | 135 dst += 4; |
129 src += 2; | 136 } |
130 dst += 4; | 137 /* Get any leftovers */ |
131 } | 138 switch (width & 3) { |
132 /* Get any leftovers */ | 139 case 3: |
133 switch (width & 3) { | 140 *(Uint16 *) dst = map[*src++]; |
134 case 3: | 141 dst += 2; |
135 *(Uint16 *)dst = map[*src++]; | 142 case 2: |
136 dst += 2; | 143 *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); |
137 case 2: | 144 src += 2; |
138 *(Uint32 *)dst = | 145 dst += 4; |
139 (map[src[HI]]<<16)|(map[src[LO]]); | 146 break; |
140 src += 2; | 147 case 1: |
141 dst += 4; | 148 *(Uint16 *) dst = map[*src++]; |
142 break; | 149 dst += 2; |
143 case 1: | 150 break; |
144 *(Uint16 *)dst = map[*src++]; | 151 } |
145 dst += 2; | 152 src += srcskip; |
146 break; | 153 dst += dstskip; |
147 } | 154 } |
148 src += srcskip; | 155 } else { |
149 dst += dstskip; | 156 while (height--) { |
150 } | 157 /* Copy in 4 pixel chunks */ |
151 } else { | 158 for (c = width / 4; c; --c) { |
152 while ( height-- ) { | 159 *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); |
153 /* Copy in 4 pixel chunks */ | 160 src += 2; |
154 for ( c=width/4; c; --c ) { | 161 dst += 4; |
155 *(Uint32 *)dst = | 162 *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); |
156 (map[src[HI]]<<16)|(map[src[LO]]); | 163 src += 2; |
157 src += 2; | 164 dst += 4; |
158 dst += 4; | 165 } |
159 *(Uint32 *)dst = | 166 /* Get any leftovers */ |
160 (map[src[HI]]<<16)|(map[src[LO]]); | 167 switch (width & 3) { |
161 src += 2; | 168 case 3: |
162 dst += 4; | 169 *(Uint16 *) dst = map[*src++]; |
163 } | 170 dst += 2; |
164 /* Get any leftovers */ | 171 case 2: |
165 switch (width & 3) { | 172 *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]); |
166 case 3: | 173 src += 2; |
167 *(Uint16 *)dst = map[*src++]; | 174 dst += 4; |
168 dst += 2; | 175 break; |
169 case 2: | 176 case 1: |
170 *(Uint32 *)dst = | 177 *(Uint16 *) dst = map[*src++]; |
171 (map[src[HI]]<<16)|(map[src[LO]]); | 178 dst += 2; |
172 src += 2; | 179 break; |
173 dst += 4; | 180 } |
174 break; | 181 src += srcskip; |
175 case 1: | 182 dst += dstskip; |
176 *(Uint16 *)dst = map[*src++]; | 183 } |
177 dst += 2; | 184 } |
178 break; | |
179 } | |
180 src += srcskip; | |
181 dst += dstskip; | |
182 } | |
183 } | |
184 #endif /* USE_DUFFS_LOOP */ | 185 #endif /* USE_DUFFS_LOOP */ |
185 } | 186 } |
186 static void Blit1to3(SDL_BlitInfo *info) | 187 static void |
188 Blit1to3 (SDL_BlitInfo * info) | |
187 { | 189 { |
188 #ifndef USE_DUFFS_LOOP | 190 #ifndef USE_DUFFS_LOOP |
189 int c; | 191 int c; |
190 #endif | 192 #endif |
191 int o; | 193 int o; |
192 int width, height; | 194 int width, height; |
193 Uint8 *src, *map, *dst; | 195 Uint8 *src, *map, *dst; |
194 int srcskip, dstskip; | 196 int srcskip, dstskip; |
195 | 197 |
196 /* Set up some basic variables */ | 198 /* Set up some basic variables */ |
197 width = info->d_width; | 199 width = info->d_width; |
198 height = info->d_height; | 200 height = info->d_height; |
199 src = info->s_pixels; | 201 src = info->s_pixels; |
200 srcskip = info->s_skip; | 202 srcskip = info->s_skip; |
201 dst = info->d_pixels; | 203 dst = info->d_pixels; |
202 dstskip = info->d_skip; | 204 dstskip = info->d_skip; |
203 map = info->table; | 205 map = info->table; |
204 | 206 |
205 while ( height-- ) { | 207 while (height--) { |
206 #ifdef USE_DUFFS_LOOP | 208 #ifdef USE_DUFFS_LOOP |
209 /* *INDENT-OFF* */ | |
207 DUFFS_LOOP( | 210 DUFFS_LOOP( |
208 { | 211 { |
209 o = *src * 4; | 212 o = *src * 4; |
210 dst[0] = map[o++]; | 213 dst[0] = map[o++]; |
211 dst[1] = map[o++]; | 214 dst[1] = map[o++]; |
212 dst[2] = map[o++]; | 215 dst[2] = map[o++]; |
213 } | 216 } |
214 src++; | 217 src++; |
215 dst += 3; | 218 dst += 3; |
216 , width); | 219 , width); |
220 /* *INDENT-ON* */ | |
217 #else | 221 #else |
218 for ( c=width; c; --c ) { | 222 for (c = width; c; --c) { |
219 o = *src * 4; | 223 o = *src * 4; |
220 dst[0] = map[o++]; | 224 dst[0] = map[o++]; |
221 dst[1] = map[o++]; | 225 dst[1] = map[o++]; |
222 dst[2] = map[o++]; | 226 dst[2] = map[o++]; |
223 src++; | 227 src++; |
224 dst += 3; | 228 dst += 3; |
225 } | 229 } |
226 #endif /* USE_DUFFS_LOOP */ | 230 #endif /* USE_DUFFS_LOOP */ |
227 src += srcskip; | 231 src += srcskip; |
228 dst += dstskip; | 232 dst += dstskip; |
229 } | 233 } |
230 } | 234 } |
231 static void Blit1to4(SDL_BlitInfo *info) | 235 static void |
236 Blit1to4 (SDL_BlitInfo * info) | |
232 { | 237 { |
233 #ifndef USE_DUFFS_LOOP | 238 #ifndef USE_DUFFS_LOOP |
234 int c; | 239 int c; |
235 #endif | 240 #endif |
236 int width, height; | 241 int width, height; |
237 Uint8 *src; | 242 Uint8 *src; |
238 Uint32 *map, *dst; | 243 Uint32 *map, *dst; |
239 int srcskip, dstskip; | 244 int srcskip, dstskip; |
240 | 245 |
241 /* Set up some basic variables */ | 246 /* Set up some basic variables */ |
242 width = info->d_width; | 247 width = info->d_width; |
243 height = info->d_height; | 248 height = info->d_height; |
244 src = info->s_pixels; | 249 src = info->s_pixels; |
245 srcskip = info->s_skip; | 250 srcskip = info->s_skip; |
246 dst = (Uint32 *)info->d_pixels; | 251 dst = (Uint32 *) info->d_pixels; |
247 dstskip = info->d_skip/4; | 252 dstskip = info->d_skip / 4; |
248 map = (Uint32 *)info->table; | 253 map = (Uint32 *) info->table; |
249 | 254 |
250 while ( height-- ) { | 255 while (height--) { |
251 #ifdef USE_DUFFS_LOOP | 256 #ifdef USE_DUFFS_LOOP |
257 /* *INDENT-OFF* */ | |
252 DUFFS_LOOP( | 258 DUFFS_LOOP( |
253 *dst++ = map[*src++]; | 259 *dst++ = map[*src++]; |
254 , width); | 260 , width); |
261 /* *INDENT-ON* */ | |
255 #else | 262 #else |
256 for ( c=width/4; c; --c ) { | 263 for (c = width / 4; c; --c) { |
257 *dst++ = map[*src++]; | 264 *dst++ = map[*src++]; |
258 *dst++ = map[*src++]; | 265 *dst++ = map[*src++]; |
259 *dst++ = map[*src++]; | 266 *dst++ = map[*src++]; |
260 *dst++ = map[*src++]; | 267 *dst++ = map[*src++]; |
261 } | 268 } |
262 switch ( width & 3 ) { | 269 switch (width & 3) { |
263 case 3: | 270 case 3: |
264 *dst++ = map[*src++]; | 271 *dst++ = map[*src++]; |
265 case 2: | 272 case 2: |
266 *dst++ = map[*src++]; | 273 *dst++ = map[*src++]; |
267 case 1: | 274 case 1: |
268 *dst++ = map[*src++]; | 275 *dst++ = map[*src++]; |
269 } | 276 } |
270 #endif /* USE_DUFFS_LOOP */ | 277 #endif /* USE_DUFFS_LOOP */ |
271 src += srcskip; | 278 src += srcskip; |
272 dst += dstskip; | 279 dst += dstskip; |
273 } | 280 } |
274 } | 281 } |
275 | 282 |
276 static void Blit1to1Key(SDL_BlitInfo *info) | 283 static void |
277 { | 284 Blit1to1Key (SDL_BlitInfo * info) |
278 int width = info->d_width; | 285 { |
279 int height = info->d_height; | 286 int width = info->d_width; |
280 Uint8 *src = info->s_pixels; | 287 int height = info->d_height; |
281 int srcskip = info->s_skip; | 288 Uint8 *src = info->s_pixels; |
282 Uint8 *dst = info->d_pixels; | 289 int srcskip = info->s_skip; |
283 int dstskip = info->d_skip; | 290 Uint8 *dst = info->d_pixels; |
284 Uint8 *palmap = info->table; | 291 int dstskip = info->d_skip; |
285 Uint32 ckey = info->src->colorkey; | 292 Uint8 *palmap = info->table; |
286 | 293 Uint32 ckey = info->src->colorkey; |
287 if ( palmap ) { | 294 |
288 while ( height-- ) { | 295 if (palmap) { |
296 while (height--) { | |
297 /* *INDENT-OFF* */ | |
289 DUFFS_LOOP( | 298 DUFFS_LOOP( |
290 { | 299 { |
291 if ( *src != ckey ) { | 300 if ( *src != ckey ) { |
292 *dst = palmap[*src]; | 301 *dst = palmap[*src]; |
293 } | 302 } |
294 dst++; | 303 dst++; |
295 src++; | 304 src++; |
296 }, | 305 }, |
297 width); | 306 width); |
298 src += srcskip; | 307 /* *INDENT-ON* */ |
299 dst += dstskip; | 308 src += srcskip; |
300 } | 309 dst += dstskip; |
301 } else { | 310 } |
302 while ( height-- ) { | 311 } else { |
312 while (height--) { | |
313 /* *INDENT-OFF* */ | |
303 DUFFS_LOOP( | 314 DUFFS_LOOP( |
304 { | 315 { |
305 if ( *src != ckey ) { | 316 if ( *src != ckey ) { |
306 *dst = *src; | 317 *dst = *src; |
307 } | 318 } |
308 dst++; | 319 dst++; |
309 src++; | 320 src++; |
310 }, | 321 }, |
311 width); | 322 width); |
312 src += srcskip; | 323 /* *INDENT-ON* */ |
313 dst += dstskip; | 324 src += srcskip; |
314 } | 325 dst += dstskip; |
315 } | 326 } |
316 } | 327 } |
317 | 328 } |
318 static void Blit1to2Key(SDL_BlitInfo *info) | 329 |
319 { | 330 static void |
320 int width = info->d_width; | 331 Blit1to2Key (SDL_BlitInfo * info) |
321 int height = info->d_height; | 332 { |
322 Uint8 *src = info->s_pixels; | 333 int width = info->d_width; |
323 int srcskip = info->s_skip; | 334 int height = info->d_height; |
324 Uint16 *dstp = (Uint16 *)info->d_pixels; | 335 Uint8 *src = info->s_pixels; |
325 int dstskip = info->d_skip; | 336 int srcskip = info->s_skip; |
326 Uint16 *palmap = (Uint16 *)info->table; | 337 Uint16 *dstp = (Uint16 *) info->d_pixels; |
327 Uint32 ckey = info->src->colorkey; | 338 int dstskip = info->d_skip; |
328 | 339 Uint16 *palmap = (Uint16 *) info->table; |
329 /* Set up some basic variables */ | 340 Uint32 ckey = info->src->colorkey; |
330 dstskip /= 2; | 341 |
331 | 342 /* Set up some basic variables */ |
332 while ( height-- ) { | 343 dstskip /= 2; |
344 | |
345 while (height--) { | |
346 /* *INDENT-OFF* */ | |
333 DUFFS_LOOP( | 347 DUFFS_LOOP( |
334 { | 348 { |
335 if ( *src != ckey ) { | 349 if ( *src != ckey ) { |
336 *dstp=palmap[*src]; | 350 *dstp=palmap[*src]; |
337 } | 351 } |
338 src++; | 352 src++; |
339 dstp++; | 353 dstp++; |
340 }, | 354 }, |
341 width); | 355 width); |
342 src += srcskip; | 356 /* *INDENT-ON* */ |
343 dstp += dstskip; | 357 src += srcskip; |
344 } | 358 dstp += dstskip; |
345 } | 359 } |
346 | 360 } |
347 static void Blit1to3Key(SDL_BlitInfo *info) | 361 |
348 { | 362 static void |
349 int width = info->d_width; | 363 Blit1to3Key (SDL_BlitInfo * info) |
350 int height = info->d_height; | 364 { |
351 Uint8 *src = info->s_pixels; | 365 int width = info->d_width; |
352 int srcskip = info->s_skip; | 366 int height = info->d_height; |
353 Uint8 *dst = info->d_pixels; | 367 Uint8 *src = info->s_pixels; |
354 int dstskip = info->d_skip; | 368 int srcskip = info->s_skip; |
355 Uint8 *palmap = info->table; | 369 Uint8 *dst = info->d_pixels; |
356 Uint32 ckey = info->src->colorkey; | 370 int dstskip = info->d_skip; |
357 int o; | 371 Uint8 *palmap = info->table; |
358 | 372 Uint32 ckey = info->src->colorkey; |
359 while ( height-- ) { | 373 int o; |
374 | |
375 while (height--) { | |
376 /* *INDENT-OFF* */ | |
360 DUFFS_LOOP( | 377 DUFFS_LOOP( |
361 { | 378 { |
362 if ( *src != ckey ) { | 379 if ( *src != ckey ) { |
363 o = *src * 4; | 380 o = *src * 4; |
364 dst[0] = palmap[o++]; | 381 dst[0] = palmap[o++]; |
367 } | 384 } |
368 src++; | 385 src++; |
369 dst += 3; | 386 dst += 3; |
370 }, | 387 }, |
371 width); | 388 width); |
372 src += srcskip; | 389 /* *INDENT-ON* */ |
373 dst += dstskip; | 390 src += srcskip; |
374 } | 391 dst += dstskip; |
375 } | 392 } |
376 | 393 } |
377 static void Blit1to4Key(SDL_BlitInfo *info) | 394 |
378 { | 395 static void |
379 int width = info->d_width; | 396 Blit1to4Key (SDL_BlitInfo * info) |
380 int height = info->d_height; | 397 { |
381 Uint8 *src = info->s_pixels; | 398 int width = info->d_width; |
382 int srcskip = info->s_skip; | 399 int height = info->d_height; |
383 Uint32 *dstp = (Uint32 *)info->d_pixels; | 400 Uint8 *src = info->s_pixels; |
384 int dstskip = info->d_skip; | 401 int srcskip = info->s_skip; |
385 Uint32 *palmap = (Uint32 *)info->table; | 402 Uint32 *dstp = (Uint32 *) info->d_pixels; |
386 Uint32 ckey = info->src->colorkey; | 403 int dstskip = info->d_skip; |
387 | 404 Uint32 *palmap = (Uint32 *) info->table; |
388 /* Set up some basic variables */ | 405 Uint32 ckey = info->src->colorkey; |
389 dstskip /= 4; | 406 |
390 | 407 /* Set up some basic variables */ |
391 while ( height-- ) { | 408 dstskip /= 4; |
409 | |
410 while (height--) { | |
411 /* *INDENT-OFF* */ | |
392 DUFFS_LOOP( | 412 DUFFS_LOOP( |
393 { | 413 { |
394 if ( *src != ckey ) { | 414 if ( *src != ckey ) { |
395 *dstp = palmap[*src]; | 415 *dstp = palmap[*src]; |
396 } | 416 } |
397 src++; | 417 src++; |
398 dstp++; | 418 dstp++; |
399 }, | 419 }, |
400 width); | 420 width); |
401 src += srcskip; | 421 /* *INDENT-ON* */ |
402 dstp += dstskip; | 422 src += srcskip; |
403 } | 423 dstp += dstskip; |
404 } | 424 } |
405 | 425 } |
406 static void Blit1toNAlpha(SDL_BlitInfo *info) | 426 |
407 { | 427 static void |
408 int width = info->d_width; | 428 Blit1toNAlpha (SDL_BlitInfo * info) |
409 int height = info->d_height; | 429 { |
410 Uint8 *src = info->s_pixels; | 430 int width = info->d_width; |
411 int srcskip = info->s_skip; | 431 int height = info->d_height; |
412 Uint8 *dst = info->d_pixels; | 432 Uint8 *src = info->s_pixels; |
413 int dstskip = info->d_skip; | 433 int srcskip = info->s_skip; |
414 SDL_PixelFormat *dstfmt = info->dst; | 434 Uint8 *dst = info->d_pixels; |
415 const SDL_Color *srcpal = info->src->palette->colors; | 435 int dstskip = info->d_skip; |
416 int dstbpp; | 436 SDL_PixelFormat *dstfmt = info->dst; |
417 const int A = info->src->alpha; | 437 const SDL_Color *srcpal = info->src->palette->colors; |
418 | 438 int dstbpp; |
419 /* Set up some basic variables */ | 439 const int A = info->src->alpha; |
420 dstbpp = dstfmt->BytesPerPixel; | 440 |
421 | 441 /* Set up some basic variables */ |
422 while ( height-- ) { | 442 dstbpp = dstfmt->BytesPerPixel; |
423 int sR, sG, sB; | 443 |
424 int dR, dG, dB; | 444 while (height--) { |
445 int sR, sG, sB; | |
446 int dR, dG, dB; | |
447 /* *INDENT-OFF* */ | |
425 DUFFS_LOOP4( | 448 DUFFS_LOOP4( |
426 { | 449 { |
427 Uint32 pixel; | 450 Uint32 pixel; |
428 sR = srcpal[*src].r; | 451 sR = srcpal[*src].r; |
429 sG = srcpal[*src].g; | 452 sG = srcpal[*src].g; |
434 ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB); | 457 ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB); |
435 src++; | 458 src++; |
436 dst += dstbpp; | 459 dst += dstbpp; |
437 }, | 460 }, |
438 width); | 461 width); |
439 src += srcskip; | 462 /* *INDENT-ON* */ |
440 dst += dstskip; | 463 src += srcskip; |
441 } | 464 dst += dstskip; |
442 } | 465 } |
443 | 466 } |
444 static void Blit1toNAlphaKey(SDL_BlitInfo *info) | 467 |
445 { | 468 static void |
446 int width = info->d_width; | 469 Blit1toNAlphaKey (SDL_BlitInfo * info) |
447 int height = info->d_height; | 470 { |
448 Uint8 *src = info->s_pixels; | 471 int width = info->d_width; |
449 int srcskip = info->s_skip; | 472 int height = info->d_height; |
450 Uint8 *dst = info->d_pixels; | 473 Uint8 *src = info->s_pixels; |
451 int dstskip = info->d_skip; | 474 int srcskip = info->s_skip; |
452 SDL_PixelFormat *srcfmt = info->src; | 475 Uint8 *dst = info->d_pixels; |
453 SDL_PixelFormat *dstfmt = info->dst; | 476 int dstskip = info->d_skip; |
454 const SDL_Color *srcpal = info->src->palette->colors; | 477 SDL_PixelFormat *srcfmt = info->src; |
455 Uint32 ckey = srcfmt->colorkey; | 478 SDL_PixelFormat *dstfmt = info->dst; |
456 int dstbpp; | 479 const SDL_Color *srcpal = info->src->palette->colors; |
457 const int A = srcfmt->alpha; | 480 Uint32 ckey = srcfmt->colorkey; |
458 | 481 int dstbpp; |
459 /* Set up some basic variables */ | 482 const int A = srcfmt->alpha; |
460 dstbpp = dstfmt->BytesPerPixel; | 483 |
461 | 484 /* Set up some basic variables */ |
462 while ( height-- ) { | 485 dstbpp = dstfmt->BytesPerPixel; |
463 int sR, sG, sB; | 486 |
464 int dR, dG, dB; | 487 while (height--) { |
488 int sR, sG, sB; | |
489 int dR, dG, dB; | |
490 /* *INDENT-OFF* */ | |
465 DUFFS_LOOP( | 491 DUFFS_LOOP( |
466 { | 492 { |
467 if ( *src != ckey ) { | 493 if ( *src != ckey ) { |
468 Uint32 pixel; | 494 Uint32 pixel; |
469 sR = srcpal[*src].r; | 495 sR = srcpal[*src].r; |
476 } | 502 } |
477 src++; | 503 src++; |
478 dst += dstbpp; | 504 dst += dstbpp; |
479 }, | 505 }, |
480 width); | 506 width); |
481 src += srcskip; | 507 /* *INDENT-ON* */ |
482 dst += dstskip; | 508 src += srcskip; |
483 } | 509 dst += dstskip; |
510 } | |
484 } | 511 } |
485 | 512 |
486 static SDL_loblit one_blit[] = { | 513 static SDL_loblit one_blit[] = { |
487 NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 | 514 NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 |
488 }; | 515 }; |
489 | 516 |
490 static SDL_loblit one_blitkey[] = { | 517 static SDL_loblit one_blitkey[] = { |
491 NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key | 518 NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key |
492 }; | 519 }; |
493 | 520 |
494 SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int blit_index) | 521 SDL_loblit |
495 { | 522 SDL_CalculateBlit1 (SDL_Surface * surface, int blit_index) |
496 int which; | 523 { |
497 SDL_PixelFormat *dstfmt; | 524 int which; |
498 | 525 SDL_PixelFormat *dstfmt; |
499 dstfmt = surface->map->dst->format; | 526 |
500 if ( dstfmt->BitsPerPixel < 8 ) { | 527 dstfmt = surface->map->dst->format; |
501 which = 0; | 528 if (dstfmt->BitsPerPixel < 8) { |
502 } else { | 529 which = 0; |
503 which = dstfmt->BytesPerPixel; | 530 } else { |
504 } | 531 which = dstfmt->BytesPerPixel; |
505 switch(blit_index) { | 532 } |
506 case 0: /* copy */ | 533 switch (blit_index) { |
507 return one_blit[which]; | 534 case 0: /* copy */ |
508 | 535 return one_blit[which]; |
509 case 1: /* colorkey */ | 536 |
510 return one_blitkey[which]; | 537 case 1: /* colorkey */ |
511 | 538 return one_blitkey[which]; |
512 case 2: /* alpha */ | 539 |
513 /* Supporting 8bpp->8bpp alpha is doable but requires lots of | 540 case 2: /* alpha */ |
514 tables which consume space and takes time to precompute, | 541 /* Supporting 8bpp->8bpp alpha is doable but requires lots of |
515 so is better left to the user */ | 542 tables which consume space and takes time to precompute, |
516 return which >= 2 ? Blit1toNAlpha : NULL; | 543 so is better left to the user */ |
517 | 544 return which >= 2 ? Blit1toNAlpha : NULL; |
518 case 3: /* alpha + colorkey */ | 545 |
519 return which >= 2 ? Blit1toNAlphaKey : NULL; | 546 case 3: /* alpha + colorkey */ |
520 | 547 return which >= 2 ? Blit1toNAlphaKey : NULL; |
521 } | 548 |
522 return NULL; | 549 } |
523 } | 550 return NULL; |
551 } | |
552 | |
553 /* vi: set ts=4 sw=4 expandtab: */ |