comparison src/video/SDL_stretch.c @ 1985:8055185ae4ed

Added source color and alpha modulation support. Added perl script to generate optimized render copy functions.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 28 Aug 2006 03:17:39 +0000
parents c121d94672cb
children 7e5ff6cd05bf
comparison
equal deleted inserted replaced
1984:b910bcabec26 1985:8055185ae4ed
119 return (0); 119 return (0);
120 } 120 }
121 121
122 #else 122 #else
123 123
124 #define DEFINE_COPY_ROW(name, type) \ 124 #define DEFINE_COPY_ROW(name, type) \
125 void name(type *src, int src_w, type *dst, int dst_w) \ 125 void name(type *src, int src_w, type *dst, int dst_w) \
126 { \ 126 { \
127 int i; \ 127 int i; \
128 int pos, inc; \ 128 int pos, inc; \
129 type pixel = 0; \ 129 type pixel = 0; \
130 \ 130 \
131 pos = 0x10000; \ 131 pos = 0x10000; \
132 inc = (src_w << 16) / dst_w; \ 132 inc = (src_w << 16) / dst_w; \
133 for ( i=dst_w; i>0; --i ) { \ 133 for ( i=dst_w; i>0; --i ) { \
134 while ( pos >= 0x10000L ) { \ 134 while ( pos >= 0x10000L ) { \
135 pixel = *src++; \ 135 pixel = *src++; \
136 pos -= 0x10000L; \ 136 pos -= 0x10000L; \
137 } \ 137 } \
138 *dst++ = pixel; \ 138 *dst++ = pixel; \
139 pos += inc; \ 139 pos += inc; \
140 } \ 140 } \
141 } 141 }
142 /* *INDENT-OFF* */
142 DEFINE_COPY_ROW(copy_row1, Uint8) 143 DEFINE_COPY_ROW(copy_row1, Uint8)
143 DEFINE_COPY_ROW(copy_row2, Uint16) DEFINE_COPY_ROW(copy_row4, Uint32) 144 DEFINE_COPY_ROW(copy_row2, Uint16)
145 DEFINE_COPY_ROW(copy_row4, Uint32)
146 /* *INDENT-ON* */
144 #endif /* USE_ASM_STRETCH */ 147 #endif /* USE_ASM_STRETCH */
145 /* The ASM code doesn't handle 24-bpp stretch blits */ 148 /* The ASM code doesn't handle 24-bpp stretch blits */
146 void 149 void
147 copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w) 150 copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w)
148 { 151 {
149 int i; 152 int i;
150 int pos, inc; 153 int pos, inc;
151 Uint8 pixel[3]; 154 Uint8 pixel[3];
152 155
276 break; 279 break;
277 default: 280 default:
278 #ifdef __GNUC__ 281 #ifdef __GNUC__
279 __asm__ __volatile__("call *%4": "=&D"(u1), "=&S"(u2): "0"(dstp), "1"(srcp), "r"(copy_row):"memory"); 282 __asm__ __volatile__("call *%4": "=&D"(u1), "=&S"(u2): "0"(dstp), "1"(srcp), "r"(copy_row):"memory");
280 #elif defined(_MSC_VER) || defined(__WATCOMC__) 283 #elif defined(_MSC_VER) || defined(__WATCOMC__)
284 /* *INDENT-OFF* */
281 { 285 {
282 void *code = copy_row; 286 void *code = copy_row;
283 __asm { 287 __asm {
284 push edi 288 push edi
285 push esi 289 push esi
286 mov edi, dstp 290 mov edi, dstp
287 mov esi, srcp call dword ptr code pop esi pop edi} 291 mov esi, srcp
292 call dword ptr code
293 pop esi
294 pop edi
295 }
288 } 296 }
297 /* *INDENT-ON* */
289 #else 298 #else
290 #error Need inline assembly for this compiler 299 #error Need inline assembly for this compiler
291 #endif 300 #endif
292 break; 301 break;
293 } 302 }