mirror of https://github.com/encounter/SDL.git
Fixed bug #964 - SDL_RenderCopy stretch loses proportion on viewport boundaries
This commit is contained in:
parent
7bf8c5a388
commit
a988ce5544
|
@ -823,8 +823,25 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||||
* to avoid potentially frequent RLE encoding/decoding.
|
* to avoid potentially frequent RLE encoding/decoding.
|
||||||
*/
|
*/
|
||||||
SDL_SetSurfaceRLE(surface, 0);
|
SDL_SetSurfaceRLE(surface, 0);
|
||||||
|
|
||||||
|
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
|
||||||
|
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
|
||||||
|
SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect->w, dstrect->h, 0, src->format->format);
|
||||||
|
/* Scale to an intermediate surface, then blit */
|
||||||
|
if (tmp) {
|
||||||
|
SDL_Rect r;
|
||||||
|
r.x = 0;
|
||||||
|
r.y = 0;
|
||||||
|
r.w = dstrect->w;
|
||||||
|
r.h = dstrect->h;
|
||||||
|
SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode);
|
||||||
|
SDL_BlitSurface(tmp, NULL, surface, dstrect);
|
||||||
|
SDL_FreeSurface(tmp);
|
||||||
|
}
|
||||||
|
} else{
|
||||||
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue