From 070ddcd14b43f4a52bd67da1ad3356595b4e6d0b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 4 Aug 2024 07:11:03 -0400 Subject: [PATCH] Change box shadow op api Pass the ccs, opacity and GdkColor and let the op decide about color conversions. Update all callers. --- gsk/gpu/gskgpuboxshadowop.c | 14 +++++++++----- gsk/gpu/gskgpuboxshadowopprivate.h | 8 +++++--- gsk/gpu/gskgpunodeprocessor.c | 22 ++++++++++++++++------ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/gsk/gpu/gskgpuboxshadowop.c b/gsk/gpu/gskgpuboxshadowop.c index 3b4b87f48b..97e03071b9 100644 --- a/gsk/gpu/gskgpuboxshadowop.c +++ b/gsk/gpu/gskgpuboxshadowop.c @@ -76,24 +76,28 @@ static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = { void gsk_gpu_box_shadow_op (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, + GdkColorState *ccs, + float opacity, + const graphene_point_t *offset, gboolean inset, const graphene_rect_t *bounds, const GskRoundedRect *outline, const graphene_point_t *shadow_offset, float spread, float blur_radius, - const graphene_point_t *offset, - const float color[4]) + const GdkColor *color) { GskGpuBoxshadowInstance *instance; + GdkColorState *alt; /* Use border shader for no blurring */ g_return_if_fail (blur_radius > 0.0f); + alt = gsk_gpu_color_states_find (ccs, color); + gsk_gpu_shader_op_alloc (frame, &GSK_GPU_BOX_SHADOW_OP_CLASS, - color_states, + gsk_gpu_color_states_create (ccs, TRUE, alt, FALSE), inset ? VARIATION_INSET : 0, clip, NULL, @@ -102,7 +106,7 @@ gsk_gpu_box_shadow_op (GskGpuFrame *frame, gsk_gpu_rect_to_float (bounds, offset, instance->bounds); gsk_rounded_rect_to_float (outline, offset, instance->outline); - gsk_gpu_vec4_to_float (color, instance->color); + gsk_gpu_color_to_float (color, alt, opacity, instance->color); instance->shadow_offset[0] = shadow_offset->x; instance->shadow_offset[1] = shadow_offset->y; instance->shadow_spread = spread; diff --git a/gsk/gpu/gskgpuboxshadowopprivate.h b/gsk/gpu/gskgpuboxshadowopprivate.h index 1ee21d1232..4984124b06 100644 --- a/gsk/gpu/gskgpuboxshadowopprivate.h +++ b/gsk/gpu/gskgpuboxshadowopprivate.h @@ -2,6 +2,7 @@ #include "gskgputypesprivate.h" #include "gsktypes.h" +#include "gdkcolorprivate.h" #include @@ -9,15 +10,16 @@ G_BEGIN_DECLS void gsk_gpu_box_shadow_op (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, + GdkColorState *ccs, + float opacity, + const graphene_point_t *offset, gboolean inset, const graphene_rect_t *bounds, const GskRoundedRect *outline, const graphene_point_t *shadow_offset, float spread, float blur_radius, - const graphene_point_t *offset, - const float color[4]); + const GdkColor *color); G_END_DECLS diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index db3a8c0077..97af3d18c6 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -2303,9 +2303,14 @@ gsk_gpu_node_processor_add_inset_shadow_node (GskGpuNodeProcessor *self, } else { + GdkColor color; + + gdk_color_init_from_rgba (&color, rgba); gsk_gpu_box_shadow_op (self->frame, gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds), - gsk_gpu_node_processor_color_states_for_rgba (self), + self->ccs, + self->opacity, + &self->offset, TRUE, &node->bounds, gsk_inset_shadow_node_get_outline (node), @@ -2313,8 +2318,8 @@ gsk_gpu_node_processor_add_inset_shadow_node (GskGpuNodeProcessor *self, gsk_inset_shadow_node_get_dy (node)), spread, blur_radius, - &self->offset, - GSK_RGBA_TO_VEC4_ALPHA (rgba, self->opacity)); + &color); + gdk_color_finish (&color); } } @@ -2357,17 +2362,22 @@ gsk_gpu_node_processor_add_outset_shadow_node (GskGpuNodeProcessor *self, } else { + GdkColor color; + + gdk_color_init_from_rgba (&color, rgba); gsk_gpu_box_shadow_op (self->frame, gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds), - gsk_gpu_node_processor_color_states_for_rgba (self), + self->ccs, + self->opacity, + &self->offset, FALSE, &node->bounds, gsk_outset_shadow_node_get_outline (node), &GRAPHENE_POINT_INIT (dx, dy), spread, blur_radius, - &self->offset, - GSK_RGBA_TO_VEC4_ALPHA (rgba, self->opacity)); + &color); + gdk_color_finish (&color); } }