Fixed bug #964 - SDL_RenderCopy stretch loses proportion on viewport.

Handle the case when there is blending
This commit is contained in:
Sylvain 2022-01-29 10:19:08 +01:00
parent 8b139e26a3
commit f7d3abddba
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E
1 changed files with 18 additions and 0 deletions

View File

@ -829,13 +829,31 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
/* Scale to an intermediate surface, then blit */
if (tmp) {
SDL_Rect r;
SDL_BlendMode blendmode;
Uint8 alphaMod, rMod, gMod, bMod;
SDL_GetSurfaceBlendMode(src, &blendmode);
SDL_GetSurfaceAlphaMod(src, &alphaMod);
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
r.x = 0;
r.y = 0;
r.w = dstrect->w;
r.h = dstrect->h;
SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_NONE);
SDL_SetSurfaceColorMod(src, 255, 255, 255);
SDL_SetSurfaceAlphaMod(src, 255);
SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode);
SDL_SetSurfaceColorMod(tmp, rMod, gMod, bMod);
SDL_SetSurfaceAlphaMod(tmp, alphaMod);
SDL_SetSurfaceBlendMode(tmp, blendmode);
SDL_BlitSurface(tmp, NULL, surface, dstrect);
SDL_FreeSurface(tmp);
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
}
} else{
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);