mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-14 05:46:00 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user