SDL: SDL API renaming: SDL_pixels.h

From 083e436a1adbe15871c03f270cbbc233e8c7e4a8 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 27 Dec 2022 06:08:13 -0800
Subject: [PATCH] SDL API renaming: SDL_pixels.h

Fixes https://github.com/libsdl-org/SDL/issues/6886
---
 WhatsNew.txt                               |  6 +++
 docs/README-migration.md                   | 12 ++++-
 include/SDL3/SDL_oldnames.h                | 16 ++++++
 include/SDL3/SDL_pixels.h                  | 34 ++++++------
 include/SDL3/SDL_surface.h                 |  4 +-
 src/dynapi/SDL_dynapi.sym                  | 12 ++---
 src/dynapi/SDL_dynapi_overrides.h          | 12 ++---
 src/dynapi/SDL_dynapi_procs.h              | 12 ++---
 src/render/SDL_render.c                    |  4 +-
 src/render/software/SDL_render_sw.c        |  2 +-
 src/test/SDL_test_common.c                 |  4 +-
 src/video/SDL_bmp.c                        |  2 +-
 src/video/SDL_pixels.c                     | 18 +++----
 src/video/SDL_surface.c                    | 12 ++---
 src/video/windows/SDL_windowsframebuffer.c |  2 +-
 src/video/x11/SDL_x11modes.c               |  2 +-
 test/testautomation_pixels.c               | 60 +++++++++++-----------
 test/testautomation_surface.c              |  8 +--
 18 files changed, 126 insertions(+), 96 deletions(-)

diff --git a/WhatsNew.txt b/WhatsNew.txt
index 95fba1d40030..00baaa859f0a 100644
--- a/WhatsNew.txt
+++ b/WhatsNew.txt
@@ -17,12 +17,16 @@ General:
     * RW_SEEK_SET -> SDL_RW_SEEK_SET
 * SDL_FreeWAV has been removed and calls can be replaced with SDL_free
 * The following functions have been renamed:
+    * SDL_AllocFormat => SDL_CreatePixelFormat
+    * SDL_AllocPalette => SDL_CreatePalette
     * SDL_AudioStreamAvailable => SDL_GetAudioStreamAvailable
     * SDL_AudioStreamClear => SDL_ClearAudioStream
     * SDL_AudioStreamFlush => SDL_FlushAudioStream
     * SDL_AudioStreamGet => SDL_GetAudioStreamData
     * SDL_AudioStreamPut => SDL_PutAudioStreamData
     * SDL_FreeAudioStream => SDL_DestroyAudioStream
+    * SDL_FreeFormat => SDL_DestroyPixelFormat
+    * SDL_FreePalette => SDL_DestroyPalette
     * SDL_JoystickAttachVirtual => SDL_AttachVirtualJoystick
     * SDL_JoystickAttachVirtualEx => SDL_AttachVirtualJoystickEx
     * SDL_JoystickClose => SDL_CloseJoystick
@@ -72,8 +76,10 @@ General:
     * SDL_JoystickSetVirtualButton => SDL_SetJoystickVirtualButton
     * SDL_JoystickSetVirtualHat => SDL_SetJoystickVirtualHat
     * SDL_JoystickUpdate => SDL_UpdateJoysticks
+    * SDL_MasksToPixelFormatEnum => SDL_GetPixelFormatEnumForMasks
     * SDL_NewAudioStream => SDL_CreateAudioStream
     * SDL_NumJoysticks => SDL_GetNumJoysticks
+    * SDL_PixelFormatEnumToMasks => SDL_GetMasksForPixelFormatEnum
 * Removed the following functions from the API, see docs/README-migration.md for details:
     * SDL_AudioInit()
     * SDL_AudioQuit()
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 911f4729c5b8..cefbbc565326 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -221,6 +221,14 @@ used by additional platforms that didn't have a SDL_RunApp-like function before)
 
 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_AllocPalette => SDL_CreatePalette
