From 44fe51247c643e2aef28a0f5f1ac2f581498ac74 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 5 Aug 2024 12:21:15 -0400 Subject: [PATCH] gsk: Change the blur op api Pass the ccs, opacity and GdkColor to the op to let it make decisions about color conversion. Update the callers. --- gsk/gpu/gskgpublurop.c | 38 +++++++++++++++++++++++------------ gsk/gpu/gskgpubluropprivate.h | 8 +++++--- gsk/gpu/gskgpunodeprocessor.c | 18 +++++++++++------ 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/gsk/gpu/gskgpublurop.c b/gsk/gpu/gskgpublurop.c index 76d897f014..86bafae4df 100644 --- a/gsk/gpu/gskgpublurop.c +++ b/gsk/gpu/gskgpublurop.c @@ -56,18 +56,22 @@ static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = { static void gsk_gpu_blur_op_full (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, - guint32 variation, + GdkColorState *ccs, + float opacity, const graphene_point_t *offset, + guint32 variation, const GskGpuShaderImage *image, const graphene_vec2_t *blur_direction, - float blur_color[4]) + const GdkColor *blur_color) { GskGpuBlurInstance *instance; + GdkColorState *alt; + + alt = gsk_gpu_color_states_find (ccs, blur_color); gsk_gpu_shader_op_alloc (frame, &GSK_GPU_BLUR_OP_CLASS, - color_states, + gsk_gpu_color_states_create (ccs, TRUE, alt, variation & VARIATION_COLORIZE ? FALSE : TRUE), variation, clip, (GskGpuImage *[1]) { image->image }, @@ -77,41 +81,49 @@ gsk_gpu_blur_op_full (GskGpuFrame *frame, gsk_gpu_rect_to_float (image->coverage, offset, instance->rect); gsk_gpu_rect_to_float (image->bounds, offset, instance->tex_rect); graphene_vec2_to_float (blur_direction, instance->blur_direction); - gsk_gpu_vec4_to_float (blur_color, instance->blur_color); + gsk_gpu_color_to_float (blur_color, alt, opacity, instance->blur_color); } void gsk_gpu_blur_op (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, + GdkColorState *ccs, + float opacity, const graphene_point_t *offset, const GskGpuShaderImage *image, const graphene_vec2_t *blur_direction) { + GdkColor blur_color; + + gdk_color_init (&blur_color, ccs, (float[]) { 1, 1, 1, 1 }); gsk_gpu_blur_op_full (frame, clip, - color_states, - 0, + ccs, + opacity, offset, + 0, image, blur_direction, - (float[4]) { 1, 1, 1, 1 }); + &blur_color); + gdk_color_finish (&blur_color); } void gsk_gpu_blur_shadow_op (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, + GdkColorState *ccs, + float opacity, const graphene_point_t *offset, const GskGpuShaderImage *image, const graphene_vec2_t *blur_direction, - float shadow_color[4]) + const GdkColor *shadow_color) { gsk_gpu_blur_op_full (frame, clip, - color_states, - VARIATION_COLORIZE, + ccs, + opacity, offset, + VARIATION_COLORIZE, image, blur_direction, shadow_color); diff --git a/gsk/gpu/gskgpubluropprivate.h b/gsk/gpu/gskgpubluropprivate.h index 7cec908151..c32642e659 100644 --- a/gsk/gpu/gskgpubluropprivate.h +++ b/gsk/gpu/gskgpubluropprivate.h @@ -8,18 +8,20 @@ G_BEGIN_DECLS void gsk_gpu_blur_op (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, + GdkColorState *ccs, + float opacity, const graphene_point_t *offset, const GskGpuShaderImage *image, const graphene_vec2_t *blur_direction); void gsk_gpu_blur_shadow_op (GskGpuFrame *frame, GskGpuShaderClip clip, - GskGpuColorStates color_states, + GdkColorState *ccs, + float opacity, const graphene_point_t *offset, const GskGpuShaderImage *image, const graphene_vec2_t *blur_direction, - float shadow_color[4]); + const GdkColor *shadow_color); G_END_DECLS diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 8e6df32f14..1f42bafebc 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -833,7 +833,7 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self, const graphene_rect_t *rect, const graphene_point_t *shadow_offset, float blur_radius, - const GdkRGBA *shadow_color, + const GdkColor *shadow_color, GskGpuImage *source_image, GdkMemoryDepth source_depth, const graphene_rect_t *source_rect) @@ -869,7 +869,8 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self, graphene_vec2_init (&direction, blur_radius, 0.0f); gsk_gpu_blur_op (other.frame, gsk_gpu_clip_get_shader_clip (&other.clip, &other.offset, &intermediate_rect), - gsk_gpu_node_processor_color_states_self (&other), + other.ccs, + 1, &other.offset, &(GskGpuShaderImage) { source_image, @@ -888,7 +889,8 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self, { gsk_gpu_blur_shadow_op (self->frame, gsk_gpu_clip_get_shader_clip (&self->clip, &real_offset, rect), - gsk_gpu_node_processor_color_states_for_rgba (self), + self->ccs, + 1, &real_offset, &(GskGpuShaderImage) { intermediate, @@ -897,13 +899,14 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self, &intermediate_rect, }, &direction, - GSK_RGBA_TO_VEC4 (shadow_color)); + shadow_color); } else { gsk_gpu_blur_op (self->frame, gsk_gpu_clip_get_shader_clip (&self->clip, &real_offset, rect), - gsk_gpu_node_processor_color_states_self (self), + self->ccs, + 1, &real_offset, &(GskGpuShaderImage) { intermediate, @@ -2662,16 +2665,19 @@ gsk_gpu_node_processor_add_shadow_node (GskGpuNodeProcessor *self, { graphene_rect_t bounds; float clip_radius = gsk_cairo_blur_compute_pixels (0.5 * shadow->radius); + GdkColor color; graphene_rect_inset_r (&child->bounds, - clip_radius, - clip_radius, &bounds); + gdk_color_init_from_rgba (&color, &shadow->color); gsk_gpu_node_processor_blur_op (self, &bounds, &GRAPHENE_POINT_INIT (shadow->dx, shadow->dy), shadow->radius, - &shadow->color, + &color, image, gdk_memory_format_get_depth (gsk_gpu_image_get_format (image), gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_SRGB), &tex_rect); + gdk_color_finish (&color); } }