Forward scale mode to SW renderer (Bug 5313)

This commit is contained in:
Sylvain Becker 2020-12-27 20:28:24 +01:00
parent 471d3c363e
commit f9b5f6cc0f
3 changed files with 28 additions and 4 deletions

View File

@ -258,6 +258,9 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode
the next call, because it might be in an array that gets realloc()'d. */
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
extern int SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
extern int SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
#endif /* SDL_sysrender_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -434,7 +434,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
retval = -1;
} else {
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
retval = SDL_BlitScaled(src_clone, srcrect, src_scaled, &scale_rect);
retval = SDL_PrivateUpperBlitScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
SDL_FreeSurface(src_clone);
src_clone = src_scaled;
src_scaled = NULL;
@ -720,7 +720,7 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
* to avoid potentially frequent RLE encoding/decoding.
*/
SDL_SetSurfaceRLE(surface, 0);
SDL_BlitScaled(src, srcrect, surface, dstrect);
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
}
break;
}

View File

@ -26,6 +26,7 @@
#include "SDL_RLEaccel_c.h"
#include "SDL_pixels_c.h"
#include "SDL_yuv_c.h"
#include "../render/SDL_sysrender.h"
/* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */
@ -745,6 +746,14 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
int
SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect)
{
return SDL_PrivateUpperBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
}
int
SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode)
{
double src_x0, src_y0, src_x1, src_y1;
double dst_x0, dst_y0, dst_x1, dst_y1;
@ -889,7 +898,7 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
return 0;
}
return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
return SDL_PrivateLowerBlitScaled(src, &final_src, dst, &final_dst, scaleMode);
}
/**
@ -899,6 +908,13 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
int
SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect)
{
return SDL_PrivateLowerBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
}
int
SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode)
{
static const Uint32 complex_copy_flags = (
SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA |
@ -914,7 +930,12 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
if ( !(src->map->info.flags & complex_copy_flags) &&
src->format->format == dst->format->format &&
!SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
if (scaleMode != SDL_ScaleModeNearest && src->format->BytesPerPixel == 4 && src->format->format != SDL_PIXELFORMAT_ARGB2101010) {
return SDL_SoftStretchLinear(src, srcrect, dst, dstrect);
} else {
return SDL_SoftStretch( src, srcrect, dst, dstrect );
}
} else {
return SDL_LowerBlit( src, srcrect, dst, dstrect );
}