1
0
Эх сурвалжийг харах

Added SDL_CreateSurfaceUninitialized()

Currently this is an internal API, but we can expose it in the future.
Sam Lantinga 16 цаг өмнө
parent
commit
fa2a726cc3

+ 2 - 2
src/camera/SDL_camera.c

@@ -1028,7 +1028,7 @@ bool SDL_PrepareCameraSurfaces(SDL_Camera *device)
         const bool downscaling_first = (device->needs_scaling < 0);
         const SDL_CameraSpec *s = downscaling_first ? appspec : devspec;
         const SDL_PixelFormat fmt = downscaling_first ? devspec->format : appspec->format;
-        device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
+        device->conversion_surface = SDL_CreateSurfaceUninitialized(s->width, s->height, fmt);
         if (!device->conversion_surface) {
             goto failed;
         }
@@ -1047,7 +1047,7 @@ bool SDL_PrepareCameraSurfaces(SDL_Camera *device)
     for (int i = 0; i < SDL_arraysize(device->output_surfaces); i++) {
         SDL_Surface *surf;
         if (device->needs_scaling || device->needs_conversion) {
-            surf = SDL_CreateSurface(appspec->width, appspec->height, appspec->format);
+            surf = SDL_CreateSurfaceUninitialized(appspec->width, appspec->height, appspec->format);
         } else {
             surf = SDL_CreateSurfaceFrom(appspec->width, appspec->height, appspec->format, NULL, 0);
         }

+ 2 - 3
src/events/SDL_mouse.c

@@ -299,9 +299,8 @@ void SDL_PostInitMouse(void)
      * so that mouse grab and focus functionality will work.
      */
     if (!mouse->def_cursor) {
-        SDL_Surface *surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888);
+        SDL_Surface *surface = SDL_CreateSurfaceZeroed(1, 1, SDL_PIXELFORMAT_ARGB8888);
         if (surface) {
-            SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
             SDL_SetDefaultCursor(SDL_CreateColorCursor(surface, 0, 0));
             SDL_DestroySurface(surface);
         }
@@ -1527,7 +1526,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h,
     w = ((w + 7) & ~7);
 
     // Create the surface from a bitmap
-    surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ARGB8888);
+    surface = SDL_CreateSurfaceUninitialized(w, h, SDL_PIXELFORMAT_ARGB8888);
     if (!surface) {
         return NULL;
     }

+ 2 - 2
src/render/SDL_render.c