+* SDL_FreeFormat => SDL_DestroyPixelFormat
+* SDL_FreePalette => SDL_DestroyPalette
+* SDL_MasksToPixelFormatEnum => SDL_GetPixelFormatEnumForMasks
+* SDL_PixelFormatEnumToMasks => SDL_GetMasksForPixelFormatEnum
+
 ## SDL_platform.h
 
 The preprocessor symbol __MACOSX__ has been renamed __MACOS__, and __IPHONEOS__ has been renamed __IOS__
@@ -419,7 +427,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_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask));
+            SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
 }
 
 SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
@@ -430,7 +438,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_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask));
+            SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
 }
 
 SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 5efa2a576fee..318824490f5e 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -121,6 +121,14 @@
 #define KMOD_SCROLL SDL_KMOD_SCROLL
 #define KMOD_SHIFT SDL_KMOD_SHIFT
 
+/* ##SDL_pixels.h */
+#define SDL_AllocFormat SDL_CreatePixelFormat
+#define SDL_AllocPalette SDL_CreatePalette
+#define SDL_FreeFormat SDL_DestroyPixelFormat
+#define SDL_FreePalette SDL_DestroyPalette
+#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatEnumForMasks
+#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormatEnum
+
 /* ##SDL_platform.h */
 #ifdef __IOS__
 #define __IPHONEOS__ __IOS__
@@ -218,6 +226,14 @@
 #define KMOD_SCROLL KMOD_SCROLL_renamed_SDL_KMOD_SCROLL
 #define KMOD_SHIFT KMOD_SHIFT_renamed_SDL_KMOD_SHIFT
 
+/* ##SDL_pixels.h */
+#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat
+#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette
+#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_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormatEnum
+
 /* ##SDL_platform.h */
 #ifdef __IOS__
 #define __IPHONEOS__ __IPHONEOS___renamed___IOS__
diff --git a/include/SDL3/SDL_pixels.h b/include/SDL3/SDL_pixels.h
index cebd2cbd414a..7e1518bf69d9 100644
--- a/include/SDL3/SDL_pixels.h
+++ b/include/SDL3/SDL_pixels.h
@@ -363,9 +363,9 @@ extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_MasksToPixelFormatEnum
+ * \sa SDL_GetPixelFormatEnumForMasks
  */
-extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
+extern DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormatEnum(Uint32 format,
                                                             int *bpp,
                                                             Uint32 * Rmask,
                                                             Uint32 * Gmask,
@@ -387,9 +387,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_PixelFormatEnumToMasks
+ * \sa SDL_GetMasksForPixelFormatEnum
  */
-extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
+extern DECLSPEC Uint32 SDLCALL SDL_GetPixelFormatEnumForMasks(int bpp,
                                                           Uint32 Rmask,
                                                           Uint32 Gmask,
                                                           Uint32 Bmask,
@@ -408,20 +408,20 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_FreeFormat
+ * \sa SDL_DestroyPixelFormat
  */
-extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
+extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_CreatePixelFormat(Uint32 pixel_format);
 
 /**
- * Free an SDL_PixelFormat structure allocated by SDL_AllocFormat().
+ * Free an SDL_PixelFormat structure allocated by SDL_CreatePixelFormat().
  *
  * \param format the SDL_PixelFormat structure to free
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_AllocFormat
+ * \sa SDL_CreatePixelFormat
  */
-extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
+extern DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
 
 /**
  * Create a palette structure with the specified number of color entries.
@@ -435,9 +435,9 @@ extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_FreePalette
+ * \sa SDL_DestroyPalette
  */
-extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
+extern DECLSPEC SDL_Palette *SDLCALL SDL_CreatePalette(int ncolors);
 
 /**
  * Set the palette for a pixel format structure.
@@ -449,8 +449,8 @@ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_AllocPalette
- * \sa SDL_FreePalette
+ * \sa SDL_CreatePalette
+ * \sa SDL_DestroyPalette
  */
 extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
                                                       SDL_Palette *palette);
@@ -467,7 +467,7 @@ extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_AllocPalette
+ * \sa SDL_CreatePalette
  * \sa SDL_CreateSurface
  */
 extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
@@ -475,15 +475,15 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
                                                  int firstcolor, int ncolors);
 
 /**
- * Free a palette created with SDL_AllocPalette().
+ * Free a palette created with SDL_CreatePalette().
  *
  * \param palette the SDL_Palette structure to be freed
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_AllocPalette
+ * \sa SDL_CreatePalette
  */
-extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
+extern DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
 
 /**
  * Map an RGB triple to an opaque pixel value for a given pixel format.
diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h
index 450eb40a9290..ce888aabb759 100644
--- a/include/SDL3/SDL_surface.h
+++ b/include/SDL3/SDL_surface.h
@@ -562,7 +562,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_AllocFormat
+ * \sa SDL_CreatePixelFormat
  * \sa SDL_ConvertSurfaceFormat
  * \sa SDL_CreateSurface
  */
@@ -585,7 +585,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface,
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_AllocFormat
+ * \sa SDL_CreatePixelFormat
  * \sa SDL_ConvertSurface
  * \sa SDL_CreateSurface
  */
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 359040021368..c9ff8b45ab25 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -182,14 +182,14 @@ SDL3_0.0.0 {
     SDL_Vulkan_GetDrawableSize;
     SDL_GetPreferredLocales;
     SDL_GetPixelFormatName;
-    SDL_PixelFormatEnumToMasks;
-    SDL_MasksToPixelFormatEnum;
-    SDL_AllocFormat;
-    SDL_FreeFormat;
-    SDL_AllocPalette;
+    SDL_GetMasksForPixelFormatEnum;
+    SDL_GetPixelFormatEnumForMasks;
+    SDL_CreatePixelFormat;
+    SDL_DestroyPixelFormat;
+    SDL_CreatePalette;
     SDL_SetPixelFormatPalette;
     SDL_SetPaletteColors;
-    SDL_FreePalette;
+    SDL_DestroyPalette;
     SDL_MapRGB;
     SDL_MapRGBA;
     SDL_GetRGB;
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 221df0fd9328..d45f9408942b 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -263,14 +263,14 @@
 #define SDL_CondWait SDL_CondWait_REAL
 #define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL
 #define SDL_GetPixelFormatName SDL_GetPixelFormatName_REAL
-#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_REAL
-#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_REAL
-#define SDL_AllocFormat SDL_AllocFormat_REAL
-#define SDL_FreeFormat SDL_FreeFormat_REAL
-#define SDL_AllocPalette SDL_AllocPalette_REAL
+#define SDL_GetMasksForPixelFormatEnum SDL_GetMasksForPixelFormatEnum_REAL
+#define SDL_GetPixelFormatEnumForMasks SDL_GetPixelFormatEnumForMasks_REAL
+#define SDL_CreatePixelFormat SDL_CreatePixelFormat_REAL
+#define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL
+#define SDL_CreatePalette SDL_CreatePalette_REAL
 #define SDL_SetPixelFormatPalette SDL_SetPixelFormatPalette_REAL
 #define SDL_SetPaletteColors SDL_SetPaletteColors_REAL
-#define SDL_FreePalette SDL_FreePalette_REAL
+#define SDL_DestroyPalette SDL_DestroyPalette_REAL
 #define SDL_MapRGB SDL_MapRGB_REAL
 #define SDL_MapRGBA SDL_MapRGBA_REAL
 #define SDL_GetRGB SDL_GetRGB_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 5af62d5b0d74..b437f36d465f 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -290,14 +290,14 @@ SDL_DYNAPI_PROC(int,SDL_CondBroadcast,(SDL_cond *a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return)
 SDL_DYNAPI_PROC(int,SDL_CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetPixelFormatName,(Uint32 a),(a),return)
-SDL_DYNAPI_PROC(SDL_bool,SDL_PixelFormatEnumToMasks,(Uint32 a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
-SDL_DYNAPI_PROC(Uint32,SDL_MasksToPixelFormatEnum,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_AllocFormat,(Uint32 a),(a),return)
-SDL_DYNAPI_PROC(void,SDL_FreeFormat,(SDL_PixelFormat *a),(a),)
-SDL_DYNAPI_PROC(SDL_Palette*,SDL_AllocPalette,(int a),(a),return)
+SDL_DYNAPI_PROC(SDL_bool,SDL_GetMasksForPixelFormatEnum,(Uint32 a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
+SDL_DYNAPI_PROC(Uint32,SDL_GetPixelFormatEnumForMasks,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
+SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(Uint32 a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
+SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_SetPixelFormatPalette,(SDL_PixelFormat *a, SDL_Palette *b),(a,b),return)
 SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(void,SDL_FreePalette,(SDL_Palette *a),(a),)
+SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),)
 SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
 SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),)
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 56aa52978e25..b3bd3b47b975 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1436,13 +1436,13 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
         SDL_Surface *temp = NULL;
 
         /* Set up a destination surface for the texture update */
-        dst_fmt = SDL_AllocFormat(format);
+        dst_fmt = SDL_CreatePixelFormat(format);
         if (dst_fmt == NULL) {
             SDL_DestroyTexture(texture);
             return NULL;
         }
         temp = SDL_ConvertSurface(surface, dst_fmt);
-        SDL_FreeFormat(dst_fmt);
+        SDL_DestroyPixelFormat(dst_fmt);
         if (temp) {
             SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
             SDL_FreeSurface(temp);
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index dbeaa0cc8ca9..9ea0d0d89a3a 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -474,7 +474,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
                          * to be created. This makes all source pixels opaque and the colors get copied correctly.
                          */
                         SDL_Surface *src_rotated_rgb;
-                        int f = SDL_MasksToPixelFormatEnum(src_rotated->format->BitsPerPixel,
+                        int f = SDL_GetPixelFormatEnumForMasks(src_rotated->format->BitsPerPixel,
                                                            src_rotated->format->Rmask,
                                                            src_rotated->format->Gmask,
                                                            src_rotated->format->Bmask,
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index fa144ec26721..c52db29f655a 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1143,7 +1143,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
                 SDL_Log("DPI: %fx%f\n", hdpi, vdpi);
 
                 SDL_GetDesktopDisplayMode(i, &mode);
-                SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask,
+                SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, &Gmask,
                                            &Bmask, &Amask);
                 SDL_Log("  Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
                         mode.w, mode.h, mode.refresh_rate, bpp,
@@ -1165,7 +1165,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
                     SDL_Log("  Fullscreen video modes:\n");
                     for (j = 0; j < m; ++j) {
                         SDL_GetDisplayMode(i, j, &mode);
-                        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
+                        SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask,
                                                    &Gmask, &Bmask, &Amask);
                         SDL_Log("    Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
                                 j, mode.w, mode.h, mode.refresh_rate, bpp,
diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
index 27d1a71a5f15..cefafe1c79f7 100644
--- a/src/video/SDL_bmp.c
+++ b/src/video/SDL_bmp.c
@@ -428,7 +428,7 @@ SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
         Uint32 format;
 
         /* Get the pixel format */
-        format = SDL_MasksToPixelFormatEnum(biBitCount, Rmask, Gmask, Bmask, Amask);
+        format = SDL_GetPixelFormatEnumForMasks(biBitCount, Rmask, Gmask, Bmask, Amask);
         surface = SDL_CreateSurface(biWidth, biHeight, format);
 
         if (surface == NULL) {
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index ace454bf9de9..0481958eea6d 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -135,7 +135,7 @@ SDL_GetPixelFormatName(Uint32 format)
 #undef CASE
 
 SDL_bool
-SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask,
+SDL_GetMasksForPixelFormatEnum(Uint32 format, int *bpp, Uint32 *Rmask,
                            Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
 {
     Uint32 masks[4];
@@ -302,7 +302,7 @@ SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask,
 }
 
 Uint32
-SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
+SDL_GetPixelFormatEnumForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
                            Uint32 Amask)
 {
     switch (bpp) {
@@ -512,7 +512,7 @@ static SDL_PixelFormat *formats;
 static SDL_SpinLock formats_lock = 0;
 
 SDL_PixelFormat *
-SDL_AllocFormat(Uint32 pixel_format)
+SDL_CreatePixelFormat(Uint32 pixel_format)
 {
     SDL_PixelFormat *format;
 
@@ -557,7 +557,7 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
     Uint32 Rmask, Gmask, Bmask, Amask;
     Uint32 mask;
 
-    if (!SDL_PixelFormatEnumToMasks(pixel_format, &bpp,
+    if (!SDL_GetMasksForPixelFormatEnum(pixel_format, &bpp,
                                     &Rmask, &Gmask, &Bmask, &Amask)) {
         return -1;
     }
@@ -623,7 +623,7 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
     return 0;
 }
 
-void SDL_FreeFormat(SDL_PixelFormat *format)
+void SDL_DestroyPixelFormat(SDL_PixelFormat *format)
 {
     SDL_PixelFormat *prev;
 
@@ -654,13 +654,13 @@ void SDL_FreeFormat(SDL_PixelFormat *format)
     SDL_AtomicUnlock(&formats_lock);
 
     if (format->palette) {
-        SDL_FreePalette(format->palette);
+        SDL_DestroyPalette(format->palette);
     }
     SDL_free(format);
 }
 
 SDL_Palette *
-SDL_AllocPalette(int ncolors)
+SDL_CreatePalette(int ncolors)
 {
     SDL_Palette *palette;
 
@@ -706,7 +706,7 @@ int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
     }
 
     if (format->palette) {
-        SDL_FreePalette(format->palette);
+        SDL_DestroyPalette(format->palette);
     }
 
     format->palette = palette;
@@ -744,7 +744,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors,
     return status;
 }
 
-void SDL_FreePalette(SDL_Palette *palette)
+void SDL_DestroyPalette(SDL_Palette *palette)
 {
     if (palette == NULL) {
         SDL_InvalidParamError("palette");
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index e8269906b305..4b7202326967 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -114,7 +114,7 @@ SDL_CreateSurface(int width, int height, Uint32 format)
         return NULL;
     }
 
-    surface->format = SDL_AllocFormat(format);
+    surface->format = SDL_CreatePixelFormat(format);
     if (!surface->format) {
         SDL_FreeSurface(surface);
         return NULL;
@@ -126,7 +126,7 @@ SDL_CreateSurface(int width, int height, Uint32 format)
 
     if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
         SDL_Palette *palette =
-            SDL_AllocPalette((1 << surface->format->BitsPerPixel));
+            SDL_CreatePalette((1 << surface->format->BitsPerPixel));
         if (palette == NULL) {
             SDL_FreeSurface(surface);
             return NULL;
@@ -141,7 +141,7 @@ SDL_CreateSurface(int width, int height, Uint32 format)
             palette->colors[1].b = 0x00;
         }
         SDL_SetSurfacePalette(surface, palette);
-        SDL_FreePalette(palette);
+        SDL_DestroyPalette(palette);
     }
 
     /* Get the pixels */
@@ -1333,10 +1333,10 @@ SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format)
     SDL_PixelFormat *fmt;
     SDL_Surface *convert = NULL;
 
-    fmt = SDL_AllocFormat(pixel_format);
+    fmt = SDL_CreatePixelFormat(pixel_format);
     if (fmt) {
         convert = SDL_ConvertSurface(surface, fmt);
-        SDL_FreeFormat(fmt);
+        SDL_DestroyPixelFormat(fmt);
     }
     return convert;
 }
@@ -1546,7 +1546,7 @@ void SDL_FreeSurface(SDL_Surface *surface)
 #endif
     if (surface->format) {
         SDL_SetSurfacePalette(surface, NULL);
-        SDL_FreeFormat(surface->format);
+        SDL_DestroyPixelFormat(surface->format);
         surface->format = NULL;
     }
     if (surface->flags & SDL_PREALLOC) {
diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c
index 1d1eff374f12..1c45f8f1b05f 100644
--- a/src/video/windows/SDL_windowsframebuffer.c
+++ b/src/video/windows/SDL_windowsframebuffer.c
@@ -63,7 +63,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void
 
         bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount;
         masks = (Uint32 *)((Uint8 *)info + info->bmiHeader.biSize);
-        *format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0);
+        *format = SDL_GetPixelFormatEnumForMasks(bpp, masks[0], masks[1], masks[2], 0);
     }
     if (*format == SDL_PIXELFORMAT_UNKNOWN) {
         /* We'll use RGB format for now */
diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index 92f8f8126d9d..5b74bcdb1d85 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -116,7 +116,7 @@ X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo)
             }
         }
 
-        return SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
+        return SDL_GetPixelFormatEnumForMasks(bpp, Rmask, Gmask, Bmask, Amask);
     }
 
     if (vinfo->class == PseudoColor || vinfo->class == StaticColor) {
diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c
index 18f7ee73acae..01e9ee426c7f 100644
--- a/test/testautomation_pixels.c
+++ b/test/testautomation_pixels.c
@@ -110,10 +110,10 @@ const char *_invalidPixelFormatsVerbose[] = {
 /* Test case functions */
 
 /**
- * @brief Call to SDL_AllocFormat and SDL_FreeFormat
+ * @brief Call to SDL_CreatePixelFormat and SDL_DestroyPixelFormat
  *
- * @sa http://wiki.libsdl.org/SDL_AllocFormat
- * @sa http://wiki.libsdl.org/SDL_FreeFormat
+ * @sa http://wiki.libsdl.org/SDL_CreatePixelFormat
+ * @sa http://wiki.libsdl.org/SDL_DestroyPixelFormat
  */
 int pixels_allocFreeFormat(void *arg)
 {
@@ -130,8 +130,8 @@ int pixels_allocFreeFormat(void *arg)
     SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format);
 
     /* Allocate format */
-    result = SDL_AllocFormat(format);
-    SDLTest_AssertPass("Call to SDL_AllocFormat()");
+    result = SDL_CreatePixelFormat(format);
+    SDLTest_AssertPass("Call to SDL_CreatePixelFormat()");
     SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
     if (result != NULL) {
         SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format);
@@ -141,8 +141,8 @@ int pixels_allocFreeFormat(void *arg)
         SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %" SDL_PRIu32, masks);
 
         /* Deallocate again */
-        SDL_FreeFormat(result);
-        SDLTest_AssertPass("Call to SDL_FreeFormat()");
+        SDL_DestroyPixelFormat(result);
+        SDLTest_AssertPass("Call to SDL_DestroyPixelFormat()");
     }
 
     /* RGB formats */
@@ -151,8 +151,8 @@ int pixels_allocFreeFormat(void *arg)
         SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format);
 
         /* Allocate format */
-        result = SDL_AllocFormat(format);
-        SDLTest_AssertPass("Call to SDL_AllocFormat()");
+        result = SDL_CreatePixelFormat(format);
+        SDLTest_AssertPass("Call to SDL_CreatePixelFormat()");
         SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
         if (result != NULL) {
             SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format);
@@ -164,8 +164,8 @@ int pixels_allocFreeFormat(void *arg)
             }
 
             /* Deallocate again */
-            SDL_FreeFormat(result);
-            SDLTest_AssertPass("Call to SDL_FreeFormat()");
+            SDL_DestroyPixelFormat(result);
+            SDLTest_AssertPass("Call to SDL_DestroyPixelFormat()");
         }
     }
 
@@ -175,8 +175,8 @@ int pixels_allocFreeFormat(void *arg)
         SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format);
 
         /* Try to allocate format */
-        result = SDL_AllocFormat(format);
-        SDLTest_AssertPass("Call to SDL_AllocFormat()");
+        result = SDL_CreatePixelFormat(format);
+        SDLTest_AssertPass("Call to SDL_CreatePixelFormat()");
         SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
     }
 
