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
This commit is contained in:
Sam Lantinga
2023-10-11 16:59:51 -07:00
parent 973c8b3273
commit 4368f70ff9
32 changed files with 434 additions and 292 deletions

View File

@@ -211,9 +211,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, Uint32 format)
* Create an RGB surface from an existing memory buffer using the given given
* enum SDL_PIXELFORMAT_* format
*/
SDL_Surface *SDL_CreateSurfaceFrom(void *pixels,
int width, int height, int pitch,
Uint32 format)
SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitch, Uint32 format)
{
SDL_Surface *surface;
@@ -256,10 +254,23 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels,
return surface;
}
SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface)
{
if (surface == NULL) {
SDL_InvalidParamError("surface");
return 0;
}
if (surface->props == 0) {
surface->props = SDL_CreateProperties();
}
return surface->props;
}
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
{
if (surface == NULL) {
return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface");
return SDL_InvalidParamError("surface");
}
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
return -1;
@@ -1550,13 +1561,14 @@ void SDL_DestroySurface(SDL_Surface *surface)
if (surface->flags & SDL_DONTFREE) {
return;
}
SDL_InvalidateMap(surface->map);
SDL_InvalidateAllBlitMap(surface);
if (--surface->refcount > 0) {
return;
}
SDL_DestroyProperties(surface->props);
SDL_InvalidateMap(surface->map);
SDL_InvalidateAllBlitMap(surface);
while (surface->locked > 0) {
SDL_UnlockSurface(surface);
}