1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
From: Sam Lantinga <slouken@libsdl.org>
Date: Mon, 31 Mar 2025 18:49:58 -0700
Subject: Fixed texture colorspace when creating a texture from a surface
(cherry picked from commit 36fc1c2c9c280a47fc4412a90bb17488b20592d5)
Bug: https://github.com/libsdl-org/SDL/issues/12691
Origin: upstream, 3.2.12, commit:02036ee643e70442eccc2129eee9cdae001436fa
---
src/render/SDL_render.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 60024b8..7920a12 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1658,8 +1658,6 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
}
}
- surface_colorspace = SDL_GetSurfaceColorspace(surface);
-
// Try to have the best pixel format for the texture
// No alpha, but a colorkey => promote to alpha
if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) && SDL_SurfaceHasColorKey(surface)) {
@@ -1721,6 +1719,9 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
}
}
+ surface_colorspace = SDL_GetSurfaceColorspace(surface);
+ texture_colorspace = surface_colorspace;
+
if (surface_colorspace == SDL_COLORSPACE_SRGB_LINEAR ||
SDL_COLORSPACETRANSFER(surface_colorspace) == SDL_TRANSFER_CHARACTERISTICS_PQ) {
if (SDL_ISPIXELFORMAT_FLOAT(format)) {
|