From d78ef58b4bc6eb9a28e91d48e151b682075c9481 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 16 Jul 2024 14:19:58 -0400 Subject: [PATCH] offscreen: Don't ever use this backend unless explicitly requested. Reference PR #10202. --- src/video/offscreen/SDL_offscreenvideo.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c index 9d2cec86fc..d9835ab4e8 100644 --- a/src/video/offscreen/SDL_offscreenvideo.c +++ b/src/video/offscreen/SDL_offscreenvideo.c @@ -51,14 +51,29 @@ static void OFFSCREEN_DeleteDevice(SDL_VideoDevice *device) SDL_free(device); } +static SDL_bool OFFSCREEN_Available(const char *enable_hint) +{ + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); + if (hint) { + if (SDL_strcmp(hint, enable_hint) == 0) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) { SDL_VideoDevice *device; + if (!OFFSCREEN_Available(OFFSCREENVID_DRIVER_NAME)) { + return NULL; + } + /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { - return 0; + return NULL; } /* General video */