Skip to content

Commit

Permalink
SDL_Surface revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 8, 2024
1 parent d604555 commit 5fa1c84
Show file tree
Hide file tree
Showing 104 changed files with 958 additions and 1,049 deletions.
17 changes: 11 additions & 6 deletions build-scripts/SDL_migration.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
@@
@@
- SDL_AllocFormat
+ SDL_CreatePixelFormat
+ SDL_GetPackedPixelDetails
(...)
@@
@@
Expand All @@ -1575,11 +1575,6 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
(...)
@@
@@
- SDL_FreeFormat
+ SDL_DestroyPixelFormat
(...)
@@
@@
- SDL_FreePalette
+ SDL_DestroyPalette
(...)
Expand Down Expand Up @@ -3488,3 +3483,13 @@ typedef SDL_Colour, SDL_Color;
@@
- SDLK_z
+ SDLK_Z
@@
typedef SDL_PixelFormat, SDL_PackedPixelDetails;
@@
- SDL_PixelFormat
+ SDL_PackedPixelDetails
@@
@@
- SDL_ConvertSurfaceFormat
+ SDL_ConvertSurface
(...)
28 changes: 17 additions & 11 deletions docs/README-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1094,17 +1094,14 @@ The following symbols have been renamed:
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).
The BitsPerPixel and BytesPerPixel fields of SDL_PixelFormat have been renamed bits_per_pixel and bytes_per_pixel.
SDL_PixelFormatEnum is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
SDL_PixelFormat is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
The following functions have been renamed:
* SDL_AllocFormat() => SDL_CreatePixelFormat()
* SDL_AllocFormat() => SDL_GetPackedPixelDetails()
* SDL_AllocPalette() => SDL_CreatePalette()
* SDL_FreeFormat() => SDL_DestroyPixelFormat()
* SDL_FreePalette() => SDL_DestroyPalette()
* SDL_MasksToPixelFormatEnum() => SDL_GetPixelFormatEnumForMasks()
* SDL_PixelFormatEnumToMasks() => SDL_GetMasksForPixelFormatEnum()
* SDL_MasksToPixelFormatEnum() => SDL_GetPixelFormatForMasks()
* SDL_PixelFormatEnumToMasks() => SDL_GetMasksForPixelFormat()
The following symbols have been renamed:
* SDL_PIXELFORMAT_BGR444 => SDL_PIXELFORMAT_XBGR4444
Expand All @@ -1114,9 +1111,16 @@ The following symbols have been renamed:
* SDL_PIXELFORMAT_RGB555 => SDL_PIXELFORMAT_XRGB1555
* SDL_PIXELFORMAT_RGB888 => SDL_PIXELFORMAT_XRGB8888
The following functions have been removed:
* SDL_FreeFormat()
* SDL_SetPixelFormatPalette()
The following macros have been removed:
* SDL_Colour - use SDL_Color instead
The following structures have been renamed:
* SDL_PixelFormat => SDL_PackedPixelDetails
## SDL_platform.h
The following platform preprocessor macros have been renamed:
Expand Down Expand Up @@ -1600,7 +1604,7 @@ The following functions have been removed:

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.
Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurface.

SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceWithFormat() have been combined into a new function SDL_CreateSurface().
SDL_CreateRGBSurfaceFrom() and SDL_CreateRGBSurfaceWithFormatFrom() have been combined into a new function SDL_CreateSurfaceFrom().
Expand All @@ -1610,7 +1614,7 @@ You can implement the old functions in your own code easily:
SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
return SDL_CreateSurface(width, height,
SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask));
}

SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
Expand All @@ -1621,7 +1625,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height,
SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
return SDL_CreateSurfaceFrom(pixels, width, height, pitch,
SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask));
}

SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
Expand All @@ -1645,10 +1649,12 @@ SDL_BlitSurfaceScaled() and SDL_BlitSurfaceUncheckedScaled() now take a scale pa

SDL_SoftStretch() now takes a scale paramater.

SDL_PixelFormatEnum is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
SDL_PixelFormat is used instead of Uint32 for API functions that refer to pixel format by enumerated value.