@@ -187,8 +187,8 @@ int pixels_allocFreeFormat(void *arg)
         SDL_ClearError();
         SDLTest_AssertPass("Call to SDL_ClearError()");
         format = _invalidPixelFormats[i];
-        result = SDL_AllocFormat(format);
-        SDLTest_AssertPass("Call to SDL_AllocFormat(%" SDL_PRIu32 ")", format);
+        result = SDL_CreatePixelFormat(format);
+        SDLTest_AssertPass("Call to SDL_CreatePixelFormat(%" SDL_PRIu32 ")", format);
         SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
         error = SDL_GetError();
         SDLTest_AssertPass("Call to SDL_GetError()");
@@ -202,8 +202,8 @@ int pixels_allocFreeFormat(void *arg)
     /* Invalid free pointer */
     SDL_ClearError();
     SDLTest_AssertPass("Call to SDL_ClearError()");
-    SDL_FreeFormat(NULL);
-    SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)");
+    SDL_DestroyPixelFormat(NULL);
+    SDLTest_AssertPass("Call to SDL_DestroyPixelFormat(NULL)");
     error = SDL_GetError();
     SDLTest_AssertPass("Call to SDL_GetError()");
     SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
@@ -299,10 +299,10 @@ int pixels_getPixelFormatName(void *arg)
 }
 
 /**
- * @brief Call to SDL_AllocPalette and SDL_FreePalette
+ * @brief Call to SDL_CreatePalette and SDL_DestroyPalette
  *
- * @sa http://wiki.libsdl.org/SDL_AllocPalette
- * @sa http://wiki.libsdl.org/SDL_FreePalette
+ * @sa http://wiki.libsdl.org/SDL_CreatePalette
+ * @sa http://wiki.libsdl.org/SDL_DestroyPalette
  */
 int pixels_allocFreePalette(void *arg)
 {
@@ -332,8 +332,8 @@ int pixels_allocFreePalette(void *arg)
             break;
         }
 
