Validate the output colorspace before setting up a renderer

This commit is contained in:
Sam Lantinga
2025-11-10 16:30:17 -08:00
parent 6baaa0fe87
commit dde7fa3b17
3 changed files with 31 additions and 25 deletions

View File

@@ -1161,6 +1161,12 @@ bool SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, S
return SDL_SetError("Unsupported surface format");
}
SDL_SetupRendererColorspace(renderer, create_props);
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
return SDL_SetError("Unsupported output colorspace");
}
renderer->software = true;
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
@@ -1202,12 +1208,6 @@ bool SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, S
SW_SelectBestFormats(renderer, surface->format);
SDL_SetupRendererColorspace(renderer, create_props);
if (renderer->output_colorspace != SDL_COLORSPACE_SRGB) {
return SDL_SetError("Unsupported output colorspace");
}
return true;
}