From 9752347856e1947a0275cd16d35a13d6fd68ab87 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 6 Feb 2025 16:15:50 -0800
Subject: [PATCH] Use SDL_StretchSurface() to implement SDL_SoftStretch() and
SDL_SoftStretchLinear()
Fixes https://github.com/libsdl-org/sdl2-compat/issues/251
---
src/sdl2_compat.c | 6 +++---
src/sdl3_include_wrapper.h | 4 ++--
src/sdl3_syms.h | 1 +
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index c22482e..3718c9e 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -398,7 +398,7 @@ static char loaderror[256];
#endif
#ifndef SDL3_REQUIRED_VER
-#define SDL3_REQUIRED_VER SDL_VERSIONNUM(3,2,0)
+#define SDL3_REQUIRED_VER SDL_VERSIONNUM(3,2,4)
#endif
#ifndef DIRSEP
@@ -3635,13 +3635,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_StretchSurface(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_StretchSurface(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 37b13cf..dafc33d 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -1273,8 +1273,8 @@
#define __BUILDING_SDL2_COMPAT__ 1
#include <SDL3/SDL.h>
-#if !SDL_VERSION_ATLEAST(3,2,0)
-#error You need to compile against SDL >= 3.2.0 headers
+#if !SDL_VERSION_ATLEAST(3,2,4)
+#error You need to compile against SDL >= 3.2.4 headers
#endif
#define SDL_MAIN_HANDLED 1
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index d271a65..bb7155d 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -676,6 +676,7 @@ SDL3_SYM(void,SignalSemaphore,(SDL_Semaphore *a),(a),return)
SDL3_SYM(bool,StartTextInput,(SDL_Window *a),(a),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,StretchSurface,(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,SurfaceHasColorKey,(SDL_Surface *a),(a),return)
SDL3_SYM(bool,SurfaceHasRLE,(SDL_Surface *a),(a),return)
SDL3_SYM_RENAMED(void,TLSCleanup,CleanupTLS,(void),(),)