From 2ba76dbe803f8e76ee02f15e80d6dda3d9177845 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 8 Jul 2024 14:59:18 -0700
Subject: [PATCH] Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure.
The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect().
SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types.
SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
---
VisualC-GDK/SDL/SDL.vcxproj | 3 +-
VisualC-GDK/SDL/SDL.vcxproj.filters | 3 +-
VisualC-WinRT/SDL-UWP.vcxproj | 3 +-
VisualC-WinRT/SDL-UWP.vcxproj.filters | 5 +-
VisualC/SDL/SDL.vcxproj | 1 +
VisualC/SDL/SDL.vcxproj.filters | 5 +-
build-scripts/SDL_migration.cocci | 29 +-
cmake/test/main_gui.c | 2 +-
docs/README-migration.md | 55 +-
include/SDL3/SDL_camera.h | 2 +-
include/SDL3/SDL_oldnames.h | 20 +-
include/SDL3/SDL_pixels.h | 167 ++--
include/SDL3/SDL_render.h | 11 +-
include/SDL3/SDL_surface.h | 218 +++--
include/SDL3/SDL_video.h | 2 +-
src/SDL.c | 3 +
src/SDL_hashtable.c | 5 +
src/SDL_hashtable.h | 40 +-
src/camera/SDL_camera.c | 22 +-
src/camera/SDL_syscamera.h | 2 +-
src/camera/android/SDL_camera_android.c | 6 +-
src/camera/coremedia/SDL_camera_coremedia.m | 6 +-
.../SDL_camera_mediafoundation.c | 8 +-
src/camera/pipewire/SDL_camera_pipewire.c | 12 +-
src/camera/v4l2/SDL_camera_v4l2.c | 8 +-
src/dynapi/SDL_dynapi.sym | 12 +-
src/dynapi/SDL_dynapi_overrides.h | 15 +-
src/dynapi/SDL_dynapi_procs.h | 42 +-
src/events/SDL_mouse.c | 4 +-
src/render/SDL_render.c | 61 +-
src/render/SDL_sysrender.h | 6 +-
src/render/SDL_yuv_sw.c | 6 +-
src/render/SDL_yuv_sw_c.h | 8 +-
src/render/direct3d/SDL_render_d3d.c | 2 +-
src/render/direct3d11/SDL_render_d3d11.c | 2 +-
src/render/direct3d12/SDL_render_d3d12.c | 2 +-
src/render/opengl/SDL_render_gl.c | 2 +-
src/render/opengles2/SDL_render_gles2.c | 2 +-
src/render/software/SDL_blendfillrect.c | 42 +-
src/render/software/SDL_blendline.c | 20 +-
src/render/software/SDL_blendpoint.c | 50 +-
src/render/software/SDL_draw.h | 8 +-
src/render/software/SDL_drawline.c | 24 +-
src/render/software/SDL_drawpoint.c | 26 +-
src/render/software/SDL_render_sw.c | 54 +-
src/render/software/SDL_rotate.c | 25 +-
src/render/software/SDL_triangle.c | 47 +-
src/render/vulkan/SDL_render_vulkan.c | 2 +-
src/test/SDL_test_common.c | 10 +-
src/test/SDL_test_compare.c | 15 +-
src/video/SDL_RLEaccel.c | 188 ++--
src/video/SDL_blit.c | 51 +-
src/video/SDL_blit.h | 55 +-
src/video/SDL_blit_0.c | 25 +-
src/video/SDL_blit_1.c | 19 +-
src/video/SDL_blit_A.c | 70 +-
src/video/SDL_blit_N.c | 84 +-
src/video/SDL_blit_slow.c | 34 +-
src/video/SDL_bmp.c | 52 +-
src/video/SDL_fillrect.c | 16 +-
src/video/SDL_pixels.c | 466 +++++----
src/video/SDL_pixels_c.h | 25 +-
src/video/SDL_stretch.c | 22 +-
src/video/SDL_surface.c | 894 +++++++++---------
src/video/SDL_surface_c.h | 80 ++
src/video/SDL_sysvideo.h | 2 +-
src/video/SDL_video.c | 24 +-
src/video/SDL_yuv.c | 52 +-
src/video/SDL_yuv_c.h | 8 +-
src/video/android/SDL_androidmouse.c | 2 +-
src/video/cocoa/SDL_cocoavideo.m | 4 +-
src/video/dummy/SDL_nullframebuffer.c | 4 +-
src/video/dummy/SDL_nullframebuffer_c.h | 2 +-
.../emscripten/SDL_emscriptenframebuffer.c | 4 +-
.../emscripten/SDL_emscriptenframebuffer.h | 2 +-
src/video/emscripten/SDL_emscriptenmouse.c | 2 +-
src/video/haiku/SDL_bframebuffer.cc | 2 +-
src/video/haiku/SDL_bframebuffer.h | 2 +-
src/video/haiku/SDL_bmodes.cc | 2 +-
src/video/haiku/SDL_bmodes.h | 2 +-
src/video/haiku/SDL_bvideo.cc | 2 +-
src/video/kmsdrm/SDL_kmsdrmmouse.c | 2 +-
src/video/n3ds/SDL_n3dsframebuffer.c | 6 +-
src/video/n3ds/SDL_n3dsframebuffer_c.h | 2 +-
src/video/n3ds/SDL_n3dsvideo.c | 2 +-
src/video/ngage/SDL_ngageframebuffer.cpp | 4 +-
src/video/ngage/SDL_ngageframebuffer_c.h | 2 +-
.../offscreen/SDL_offscreenframebuffer.c | 4 +-
.../offscreen/SDL_offscreenframebuffer_c.h | 2 +-
src/video/qnx/SDL_qnxvideo.c | 2 +-
src/video/raspberry/SDL_rpimouse.c | 2 +-
src/video/riscos/SDL_riscosframebuffer.c | 2 +-
src/video/riscos/SDL_riscosframebuffer_c.h | 2 +-
src/video/riscos/SDL_riscosmodes.c | 4 +-
src/video/vita/SDL_vitaframebuffer.c | 2 +-
src/video/vita/SDL_vitaframebuffer.h | 2 +-
src/video/wayland/SDL_waylandmouse.c | 2 +-
src/video/windows/SDL_windowsframebuffer.c | 4 +-
src/video/windows/SDL_windowsframebuffer.h | 2 +-
src/video/windows/SDL_windowsmouse.c | 6 +-
src/video/windows/SDL_windowswindow.c | 2 +-
src/video/winrt/SDL_winrtvideo.cpp | 2 +-
src/video/x11/SDL_x11framebuffer.c | 2 +-
src/video/x11/SDL_x11framebuffer.h | 2 +-
src/video/x11/SDL_x11modes.c | 4 +-
src/video/x11/SDL_x11modes.h | 2 +-
src/video/x11/SDL_x11mouse.c | 4 +-
src/video/x11/SDL_x11window.c | 2 +-
test/testautomation_blit.c | 10 +-
test/testautomation_images.c | 68 +-
test/testautomation_pixels.c | 46 +-
test/testautomation_render.c | 4 +-
test/testautomation_surface.c | 106 +--
test/testcamera.c | 5 +-
test/testcustomcursor.c | 8 +-
test/testffmpeg.c | 12 +-
test/testgles2_sdf.c | 2 +-
test/testoverlay.c | 2 +-
test/testshape.c | 4 +-
test/testspriteminimal.c | 2 +-
test/testutils.c | 8 +-
test/testwaylandcustom.c | 2 +-
test/testyuv.c | 22 +-
123 files changed, 1862 insertions(+), 1835 deletions(-)
create mode 100644 src/video/SDL_surface_c.h
diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj
index 28fdc639ff8f2..e136005281e9d 100644
--- a/VisualC-GDK/SDL/SDL.vcxproj
+++ b/VisualC-GDK/SDL/SDL.vcxproj
@@ -558,6 +558,7 @@
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
@@ -863,4 +864,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters
index 069e3bd14afd7..4260bfcd900a9 100644
--- a/VisualC-GDK/SDL/SDL.vcxproj.filters
+++ b/VisualC-GDK/SDL/SDL.vcxproj.filters
@@ -436,6 +436,7 @@
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
@@ -462,4 +463,4 @@
<ItemGroup>
<ResourceCompile Include="..\..\src\core\windows\version.rc" />
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj
index 32966b4fedbc6..a80d0924bab2a 100644
--- a/VisualC-WinRT/SDL-UWP.vcxproj
+++ b/VisualC-WinRT/SDL-UWP.vcxproj
@@ -185,6 +185,7 @@
<ClInclude Include="..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\src\video\SDL_RLEaccel_c.h" />
+ <ClInclude Include="..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\src\video\SDL_sysvidocapture.h" />
<ClInclude Include="..\src\video\SDL_yuv_c.h" />
@@ -917,4 +918,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters
index 46d67b1459878..e57ee7174426e 100644
--- a/VisualC-WinRT/SDL-UWP.vcxproj.filters
+++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters
@@ -438,6 +438,9 @@
<ClInclude Include="..\src\video\SDL_RLEaccel_c.h">
<Filter>Source Files</Filter>
</ClInclude>
+ <ClInclude Include="..\src\video\SDL_surface_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
<ClInclude Include="..\src\video\SDL_sysvideo.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -973,4 +976,4 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index 879c607e8dd80..3a7f523d9f907 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -464,6 +464,7 @@
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters
index faa6a9d55598d..24579a58ebcb0 100644
--- a/VisualC/SDL/SDL.vcxproj.filters
+++ b/VisualC/SDL/SDL.vcxproj.filters
@@ -615,6 +615,9 @@
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h">
<Filter>video</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_surface_c.h">
+ <Filter>video</Filter>
+ </ClInclude>
<ClInclude Include="..\..\src\video\SDL_blit.h">
<Filter>video</Filter>
</ClInclude>
@@ -1554,4 +1557,4 @@
<ItemGroup>
<MASM Include="..\..\src\stdlib\SDL_mslibc_x64.masm" />
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index fef3d353644c9..67fa06af3d87e 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -1566,7 +1566,7 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
@@
@@
- SDL_AllocFormat
-+ SDL_CreatePixelFormat
++ SDL_GetPixelFormatDetails
(...)
@@
@@
@@ -1575,23 +1575,18 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
(...)
@@
@@
-- SDL_FreeFormat
-+ SDL_DestroyPixelFormat
- (...)
-@@
-@@
- SDL_FreePalette
+ SDL_DestroyPalette
(...)
@@
@@
- SDL_MasksToPixelFormatEnum
-+ SDL_GetPixelFormatEnumForMasks
++ SDL_GetPixelFormatForMasks
(...)
@@
@@
- SDL_PixelFormatEnumToMasks
-+ SDL_GetMasksForPixelFormatEnum
++ SDL_GetMasksForPixelFormat
(...)
@@
@@
@@ -3488,3 +3483,21 @@ typedef SDL_Colour, SDL_Color;
@@
- SDLK_z
+ SDLK_Z
+@@
+typedef SDL_PixelFormat, SDL_PackedPixelDetails;
+@@
+- SDL_PixelFormat
++ SDL_PixelFormatDetails
+@@
+@@
+- SDL_ConvertSurfaceFormat
++ SDL_ConvertSurface
+ (...)
+@@
+@@
+- SDL_PREALLOC
++ SDL_SURFACE_PREALLOCATED
+@@
+@@
+- SDL_SIMD_ALIGNED
++ SDL_SURFACE_SIMD_ALIGNED
diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c
index c8cc03c1289b1..016573847141d 100644
--- a/cmake/test/main_gui.c
+++ b/cmake/test/main_gui.c
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
return 1;
}
screenSurface = SDL_GetWindowSurface(window);
- SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xff, 0xff, 0xff));
+ SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff));
SDL_UpdateWindowSurface(window);
SDL_Delay(100);
SDL_DestroyWindow(window);
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 61411ded21e6e..526b4e15b4435 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1092,19 +1092,22 @@ The following symbols have been renamed:
## SDL_pixels.h
-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)).
+SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types.
+
+SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
-The BitsPerPixel and BytesPerPixel fields of SDL_PixelFormat have been renamed bits_per_pixel and bytes_per_pixel.
+SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
-SDL_PixelFormatEnum is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
+SDL_GetMasksForPixelFormat() now returns the standard int error code.
+
+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 following functions have been renamed:
-* SDL_AllocFormat() => SDL_CreatePixelFormat()
+* SDL_AllocFormat() => SDL_GetPixelFormatDetails()
* 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
@@ -1114,9 +1117,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_PixelFormatDetails
+
## SDL_platform.h
The following platform preprocessor macros have been renamed:
@@ -1598,19 +1608,23 @@ The following functions have been removed:
## SDL_surface.h
+SDL_Surface has been simplified and internal details are no longer in the public structure.
+
+The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect().
+
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 the unused 'flags' parameter from 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().
+SDL_CreateRGBSurfaceFrom() and SDL_CreateRGBSurfaceWithFormatFrom() have been combined into a new function SDL_CreateSurfaceFrom(), and the parameter order has changed for consistency with SDL_CreateSurface().
You can implement the old functions in your own code easily:
```c
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)
@@ -1620,13 +1634,14 @@ 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));
+ return SDL_CreateSurfaceFrom(width, height,
+ SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask),
+ pixels, pitch);
}
SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
{
- return SDL_CreateSurfaceFrom(pixels, width, height, pitch, format);
+ return SDL_CreateSurfaceFrom(width, height, format, pixels, pitch);
}
@@ -1645,10 +1660,15 @@ 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.
+
+SDL_SetSurfaceColorKey() takes an SDL_bool to enable and disable colorkey. RLE acceleration isn’t controlled by the parameter, you should use SDL_SetSurfaceRLE() to change that separately.
+
+SDL_SetSurfaceRLE() takes an SDL_bool to enable and disable RLE acceleration.
The following functions have been renamed:
- SDL_BlitScaled() => SDL_BlitSurfaceScaled()
+* SDL_ConvertSurfaceFormat() => SDL_ConvertSurface() - SDL_FillRect() => SDL_FillSurfaceRect()
- SDL_FillRects() => SDL_FillSurfaceRects()
- SDL_FreeSurface() => SDL_DestroySurface()
@@ -1669,11 +1689,16 @@ The following symbols have been removed: - SDL_SWSURFACE
The following functions have been removed:
+* SDL_FreeFormat()
- SDL_GetYUVConversionMode()
- SDL_GetYUVConversionModeForResolution()
- SDL_SetYUVConversionMode() - use SDL_SetSurfaceColorspace() to set the surface colorspace and SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER with SDL_CreateTextureWithProperties() to set the texture colorspace. The default colorspace for YUV pixel formats is SDL_COLORSPACE_JPEG.
- SDL_SoftStretchLinear() - use SDL_SoftStretch() with SDL_SCALEMODE_LINEAR
+The following symbols have been renamed:
+* SDL_PREALLOC => SDL_SURFACE_PREALLOCATED
+* SDL_SIMD_ALIGNED => SDL_SURFACE_SIMD_ALIGNED
+
SDL_system.h
SDL_WindowsMessageHook has changed signatures so the message may be modified and it can block further message processing.
@@ -1835,7 +1860,7 @@ The callback passed to SDL_AddTimer() has changed parameters to:
Uint32 SDLCALL TimerCallback(void *userdata, SDL_TimerID timerID, Uint32 interval);
-The return value of SDL_RemoveTimer() has changed to the standard int error code.
+SDL_RemoveTimer() now returns the standard int error code.
## SDL_touch.h
diff --git a/include/SDL3/SDL_camera.h b/include/SDL3/SDL_camera.h
index de8e1358b96eb..f7468426f4650 100644
--- a/include/SDL3/SDL_camera.h
+++ b/include/SDL3/SDL_camera.h
@@ -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 */
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 7d1bf8360e0e4..c9abf8147633e 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -453,19 +453,18 @@
#define SDL_sem SDL_Semaphore
/* ##SDL_pixels.h */
-#define SDL_AllocFormat SDL_CreatePixelFormat
+#define SDL_AllocFormat SDL_GetPixelFormatDetails
#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
@@ -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
@@ -590,6 +590,8 @@
#define SDL_LoadBMP_RW SDL_LoadBMP_IO
#define SDL_LowerBlit SDL_BlitSurfaceUnchecked
#define SDL_LowerBlitScaled SDL_BlitSurfaceUncheckedScaled
+#define SDL_PREALLOC SDL_SURFACE_PREALLOCATED
+#define SDL_SIMD_ALIGNED SDL_SURFACE_SIMD_ALIGNED
#define SDL_SaveBMP_RW SDL_SaveBMP_IO
#define SDL_SetClipRect SDL_SetSurfaceClipRect
#define SDL_SetColorKey SDL_SetSurfaceColorKey
@@ -1048,19 +1050,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_GetPixelFormatDetails
#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
@@ -1175,6 +1176,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
@@ -1185,6 +1187,8 @@
#define SDL_LoadBMP_RW SDL_LoadBMP_RW_renamed_SDL_LoadBMP_IO
#define SDL_LowerBlit SDL_LowerBlit_renamed_SDL_BlitSurfaceUnchecked
#define SDL_LowerBlitScaled SDL_LowerBlitScaled_renamed_SDL_BlitSurfaceUncheckedScaled
+#define SDL_PREALLOC SDL_PREALLOC_renamed_SDL_SURFACE_PREALLOCATED
+#define SDL_SIMD_ALIGNED SDL_SIMD_ALIGNED_renamed_SDL_SURFACE_SIMD_ALIGNED
#define SDL_SaveBMP_RW SDL_SaveBMP_RW_renamed_SDL_SaveBMP_IO
#define SDL_SetClipRect SDL_SetClipRect_renamed_SDL_SetSurfaceClipRect
#define SDL_SetColorKey SDL_SetColorKey_renamed_SDL_SetSurfaceColorKey
diff --git a/include/SDL3/SDL_pixels.h b/include/SDL3/SDL_pixels.h
index ec758d8d82fb1..bdb37f73d5a66 100644
--- a/include/SDL3/SDL_pixels.h
+++ b/include/SDL3/SDL_pixels.h
@@ -133,7 +133,8 @@ typedef enum SDL_PackedLayout
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
-#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
+#define SDL_BITSPERPIXEL(X) \
+ (SDL_ISPIXELFORMAT_FOURCC(X) ? 0 : (((X) >> 8) & 0xFF))
#define SDL_BYTESPERPIXEL(X) \
(SDL_ISPIXELFORMAT_FOURCC(X) ? \
((((X) == SDL_PIXELFORMAT_YUY2) || \
@@ -222,7 +223,7 @@ typedef enum SDL_PackedLayout
*
* \since This enum is available since SDL 3.0.0.
*/
-typedef enum SDL_PixelFormatEnum
+typedef enum SDL_PixelFormat
{
SDL_PIXELFORMAT_UNKNOWN,
SDL_PIXELFORMAT_INDEX1LSB =
@@ -426,7 +427,7 @@ typedef enum SDL_PixelFormatEnum
SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'),
SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */
SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
-} SDL_PixelFormatEnum;
+} SDL_PixelFormat;
/**
* Pixels are a representation of a color in a particular color space.
@@ -721,7 +722,6 @@ typedef struct SDL_FColor
*
* \since This struct is available since SDL 3.0.0.
*
- * \sa SDL_PixelFormat
* \sa SDL_SetPaletteColors
*/
typedef struct SDL_Palette
@@ -735,15 +735,11 @@ typedef struct SDL_Palette
/**
* Details about the format of a pixel.
*
- * Generally this is used with SDL_Surface, and covers many possible
- * configurations, including paletted data and various bit patterns.
- *
* \since This struct is available since SDL 3.0.0.
*/
-typedef struct SDL_PixelFormat
+typedef struct SDL_PixelFormatDetails
{
- SDL_PixelFormatEnum format;
- SDL_Palette *palette;
+ SDL_PixelFormat format;
Uint8 bits_per_pixel;
Uint8 bytes_per_pixel;
Uint8 padding[2];
@@ -751,17 +747,15 @@ typedef struct SDL_PixelFormat
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
- Uint8 Rloss;
- Uint8 Gloss;
- Uint8 Bloss;
- Uint8 Aloss;
+ Uint8 Rbits;
+ Uint8 Gbits;
+ Uint8 Bbits;
+ Uint8 Abits;
Uint8 Rshift;
Uint8 Gshift;
Uint8 Bshift;
Uint8 Ashift;
- int refcount;
- struct SDL_PixelFormat *next;
-} SDL_PixelFormat;
+} SDL_PixelFormatDetails;
/**
* Get the human readable name of a pixel format.
@@ -772,32 +766,31 @@ typedef struct SDL_PixelFormat
* \returns the human readable name of the specified pixel format or
* `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
*
+ * \threadsafety It is safe to call this function from any thread.
+ *
* \since This function is available since SDL 3.0.0.
*/
-extern SDL_DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(SDL_PixelFormatEnum format);
+extern SDL_DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat format);
/**
* Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
*
- * \param format one of the SDL_PixelFormatEnum values.
+ * \param format one of the SDL_PixelFormat values.
* \param bpp a bits per pixel value; usually 15, 16, or 32.
* \param Rmask a pointer filled in with the red mask for the format.
* \param Gmask a pointer filled in with the green mask for the format.
* \param Bmask a pointer filled in with the blue mask for the format.
* \param Amask a pointer filled in with the alpha mask for the format.
- * \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
- * possible; call SDL_GetError() for more information.
+ * \returns 0 on success or a negative error code 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_GetPixelFormatEnumForMasks
+ * \sa SDL_GetPixelFormatForMasks
*/
-extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format,
- int *bpp,
- Uint32 * Rmask,
- Uint32 * Gmask,
- Uint32 * Bmask,
- Uint32 * Amask);
+extern SDL_DECLSPEC int SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);
/**
* Convert a bpp value and RGBA masks to an enumerated pixel format.
@@ -810,47 +803,33 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormatEnum(SDL_PixelFor
* \param Gmask the green mask for the format.
* \param Bmask the blue mask for the format.
* \param Amask the alpha mask for the format.
- * \returns the SDL_PixelFormatEnum value corresponding to the format masks,
+ * \returns the SDL_PixelFormat value corresponding to the format masks,
* or SDL_
```
(Patch may be truncated, please check the link at the top of this post.)