sdl2-compat: Use SDL_SoftStretch() from SDL3

From 3ffd92536b0d57af0d7a73a587503d5fe94ccc0a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 2 Feb 2025 13:42:11 -0800
Subject: [PATCH] Use SDL_SoftStretch() from SDL3

Fixes https://github.com/libsdl-org/sdl2-compat/issues/251
---
 src/sdl2_compat.c          | 4 ++--
 src/sdl3_include_wrapper.h | 5 +++++
 src/sdl3_syms.h            | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 3c9cd88..1aaabab 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -3405,13 +3405,13 @@ SDL_LowerBlitScaled(SDL2_Surface *src2, SDL_Rect *srcrect, SDL2_Surface *dst2, S
 SDL_DECLSPEC int SDLCALL
 SDL_SoftStretch(SDL2_Surface *src, const SDL_Rect *srcrect, SDL2_Surface *dst, const SDL_Rect *dstrect)
 {
-    return SDL3_BlitSurfaceScaled(Surface2to3(src), srcrect, Surface2to3(dst), dstrect, SDL_SCALEMODE_NEAREST) ? 0 : -1;
+    return SDL3_SoftStretch(Surface2to3(src), srcrect, Surface2to3(dst), dstrect, SDL_SCALEMODE_NEAREST) ? 0 : -1;
 }
 
 SDL_DECLSPEC int SDLCALL
 SDL_SoftStretchLinear(SDL2_Surface *src, const SDL_Rect *srcrect, SDL2_Surface *dst, const SDL_Rect *dstrect)
 {
-    return SDL3_BlitSurfaceScaled(Surface2to3(src), srcrect, Surface2to3(dst), dstrect, SDL_SCALEMODE_LINEAR) ? 0 : -1;
+    return SDL3_SoftStretch(Surface2to3(src), srcrect, Surface2to3(dst), dstrect, SDL_SCALEMODE_LINEAR) ? 0 : -1;
 }
 
 /* SDL_GetTicks is 64-bit in SDL3. Clamp it for SDL2. */
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index e83f74d..c5591c5 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -942,6 +942,7 @@
 #define SDL_ShowWindowSystemMenu IGNORE_THIS_VERSION_OF_SDL_ShowWindowSystemMenu
 #define SDL_SignalCondition IGNORE_THIS_VERSION_OF_SDL_SignalCondition
 #define SDL_SignalSemaphore IGNORE_THIS_VERSION_OF_SDL_SignalSemaphore
+#define SDL_SoftStretch IGNORE_THIS_VERSION_OF_SDL_SoftStretch
 #define SDL_StartTextInput IGNORE_THIS_VERSION_OF_SDL_StartTextInput
 #define SDL_StartTextInputWithProperties IGNORE_THIS_VERSION_OF_SDL_StartTextInputWithProperties
 #define SDL_StepUTF8 IGNORE_THIS_VERSION_OF_SDL_StepUTF8
@@ -4925,6 +4926,10 @@
 #undef SDL_SignalSemaphore
 #endif
 
+#ifdef SDL_SoftStretch
+#undef SDL_SoftStretch
+#endif
+
 #ifdef SDL_StartTextInput
 #undef SDL_StartTextInput
 #endif
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 29a8e7a..498fc58 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -671,6 +671,7 @@ SDL3_SYM(bool,ShowWindow,(SDL_Window *a),(a),return)
 SDL3_SYM(void,SignalCondition,(SDL_Condition *a),(a),return)
 SDL3_SYM(void,SignalSemaphore,(SDL_Semaphore *a),(a),return)
 SDL3_SYM(bool,StartTextInput,(SDL_Window *a),(a),return)
+SDL3_SYM(bool,SoftStretch,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
 SDL3_SYM(bool,StartTextInputWithProperties,(SDL_Window *a, SDL_PropertiesID b),(a,b),return)
 SDL3_SYM(bool,StopTextInput,(SDL_Window *a),(a),return)
 SDL3_SYM(bool,SurfaceHasColorKey,(SDL_Surface *a),(a),return)