SDL: render: Added SDL_GetTextureRenderer().

From 9bc7cfc755baf055b0ac133712c4c5b3049fa302 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 8 Jan 2024 10:17:38 -0500
Subject: [PATCH] render: Added SDL_GetTextureRenderer().

---
 include/SDL3/SDL_render.h         | 17 +++++++++++++++++
 src/dynapi/SDL_dynapi.sym         |  1 +
 src/dynapi/SDL_dynapi_overrides.h |  1 +
 src/dynapi/SDL_dynapi_procs.h     |  1 +
 src/render/SDL_render.c           |  6 ++++++
 5 files changed, 26 insertions(+)

diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h
index e689b94c202d..7005f78f837e 100644
--- a/include/SDL3/SDL_render.h
+++ b/include/SDL3/SDL_render.h
@@ -702,6 +702,23 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureWithProperties(SDL_Rendere
  */
 extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
 
+/**
+ * Get the renderer that created an SDL_Texture.
+ *
+ * \param texture the texture to query
+ * \returns a pointer to the SDL_Renderer that created the texture, or NULL
+ *          on failure; call SDL_GetError() for more information.
+ *
+ * \threadsafety It is safe to call this function from any thread.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_CreateTexture
+ * \sa SDL_CreateTextureFromSurface
+ * \sa SDL_CreateTextureWithProperties
+ */
+extern DECLSPEC SDL_Renderer *SDLCALL SDL_GetTextureRenderer(SDL_Texture *texture);
+
 /**
  * Query the attributes of a texture.
  *
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 4e3ea9e52ae1..51f3629b8151 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -961,6 +961,7 @@ SDL3_0.0.0 {
     SDL_wcsnstr;
     SDL_SyncWindow;
     SDL_GetGamepadSteamHandle;
+    SDL_GetTextureRenderer;
     # extra symbols go here (don't modify this line)
   local: *;
 };
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 0e2636fa4f4f..ddd57de6a69a 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -986,3 +986,4 @@
 #define SDL_wcsnstr SDL_wcsnstr_REAL
 #define SDL_SyncWindow SDL_SyncWindow_REAL
 #define SDL_GetGamepadSteamHandle SDL_GetGamepadSteamHandle_REAL
+#define SDL_GetTextureRenderer SDL_GetTextureRenderer_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index fbd18f1b8ef8..7d92febecd76 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -1011,3 +1011,4 @@ SDL_DYNAPI_PROC(char*,SDL_strnstr,(const char *a, const char *b, size_t c),(a,b,
 SDL_DYNAPI_PROC(wchar_t*,SDL_wcsnstr,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
 SDL_DYNAPI_PROC(int,SDL_SyncWindow,(SDL_Window *a),(a),return)
 SDL_DYNAPI_PROC(Uint64,SDL_GetGamepadSteamHandle,(SDL_Gamepad *a),(a),return)
+SDL_DYNAPI_PROC(SDL_Renderer*,SDL_GetTextureRenderer,(SDL_Texture *a),(a),return)
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 76f8074e8ae8..66453024b526 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1396,6 +1396,12 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
     return texture;
 }
 
+SDL_Renderer *SDL_GetTextureRenderer(SDL_Texture *texture)
+{
+    CHECK_TEXTURE_MAGIC(texture, NULL);
+    return texture->renderer;
+}
+
 SDL_PropertiesID SDL_GetTextureProperties(SDL_Texture *texture)
 {
     CHECK_TEXTURE_MAGIC(texture, 0);