@@ -1651,7 +1651,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
                 return NULL;
             }
         } else if (SDL_ISPIXELFORMAT_INDEXED(texture->format)) {
-            texture->palette_surface = SDL_CreateSurface(w, h, texture->format);
+            texture->palette_surface = SDL_CreateSurfaceZeroed(w, h, texture->format);
             if (!texture->palette_surface) {
                 SDL_DestroyTexture(texture);
                 return NULL;
@@ -5956,7 +5956,7 @@ static bool CreateDebugTextAtlas(SDL_Renderer *renderer)
 
     // actually make each glyph two pixels taller/wider, to prevent scaling artifacts.
     const int rows = (SDL_DEBUG_FONT_NUM_GLYPHS / SDL_DEBUG_FONT_GLYPHS_PER_ROW) + 1;
-    SDL_Surface *atlas = SDL_CreateSurface((charWidth + 2) * SDL_DEBUG_FONT_GLYPHS_PER_ROW, rows * (charHeight + 2), SDL_PIXELFORMAT_INDEX8);
+    SDL_Surface *atlas = SDL_CreateSurfaceZeroed((charWidth + 2) * SDL_DEBUG_FONT_GLYPHS_PER_ROW, rows * (charHeight + 2), SDL_PIXELFORMAT_INDEX8);
     if (!atlas) {
         return false;
     }

+ 1 - 1
src/render/SDL_yuv_sw.c

@@ -372,7 +372,7 @@ bool SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, SDL
             swdata->target_format = target_format;
         }
         if (!swdata->stretch) {
-            swdata->stretch = SDL_CreateSurface(swdata->w, swdata->h, target_format);
+            swdata->stretch = SDL_CreateSurfaceUninitialized(swdata->w, swdata->h, target_format);
             if (!swdata->stretch) {
                 return false;
             }

+ 1 - 1
src/render/gpu/SDL_render_gpu.c

@@ -1397,7 +1397,7 @@ static SDL_Surface *GPU_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
         return NULL;
     }
 
-    SDL_Surface *surface = SDL_CreateSurface(rect->w, rect->h, pixfmt);
+    SDL_Surface *surface = SDL_CreateSurfaceUninitialized(rect->w, rect->h, pixfmt);
 
     if (!surface) {
         return NULL;

+ 1 - 1
src/render/metal/SDL_render_metal.m

@@ -2063,7 +2063,7 @@ static SDL_Surface *METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
             SDL_SetError("Unknown framebuffer pixel format");
             return NULL;
         }
-        surface = SDL_CreateSurface(read_rect.w, read_rect.h, format);
+        surface = SDL_CreateSurfaceUninitialized(read_rect.w, read_rect.h, format);
         if (surface) {
             [mtltexture getBytes:surface->pixels bytesPerRow:surface->pitch fromRegion:mtlregion mipmapLevel:0];
             if (SDL_RenderingLinearSpace(renderer) &&

+ 1 - 1
src/render/opengl/SDL_render_gl.c

@@ -1630,7 +1630,7 @@ static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
         return NULL;
     }
 
-    surface = SDL_CreateSurface(rect->w, rect->h, format);
+    surface = SDL_CreateSurfaceUninitialized(rect->w, rect->h, format);
     if (!surface) {
         return NULL;
     }

+ 1 - 1
src/render/opengles/SDL_render_gles.c

@@ -958,7 +958,7 @@ static SDL_Surface *GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect
     SDL_PixelFormat format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32;
     SDL_Surface *surface;
 
-    surface = SDL_CreateSurface(rect->w, rect->h, format);
+    surface = SDL_CreateSurfaceUninitialized(rect->w, rect->h, format);
     if (!surface) {
         return NULL;
     }

+ 1 - 1
src/render/opengles2/SDL_render_gles2.c

@@ -2235,7 +2235,7 @@ static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rec
     SDL_PixelFormat format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32;
     SDL_Surface *surface;
 
-    surface = SDL_CreateSurface(rect->w, rect->h, format);
+    surface = SDL_CreateSurfaceUninitialized(rect->w, rect->h, format);
     if (!surface) {
         return NULL;
     }

+ 4 - 4
src/render/software/SDL_render_sw.c

@@ -135,7 +135,7 @@ static bool SW_ChangeTexturePalette(SDL_Renderer *renderer, SDL_Texture *texture
 
 static bool SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
 {
-    SDL_Surface *surface = SDL_CreateSurface(texture->w, texture->h, texture->format);
+    SDL_Surface *surface = SDL_CreateSurfaceUninitialized(texture->w, texture->h, texture->format);
     if (!surface) {
         return SDL_SetError("Can't create surface");
     }
@@ -438,7 +438,7 @@ static bool SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Te
      * to clear the pixels in the destination surface. The other steps are explained below.
      */
     if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
-        mask = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
+        mask = SDL_CreateSurfaceZeroed(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
         if (!mask) {
             result = false;
         } else {
@@ -451,7 +451,7 @@ static bool SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Te
      */
     if (result && (blitRequired || applyModulation)) {
         SDL_Rect scale_rect = tmp_rect;
-        src_scaled = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
+        src_scaled = SDL_CreateSurfaceUninitialized(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888);
         if (!src_scaled) {
             result = false;
         } else {
@@ -871,7 +871,7 @@ static bool SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
                 // 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_PixelFormat tmp_format = SDL_ISPIXELFORMAT_ALPHA(src->format) ? SDL_PIXELFORMAT_ARGB8888 : surface->format;
-                    SDL_Surface *tmp = SDL_CreateSurface(dstrect->w, dstrect->h, tmp_format);
+                    SDL_Surface *tmp = SDL_CreateSurfaceUninitialized(dstrect->w, dstrect->h, tmp_format);
                     // Scale to an intermediate surface, then blit
                     if (tmp) {
                         SDL_Rect r;

+ 1 - 1
src/render/software/SDL_triangle.c

@@ -299,7 +299,7 @@ bool SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poi
         }
 
         // Use an intermediate surface
-        tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format);
+        tmp = SDL_CreateSurfaceZeroed(dstrect.w, dstrect.h, format);
         if (!tmp) {
             result = false;
             goto end;

+ 1 - 1
src/render/vitagxm/SDL_render_vita_gxm.c

@@ -1172,7 +1172,7 @@ static SDL_Surface *VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_
         return NULL;
     }
 
-    surface = SDL_CreateSurface(rect->w, rect->h, format);
+    surface = SDL_CreateSurfaceUninitialized(rect->w, rect->h, format);
     if (!surface) {
         return NULL;
     }

+ 1 - 1
src/video/SDL_bmp.c

@@ -432,7 +432,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio)
 
         // Get the pixel format
         format = SDL_GetPixelFormatForMasks(biBitCount, Rmask, Gmask, Bmask, Amask);
-        surface = SDL_CreateSurface(biWidth, biHeight, format);
+        surface = SDL_CreateSurfaceUninitialized(biWidth, biHeight, format);
 
         if (!surface) {
             goto done;

+ 2 - 2
src/video/SDL_rotate.c

@@ -513,13 +513,13 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
     rz_dst = NULL;
     if (is8bit) {
         // Target surface is 8 bit
-        rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
+        rz_dst = SDL_CreateSurfaceZeroed(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
         if (rz_dst) {
             SDL_SetSurfacePalette(rz_dst, src->palette);
         }
     } else {
         // Target surface is 32 bit with source RGBA ordering
-        rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
+        rz_dst = SDL_CreateSurfaceZeroed(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
     }
 
     // Check target

+ 1 - 1
src/video/SDL_stb.c

@@ -330,7 +330,7 @@ static SDL_Surface *SDL_LoadSTB_IO(SDL_IOStream *src)
         }
 
     } else if (format == STBI_grey_alpha) {
-        surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_RGBA32);
+        surface = SDL_CreateSurfaceUninitialized(w, h, SDL_PIXELFORMAT_RGBA32);
         if (surface) {
             Uint8 *src_ptr = pixels;
             Uint8 *dst = (Uint8 *)surface->pixels;

+ 1 - 1
src/video/SDL_stretch.c

@@ -62,7 +62,7 @@ bool SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *
         }
 
         SDL_Surface *src_tmp = SDL_ConvertSurface(src, SDL_PIXELFORMAT_XRGB8888);
-        SDL_Surface *dst_tmp = SDL_CreateSurface(dstrect->w, dstrect->h, SDL_PIXELFORMAT_XRGB8888);
+        SDL_Surface *dst_tmp = SDL_CreateSurfaceUninitialized(dstrect->w, dstrect->h, SDL_PIXELFORMAT_XRGB8888);
         if (src_tmp && dst_tmp) {
             result = SDL_StretchSurface(src_tmp, srcrect, dst_tmp, NULL, scaleMode);
             if (result) {

+ 29 - 12
src/video/SDL_surface.c

@@ -192,7 +192,7 @@ static bool SDL_InitializeSurface(SDL_Surface *surface, int width, int height, S
 /*
  * Create an empty surface of the appropriate depth using the given format
  */
-SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
+static SDL_Surface *SDL_CreateSurfaceInternal(int width, int height, SDL_PixelFormat format, bool clear_surface)
 {
     size_t pitch, size;
     SDL_Surface *surface;
@@ -240,12 +240,29 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
             return NULL;
         }
 
-        // This is important for bitmaps
-        SDL_memset(surface->pixels, 0, size);
+        if (clear_surface) {
+            SDL_memset(surface->pixels, 0, size);
+        }
     }
     return surface;
 }
 
+SDL_Surface *SDL_CreateSurfaceZeroed(int width, int height, SDL_PixelFormat format)
+{
+    return SDL_CreateSurfaceInternal(width, height, format, true);
+}
+
+SDL_Surface *SDL_CreateSurfaceUninitialized(int width, int height, SDL_PixelFormat format)
+{
+    return SDL_CreateSurfaceInternal(width, height, format, false);
+}
+
+SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
+{
+    return SDL_CreateSurfaceZeroed(width, height, format);
+}
+
+
 /*
  * Create an RGB surface from an existing memory buffer using the given
  * enum SDL_PIXELFORMAT_* format
@@ -1336,7 +1353,7 @@ bool SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, S
             // Intermediate scaling
             if (is_complex_copy_flags || src->format != dst->format) {
                 SDL_Rect tmprect;
-                SDL_Surface *tmp2 = SDL_CreateSurface(dstrect->w, dstrect->h, src->format);
+                SDL_Surface *tmp2 = SDL_CreateSurfaceUninitialized(dstrect->w, dstrect->h, src->format);
                 SDL_StretchSurface(src, &srcrect2, tmp2, NULL, SDL_SCALEMODE_LINEAR);
 
                 SDL_SetSurfaceColorMod(tmp2, r, g, b);
@@ -1927,7 +1944,7 @@ static SDL_Surface *SDL_ConvertSurfaceRectAndColorspace(SDL_Surface *surface, co
 
     // Create a new surface with the desired format
     if (surface->pixels || SDL_MUSTLOCK(surface)) {
-        convert = SDL_CreateSurface(rect->w, rect->h, format);
+        convert = SDL_CreateSurfaceUninitialized(rect->w, rect->h, format);
     } else {
         convert = SDL_CreateSurfaceFrom(rect->w, rect->h, format, NULL, 0);
     }
@@ -2089,7 +2106,7 @@ static SDL_Surface *SDL_ConvertSurfaceRectAndColorspace(SDL_Surface *surface, co
             int converted_colorkey = 0;
 
             // Create a dummy surface to get the colorkey converted
-            tmp = SDL_CreateSurface(1, 1, surface->format);
+            tmp = SDL_CreateSurfaceUninitialized(1, 1, surface->format);
             if (!tmp) {
                 goto error;
             }
@@ -2265,7 +2282,7 @@ SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_S
 
     // Create a new surface with the desired size
     if (surface->pixels || SDL_MUSTLOCK(surface)) {
-        convert = SDL_CreateSurface(width, height, surface->format);
+        convert = SDL_CreateSurfaceUninitialized(width, height, surface->format);
     } else {
         convert = SDL_CreateSurfaceFrom(width, height, surface->format, NULL, 0);
     }
@@ -2342,7 +2359,7 @@ SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormat format,
 {
     SDL_Surface *surface;
     if (pixels) {
-        surface = SDL_CreateSurface(width, height, format);
+        surface = SDL_CreateSurfaceUninitialized(width, height, format);
     } else {
         surface = SDL_CreateSurfaceFrom(width, height, format, NULL, 0);
     }
@@ -2607,7 +2624,7 @@ static bool SDL_PremultiplyAlphaPixelsAndColorspace(int width, int height, SDL_P
     }
 
     if (src_format != format || src_colorspace != colorspace) {
-        convert = SDL_CreateSurface(width, height, format);
+        convert = SDL_CreateSurfaceUninitialized(width, height, format);
         if (!convert) {
             goto done;
         }
@@ -2621,7 +2638,7 @@ static bool SDL_PremultiplyAlphaPixelsAndColorspace(int width, int height, SDL_P
         dst_pitch = convert->pitch;
 
     } else if (dst_format != format || dst_colorspace != colorspace) {
-        convert = SDL_CreateSurface(width, height, format);
+        convert = SDL_CreateSurfaceUninitialized(width, height, format);
         if (!convert) {
             goto done;
         }
@@ -2708,7 +2725,7 @@ bool SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a)
         result = SDL_FillSurfaceRect(surface, NULL, color);
     } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) {
         // We can't directly set an RGB value on a YUV surface
-        SDL_Surface *tmp = SDL_CreateSurface(surface->w, surface->h, SDL_PIXELFORMAT_ARGB8888);
+        SDL_Surface *tmp = SDL_CreateSurfaceUninitialized(surface->w, surface->h, SDL_PIXELFORMAT_ARGB8888);
         if (!tmp) {
             goto done;
         }
@@ -2719,7 +2736,7 @@ bool SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a)
         SDL_DestroySurface(tmp);
     } else {
         // Take advantage of blit color conversion
-        SDL_Surface *tmp = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_RGBA128_FLOAT);
+        SDL_Surface *tmp = SDL_CreateSurfaceUninitialized(1, 1, SDL_PIXELFORMAT_RGBA128_FLOAT);
         if (!tmp) {
             goto done;
         }

+ 2 - 0
src/video/SDL_surface_c.h

@@ -91,6 +91,8 @@ extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace);
 extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace);
 extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace);
 extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace);
+extern SDL_Surface *SDL_CreateSurfaceZeroed(int width, int height, SDL_PixelFormat format);
+extern SDL_Surface *SDL_CreateSurfaceUninitialized(int width, int height, SDL_PixelFormat format);
 extern SDL_Surface *SDL_GetSurfaceImage(SDL_Surface *surface, float display_scale);
 extern SDL_Surface *SDL_ConvertSurfaceRect(SDL_Surface *surface, const SDL_Rect *rect, SDL_PixelFormat format);
 extern bool SDL_IsBMP(SDL_IOStream *src);

+ 1 - 2
src/video/android/SDL_androidmouse.c

@@ -115,9 +115,8 @@ static void Android_FreeCursor(SDL_Cursor *cursor)
 static SDL_Cursor *Android_CreateEmptyCursor(void)
 {
     if (!empty_cursor) {
-        SDL_Surface *empty_surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888);
+        SDL_Surface *empty_surface = SDL_CreateSurfaceZeroed(1, 1, SDL_PIXELFORMAT_ARGB8888);
         if (empty_surface) {
-            SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch);
             empty_cursor = Android_CreateCursor(empty_surface, 0, 0);
             SDL_DestroySurface(empty_surface);
         }

+ 3 - 3
src/video/dos/SDL_dosframebuffer.c

@@ -92,7 +92,7 @@ static SDL_Surface *GetConvertedCursorSurface(SDL_CursorData *curdata, SDL_Surfa
 
     int w = src->w;
     int h = src->h;
-    SDL_Surface *conv = SDL_CreateSurface(w, h, dst->format);
+    SDL_Surface *conv = SDL_CreateSurfaceUninitialized(w, h, dst->format);
     if (!conv) {
         return NULL;
     }
@@ -168,7 +168,7 @@ void DOSVESA_InvalidateCachedFramebuffer(void)
 // Create a system-RAM surface (with a blank palette if INDEX8 and update the VGA DAC).
 static SDL_Surface *CreateSystemSurface(SDL_VideoData *data, int w, int h, SDL_PixelFormat surface_format)
 {
-    SDL_Surface *surface = SDL_CreateSurface(w, h, surface_format);
+    SDL_Surface *surface = SDL_CreateSurfaceZeroed(w, h, surface_format);
     if (!surface) {
         return NULL;
     }
@@ -758,7 +758,7 @@ bool DOSVESA_UpdateWindowFramebuffer(SDL_VideoDevice *device, SDL_Window *window
                     have_cursor_rect = true;
 
                     // Save the pixels under the cursor so we can restore them after the copy.
-                    cursor_save = SDL_CreateSurface(cursor_clipped.w, cursor_clipped.h, src->format);
+                    cursor_save = SDL_CreateSurfaceUninitialized(cursor_clipped.w, cursor_clipped.h, src->format);
                     if (cursor_save) {
                         if (src->format == SDL_PIXELFORMAT_INDEX8) {
                             SDL_Palette *sp = SDL_GetSurfacePalette(src);

+ 1 - 1
src/video/dummy/SDL_nullframebuffer.c

@@ -37,7 +37,7 @@ bool SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo
 
     // Create a new framebuffer
     SDL_GetWindowSizeInPixels(window, &w, &h);
-    surface = SDL_CreateSurface(w, h, surface_format);
+    surface = SDL_CreateSurfaceZeroed(w, h, surface_format);
     if (!surface) {
         return false;
     }

+ 1 - 1
src/video/emscripten/SDL_emscriptenframebuffer.c

@@ -41,7 +41,7 @@ bool Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wind
     // Create a new one
     SDL_GetWindowSizeInPixels(window, &w, &h);
 
-    surface = SDL_CreateSurface(w, h, surface_format);
+    surface = SDL_CreateSurfaceZeroed(w, h, surface_format);
     if (!surface) {
         return false;
     }

+ 1 - 1
src/video/n3ds/SDL_n3dsframebuffer.c

@@ -52,7 +52,7 @@ bool SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window
 
     mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window));
     SDL_GetWindowSizeInPixels(window, &w, &h);
-    framebuffer = SDL_CreateSurface(w, h, mode->format);
+    framebuffer = SDL_CreateSurfaceZeroed(w, h, mode->format);
 
     if (!framebuffer) {
         return false;

+ 1 - 1
src/video/offscreen/SDL_offscreenframebuffer.c

@@ -37,7 +37,7 @@ bool SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *w
 
     // Create a new framebuffer
     SDL_GetWindowSizeInPixels(window, &w, &h);
-    surface = SDL_CreateSurface(w, h, surface_format);
+    surface = SDL_CreateSurfaceZeroed(w, h, surface_format);
     if (!surface) {
         return false;
     }

+ 1 - 1
src/video/windows/SDL_windowsmouse.c

@@ -470,7 +470,7 @@ static SDL_Cursor *WIN_CreateAnimatedCursor(SDL_CursorFrameInfo *frames, int fra
 static SDL_Cursor *WIN_CreateBlankCursor(void)
 {
     SDL_Cursor *cursor = NULL;
-    SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_ARGB8888);
+    SDL_Surface *surface = SDL_CreateSurfaceZeroed(32, 32, SDL_PIXELFORMAT_ARGB8888);
     if (surface) {
         cursor = WIN_CreateCursor(surface, 0, 0);
         SDL_DestroySurface(surface);

+ 1 - 1
src/video/windows/SDL_windowsshape.c

@@ -78,7 +78,7 @@ bool WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfa
         RECT rect;
 
         if (shape->w != window->w || shape->h != window->h) {
-            stretched = SDL_CreateSurface(window->w, window->h, SDL_PIXELFORMAT_ARGB32);
+            stretched = SDL_CreateSurfaceUninitialized(window->w, window->h, SDL_PIXELFORMAT_ARGB32);
             if (!stretched) {
                 return false;
             }

+ 1 - 1
src/video/x11/SDL_x11shape.c

@@ -67,7 +67,7 @@ bool X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surfa
         Pixmap pixmap;
 
         if (shape->w != window->w || shape->h != window->h) {
-            stretched = SDL_CreateSurface(window->w, window->h, SDL_PIXELFORMAT_ARGB32);
+            stretched = SDL_CreateSurfaceUninitialized(window->w, window->h, SDL_PIXELFORMAT_ARGB32);
             if (!stretched) {
                 return false;
             }