sdl2-compat: Updated for latest SDL3 changes as of 80a907e0e688268083af4f9eb5661c792e1158aa

From ee0a86a2d2e8442898c1889efd44080fc5d195bb Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 12 Jun 2024 19:29:34 -0700
Subject: [PATCH] Updated for latest SDL3 changes as of
 80a907e0e688268083af4f9eb5661c792e1158aa

---
 src/sdl2_compat.c | 73 ++++++-----------------------------------------
 src/sdl3_syms.h   | 14 ++++-----
 2 files changed, 15 insertions(+), 72 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index b15083e..ace1e01 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -3871,22 +3871,6 @@ SDL_GetRendererInfo(SDL_Renderer *renderer, SDL2_RendererInfo *info)
     return 0;
 }
 
-SDL_DECLSPEC int SDLCALL
-SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h)
-{
-    float fw = 0.0f, fh = 0.0f;
-    if (SDL3_GetRenderOutputSize(renderer, &fw, &fh) < 0) {
-        return -1;
-    }
-    if (w) {
-        *w = (int)fw;
-    }
-    if (h) {
-        *h = (int)fh;
-    }
-    return 0;
-}
-
 SDL_DECLSPEC int SDLCALL
 SDL_GetRenderDriverInfo(int idx, SDL2_RendererInfo *info)
 {
@@ -4016,27 +4000,13 @@ SDL_RenderTargetSupported(SDL_Renderer *renderer)
 SDL_DECLSPEC void SDLCALL
 SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
 {
-    SDL_FRect frect;
-    SDL3_GetRenderViewport(renderer, &frect);
-    if (rect) {
-        rect->x = (int)frect.x;
-        rect->y = (int)frect.y;
-        rect->w = (int)frect.w;
-        rect->h = (int)frect.h;
-    }
+    SDL3_GetRenderViewport(renderer, rect);
 }
 
 SDL_DECLSPEC void SDLCALL
 SDL_RenderGetClipRect(SDL_Renderer *renderer, SDL_Rect *rect)
 {
-    SDL_FRect frect;
-    SDL3_GetRenderClipRect(renderer, &frect);
-    if (rect) {
-        rect->x = (int)frect.x;
-        rect->y = (int)frect.y;
-        rect->w = (int)frect.w;
-        rect->h = (int)frect.h;
-    }
+    SDL3_GetRenderClipRect(renderer, rect);
 }
 
 SDL_DECLSPEC void SDLCALL
@@ -4069,9 +4039,9 @@ SDL_RenderSetLogicalSize(SDL_Renderer *renderer, int w, int h)
 {
     int retval;
     if (w == 0 && h == 0) {
-        retval = SDL3_SetRenderLogicalPresentation(renderer, 0.0f, 0.0f, SDL_LOGICAL_PRESENTATION_DISABLED, SDL_SCALEMODE_NEAREST);
+        retval = SDL3_SetRenderLogicalPresentation(renderer, 0, 0, SDL_LOGICAL_PRESENTATION_DISABLED, SDL_SCALEMODE_NEAREST);
     } else {
-        retval = SDL3_SetRenderLogicalPresentation(renderer, (float)w, (float)h, SDL_LOGICAL_PRESENTATION_LETTERBOX, SDL_SCALEMODE_LINEAR);
+        retval = SDL3_SetRenderLogicalPresentation(renderer, w, h, SDL_LOGICAL_PRESENTATION_LETTERBOX, SDL_SCALEMODE_LINEAR);
     }
     return retval < 0 ? retval : FlushRendererIfNotBatching(renderer);
 }
@@ -4079,14 +4049,7 @@ SDL_RenderSetLogicalSize(SDL_Renderer *renderer, int w, int h)
 SDL_DECLSPEC void SDLCALL
 SDL_RenderGetLogicalSize(SDL_Renderer *renderer, int *w, int *h)
 {
-    float fw, fh;
-    SDL3_GetRenderLogicalPresentation(renderer, &fw, &fh, NULL, NULL);
-    if (w) {
-        *w = (int)fw;
-    }
-    if (h) {
-        *h = (int)fh;
-    }
+    SDL3_GetRenderLogicalPresentation(renderer, w, h, NULL, NULL);
 }
 
 SDL_DECLSPEC int SDLCALL
@@ -4094,7 +4057,7 @@ SDL_RenderSetIntegerScale(SDL_Renderer *renderer, SDL_bool enable)
 {
     SDL_ScaleMode scale_mode;
     SDL_RendererLogicalPresentation mode;
-    float w, h;
+    int w, h;
     int retval;
 
     retval = SDL3_GetRenderLogicalPresentation(renderer, &w, &h, &mode, &scale_mode);
@@ -4133,34 +4096,14 @@ SDL_RenderGetIntegerScale(SDL_Renderer *renderer)
 SDL_DECLSPEC int SDLCALL
 SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
 {
-    int retval;
-    if (rect) {
-        SDL_FRect frect;
-        frect.x = (float)rect->x;
-        frect.y = (float)rect->y;
-        frect.w = (float)rect->w;
-        frect.h = (float)rect->h;
-        retval = SDL3_SetRenderViewport(renderer, &frect);
-    } else {
-        retval = SDL3_SetRenderViewport(renderer, NULL);
-    }
+    const int retval = SDL3_SetRenderViewport(renderer, rect);
     return retval < 0 ? retval : FlushRendererIfNotBatching(renderer);
 }
 
 SDL_DECLSPEC int SDLCALL
 SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect)
 {
-    int retval;
-    if (rect) {
-        SDL_FRect frect;
-        frect.x = (float)rect->x;
-        frect.y = (float)rect->y;
-        frect.w = (float)rect->w;
-        frect.h = (float)rect->h;
-        retval = SDL3_SetRenderClipRect(renderer, &frect);
-    } else {
-        retval = SDL3_SetRenderClipRect(renderer, NULL);
-    }
+    const int retval = SDL3_SetRenderClipRect(renderer, rect);
     return retval < 0 ? retval : FlushRendererIfNotBatching(renderer);
 }
 
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index f7e1e53..0ecf6e7 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -300,7 +300,7 @@ SDL3_SYM(SDL_Renderer*,CreateRenderer,(SDL_Window *a, const char *b),(a,b),retur
 SDL3_SYM_PASSTHROUGH(SDL_Renderer*,CreateSoftwareRenderer,(SDL_Surface *a),(a),return)
 SDL3_SYM_PASSTHROUGH(SDL_Renderer*,GetRenderer,(SDL_Window *a),(a),return)
 SDL3_SYM(const char*,GetRendererName,(SDL_Renderer *a),(a),return)
-SDL3_SYM(int,GetRenderOutputSize,(SDL_Renderer *a, float *b, float *c),(a,b,c),return)
+SDL3_SYM_RENAMED(int,GetRendererOutputSize,GetRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
 SDL3_SYM(SDL_Texture*,CreateTexture,(SDL_Renderer *a, SDL_PixelFormatEnum b, int c, int d, int e),(a,b,c,d,e),return)
 SDL3_SYM(SDL_Texture*,CreateTextureFromSurface,(SDL_Renderer *a, SDL_Surface *b),(a,b),return)
 SDL3_SYM_PASSTHROUGH(int,SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
@@ -316,11 +316,11 @@ SDL3_SYM_PASSTHROUGH(int,LockTexture,(SDL_Texture *a, const SDL_Rect *b, void **
 SDL3_SYM_PASSTHROUGH(void,UnlockTexture,(SDL_Texture *a),(a),)
 SDL3_SYM_PASSTHROUGH(int,SetRenderTarget,(SDL_Renderer *a, SDL_Texture *b),(a,b),return)
 SDL3_SYM_PASSTHROUGH(SDL_Texture*,GetRenderTarget,(SDL_Renderer *a),(a),return)
-SDL3_SYM(int,SetRenderViewport,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
-SDL3_SYM(int,SetRenderClipRect,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
+SDL3_SYM(int,SetRenderViewport,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
+SDL3_SYM(int,SetRenderClipRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
 SDL3_SYM_RENAMED(int,RenderSetScale,SetRenderScale,(SDL_Renderer *a, float b, float c),(a,b,c),return)
-SDL3_SYM(int,GetRenderViewport,(SDL_Renderer *a, SDL_FRect *b),(a,b),return)
-SDL3_SYM(int,GetRenderClipRect,(SDL_Renderer *a, SDL_FRect *b),(a,b),return)
+SDL3_SYM(int,GetRenderViewport,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
+SDL3_SYM(int,GetRenderClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
 SDL3_SYM(int,GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a,b,c),return)
 SDL3_SYM_PASSTHROUGH(int,SetRenderDrawColor,(SDL_Renderer *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
 SDL3_SYM_PASSTHROUGH(int,GetRenderDrawColor,(SDL_Renderer *a, Uint8 *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),return)
@@ -788,8 +788,8 @@ SDL3_SYM(SDL_DisplayID,GetPrimaryDisplay,(void),(),return)
 SDL3_SYM(int,RunApp,(int a, char **b, SDL_main_func c, void *d),(a,b,c,d),return)
 SDL3_SYM(const SDL_DisplayMode *,GetWindowFullscreenMode,(SDL_Window *a),(a),return)
 SDL3_SYM(const SDL_DisplayMode **,GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)
-SDL3_SYM(int,GetRenderLogicalPresentation,(SDL_Renderer *a, float *b, float *c, SDL_RendererLogicalPresentation *d, SDL_ScaleMode *e),(a,b,c,d,e),return)
-SDL3_SYM(int,SetRenderLogicalPresentation,(SDL_Renderer *a, float b, float c, SDL_RendererLogicalPresentation d, SDL_ScaleMode e),(a,b,c,d,e),return)
+SDL3_SYM(int,GetRenderLogicalPresentation,(SDL_Renderer *a, int *b, int *c, SDL_RendererLogicalPresentation *d, SDL_ScaleMode *e),(a,b,c,d,e),return)
+SDL3_SYM(int,SetRenderLogicalPresentation,(SDL_Renderer *a, int b, int c, SDL_RendererLogicalPresentation d, SDL_ScaleMode e),(a,b,c,d,e),return)
 SDL3_SYM_RENAMED(SDL_bool,HasWindowSurface,WindowHasSurface,(SDL_Window *a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,DestroyWindowSurface,(SDL_Window *a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,GetNumAudioDrivers,(void),(),return)