Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_1.c @ 2267:c785543d1843
Okay, still some bugs, but everything builds again...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 18 Aug 2007 05:39:09 +0000 |
parents | bee005ace1bf |
children | e1da92da346c |
comparison
equal
deleted
inserted
replaced
2266:e61ad15a205f | 2267:c785543d1843 |
---|---|
40 | 40 |
41 /* Set up some basic variables */ | 41 /* Set up some basic variables */ |
42 width = info->dst_w; | 42 width = info->dst_w; |
43 height = info->dst_h; | 43 height = info->dst_h; |
44 src = info->src; | 44 src = info->src; |
45 srcskip = info->s_skip; | 45 srcskip = info->src_skip; |
46 dst = info->dst; | 46 dst = info->dst; |
47 dstskip = info->dst_pitch; | 47 dstskip = info->dst_skip; |
48 map = info->table; | 48 map = info->table; |
49 | 49 |
50 while (height--) { | 50 while (height--) { |
51 #ifdef USE_DUFFS_LOOP | 51 #ifdef USE_DUFFS_LOOP |
52 /* *INDENT-OFF* */ | 52 /* *INDENT-OFF* */ |
91 | 91 |
92 /* Set up some basic variables */ | 92 /* Set up some basic variables */ |
93 width = info->dst_w; | 93 width = info->dst_w; |
94 height = info->dst_h; | 94 height = info->dst_h; |
95 src = info->src; | 95 src = info->src; |
96 srcskip = info->s_skip; | 96 srcskip = info->src_skip; |
97 dst = info->dst; | 97 dst = info->dst; |
98 dstskip = info->dst_pitch; | 98 dstskip = info->dst_skip; |
99 map = (Uint16 *) info->table; | 99 map = (Uint16 *) info->table; |
100 | 100 |
101 #ifdef USE_DUFFS_LOOP | 101 #ifdef USE_DUFFS_LOOP |
102 while (height--) { | 102 while (height--) { |
103 /* *INDENT-OFF* */ | 103 /* *INDENT-OFF* */ |
197 | 197 |
198 /* Set up some basic variables */ | 198 /* Set up some basic variables */ |
199 width = info->dst_w; | 199 width = info->dst_w; |
200 height = info->dst_h; | 200 height = info->dst_h; |
201 src = info->src; | 201 src = info->src; |
202 srcskip = info->s_skip; | 202 srcskip = info->src_skip; |
203 dst = info->dst; | 203 dst = info->dst; |
204 dstskip = info->dst_pitch; | 204 dstskip = info->dst_skip; |
205 map = info->table; | 205 map = info->table; |
206 | 206 |
207 while (height--) { | 207 while (height--) { |
208 #ifdef USE_DUFFS_LOOP | 208 #ifdef USE_DUFFS_LOOP |
209 /* *INDENT-OFF* */ | 209 /* *INDENT-OFF* */ |
245 | 245 |
246 /* Set up some basic variables */ | 246 /* Set up some basic variables */ |
247 width = info->dst_w; | 247 width = info->dst_w; |
248 height = info->dst_h; | 248 height = info->dst_h; |
249 src = info->src; | 249 src = info->src; |
250 srcskip = info->s_skip; | 250 srcskip = info->src_skip; |
251 dst = (Uint32 *) info->dst; | 251 dst = (Uint32 *) info->dst; |
252 dstskip = info->dst_pitch / 4; | 252 dstskip = info->dst_skip / 4; |
253 map = (Uint32 *) info->table; | 253 map = (Uint32 *) info->table; |
254 | 254 |
255 while (height--) { | 255 while (height--) { |
256 #ifdef USE_DUFFS_LOOP | 256 #ifdef USE_DUFFS_LOOP |
257 /* *INDENT-OFF* */ | 257 /* *INDENT-OFF* */ |
284 Blit1to1Key(SDL_BlitInfo * info) | 284 Blit1to1Key(SDL_BlitInfo * info) |
285 { | 285 { |
286 int width = info->dst_w; | 286 int width = info->dst_w; |
287 int height = info->dst_h; | 287 int height = info->dst_h; |
288 Uint8 *src = info->src; | 288 Uint8 *src = info->src; |
289 int srcskip = info->s_skip; | 289 int srcskip = info->src_skip; |
290 Uint8 *dst = info->dst; | 290 Uint8 *dst = info->dst; |
291 int dstskip = info->dst_pitch; | 291 int dstskip = info->dst_skip; |
292 Uint8 *palmap = info->table; | 292 Uint8 *palmap = info->table; |
293 Uint32 ckey = info->ckey; | 293 Uint32 ckey = info->colorkey; |
294 | 294 |
295 if (palmap) { | 295 if (palmap) { |
296 while (height--) { | 296 while (height--) { |
297 /* *INDENT-OFF* */ | 297 /* *INDENT-OFF* */ |
298 DUFFS_LOOP( | 298 DUFFS_LOOP( |
331 Blit1to2Key(SDL_BlitInfo * info) | 331 Blit1to2Key(SDL_BlitInfo * info) |
332 { | 332 { |
333 int width = info->dst_w; | 333 int width = info->dst_w; |
334 int height = info->dst_h; | 334 int height = info->dst_h; |
335 Uint8 *src = info->src; | 335 Uint8 *src = info->src; |
336 int srcskip = info->s_skip; | 336 int srcskip = info->src_skip; |
337 Uint16 *dstp = (Uint16 *) info->dst; | 337 Uint16 *dstp = (Uint16 *) info->dst; |
338 int dstskip = info->dst_pitch; | 338 int dstskip = info->dst_skip; |
339 Uint16 *palmap = (Uint16 *) info->table; | 339 Uint16 *palmap = (Uint16 *) info->table; |
340 Uint32 ckey = info->ckey; | 340 Uint32 ckey = info->colorkey; |
341 | 341 |
342 /* Set up some basic variables */ | 342 /* Set up some basic variables */ |
343 dstskip /= 2; | 343 dstskip /= 2; |
344 | 344 |
345 while (height--) { | 345 while (height--) { |
363 Blit1to3Key(SDL_BlitInfo * info) | 363 Blit1to3Key(SDL_BlitInfo * info) |
364 { | 364 { |
365 int width = info->dst_w; | 365 int width = info->dst_w; |
366 int height = info->dst_h; | 366 int height = info->dst_h; |
367 Uint8 *src = info->src; | 367 Uint8 *src = info->src; |
368 int srcskip = info->s_skip; | 368 int srcskip = info->src_skip; |
369 Uint8 *dst = info->dst; | 369 Uint8 *dst = info->dst; |
370 int dstskip = info->dst_pitch; | 370 int dstskip = info->dst_skip; |
371 Uint8 *palmap = info->table; | 371 Uint8 *palmap = info->table; |
372 Uint32 ckey = info->ckey; | 372 Uint32 ckey = info->colorkey; |
373 int o; | 373 int o; |
374 | 374 |
375 while (height--) { | 375 while (height--) { |
376 /* *INDENT-OFF* */ | 376 /* *INDENT-OFF* */ |
377 DUFFS_LOOP( | 377 DUFFS_LOOP( |
396 Blit1to4Key(SDL_BlitInfo * info) | 396 Blit1to4Key(SDL_BlitInfo * info) |
397 { | 397 { |
398 int width = info->dst_w; | 398 int width = info->dst_w; |
399 int height = info->dst_h; | 399 int height = info->dst_h; |
400 Uint8 *src = info->src; | 400 Uint8 *src = info->src; |
401 int srcskip = info->s_skip; | 401 int srcskip = info->src_skip; |
402 Uint32 *dstp = (Uint32 *) info->dst; | 402 Uint32 *dstp = (Uint32 *) info->dst; |
403 int dstskip = info->dst_pitch; | 403 int dstskip = info->dst_skip; |
404 Uint32 *palmap = (Uint32 *) info->table; | 404 Uint32 *palmap = (Uint32 *) info->table; |
405 Uint32 ckey = info->ckey; | 405 Uint32 ckey = info->colorkey; |
406 | 406 |
407 /* Set up some basic variables */ | 407 /* Set up some basic variables */ |
408 dstskip /= 4; | 408 dstskip /= 4; |
409 | 409 |
410 while (height--) { | 410 while (height--) { |
428 Blit1toNAlpha(SDL_BlitInfo * info) | 428 Blit1toNAlpha(SDL_BlitInfo * info) |
429 { | 429 { |
430 int width = info->dst_w; | 430 int width = info->dst_w; |
431 int height = info->dst_h; | 431 int height = info->dst_h; |
432 Uint8 *src = info->src; | 432 Uint8 *src = info->src; |
433 int srcskip = info->s_skip; | 433 int srcskip = info->src_skip; |
434 Uint8 *dst = info->dst; | 434 Uint8 *dst = info->dst; |
435 int dstskip = info->dst_pitch; | 435 int dstskip = info->dst_skip; |
436 SDL_PixelFormat *dstfmt = info->dst; | 436 SDL_PixelFormat *dstfmt = info->dst_fmt; |
437 const SDL_Color *srcpal = info->src->palette->colors; | 437 const SDL_Color *srcpal = info->src_fmt->palette->colors; |
438 int dstbpp; | 438 int dstbpp; |
439 const int A = (info->cmod >> 24); | 439 const int A = info->a; |
440 | 440 |
441 /* Set up some basic variables */ | 441 /* Set up some basic variables */ |
442 dstbpp = dstfmt->BytesPerPixel; | 442 dstbpp = dstfmt->BytesPerPixel; |
443 | 443 |
444 while (height--) { | 444 while (height--) { |
469 Blit1toNAlphaKey(SDL_BlitInfo * info) | 469 Blit1toNAlphaKey(SDL_BlitInfo * info) |
470 { | 470 { |
471 int width = info->dst_w; | 471 int width = info->dst_w; |
472 int height = info->dst_h; | 472 int height = info->dst_h; |
473 Uint8 *src = info->src; | 473 Uint8 *src = info->src; |
474 int srcskip = info->s_skip; | 474 int srcskip = info->src_skip; |
475 Uint8 *dst = info->dst; | 475 Uint8 *dst = info->dst; |
476 int dstskip = info->dst_pitch; | 476 int dstskip = info->dst_skip; |
477 SDL_PixelFormat *srcfmt = info->src; | 477 SDL_PixelFormat *srcfmt = info->src_fmt; |
478 SDL_PixelFormat *dstfmt = info->dst; | 478 SDL_PixelFormat *dstfmt = info->dst_fmt; |
479 const SDL_Color *srcpal = info->src->palette->colors; | 479 const SDL_Color *srcpal = info->src_fmt->palette->colors; |
480 Uint32 ckey = info->ckey; | 480 Uint32 ckey = info->colorkey; |
481 int dstbpp; | 481 int dstbpp; |
482 const int A = (info->cmod >> 24); | 482 const int A = info->a; |
483 | 483 |
484 /* Set up some basic variables */ | 484 /* Set up some basic variables */ |
485 dstbpp = dstfmt->BytesPerPixel; | 485 dstbpp = dstfmt->BytesPerPixel; |
486 | 486 |
487 while (height--) { | 487 while (height--) { |
508 src += srcskip; | 508 src += srcskip; |
509 dst += dstskip; | 509 dst += dstskip; |
510 } | 510 } |
511 } | 511 } |
512 | 512 |
513 static SDL_loblit one_blit[] = { | 513 static SDL_BlitFunc one_blit[] = { |
514 NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 | 514 NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 |
515 }; | 515 }; |
516 | 516 |
517 static SDL_loblit one_blitkey[] = { | 517 static SDL_BlitFunc one_blitkey[] = { |
518 NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key | 518 NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key |
519 }; | 519 }; |
520 | 520 |
521 SDL_loblit | 521 SDL_BlitFunc |
522 SDL_CalculateBlit1(SDL_Surface * surface, int blit_index) | 522 SDL_CalculateBlit1(SDL_Surface * surface) |
523 { | 523 { |
524 int which; | 524 int which; |
525 SDL_PixelFormat *dstfmt; | 525 SDL_PixelFormat *dstfmt; |
526 | 526 |
527 dstfmt = surface->map->dst->format; | 527 dstfmt = surface->map->dst->format; |
528 if (dstfmt->BitsPerPixel < 8) { | 528 if (dstfmt->BitsPerPixel < 8) { |
529 which = 0; | 529 which = 0; |
530 } else { | 530 } else { |
531 which = dstfmt->BytesPerPixel; | 531 which = dstfmt->BytesPerPixel; |
532 } | 532 } |
533 switch (blit_index) { | 533 switch (surface->map->info.flags) { |
534 case 0: /* copy */ | 534 case 0: |
535 return one_blit[which]; | 535 return one_blit[which]; |
536 | 536 |
537 case 1: /* colorkey */ | 537 case SDL_COPY_COLORKEY: |
538 return one_blitkey[which]; | 538 return one_blitkey[which]; |
539 | 539 |
540 case 2: /* alpha */ | 540 case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: |
541 /* Supporting 8bpp->8bpp alpha is doable but requires lots of | 541 /* Supporting 8bpp->8bpp alpha is doable but requires lots of |
542 tables which consume space and takes time to precompute, | 542 tables which consume space and takes time to precompute, |
543 so is better left to the user */ | 543 so is better left to the user */ |
544 return which >= 2 ? Blit1toNAlpha : NULL; | 544 return which >= 2 ? Blit1toNAlpha : NULL; |
545 | 545 |
546 case 3: /* alpha + colorkey */ | 546 case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: |
547 return which >= 2 ? Blit1toNAlphaKey : NULL; | 547 return which >= 2 ? Blit1toNAlphaKey : NULL; |
548 | |
549 } | 548 } |
550 return NULL; | 549 return NULL; |
551 } | 550 } |
552 | 551 |
553 /* vi: set ts=4 sw=4 expandtab: */ | 552 /* vi: set ts=4 sw=4 expandtab: */ |