From 4368f70ff9447f5960e1afa7a2bb878414c50bc1 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 11 Oct 2023 16:59:51 -0700
Subject: [PATCH] Added properties to various SDL objects
The following objects now have properties that can be user modified:
* SDL_AudioStream
* SDL_Gamepad
* SDL_Joystick
* SDL_RWops
* SDL_Renderer
* SDL_Sensor
* SDL_Surface
* SDL_Texture
* SDL_Window
---
build-scripts/SDL_migration.cocci | 10 ++
docs/README-migration.md | 6 +
include/SDL3/SDL_audio.h | 17 ++-
include/SDL3/SDL_gamepad.h | 19 ++-
include/SDL3/SDL_joystick.h | 14 ++
include/SDL3/SDL_properties.h | 15 +++
include/SDL3/SDL_render.h | 54 ++++----
include/SDL3/SDL_rwops.h | 15 +++
include/SDL3/SDL_sensor.h | 14 ++
include/SDL3/SDL_surface.h | 18 ++-
include/SDL3/SDL_video.h | 45 ++-----
src/SDL_properties.c | 5 +
src/audio/SDL_audiocvt.c | 14 ++
src/audio/SDL_sysaudio.h | 2 +
src/dynapi/SDL_dynapi.sym | 14 +-
src/dynapi/SDL_dynapi_overrides.h | 14 +-
src/dynapi/SDL_dynapi_procs.h | 14 +-
src/file/SDL_rwops.c | 14 ++
src/joystick/SDL_gamepad.c | 15 +++
src/joystick/SDL_joystick.c | 23 ++++
src/joystick/SDL_sysjoystick.h | 2 +
src/render/SDL_render.c | 47 ++++---
src/render/SDL_sysrender.h | 5 +-
src/sensor/SDL_sensor.c | 23 ++++
src/sensor/SDL_syssensor.h | 2 +
src/video/SDL_surface.c | 28 ++--
src/video/SDL_sysvideo.h | 9 +-
src/video/SDL_video.c | 121 +++++-------------
src/video/dummy/SDL_nullframebuffer.c | 21 +--
src/video/n3ds/SDL_n3dsframebuffer.c | 35 ++---
.../offscreen/SDL_offscreenframebuffer.c | 21 +--
test/testautomation_video.c | 68 +++-------
32 files changed, 433 insertions(+), 291 deletions(-)
diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index df9acc0070e6..8a6012e28086 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -2735,3 +2735,13 @@ typedef SDL_cond, SDL_Condition;
- SDL_WriteBE64
+ SDL_WriteU64BE
(...)
+@@
+expression e, n;
+@@
+- SDL_GetWindowData(e, n)
++ SDL_GetProperty(SDL_GetWindowProperties(e), n)
+@@
+expression e, n, v;
+@@
+- SDL_SetWindowData(e, n, v)
++ SDL_SetProperty(SDL_GetWindowProperties(e), n, v, NULL, NULL)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 7878b1f4d07a..db1b8db00669 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -854,9 +854,11 @@ The following functions have been renamed:
* SDL_RenderWindowToLogical() => SDL_RenderCoordinatesFromWindow()
The following functions have been removed:
+* SDL_GetTextureUserData() - use SDL_GetTextureProperties() instead
* SDL_RenderGetIntegerScale()
* SDL_RenderSetIntegerScale() - this is now explicit with SDL_LOGICAL_PRESENTATION_INTEGER_SCALE
* SDL_RenderTargetSupported() - render targets are always supported
+* SDL_SetTextureUserData() - use SDL_GetTextureProperties() instead
The following symbols have been renamed:
* SDL_ScaleModeBest => SDL_SCALEMODE_BEST
@@ -1068,6 +1070,8 @@ The following functions have been renamed:
## SDL_surface.h
+The userdata member of SDL_Surface has been replaced with a more general properties interface, which can be queried with SDL_GetSurfaceProperties()
+
Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat.
SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceWithFormat() have been combined into a new function SDL_CreateSurface().
@@ -1274,6 +1278,8 @@ The following functions have been removed:
* SDL_GetDisplayMode()
* SDL_GetNumDisplayModes() - replaced with SDL_GetFullscreenDisplayModes()
* SDL_GetNumVideoDisplays() - replaced with SDL_GetDisplays()
+* SDL_GetWindowData() - use SDL_GetWindowProperties() instead
+* SDL_SetWindowData() - use SDL_GetWindowProperties() instead
SDL_Window id type is named SDL_WindowID
diff --git a/include/SDL3/SDL_audio.h b/include/SDL3/SDL_audio.h
index 9b8737919e54..481bfc599a38 100644
--- a/include/SDL3/SDL_audio.h
+++ b/include/SDL3/SDL_audio.h
@@ -29,11 +29,12 @@
#define SDL_audio_h_
#include <SDL3/SDL_stdinc.h>
-#include <SDL3/SDL_error.h>
#include <SDL3/SDL_endian.h>
+#include <SDL3/SDL_error.h>
#include <SDL3/SDL_mutex.h>
-#include <SDL3/SDL_thread.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rwops.h>
+#include <SDL3/SDL_thread.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
@@ -675,6 +676,18 @@ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_GetAudioStreamDevice(SDL_AudioStre
*/
extern DECLSPEC SDL_AudioStream *SDLCALL SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec);
+/**
+ * Get the properties associated with an audio stream.
+ *
+ * \param stream the SDL_AudioStream to query
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream);
/**
* Query the current format of an audio stream.
diff --git a/include/SDL3/SDL_gamepad.h b/include/SDL3/SDL_gamepad.h
index b9c31e8d4d3d..bb950272f37b 100644
--- a/include/SDL3/SDL_gamepad.h
+++ b/include/SDL3/SDL_gamepad.h
@@ -30,9 +30,10 @@
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_error.h>
+#include <SDL3/SDL_joystick.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rwops.h>
#include <SDL3/SDL_sensor.h>
-#include <SDL3/SDL_joystick.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
@@ -554,6 +555,22 @@ extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromInstanceID(SDL_JoystickID
*/
extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
+/**
+ * Get the properties associated with an opened gamepad.
+ *
+ * These properties are shared with the underlying joystick object.
+ *
+ * \param gamepad a gamepad identifier previously returned by
+ * SDL_OpenGamepad()
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
+
/**
* Get the instance ID of an opened gamepad.
*
diff --git a/include/SDL3/SDL_joystick.h b/include/SDL3/SDL_joystick.h
index c7985a92b2c5..e3c9a9f8cf94 100644
--- a/include/SDL3/SDL_joystick.h
+++ b/include/SDL3/SDL_joystick.h
@@ -42,6 +42,7 @@
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_guid.h>
#include <SDL3/SDL_mutex.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
@@ -456,6 +457,19 @@ extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick,
*/
extern DECLSPEC int SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value);
+/**
+ * Get the properties associated with a joystick.
+ *
+ * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick);
+
/**
* Get the implementation dependent name of a joystick.
*
diff --git a/include/SDL3/SDL_properties.h b/include/SDL3/SDL_properties.h
index 13a881c0b8ae..efa700ee9e98 100644
--- a/include/SDL3/SDL_properties.h
+++ b/include/SDL3/SDL_properties.h
@@ -111,6 +111,21 @@ extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *
*/
extern DECLSPEC void *SDLCALL SDL_GetProperty(SDL_PropertiesID props, const char *name);
+/**
+ * Clear a property on a set of properties
+ *
+ * \param props the properties to modify
+ * \param name the name of the property to clear
+ *
+ * \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_GetProperty
+ */
+extern DECLSPEC int SDLCALL SDL_ClearProperty(SDL_PropertiesID props, const char *name);
+
/**
* Destroy a set of properties
*
diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h
index e4a243062006..ae08703697cf 100644
--- a/include/SDL3/SDL_render.h
+++ b/include/SDL3/SDL_render.h
@@ -50,6 +50,7 @@
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_events.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_video.h>
@@ -315,6 +316,19 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
*/
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info);
+/**
+ * Get the properties associated with a renderer.
+ *
+ * \param renderer the rendering context
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);
+
/**
* Get the output size in pixels of a rendering context.
*
@@ -422,6 +436,19 @@ typedef struct IDXGIResource IDXGIResource;
*/
extern DECLSPEC IDXGIResource* SDLCALL SDL_GetTextureDXGIResource(SDL_Texture *texture);
+/**
+ * Get the properties associated with a texture.
+ *
+ * \param texture the texture to query
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
+
/**
* Query the attributes of a texture.
*
@@ -590,33 +617,6 @@ extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_Sc
*/
extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
-/**
- * Associate a user-specified pointer with a texture.
- *
- * \param texture the texture to update.
- * \param userdata the pointer to associate with the texture.
- * \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_GetTextureUserData
- */
-extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture *texture, void *userdata);
-
-/**
- * Get the user-specified pointer associated with a texture
- *
- * \param texture the texture to query.
- * \returns the pointer associated with the texture, or NULL if the texture is
- * not valid.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SetTextureUserData
- */
-extern DECLSPEC void *SDLCALL SDL_GetTextureUserData(SDL_Texture *texture);
-
/**
* Update the given texture rectangle with new pixel data.
*
diff --git a/include/SDL3/SDL_rwops.h b/include/SDL3/SDL_rwops.h
index 6f6c3c013cc7..74c1ec6ec187 100644
--- a/include/SDL3/SDL_rwops.h
+++ b/include/SDL3/SDL_rwops.h
@@ -31,6 +31,7 @@
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_error.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
@@ -99,6 +100,7 @@ typedef struct SDL_RWops
Uint32 type;
Uint32 status;
+ SDL_PropertiesID props;
union
{
#ifdef __ANDROID__
@@ -331,6 +333,19 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_CreateRW(void);
*/
extern DECLSPEC void SDLCALL SDL_DestroyRW(SDL_RWops *context);
+/**
+ * Get the properties associated with an SDL_RWops.
+ *
+ * \param context a pointer to an SDL_RWops structure
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRWProperties(SDL_RWops *context);
+
#define SDL_RW_SEEK_SET 0 /**< Seek from the beginning of data */
#define SDL_RW_SEEK_CUR 1 /**< Seek relative to current read point */
#define SDL_RW_SEEK_END 2 /**< Seek relative to the end of data */
diff --git a/include/SDL3/SDL_sensor.h b/include/SDL3/SDL_sensor.h
index 5715cab9a5b4..4829bea472e9 100644
--- a/include/SDL3/SDL_sensor.h
+++ b/include/SDL3/SDL_sensor.h
@@ -30,6 +30,7 @@
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_error.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_begin_code.h>
/* Set up for C function definitions, even when using C++ */
@@ -189,6 +190,19 @@ extern DECLSPEC SDL_Sensor *SDLCALL SDL_OpenSensor(SDL_SensorID instance_id);
*/
extern DECLSPEC SDL_Sensor *SDLCALL SDL_GetSensorFromInstanceID(SDL_SensorID instance_id);
+/**
+ * Get the properties associated with a sensor.
+ *
+ * \param sensor The SDL_Sensor object
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSensorProperties(SDL_Sensor *sensor);
+
/**
* Get the implementation dependent name of a sensor
*
diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h
index 6bf4b1d94c8b..4a782175d564 100644
--- a/include/SDL3/SDL_surface.h
+++ b/include/SDL3/SDL_surface.h
@@ -29,9 +29,10 @@
#define SDL_surface_h_
#include <SDL3/SDL_stdinc.h>
+#include <SDL3/SDL_blendmode.h>
#include <SDL3/SDL_pixels.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rect.h>
-#include <SDL3/SDL_blendmode.h>
#include <SDL3/SDL_rwops.h>
#include <SDL3/SDL_begin_code.h>
@@ -92,7 +93,7 @@ typedef struct SDL_Surface
void *pixels; /**< Read-write */
/** Application data associated with the surface */
- void *userdata; /**< Read-write */
+ SDL_PropertiesID props; /**< Read-write */
/** information needed for surfaces requiring locks */
int locked; /**< Read-only */
@@ -189,6 +190,19 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurfaceFrom
*/
extern DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface);
+/**
+ * Get the properties associated with a surface.
+ *
+ * \param surface the SDL_Surface structure to query
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *surface);
+
/**
* Set the palette used by a surface.
*
diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h
index dd018de1d1d6..c3958e37492d 100644
--- a/include/SDL3/SDL_video.h
+++ b/include/SDL3/SDL_video.h
@@ -30,6 +30,7 @@
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_pixels.h>
+#include <SDL3/SDL_properties.h>
#include <SDL3/SDL_rect.h>
#include <SDL3/SDL_surface.h>
@@ -93,7 +94,6 @@ typedef enum
* \sa SDL_CreateWindowWithPosition()
* \sa SDL_DestroyWindow()
* \sa SDL_FlashWindow()
- * \sa SDL_GetWindowData()
* \sa SDL_GetWindowFlags()
* \sa SDL_GetWindowGrab()
* \sa SDL_GetWindowKeyboardGrab()
@@ -106,7 +106,6 @@ typedef enum
* \sa SDL_MinimizeWindow()
* \sa SDL_RaiseWindow()
* \sa SDL_RestoreWindow()
- * \sa SDL_SetWindowData()
* \sa SDL_SetWindowFullscreen()
* \sa SDL_SetWindowGrab()
* \sa SDL_SetWindowKeyboardGrab()
@@ -918,6 +917,19 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
*/
extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window);
+/**
+ * Get the properties associated with a window.
+ *
+ * \param window the window to query
+ * \returns a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetProperty
+ * \sa SDL_SetProperty
+ */
+extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window);
+
/**
* Get the window flags.
*
@@ -977,35 +989,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window *window);
*/
extern DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
-/**
- * Associate an arbitrary named pointer with a window.
- *
- * `name` is case-sensitive.
- *
- * \param window the window to associate with the pointer
- * \param name the name of the pointer
- * \param userdata the associated pointer
- * \returns the previous value associated with `name`.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetWindowData
- */
-extern DECLSPEC void *SDLCALL SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata);
-
-/**
- * Retrieve the data pointer associated with a window.
- *
- * \param window the window to query
- * \param name the name of the pointer
- * \returns the value associated with `name`.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_SetWindowData
- */
-extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *name);
-
/**
* Set the position of a window.
*
diff --git a/src/SDL_properties.c b/src/SDL_properties.c
index a83067501dc4..29dd2391e130 100644
--- a/src/SDL_properties.c
+++ b/src/SDL_properties.c
@@ -265,6 +265,11 @@ void *SDL_GetProperty(SDL_PropertiesID props, const char *name)
return value;
}
+int SDL_ClearProperty(SDL_PropertiesID props, const char *name)
+{
+ return SDL_SetProperty(props, name, NULL, NULL, NULL);
+}
+
void SDL_DestroyProperties(SDL_PropertiesID props)
{
if (!props) {
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 0dc1719658ec..126a26c64e42 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -438,6 +438,18 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_
return retval;
}
+SDL_PropertiesID SDL_GetAudioStreamProperties(SDL_AudioStream *stream)
+{
+ if (!stream) {
+ SDL_InvalidParamError("stream");
+ return 0;
+ }
+ if (stream->props == 0) {
+ stream->props = SDL_CreateProperties();
+ }
+ return stream->props;
+}
+
int SDL_SetAudioStreamGetCallback(SDL_AudioStream *stream, SDL_AudioStreamCallback callback, void *userdata)
{
if (!stream) {
@@ -1161,6 +1173,8 @@ void SDL_DestroyAudioStream(SDL_AudioStream *stream)
return;
}
+ SDL_DestroyProperties(stream->props);
+
OnAudioStreamDestroy(stream);
const SDL_bool simplified = stream->simplified;
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index 68003171563e..043b562af3a1 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -170,6 +170,8 @@ struct SDL_AudioStream
{
SDL_Mutex* lock;
+ SDL_PropertiesID props;
+
SDL_AudioStreamCallback get_callback;
void *get_callback_userdata;
SDL_AudioStreamCallback put_callback;
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index c73472068380..c53c02adc6cd 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -330,7 +330,6 @@ SDL3_0.0.0 {
SDL_GetTextureBlendMode;
SDL_GetTextureColorMod;
SDL_GetTextureScaleMode;
- SDL_GetTextureUserData;
SDL_GetThreadID;
SDL_GetThreadName;
SDL_GetTicks;
@@ -342,7 +341,6 @@ SDL3_0.0.0 {
SDL_GetVersion;
SDL_GetVideoDriver;
SDL_GetWindowBordersSize;
- SDL_GetWindowData;
SDL_GetWindowDisplayScale;
SDL_GetWindowFlags;
SDL_GetWindowFromID;
@@ -601,11 +599,9 @@ SDL3_0.0.0 {
SDL_SetTextureBlendMode;
SDL_SetTextureColorMod;
SDL_SetTextureScaleMode;
- SDL_SetTextureUserData;
SDL_SetThreadPriority;
SDL_SetWindowAlwaysOnTop;
SDL_SetWindowBordered;
- SDL_SetWindowData;
SDL_SetWindowFullscreen;
SDL_SetWindowFullscreenMode;
SDL_SetWindowGrab;
@@ -914,6 +910,16 @@ SDL3_0.0.0 {
SDL_SetProperty;
SDL_GetProperty;
SDL_DestroyProperties;
+ SDL_GetAudioStreamProperties;
+ SDL_GetGamepadProperties;
+ SDL_GetJoystickProperties;
+ SDL_GetRendererProperties;
+ SDL_GetTextureProperties;
+ SDL_GetRWProperties;
+ SDL_GetSensorProperties;
+ SDL_GetSurfaceProperties;
+ SDL_GetWindowProperties;
+ SDL_ClearProperty;
# 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 8148554c54df..dc85966627dd 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -354,7 +354,6 @@
#define SDL_GetTextureBlendMode SDL_GetTextureBlendMode_REAL
#define SDL_GetTextureColorMod SDL_GetTextureColorMod_REAL
#define SDL_GetTextureScaleMode SDL_GetTextureScaleMode_REAL
-#define SDL_GetTextureUserData SDL_GetTextureUserData_REAL
#define SDL_GetThreadID SDL_GetThreadID_REAL
#define SDL_GetThreadName SDL_GetThreadName_REAL
#define SDL_GetTicks SDL_GetTicks_REAL
@@ -366,7 +365,6 @@
#define SDL_GetVersion SDL_GetVersion_REAL
#define SDL_GetVideoDriver SDL_GetVideoDriver_REAL
#define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL
-#define SDL_GetWindowData SDL_GetWindowData_REAL
#define SDL_GetWindowDisplayScale SDL_GetWindowDisplayScale_REAL
#define SDL_GetWindowFlags SDL_GetWindowFlags_REAL
#define SDL_GetWindowFromID SDL_GetWindowFromID_REAL
@@ -624,11 +622,9 @@
#define SDL_SetTextureBlendMode SDL_SetTextureBlendMode_REAL
#define SDL_SetTextureColorMod SDL_SetTextureColorMod_REAL
#define SDL_SetTextureScaleMode SDL_SetTextureScaleMode_REAL
-#define SDL_SetTextureUserData SDL_SetTextureUserData_REAL
#define SDL_SetThreadPriority SDL_SetThreadPriority_REAL
#define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL
#define SDL_SetWindowBordered SDL_SetWindowBordered_REAL
-#define SDL_SetWindowData SDL_SetWindowData_REAL
#define SDL_SetWindowFullscreen SDL_SetWindowFullscreen_REAL
#define SDL_SetWindowFullscreenMode SDL_SetWindowFullscreenMode_REAL
#define SDL_SetWindowGrab SDL_SetWindowGrab_REAL
@@ -939,3 +935,13 @@
#define SDL_SetProperty SDL_SetProperty_REAL
#define SDL_GetProperty SDL_GetProperty_REAL
#define SDL_DestroyProperties SDL_DestroyProperties_REAL
+#define SDL_GetAudioStreamProperties SDL_GetAudioStreamProperties_REAL
+#define SDL_GetGamepadProperties SDL_GetGamepadProperties_REAL
+#define SDL_GetJoystickProperties SDL_GetJoystickProperties_REAL
+#define SDL_GetRendererProperties SDL_GetRendererProperties_REAL
+#define SDL_GetTextureProperties SDL_GetTextureProperties_REAL
+#define SDL_GetRWProperties SDL_GetRWProperties_REAL
+#define SDL_GetSensorProperties SDL_GetSensorProperties_REAL
+#define SDL_GetSurfaceProperties SDL_GetSurfaceProperties_REAL
+#define SDL_GetWindowProperties SDL_GetWindowProperties_REAL
+#define SDL_ClearProperty SDL_ClearProperty_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 985b13eb5d6d..4e04f0c0b234 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -427,7 +427,6 @@ SDL_DYNAPI_PROC(int,SDL_GetTextureAlphaMod,(SDL_Texture *a, Uint8 *b),(a,b),retu
SDL_DYNAPI_PROC(int,SDL_GetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureColorMod,(SDL_Texture *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_GetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode *b),(a,b),return)
-SDL_DYNAPI_PROC(void*,SDL_GetTextureUserData,(SDL_Texture *a),(a),return)
SDL_DYNAPI_PROC(SDL_threadID,SDL_GetThreadID,(SDL_Thread *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetThreadName,(SDL_Thread *a),(a),return)
SDL_DYNAPI_PROC(Uint64,SDL_GetTicks,(void),(),return)
@@ -439,7 +438,6 @@ SDL_DYNAPI_PROC(const char*,SDL_GetTouchName,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetVersion,(SDL_version *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(void*,SDL_GetWindowData,(SDL_Window *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowDisplayScale,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetWindowFlags,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromID,(Uint32 a),(a),return)
@@ -680,11 +678,9 @@ SDL_DYNAPI_PROC(int,SDL_SetTextureAlphaMod,(SDL_Texture *a, Uint8 b),(a,b),retur
SDL_DYNAPI_PROC(int,SDL_SetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_SetTextureScaleMode,(SDL_Texture *a, SDL_ScaleMode b),(a,b),return)
-SDL_DYNAPI_PROC(int,SDL_SetTextureUserData,(SDL_Texture *a, void *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetThreadPriority,(SDL_ThreadPriority a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowBordered,(SDL_Window *a, SDL_bool b),(a,b),return)
-SDL_DYNAPI_PROC(void*,SDL_SetWindowData,(SDL_Window *a, const char *b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreen,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreenMode,(SDL_Window *a, const SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowGrab,(SDL_Window *a, SDL_bool b),(a,b),return)
@@ -985,3 +981,13 @@ SDL_DYNAPI_PROC(void,SDL_UnlockProperties,(SDL_PropertiesID a),(a),)
SDL_DYNAPI_PROC(int,SDL_SetProperty,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void*,SDL_GetProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_DestroyProperties,(SDL_PropertiesID a),(a),)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetAudioStreamProperties,(SDL_AudioStream *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetGamepadProperties,(SDL_Gamepad *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetJoystickProperties,(SDL_Joystick *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetRendererProperties,(SDL_Renderer *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetTextureProperties,(SDL_Texture *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetRWProperties,(SDL_RWops *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetSensorProperties,(SDL_Sensor *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetSurfaceProperties,(SDL_Surface *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetWindowProperties,(SDL_Window *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_ClearProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index cdd5b361d121..aa429609982f 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -619,6 +619,7 @@ SDL_RWops *SDL_CreateRW(void)
void SDL_DestroyRW(SDL_RWops *context)
{
+ SDL_DestroyProperties(context->props);
SDL_free(context);
}
@@ -698,6 +699,19 @@ void *SDL_LoadFile(const char *file, size_t *datasize)
return SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, SDL_TRUE);
}
+SDL_PropertiesID SDL_GetRWProperties(SDL_RWops *context)
+{
+ if (!context) {
+ SDL_InvalidParamError("context");
+ return 0;
+ }
+
+ if (context->props == 0) {
+ context->props = SDL_CreateProperties();
+ }
+ return context->props;
+}
+
Sint64 SDL_RWsize(SDL_RWops *context)
{
if (!context) {
diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c
index 4cb4a1481da2..6bb982c57e37 100644
--- a/src/joystick/SDL_gamepad.c
+++ b/src/joystick/SDL_gamepad.c
@@ -2925,6 +2925,21 @@ SDL_JoystickID SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad)
return SDL_GetJoystickInstanceID(joystick);
}
+SDL_PropertiesID SDL_GetGamepadProperties(SDL_Gamepad *gamepad)
+{
+ SDL_PropertiesID retval = 0;
+
+ SDL_LockJoysticks();
+ {
+ CHECK_GAMEPAD_MAGIC(gamepad, 0);
+
+ retval = SDL_GetJoystickProperties(gamepad->joystick);
+ }
+ SDL_UnlockJoysticks();
+
+ return retval;
+}
+
const char *SDL_GetGamepadName(SDL_Gamepad *gamepad)
{
const char *retval = NULL;
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 268ba9fc49ea..1a58402227bb 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -1213,6 +1213,27 @@ SDL_Joystick *SDL_GetJoystickFromPlayerIndex(int player_index)
return joystick;
}
+/*
+ * Get the properties associated with a joystick
+ */
+SDL_PropertiesID SDL_GetJoystickProperties(SDL_Joystick *joystick)
+{
+ SDL_PropertiesID retval;
+
+ SDL_LockJoysticks();
+ {
+ CHECK_JOYSTICK_MAGIC(joystick, 0);
+
+ if (joystick->props == 0) {
+ joystick->props = SDL_CreateProperties();
+ }
+ retval = joystick->props;
+ }
+ SDL_UnlockJoysticks();
+
+ return retval;
+}
+
/*
* Get the friendly name of this joystick
*/
@@ -1465,6 +1486,8 @@ void SDL_CloseJoystick(SDL_Joystick *joystick)
return;
}
+ SDL_DestroyProperties(joystick->props);
+
if (joystick->rumble_expiration) {
SDL_RumbleJoystick(joystick, 0, 0, 0);
}
diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h
index f0f547e10d97..8ac081026aff 100644
--- a/src/joystick/SDL_sysjoystick.h
+++ b/src/joystick/SDL_sysjoystick.h
@@ -125,6 +125,8 @@ struct SDL_Joystick
struct joystick_hwdata *hwdata _guarded; /* Driver dependent information */
+ SDL_PropertiesID props _guarded;
+
int ref_count _guarded; /* Reference count for multiple opens */
struct SDL_Joystick *next _guarded; /* pointer to next joystick we have allocated */
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 9e9fc1629bdf..dfcd8a97d0f5 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -929,7 +929,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl
renderer->hidden = SDL_FALSE;
}
- SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer);
+ SDL_SetProperty(SDL_GetWindowProperties(window), SDL_WINDOWRENDERDATA, renderer, NULL, NULL);
SDL_SetRenderViewport(renderer, NULL);
@@ -994,7 +994,7 @@ SDL_Renderer *SDL_CreateSoftwareRenderer(SDL_Surface *surface)
SDL_Renderer *SDL_GetRenderer(SDL_Window *window)
{
- return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WIND
(Patch may be truncated, please check the link at the top of this post.)