-        result = SDL_AllocPalette(ncolors);
-        SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
+        result = SDL_CreatePalette(ncolors);
+        SDLTest_AssertPass("Call to SDL_CreatePalette(%d)", ncolors);
         SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
         if (result != NULL) {
             SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors);
@@ -349,8 +349,8 @@ int pixels_allocFreePalette(void *arg)
             }
 
             /* Deallocate again */
-            SDL_FreePalette(result);
-            SDLTest_AssertPass("Call to SDL_FreePalette()");
+            SDL_DestroyPalette(result);
+            SDLTest_AssertPass("Call to SDL_DestroyPalette()");
         }
     }
 
@@ -360,8 +360,8 @@ int pixels_allocFreePalette(void *arg)
     for (ncolors = 0; ncolors > -3; ncolors--) {
         SDL_ClearError();
         SDLTest_AssertPass("Call to SDL_ClearError()");
-        result = SDL_AllocPalette(ncolors);
-        SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors);
+        result = SDL_CreatePalette(ncolors);
+        SDLTest_AssertPass("Call to SDL_CreatePalette(%d)", ncolors);
         SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
         error = SDL_GetError();
         SDLTest_AssertPass("Call to SDL_GetError()");
@@ -375,8 +375,8 @@ int pixels_allocFreePalette(void *arg)
     /* Invalid free pointer */
     SDL_ClearError();
     SDLTest_AssertPass("Call to SDL_ClearError()");
-    SDL_FreePalette(NULL);
-    SDLTest_AssertPass("Call to SDL_FreePalette(NULL)");
+    SDL_DestroyPalette(NULL);
+    SDLTest_AssertPass("Call to SDL_DestroyPalette(NULL)");
     error = SDL_GetError();
     SDLTest_AssertPass("Call to SDL_GetError()");
     SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
@@ -392,11 +392,11 @@ int pixels_allocFreePalette(void *arg)
 
 /*

(Patch may be truncated, please check the link at the top of this post.)