From 9a9c053d040c705624ee00ce6db0b775caa50e61 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 8 Jun 2024 09:01:46 -0400 Subject: [PATCH] gpu: Take color state into account for glyph lookup Add a 'linear' bit to the glyph cache key, so we can get have separate cached images for the two cases. Note that the image tagging with color state is ignored here - we simply copy the glyph image out of the atlas as-is, and rely on the cache to give use the right color state. --- gsk/gpu/gskgpudevice.c | 1 + gsk/gpu/gskgpudeviceprivate.h | 3 ++- gsk/gpu/gskgpunodeprocessor.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gsk/gpu/gskgpudevice.c b/gsk/gpu/gskgpudevice.c index 3a42bf23e9..115cba0bcf 100644 --- a/gsk/gpu/gskgpudevice.c +++ b/gsk/gpu/gskgpudevice.c @@ -982,6 +982,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self, gsk_gpu_upload_glyph_op (frame, cache->image, + (flags & GSK_GPU_GLYPH_LINEAR) != 0, scaled_font, glyph, &(cairo_rectangle_int_t) { diff --git a/gsk/gpu/gskgpudeviceprivate.h b/gsk/gpu/gskgpudeviceprivate.h index d4b3cee78f..ad4598eafd 100644 --- a/gsk/gpu/gskgpudeviceprivate.h +++ b/gsk/gpu/gskgpudeviceprivate.h @@ -93,7 +93,8 @@ typedef enum GSK_GPU_GLYPH_X_OFFSET_3 = 0x3, GSK_GPU_GLYPH_Y_OFFSET_1 = 0x4, GSK_GPU_GLYPH_Y_OFFSET_2 = 0x8, - GSK_GPU_GLYPH_Y_OFFSET_3 = 0xC + GSK_GPU_GLYPH_Y_OFFSET_3 = 0xC, + GSK_GPU_GLYPH_LINEAR = 0x10, } GskGpuGlyphLookupFlags; GskGpuImage * gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self, diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 2622394a77..338dcd55f8 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -3108,6 +3108,9 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self, glyph_origin.x *= inv_align_scale_x; glyph_origin.y *= inv_align_scale_y; + if (self->color_state == gdk_color_state_get_srgb_linear ()) + flags |= GSK_GPU_GLYPH_LINEAR; + image = gsk_gpu_device_lookup_glyph_image (device, self->frame, font,