From 12e50d17a2c1f3f906698b797beeddb9d7af5613 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 20 Jul 2024 15:52:42 -0700 Subject: [PATCH] Removed SDL_SoftStretch() from the public API SDL_BlitSurfaceScaled() is more flexible and uses the SDL_SoftStretch() fast path when possible. Having two surface scaling APIs was confusing, especially when one of them has unexpected limitations. --- docs/README-migration.md | 3 ++- include/SDL3/SDL_surface.h | 22 ---------------------- src/dynapi/SDL_dynapi.sym | 1 - src/dynapi/SDL_dynapi_overrides.h | 1 - src/dynapi/SDL_dynapi_procs.h | 1 - src/render/SDL_yuv_sw.c | 1 + src/video/SDL_surface_c.h | 1 + src/video/windows/SDL_windowsshape.c | 2 ++ src/video/x11/SDL_x11shape.c | 2 ++ 9 files changed, 8 insertions(+), 26 deletions(-) diff --git a/docs/README-migration.md b/docs/README-migration.md index 9b5ae1efe..0d3083069 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1756,7 +1756,8 @@ The following functions have been removed: * SDL_GetYUVConversionMode() * SDL_GetYUVConversionModeForResolution() * SDL_SetYUVConversionMode() - use SDL_SetSurfaceColorspace() to set the surface colorspace and SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER with SDL_CreateTextureWithProperties() to set the texture colorspace. The default colorspace for YUV pixel formats is SDL_COLORSPACE_JPEG. -* SDL_SoftStretchLinear() - use SDL_SoftStretch() with SDL_SCALEMODE_LINEAR +* SDL_SoftStretch() - use SDL_BlitSurfaceScaled() with SDL_SCALEMODE_NEAREST +* SDL_SoftStretchLinear() - use SDL_BlitSurfaceScaled() with SDL_SCALEMODE_LINEAR The following symbols have been renamed: * SDL_PREALLOC => SDL_SURFACE_PREALLOCATED diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h index cd3d72245..df035a879 100644 --- a/include/SDL3/SDL_surface.h +++ b/include/SDL3/SDL_surface.h @@ -997,28 +997,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect */ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); -/** - * Perform stretch blit between two surfaces of the same format. - * - * Using SDL_SCALEMODE_NEAREST: fast, low quality. Using SDL_SCALEMODE_LINEAR: - * bilinear scaling, slower, better quality, only 32BPP. - * - * \param src the SDL_Surface structure to be copied from. - * \param srcrect the SDL_Rect structure representing the rectangle to be - * copied, may not be NULL. - * \param dst the SDL_Surface structure that is the blit target. - * \param dstrect the SDL_Rect structure representing the target rectangle in - * the destination surface, may not be NULL. - * \param scaleMode scale algorithm to be used. - * \returns 0 on success or a negative error code on failure; call - * SDL_GetError() for more information. - * - * \since This function is available since SDL 3.0.0. - * - * \sa SDL_BlitSurfaceScaled - */ -extern SDL_DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); - /** * Perform a scaled blit to a destination surface, which may be of a different * format. diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index bfb01a6a7..98c9e98c2 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -806,7 +806,6 @@ SDL3_0.0.0 { SDL_ShowWindow; SDL_ShowWindowSystemMenu; SDL_SignalCondition; - SDL_SoftStretch; SDL_StartTextInput; SDL_StepUTF8; SDL_StopHapticEffect; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index bc3def34b..629db5f94 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -831,7 +831,6 @@ #define SDL_ShowWindow SDL_ShowWindow_REAL #define SDL_ShowWindowSystemMenu SDL_ShowWindowSystemMenu_REAL #define SDL_SignalCondition SDL_SignalCondition_REAL -#define SDL_SoftStretch SDL_SoftStretch_REAL #define SDL_StartTextInput SDL_StartTextInput_REAL #define SDL_StepUTF8 SDL_StepUTF8_REAL #define SDL_StopHapticEffect SDL_StopHapticEffect_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 2de7eccb3..55c8a0b32 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -841,7 +841,6 @@ SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(SDL_MessageBoxFlags a, const char SDL_DYNAPI_PROC(int,SDL_ShowWindow,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_ShowWindowSystemMenu,(SDL_Window *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_Condition *a),(a),return) -SDL_DYNAPI_PROC(int,SDL_SoftStretch,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_StartTextInput,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_StepUTF8,(const char **a, size_t *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_StopHapticEffect,(SDL_Haptic *a, int b),(a,b),return) diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 7f8091eaa..dd885fed7 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -25,6 +25,7 @@ #if SDL_HAVE_YUV #include "SDL_yuv_sw_c.h" +#include "../video/SDL_blit.h" #include "../video/SDL_yuv_c.h" SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h) diff --git a/src/video/SDL_surface_c.h b/src/video/SDL_surface_c.h index 215387bd6..cd8420e78 100644 --- a/src/video/SDL_surface_c.h +++ b/src/video/SDL_surface_c.h @@ -76,5 +76,6 @@ extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace); extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace); extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace); extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace); +extern int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode); #endif /* SDL_surface_c_h_ */ diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index dd86b70d2..0abf374f3 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -25,6 +25,8 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsshape.h" +#include "../SDL_blit.h" + static void AddRegion(HRGN *mask, int x1, int y1, int x2, int y2) { diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 792937d3b..81da584d4 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -25,6 +25,8 @@ #include "SDL_x11video.h" #include "SDL_x11shape.h" +#include "../SDL_blit.h" + #ifdef SDL_VIDEO_DRIVER_X11_XSHAPE static Uint8 *GenerateShapeMask(SDL_Surface *shape)