The following functions have been renamed:
* SDL_BlitScaled() => SDL_BlitSurfaceScaled()
* SDL_ConvertSurface() => SDL_ConvertSurface()
* SDL_ConvertSurfaceFormat() => SDL_ConvertSurface()
* SDL_FillRect() => SDL_FillSurfaceRect()
* SDL_FillRects() => SDL_FillSurfaceRects()
* SDL_FreeSurface() => SDL_DestroySurface()
Expand Down
2 changes: 1 addition & 1 deletion include/SDL3/SDL_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef struct SDL_Camera SDL_Camera;
*/
typedef struct SDL_CameraSpec
{
SDL_PixelFormatEnum format; /**< Frame format */
SDL_PixelFormat format; /**< Frame format */
SDL_Colorspace colorspace; /**< Frame colorspace */
int width; /**< Frame width */
int height; /**< Frame height */
Expand Down
16 changes: 8 additions & 8 deletions include/SDL3/SDL_oldnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,19 +453,18 @@
#define SDL_sem SDL_Semaphore

/* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_CreatePixelFormat
#define SDL_AllocFormat SDL_GetPackedPixelDetails
#define SDL_AllocPalette SDL_CreatePalette
#define SDL_Colour SDL_Color
#define SDL_FreeFormat SDL_DestroyPixelFormat
#define SDL_FreePalette SDL_DestroyPalette
#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatEnumForMasks
#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatForMasks
#define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_XBGR4444
#define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_XBGR1555
#define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_XBGR8888
#define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_XRGB4444
#define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_XRGB1555
#define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_XRGB8888
#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormatEnum
#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormat

/* ##SDL_rect.h */
#define SDL_EncloseFPoints SDL_GetRectEnclosingPointsFloat
Expand Down Expand Up @@ -580,6 +579,7 @@

/* ##SDL_surface.h */
#define SDL_BlitScaled SDL_BlitSurfaceScaled
#define SDL_ConvertSurfaceFormat SDL_ConvertSurface
#define SDL_FillRect SDL_FillSurfaceRect
#define SDL_FillRects SDL_FillSurfaceRects
#define SDL_FreeSurface SDL_DestroySurface
Expand Down Expand Up @@ -1048,19 +1048,18 @@
#define SDL_sem SDL_sem_renamed_SDL_Semaphore

/* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_GetPackedPixelDetails
#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette
#define SDL_Colour SDL_Colour_renamed_SDL_Color
#define SDL_FreeFormat SDL_FreeFormat_renamed_SDL_DestroyPixelFormat
#define SDL_FreePalette SDL_FreePalette_renamed_SDL_DestroyPalette
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatEnumForMasks
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatForMasks
#define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_BGR444_renamed_SDL_PIXELFORMAT_XBGR4444
#define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_BGR555_renamed_SDL_PIXELFORMAT_XBGR1555
#define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_BGR888_renamed_SDL_PIXELFORMAT_XBGR8888
#define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_RGB444_renamed_SDL_PIXELFORMAT_XRGB4444
#define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_RGB555_renamed_SDL_PIXELFORMAT_XRGB1555
#define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_RGB888_renamed_SDL_PIXELFORMAT_XRGB8888
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormatEnum
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormat

/* ##SDL_rect.h */
#define SDL_EncloseFPoints SDL_EncloseFPoints_renamed_SDL_GetRectEnclosingPointsFloat
Expand Down Expand Up @@ -1175,6 +1174,7 @@

/* ##SDL_surface.h */
#define SDL_BlitScaled SDL_BlitScaled_renamed_SDL_BlitSurfaceScaled
#define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_renamed_SDL_ConvertSurface
#define SDL_FillRect SDL_FillRect_renamed_SDL_FillSurfaceRect
#define SDL_FillRects SDL_FillRects_renamed_SDL_FillSurfaceRects
#define SDL_FreeSurface SDL_FreeSurface_renamed_SDL_DestroySurface
Expand Down
Loading

0 comments on commit 5fa1c84

Please sign in to comment.