Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
- Note
- This function uses a static buffer, and is not thread-safe.
Definition at line 203 of file SDL_stretch.c.
210 int src_row, dst_row;
215 #ifdef USE_ASM_STRETCH
221 const int bpp =
dst->format->BytesPerPixel;
223 if (
src->format->format !=
dst->format->format) {
224 return SDL_SetError(
"Only works with same format surfaces");
229 if ((srcrect->
x < 0) || (srcrect->
y < 0) ||
230 ((srcrect->
x + srcrect->
w) >
src->w) ||
231 ((srcrect->
y + srcrect->
h) >
src->h)) {
242 if ((dstrect->
x < 0) || (dstrect->
y < 0) ||
243 ((dstrect->
x + dstrect->
w) >
dst->w) ||
244 ((dstrect->
y + dstrect->
h) >
dst->h)) {
245 return SDL_SetError(
"Invalid destination blit rectangle");
259 return SDL_SetError(
"Unable to lock destination surface");
277 inc = (srcrect->
h << 16) / dstrect->
h;
278 src_row = srcrect->
y;
279 dst_row = dstrect->
y;
281 #ifdef USE_ASM_STRETCH
283 if ((
bpp == 3) || (generate_rowbytes(srcrect->
w, dstrect->
w,
bpp) < 0)) {
289 for (dst_maxrow = dst_row + dstrect->
h; dst_row < dst_maxrow; ++dst_row) {
290 dstp = (
Uint8 *)
dst->pixels + (dst_row *
dst->pitch)
291 + (dstrect->
x *
bpp);
292 while (pos >= 0x10000L) {
293 srcp = (
Uint8 *)
src->pixels + (src_row *
src->pitch)
294 + (srcrect->
x *
bpp);
298 #ifdef USE_ASM_STRETCH
301 __asm__ __volatile__(
"call *%4":
"=&D"(
u1),
"=&S"(
u2)
302 :
"0"(dstp),
"1"(srcp),
"r"(copy_row)
304 #elif defined(_MSC_VER) || defined(__WATCOMC__)
307 void *code = copy_row;
320 #error Need inline assembly for this compiler
326 copy_row1(srcp, srcrect->
w, dstp, dstrect->
w);
329 copy_row2((
Uint16 *) srcp, srcrect->
w,
336 copy_row4((
Uint32 *) srcp, srcrect->
w,
References bpp, copy_row3(), SDL_Rect::h, if, mov, NULL, pop, ptr, SDL_FALSE, SDL_LockSurface, SDL_MUSTLOCK, SDL_SetError, SDL_TRUE, SDL_UnlockSurface, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.