comparison src/video/SDL_RLEaccel.c @ 1:cf2af46e9e2a

Changes since SDL 1.2.0 release
author Sam Lantinga <slouken@lokigames.com>
date Thu, 26 Apr 2001 16:50:19 +0000
parents 74212992fb08
children e8157fcb3114
comparison
equal deleted inserted replaced
0:74212992fb08 1:cf2af46e9e2a
107 #endif 107 #endif
108 #ifndef MIN 108 #ifndef MIN
109 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 109 #define MIN(a, b) ((a) < (b) ? (a) : (b))
110 #endif 110 #endif
111 111
112 #define PIXEL_COPY(to, from, len, bpp) \
113 do { \
114 if(bpp == 4) { \
115 SDL_memcpy4(to, from, (unsigned)(len)); \
116 } else { \
117 SDL_memcpy(to, from, (unsigned)(len) * (bpp)); \
118 } \
119 } while(0)
120
112 /* 121 /*
113 * Various colorkey blit methods, for opaque and per-surface alpha 122 * Various colorkey blit methods, for opaque and per-surface alpha
114 */ 123 */
115 124
116 #define OPAQUE_BLIT(to, from, length, bpp, alpha) \ 125 #define OPAQUE_BLIT(to, from, length, bpp, alpha) \
117 SDL_memcpy(to, from, (unsigned)(length * bpp)) 126 PIXEL_COPY(to, from, length, bpp)
118 127
119 /* 128 /*
120 * For 32bpp pixels on the form 0x00rrggbb: 129 * For 32bpp pixels on the form 0x00rrggbb:
121 * If we treat the middle component separately, we can process the two 130 * If we treat the middle component separately, we can process the two
122 * remaining in parallel. This is safe to do because of the gap to the left 131 * remaining in parallel. This is safe to do because of the gap to the left
655 cofs = left; \ 664 cofs = left; \
656 } \ 665 } \
657 if(crun > right - cofs) \ 666 if(crun > right - cofs) \
658 crun = right - cofs; \ 667 crun = right - cofs; \
659 if(crun > 0) \ 668 if(crun > 0) \
660 SDL_memcpy(dstbuf + cofs * sizeof(Ptype), \ 669 PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \
661 srcbuf + (cofs - ofs) * sizeof(Ptype), \ 670 srcbuf + (cofs - ofs) * sizeof(Ptype), \
662 (unsigned)crun * sizeof(Ptype)); \ 671 (unsigned)crun, sizeof(Ptype)); \
663 srcbuf += run * sizeof(Ptype); \ 672 srcbuf += run * sizeof(Ptype); \
664 ofs += run; \ 673 ofs += run; \
665 } else if(!ofs) \ 674 } else if(!ofs) \
666 return; \ 675 return; \
667 } while(ofs < w); \ 676 } while(ofs < w); \
814 unsigned run; \ 823 unsigned run; \
815 ofs += ((Ctype *)srcbuf)[0]; \ 824 ofs += ((Ctype *)srcbuf)[0]; \
816 run = ((Ctype *)srcbuf)[1]; \ 825 run = ((Ctype *)srcbuf)[1]; \
817 srcbuf += 2 * sizeof(Ctype); \ 826 srcbuf += 2 * sizeof(Ctype); \
818 if(run) { \ 827 if(run) { \
819 SDL_memcpy(dstbuf + ofs * sizeof(Ptype), srcbuf, \ 828 PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \
820 run * sizeof(Ptype)); \ 829 run, sizeof(Ptype)); \
821 srcbuf += run * sizeof(Ptype); \ 830 srcbuf += run * sizeof(Ptype); \
822 ofs += run; \ 831 ofs += run; \
823 } else if(!ofs) \ 832 } else if(!ofs) \
824 goto done; \ 833 goto done; \
825 } while(ofs < w); \ 834 } while(ofs < w); \