From 6c54d0a7e2439e2952d9570bd9a5dc3c040caee2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 6 Aug 2024 22:10:39 +0200 Subject: [PATCH] gpu: Consult target colorstate for depth When creating images for use with different colorstates, ensure that they have the depth of that colorstate. Otherwise we might lose accuracy due to quantization. Fixes mipmaps in rec2100 being rendered as RGBA8. --- gsk/gpu/gskgpunodeprocessor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 785da25db4..1f29b36d30 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -620,15 +620,18 @@ gsk_gpu_copy_image (GskGpuFrame *frame, GskGpuImage *copy; gsize width, height; GskGpuImageFlags flags; + GdkMemoryDepth depth; width = gsk_gpu_image_get_width (image); height = gsk_gpu_image_get_height (image); flags = gsk_gpu_image_get_flags (image); + depth = gdk_memory_format_get_depth (gsk_gpu_image_get_format (image), + flags & GSK_GPU_IMAGE_SRGB); + depth = gdk_memory_depth_merge (depth, gdk_color_state_get_depth (ccs)); copy = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame), prepare_mipmap, - gdk_memory_format_get_depth (gsk_gpu_image_get_format (image), - flags & GSK_GPU_IMAGE_SRGB), + depth, width, height); if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_BLIT) &&