From 876f10795f01d195ca598a5bc9b1f9d4955a8469 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 11 Jun 2024 19:58:20 -0700 Subject: [PATCH] Don't set a YCbCr colorspace for an RGB texture Fixes https://github.com/libsdl-org/SDL/issues/10006 --- src/render/SDL_render.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 06dfc4142f..a830895d09 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1360,7 +1360,12 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert closest_format = renderer->texture_formats[0]; } - SDL_SetNumberProperty(native_props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, texture->colorspace); + default_colorspace = SDL_GetDefaultColorspaceForFormat(closest_format); + if (SDL_COLORSPACETYPE(texture->colorspace) == SDL_COLORSPACETYPE(default_colorspace)) { + SDL_SetNumberProperty(native_props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, texture->colorspace); + } else { + SDL_SetNumberProperty(native_props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, default_colorspace); + } SDL_SetNumberProperty(native_props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, closest_format); SDL_SetNumberProperty(native_props, SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER, texture->access); SDL_SetNumberProperty(native_props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, texture->w);