surface: Renamed hint to SDL_HINT_CREATE_SURFACE_ZEROED.

This commit is contained in:
Ryan C. Gordon 2026-06-04 22:46:46 -04:00
parent 2ac6dc9ce4
commit c20b3ba2c9
No known key found for this signature in database
GPG key ID: FA148B892AB48044
2 changed files with 8 additions and 8 deletions

View file

@ -703,10 +703,10 @@ extern "C" {
#define SDL_HINT_CPU_FEATURE_MASK "SDL_CPU_FEATURE_MASK" #define SDL_HINT_CPU_FEATURE_MASK "SDL_CPU_FEATURE_MASK"
/** /**
* A variable that decides whether SDL_CreateSurface() clears pixels. * A variable that decides whether SDL_CreateSurface() zeroes pixels.
* *
* By default, SDL_CreateSurface() will clear the newly-created surface by * By default, SDL_CreateSurface() will clear the newly-created surface by
* setting all bytes of its `pixels` buffer to zero; for many formats this * setting all bytes in its `pixels` buffer to zero; for many formats this
* clears the surface black, as a reasonable default. * clears the surface black, as a reasonable default.
* *
* However, clearing the surface is wasted effort if the app plans to * However, clearing the surface is wasted effort if the app plans to
@ -723,7 +723,7 @@ extern "C" {
* *
* \since This hint is available since SDL 3.6.0. * \since This hint is available since SDL 3.6.0.
*/ */
#define SDL_HINT_CREATE_SURFACE_CLEAR "SDL_CREATE_SURFACE_CLEAR" #define SDL_HINT_CREATE_SURFACE_ZEROED "SDL_CREATE_SURFACE_ZEROED"
/** /**
* A variable controlling whether DirectInput should be used for controllers. * A variable controlling whether DirectInput should be used for controllers.

View file

@ -46,12 +46,12 @@ static char SDL_surface_magic;
// Some hint callbacks. // Some hint callbacks.
static SDL_InitState create_surface_hints_init; static SDL_InitState create_surface_hints_init;
static bool create_surface_clear_hint = true; // tracks SDL_HINT_CREATE_SURFACE_CLEAR state. static bool create_surface_zeroed_hint = true; // tracks SDL_HINT_CREATE_SURFACE_ZEROED state.
static bool create_surface_malloc_hint = false; // tracks "SDL_SURFACE_MALLOC" state. static bool create_surface_malloc_hint = false; // tracks "SDL_SURFACE_MALLOC" state.
static void SDLCALL SDL_SurfaceClearHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue) static void SDLCALL SDL_SurfaceClearHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue)
{ {
create_surface_clear_hint = SDL_GetStringBoolean(newValue, true); create_surface_zeroed_hint = SDL_GetStringBoolean(newValue, true);
} }
static void SDLCALL SDL_SurfaceMallocHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue) static void SDLCALL SDL_SurfaceMallocHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue)
@ -64,7 +64,7 @@ static void SDLCALL SDL_SurfaceMallocHintWatcher(void *userdata, const char *nam
void SDL_QuitSurfaceHints(void) void SDL_QuitSurfaceHints(void)
{ {
if (SDL_ShouldQuit(&create_surface_hints_init)) { if (SDL_ShouldQuit(&create_surface_hints_init)) {
SDL_RemoveHintCallback(SDL_HINT_CREATE_SURFACE_CLEAR, SDL_SurfaceClearHintWatcher, NULL); SDL_RemoveHintCallback(SDL_HINT_CREATE_SURFACE_ZEROED, SDL_SurfaceClearHintWatcher, NULL);
SDL_RemoveHintCallback("SDL_SURFACE_MALLOC", SDL_SurfaceMallocHintWatcher, NULL); SDL_RemoveHintCallback("SDL_SURFACE_MALLOC", SDL_SurfaceMallocHintWatcher, NULL);
SDL_SetInitialized(&create_surface_hints_init, false); SDL_SetInitialized(&create_surface_hints_init, false);
} }
@ -256,12 +256,12 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
if (surface->w && surface->h && format != SDL_PIXELFORMAT_MJPG) { if (surface->w && surface->h && format != SDL_PIXELFORMAT_MJPG) {
if (SDL_ShouldInit(&create_surface_hints_init)) { if (SDL_ShouldInit(&create_surface_hints_init)) {
SDL_AddHintCallback(SDL_HINT_CREATE_SURFACE_CLEAR, SDL_SurfaceClearHintWatcher, NULL); SDL_AddHintCallback(SDL_HINT_CREATE_SURFACE_ZEROED, SDL_SurfaceClearHintWatcher, NULL);
SDL_AddHintCallback("SDL_SURFACE_MALLOC", SDL_SurfaceMallocHintWatcher, NULL); SDL_AddHintCallback("SDL_SURFACE_MALLOC", SDL_SurfaceMallocHintWatcher, NULL);
SDL_SetInitialized(&create_surface_hints_init, true); SDL_SetInitialized(&create_surface_hints_init, true);
} }
bool must_clear = create_surface_clear_hint; // SDL_HINT_CREATE_SURFACE_CLEAR, tracked by callback. bool must_clear = create_surface_zeroed_hint; // SDL_HINT_CREATE_SURFACE_ZEROED, tracked by callback.
surface->flags &= ~SDL_SURFACE_PREALLOCATED; surface->flags &= ~SDL_SURFACE_PREALLOCATED;
if (create_surface_malloc_hint) { // "SDL_SURFACE_MALLOC" hint, tracked by callback. if (create_surface_malloc_hint) { // "SDL_SURFACE_MALLOC" hint, tracked by callback.
if (must_clear) { if (must_clear) {