SDL: Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_Create… (#6685)

From fc4fc5295fa7b3c4eb1a1c73711d9b30504d129d Mon Sep 17 00:00:00 2001
From: Sylvain Becker <[EMAIL REDACTED]>
Date: Tue, 29 Nov 2022 18:40:09 +0100
Subject: [PATCH] =?UTF-8?q?Remove=20depth=20field=20from=20SDL=5FCreateRGB?=
 =?UTF-8?q?SurfaceWithFormat=20and=20SDL=5FCreate=E2=80=A6=20(#6685)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_CreateRGBSurfaceWithFormatFrom
* Removed unused 'flags' parameter from SDL_CreateRGBSurface and SDL_CreateRGBSurfaceWithFormat
* Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat
---
 WhatsNew.txt                                  |  4 ++
 Xcode-iOS/Demos/src/fireworks.c               |  2 +-
 Xcode-iOS/Demos/src/keyboard.c                |  2 +-
 docs/README-migration.md                      |  7 +++
 include/SDL3/SDL_surface.h                    | 22 ++-------
 src/dynapi/SDL_dynapi_procs.h                 | 10 ++--
 src/events/SDL_mouse.c                        |  4 +-
 src/render/SDL_render.c                       |  4 +-
 src/render/SDL_yuv_sw.c                       |  2 +-
 src/render/software/SDL_render_sw.c           |  8 ++--
 src/render/software/SDL_rotate.c              |  4 +-
 src/render/software/SDL_triangle.c            |  2 +-
 src/test/SDL_test_common.c                    |  2 +-
 src/test/SDL_test_font.c                      |  3 +-
 src/video/SDL_bmp.c                           |  4 +-
 src/video/SDL_surface.c                       | 44 +++++++----------
 src/video/SDL_video.c                         |  2 +-
 src/video/android/SDL_androidmouse.c          |  4 +-
 src/video/cocoa/SDL_cocoavideo.m              |  2 +-
 src/video/dummy/SDL_nullframebuffer.c         |  2 +-
 .../emscripten/SDL_emscriptenframebuffer.c    |  2 +-
 src/video/emscripten/SDL_emscriptenmouse.c    |  2 +-
 src/video/n3ds/SDL_n3dsframebuffer.c          |  2 +-
 .../offscreen/SDL_offscreenframebuffer.c      |  2 +-
 src/video/windows/SDL_windowsmouse.c          |  2 +-
 test/testautomation_surface.c                 | 48 +++++++++----------
 test/testgles2_sdf.c                          |  2 +-
 test/testoffscreen.c                          |  2 +-
 test/testshader.c                             |  2 +-
 test/testyuv.c                                |  6 +--
 30 files changed, 95 insertions(+), 109 deletions(-)

diff --git a/WhatsNew.txt b/WhatsNew.txt
index 010524f3f03c..833e28bd4443 100644
--- a/WhatsNew.txt
+++ b/WhatsNew.txt
@@ -25,3 +25,7 @@ General:
 	* SDL_HINT_VIDEO_X11_XINERAMA
 	* SDL_HINT_VIDEO_X11_XVIDMODE
 * SDL_stdinc.h no longer includes stdio.h, stdlib.h, etc., it only provides the SDL C runtime functionality
+* Removed unused 'depth' parameter from SDL_CreateRGBSurfaceWithFormat and SDL_CreateRGBSurfaceWithFormatFrom
+* Removed unused 'flags' parameter from SDL_CreateRGBSurface and SDL_CreateRGBSurfaceWithFormat
+* Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat
+
diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c
index eb3bb4cdeec9..dbb86f392aff 100644
--- a/Xcode-iOS/Demos/src/fireworks.c
+++ b/Xcode-iOS/Demos/src/fireworks.c
@@ -343,7 +343,7 @@ initializeTexture()
                                &Bmask, &Amask);
     /* Create surface that will hold pixels passed into OpenGL */
     bmp_surface_rgba8888 =
-        SDL_CreateRGBSurface(0, bmp_surface->w, bmp_surface->h, bpp, Rmask,
+        SDL_CreateRGBSurface(bmp_surface->w, bmp_surface->h, bpp, Rmask,
                              Gmask, Bmask, Amask);
     /* Blit to this surface, effectively converting the format */
     SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba8888, NULL);
diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c
index 6ab1db213aa4..e9896977d9b5 100644
--- a/Xcode-iOS/Demos/src/keyboard.c
+++ b/Xcode-iOS/Demos/src/keyboard.c
@@ -178,7 +178,7 @@ loadFont(void)
         SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask,
                                    &Amask);
         SDL_Surface *converted =
