File: Fixed-texture-colorspace-when-creating-a-texture-from-a-s.patch

package info (click to toggle)
libsdl3 3.2.10%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 42,240 kB
  • sloc: ansic: 389,254; objc: 12,241; xml: 9,084; cpp: 5,728; perl: 4,547; python: 3,370; sh: 947; makefile: 265; cs: 56
file content (35 lines) | stat: -rw-r--r-- 1,407 bytes parent folder | download
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)) {