-            SDL_CreateRGBSurface(0, surface->w, surface->h, bpp, Rmask, Gmask,
+            SDL_CreateRGBSurface(surface->w, surface->h, bpp, Rmask, Gmask,
                                  Bmask, Amask);
         SDL_BlitSurface(surface, NULL, converted, NULL);
         /* create our texture */
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 9346b3d47046..d7aeb5c085ca 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -160,6 +160,13 @@ The standard C headers like stdio.h and stdlib.h are no longer included, you sho
 M_PI is no longer defined in SDL_stdinc.h, you can use the new symbols SDL_PI_D (double) and SDL_PI_F (float) instead.
 
 
+## SDL_surface.h
+
+Removed unused 'depth' parameter from SDL_CreateRGBSurfaceWithFormat() and SDL_CreateRGBSurfaceWithFormatFrom()
+Removed unused 'flags' parameter from SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceWithFormat()
+Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat
+
+
 ## SDL_syswm.h
 
 This header no longer includes platform specific headers and type definitions, instead allowing you to include the ones appropriate for your use case. You should define one or more of the following to enable the relevant platform-specific support:
diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h
index 7b7e979d20c8..c2d832b49130 100644
--- a/include/SDL3/SDL_surface.h
+++ b/include/SDL3/SDL_surface.h
@@ -140,7 +140,6 @@ typedef enum
  * You can change this by calling SDL_SetSurfaceBlendMode() and selecting a
  * different `blendMode`.
  *
- * \param flags the flags are unused and should be set to 0
  * \param width the width of the surface
  * \param height the height of the surface
  * \param depth the depth of the surface in bits
@@ -158,12 +157,10 @@ typedef enum
  * \sa SDL_FreeSurface
  */
 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
-    (Uint32 flags, int width, int height, int depth,
+    (int width, int height, int depth,
      Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
 
 
-/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
-
 /**
  * Allocate a new RGB surface with a specific pixel format.
  *
@@ -171,10 +168,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
  * of providing pixel color masks, you provide it with a predefined format
  * from SDL_PixelFormatEnum.
  *
- * \param flags the flags are unused and should be set to 0
  * \param width the width of the surface
  * \param height the height of the surface
- * \param depth the depth of the surface in bits
  * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
  * \returns the new SDL_Surface structure that is created or NULL if it fails;
  *          call SDL_GetError() for more information.
@@ -186,7 +181,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
  * \sa SDL_FreeSurface
  */
 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
-    (Uint32 flags, int width, int height, int depth, Uint32 format);
+    (int width, int height, Uint32 format);
 
 /**
  * Allocate a new RGB surface with existing pixel data.
@@ -226,8 +221,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
                                                               Uint32 Bmask,
                                                               Uint32 Amask);
 
-/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
-
 /**
  * Allocate a new RGB surface with with a specific pixel format and existing
  * pixel data.
@@ -242,7 +235,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
  * \param pixels a pointer to existing pixel data
  * \param width the width of the surface
  * \param height the height of the surface
- * \param depth the depth of the surface in bits
  * \param pitch the pitch of the surface in bytes
  * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
  * \returns the new SDL_Surface structure that is created or NULL if it fails;
@@ -255,7 +247,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
  * \sa SDL_FreeSurface
  */
 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom
-    (void *pixels, int width, int height, int depth, int pitch, Uint32 format);
+    (void *pixels, int width, int height, int pitch, Uint32 format);
 
 /**
  * Free an RGB surface.
@@ -661,8 +653,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
  * \param src the existing SDL_Surface structure to convert
  * \param fmt the SDL_PixelFormat structure that the new surface is optimized
  *            for
- * \param flags the flags are unused and should be set to 0; this is a
- *              leftover from SDL 1.2's API
  * \returns the new SDL_Surface structure that is created or NULL if it fails;
  *          call SDL_GetError() for more information.
  *
@@ -673,7 +663,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
  * \sa SDL_CreateRGBSurface
  */
 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
-    (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
+    (SDL_Surface * src, const SDL_PixelFormat * fmt);
 
 /**
  * Copy an existing surface to a new surface of the specified format enum.
@@ -686,8 +676,6 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
  * \param src the existing SDL_Surface structure to convert
  * \param pixel_format the SDL_PixelFormatEnum that the new surface is
  *                     optimized for
- * \param flags the flags are unused and should be set to 0; this is a
- *              leftover from SDL 1.2's API
  * \returns the new SDL_Surface structure that is created or NULL if it fails;
  *          call SDL_GetError() for more information.
  *
@@ -698,7 +686,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
  * \sa SDL_CreateRGBSurface
  */
 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
-    (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
+    (SDL_Surface * src, Uint32 pixel_format);
 
 /**
  * Copy a block of pixels of one format to another format.
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index ec66a626c428..a18ad3c17b69 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -464,7 +464,7 @@ SDL_DYNAPI_PROC(SDL_iconv_t,SDL_iconv_open,(const char *a, const char *b),(a,b),
 SDL_DYNAPI_PROC(int,SDL_iconv_close,(SDL_iconv_t a),(a),return)
 SDL_DYNAPI_PROC(size_t,SDL_iconv,(SDL_iconv_t a, const char **b, size_t *c, char **d, size_t *e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(char*,SDL_iconv_string,(const char *a, const char *b, const char *c, size_t d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurface,(Uint32 a, int b, int c, int d, Uint32 e, Uint32 f, Uint32 g, Uint32 h),(a,b,c,d,e,f,g,h),return)
+SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurface,(int a, int b, int c, Uint32 d, Uint32 e, Uint32 f, Uint32 g),(a,b,c,d,e,f,g),return)
 SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceFrom,(void *a, int b, int c, int d, int e, Uint32 f, Uint32 g, Uint32 h, Uint32 i),(a,b,c,d,e,f,g,h,i),return)
 SDL_DYNAPI_PROC(void,SDL_FreeSurface,(SDL_Surface *a),(a),)
 SDL_DYNAPI_PROC(int,SDL_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return)
@@ -483,8 +483,8 @@ SDL_DYNAPI_PROC(int,SDL_SetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode b),(a
 SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_SetClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return)
 SDL_DYNAPI_PROC(void,SDL_GetClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),)
-SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b, Uint32 c),(a,b,c),return)
-SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b, Uint32 c),(a,b,c),return)
+SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b),(a,b),return)
 SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return)
 SDL_DYNAPI_PROC(int,SDL_FillRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return)
 SDL_DYNAPI_PROC(int,SDL_FillRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return)
@@ -625,8 +625,8 @@ SDL_DYNAPI_PROC(int,SDL_RenderSetIntegerScale,(SDL_Renderer *a, SDL_bool b),(a,b
 SDL_DYNAPI_PROC(SDL_bool,SDL_RenderGetIntegerScale,(SDL_Renderer *a),(a),return)
 SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c),(a,b,c),return)
 SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),)
-SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormatFrom,(void *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return)
+SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(int a, int b, Uint32 c),(a,b,c),return)
+SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormatFrom,(void *a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return)
 SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceVendor,(int a),(a),return)
 SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return)
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index bfb62e13b48c..1b93bd8e3ab2 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -1254,7 +1254,7 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
     w = ((w + 7) & ~7);
 
     /* Create the surface from a bitmap */
-    surface = SDL_CreateRGBSurface(0, w, h, 32,
+    surface = SDL_CreateRGBSurface(w, h, 32,
                                    0x00FF0000,
                                    0x0000FF00,
                                    0x000000FF,
@@ -1311,7 +1311,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
     }
 
     if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
-        temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
+        temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
         if (temp == NULL) {
             return NULL;
         }
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 61ed046d3d85..4c8264daeb7a 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1485,7 +1485,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
            SDL_DestroyTexture(texture);
            return NULL;
         }
-        temp = SDL_ConvertSurface(surface, dst_fmt, 0);
+        temp = SDL_ConvertSurface(surface, dst_fmt);
         SDL_FreeFormat(dst_fmt);
         if (temp) {
             SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
@@ -2131,7 +2131,7 @@ SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect,
         return ret;
     }
 
-    texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format);
+    texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, pitch, texture->format);
     if (texture->locked_surface == NULL) {
         SDL_UnlockTexture(texture);
         return -1;
diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c
index 2b92fe77cd65..b731d64f5272 100644
--- a/src/render/SDL_yuv_sw.c
+++ b/src/render/SDL_yuv_sw.c
@@ -413,7 +413,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
             SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
                                        &Bmask, &Amask);
             swdata->stretch =
-                SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask,
+                SDL_CreateRGBSurface(swdata->w, swdata->h, bpp, Rmask,
                                      Gmask, Bmask, Amask);
             if (!swdata->stretch) {
                 return -1;
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index 975447afc7aa..9830c85f0232 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -113,7 +113,7 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
     }
 
     texture->driverdata =
-        SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
+        SDL_CreateRGBSurface(texture->w, texture->h, bpp, Rmask, Gmask,
                              Bmask, Amask);
     SDL_SetSurfaceColorMod(texture->driverdata, texture->color.r, texture->color.g, texture->color.b);
     SDL_SetSurfaceAlphaMod(texture->driverdata, texture->color.a);
@@ -405,7 +405,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
      * to clear the pixels in the destination surface. The other steps are explained below.
      */
     if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
-        mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32,
+        mask = SDL_CreateRGBSurface(final_rect->w, final_rect->h, 32,
                                     0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
         if (mask == NULL) {
             retval = -1;
@@ -419,7 +419,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
      */
     if (!retval && (blitRequired || applyModulation)) {
         SDL_Rect scale_rect = tmp_rect;
-        src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32,
+        src_scaled = SDL_CreateRGBSurface(final_rect->w, final_rect->h, 32,
                                           0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
         if (src_scaled == NULL) {
             retval = -1;
@@ -831,7 +831,7 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
 
                     /* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
                     if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
-                        SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect->w, dstrect->h, 0, src->format->format);
+                        SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
                         /* Scale to an intermediate surface, then blit */
                         if (tmp) {
                             SDL_Rect r;
diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index 258e5dba5a5d..639d02ee71e9 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -500,7 +500,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
     rz_dst = NULL;
     if (is8bit) {
         /* Target surface is 8 bit */
-        rz_dst = SDL_CreateRGBSurfaceWithFormat(0, rect_dest->w, rect_dest->h + GUARD_ROWS, 8, src->format->format);
+        rz_dst = SDL_CreateRGBSurfaceWithFormat(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format);
         if (rz_dst != NULL) {
             if (src->format->palette) {
                 for (i = 0; i < src->format->palette->ncolors; i++) {
@@ -511,7 +511,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
         }
     } else {
         /* Target surface is 32 bit with source RGBA ordering */
-        rz_dst = SDL_CreateRGBSurface(0, rect_dest->w, rect_dest->h + GUARD_ROWS, 32,
+        rz_dst = SDL_CreateRGBSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, 32,
                                       src->format->Rmask, src->format->Gmask,
                                       src->format->Bmask, src->format->Amask);
     }
diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c
index b2bd163e151e..1dd7271724c6 100644
--- a/src/render/software/SDL_triangle.c
+++ b/src/render/software/SDL_triangle.c
@@ -274,7 +274,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
         }
 
         /* Use an intermediate surface */
-        tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect.w, dstrect.h, 0, format);
+        tmp = SDL_CreateRGBSurfaceWithFormat(dstrect.w, dstrect.h, format);
         if (tmp == NULL) {
             ret = -1;
             goto end;
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index c2ef00254a59..e7dc1e184a06 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1766,7 +1766,7 @@ SDLTest_ScreenShot(SDL_Renderer *renderer)
     }
 
     SDL_RenderGetViewport(renderer, &viewport);
-    surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24,
+    surface = SDL_CreateRGBSurface(viewport.w, viewport.h, 24,
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
                     0x00FF0000, 0x0000FF00, 0x000000FF,
 #else
diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c
index 6884f827c784..20ea43ecb824 100644
--- a/src/test/SDL_test_font.c
+++ b/src/test/SDL_test_font.c
@@ -3185,8 +3185,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c)
         /*
          * Redraw character into surface
          */
-        character = SDL_CreateRGBSurface(SDL_SWSURFACE,
-            charWidth, charHeight, 32,
+        character = SDL_CreateRGBSurface(charWidth, charHeight, 32,
             0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
         if (character == NULL) {
             return -1;
diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
index 9b8c123fcaf0..e7acf3b85f09 100644
--- a/src/video/SDL_bmp.c
+++ b/src/video/SDL_bmp.c
@@ -417,7 +417,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
 
     /* Create a compatible surface, note that the colors are RGB ordered */
     surface =
-        SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
+        SDL_CreateRGBSurface(biWidth, biHeight, biBitCount, Rmask, Gmask,
                              Bmask, Amask);
     if (surface == NULL) {
         was_error = SDL_TRUE;
@@ -689,7 +689,7 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst)
             } else {
                 SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
             }
-            surface = SDL_ConvertSurface(saveme, &format, 0);
+            surface = SDL_ConvertSurface(saveme, &format);
             if (surface == NULL) {
                 SDL_SetError("Couldn't convert image to %d bpp",
                              format.BitsPerPixel);
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index fc3a06697cd5..b13805a12d12 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -68,21 +68,16 @@ SDL_CalculatePitch(Uint32 format, size_t width, SDL_bool minimal)
     return pitch;
 }
 
-/* TODO: In SDL 3, drop the unused flags and depth parameters */
 /*
  * Create an empty RGB surface of the appropriate depth using the given
  * enum SDL_PIXELFORMAT_* format
  */
 SDL_Surface *
-SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
-                               Uint32 format)
+SDL_CreateRGBSurfaceWithFormat(int width, int height, Uint32 format)
 {
     size_t pitch;
     SDL_Surface *surface;
 
-    /* The flags are no longer used, make the compiler happy */
-    (void)flags;
-
     if (width < 0) {
         SDL_InvalidParamError("width");
         return NULL;
@@ -176,13 +171,11 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
     return surface;
 }
 
-/* TODO: In SDL 3, drop the unused flags parameter */
 /*
  * Create an empty RGB surface of the appropriate depth
  */
 SDL_Surface *
-SDL_CreateRGBSurface(Uint32 flags,
-                     int width, int height, int depth,
+SDL_CreateRGBSurface(int width, int height, int depth,
                      Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
 {
     Uint32 format;
@@ -194,7 +187,7 @@ SDL_CreateRGBSurface(Uint32 flags,
         return NULL;
     }
 
-    return SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format);
+    return SDL_CreateRGBSurfaceWithFormat(width, height, format);
 }
 
 /*
@@ -234,7 +227,7 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
         return NULL;
     }
 
-    surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
+    surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
     if (surface != NULL) {
         surface->flags |= SDL_PREALLOC;
         surface->pixels = pixels;
@@ -246,14 +239,13 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
     return surface;
 }
 
-/* TODO: In SDL 3, drop the unused depth parameter */
 /*
  * Create an RGB surface from an existing memory buffer using the given given
  * enum SDL_PIXELFORMAT_* format
  */
 SDL_Surface *
 SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
-                         int width, int height, int depth, int pitch,
+                         int width, int height, int pitch,
                          Uint32 format)
 {
     SDL_Surface *surface;
@@ -276,7 +268,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
         return NULL;
     }
 
-    surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
+    surface = SDL_CreateRGBSurfaceWithFormat(0, 0, format);
     if (surface != NULL) {
         surface->flags |= SDL_PREALLOC;
         surface->pixels = pixels;
@@ -1034,13 +1026,11 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
             SDL_Rect srcrect2;
             int is_complex_copy_flags = (src->map->info.flags & complex_copy_flags);
 
-            Uint32 flags;
             Uint8 r, g, b;
             Uint8 alpha;
             SDL_BlendMode blendMode;
 
             /* Save source infos */
-            flags = src->flags;
             SDL_GetSurfaceColorMod(src, &r, &g, &b);
             SDL_GetSurfaceAlphaMod(src, &alpha);
             SDL_GetSurfaceBlendMode(src, &blendMode);
@@ -1062,7 +1052,7 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
                 } else {
                     fmt = SDL_PIXELFORMAT_ARGB8888;
                 }
-                tmp1 = SDL_CreateRGBSurfaceWithFormat(flags, src->w, src->h, 0, fmt);
+                tmp1 = SDL_CreateRGBSurfaceWithFormat(src->w, src->h, fmt);
                 SDL_LowerBlit(src, srcrect, tmp1, &tmprect);
 
 
@@ -1078,7 +1068,7 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
             /* Intermediate scaling */
             if (is_complex_copy_flags || src->format->format != dst->format->format) {
                 SDL_Rect tmprect;
-                SDL_Surface *tmp2 = SDL_CreateRGBSurfaceWithFormat(flags, dstrect->w, dstrect->h, 0, src->format->format);
+                SDL_Surface *tmp2 = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
                 SDL_SoftStretchLinear(src, &srcrect2, tmp2, NULL);
 
                 SDL_SetSurfaceColorMod(tmp2, r, g, b);
@@ -1150,15 +1140,14 @@ SDL_UnlockSurface(SDL_Surface * surface)
 SDL_Surface *
 SDL_DuplicateSurface(SDL_Surface * surface)
 {
-    return SDL_ConvertSurface(surface, surface->format, surface->flags);
+    return SDL_ConvertSurface(surface, surface->format);
 }
 
 /*
  * Convert a surface into the specified pixel format.
  */
 SDL_Surface *
-SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
-                   Uint32 flags)
+SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format)
 {
     SDL_Surface *convert;
     Uint32 copy_flags;
@@ -1195,7 +1184,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
     }
 
     /* Create a new surface with the desired format */
-    convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
+    convert = SDL_CreateRGBSurface(surface->w, surface->h,
                                    format->BitsPerPixel, format->Rmask,
                                    format->Gmask, format->Bmask,
                                    format->Amask);
@@ -1340,7 +1329,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
             int converted_colorkey = 0;
 
             /* Create a dummy surface to get the colorkey converted */
-            tmp = SDL_CreateRGBSurface(0, 1, 1,
+            tmp = SDL_CreateRGBSurface(1, 1,
                                    surface->format->BitsPerPixel, surface->format->Rmask,
                                    surface->format->Gmask, surface->format->Bmask,
                                    surface->format->Amask);
@@ -1355,7 +1344,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
             tmp->map->info.flags &= ~SDL_COPY_COLORKEY;
 
             /* Convertion of the colorkey */
-            tmp2 = SDL_ConvertSurface(tmp, format, 0);
+            tmp2 = SDL_ConvertSurface(tmp, format);
 
             /* Get the converted colorkey */
             SDL_memcpy(&converted_colorkey, tmp2->pixels, tmp2->format->BytesPerPixel);
@@ -1381,7 +1370,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
         (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
         SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
     }
-    if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
+    if ((copy_flags & SDL_COPY_RLE_DESIRED)) {
         SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
     }
 
@@ -1390,15 +1379,14 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
 }
 
 SDL_Surface *
-SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format,
-                         Uint32 flags)
+SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format)
 {
     SDL_PixelFormat *fmt;
     SDL_Surface *convert = NULL;
 
     fmt = SDL_AllocFormat(pixel_format);
     if (fmt) {
-        convert = SDL_ConvertSurface(surface, fmt, flags);
+        convert = SDL_ConvertSurface(surface, fmt);
         SDL_FreeFormat(fmt);
     }
     return convert;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 9b9f508ed527..0aa44c2577d0 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2065,7 +2065,7 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon)
     SDL_FreeSurface(window->icon);
 
     /* Convert the icon into ARGB8888 */
-    window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0);
+    window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888);
     if (!window->icon) {
         return;
     }
diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c
index 386c777d4c16..5cd610d8bacf 100644
--- a/src/video/android/SDL_androidmouse.c
+++ b/src/video/android/SDL_androidmouse.c
@@ -90,7 +90,7 @@ Android_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
     int custom_cursor;
     SDL_Surface *converted;
 
-    converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
+    converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
     if (converted == NULL) {
         return NULL;
     }
@@ -124,7 +124,7 @@ static SDL_Cursor *
 Android_CreateEmptyCursor()
 {
     if (empty_cursor == NULL) {
-        SDL_Surface *empty

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