From cd33baff7d285af26475777fab1f59537c517cb5 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 29 Jan 2024 14:27:07 +0100 Subject: [PATCH] cleanup: Prefer CoglColor.init_form_4f As we are slowly moving colors to be represented by a [0, 1] floats. The unsigned integer variant will likely be removed in the near future, so be ready for that already Part-of: --- src/st/st-private.c | 12 ++++++------ src/st/st-theme-node-drawing.c | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/st/st-private.c b/src/st/st-private.c index f7ea118a5..e310bdb70 100644 --- a/src/st/st-private.c +++ b/src/st/st-private.c @@ -558,7 +558,7 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec, return NULL; } - cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0); clutter_actor_get_position (actor, &x, &y); x *= resource_scale; y *= resource_scale; @@ -787,11 +787,11 @@ _st_paint_shadow_with_opacity (StShadow *shadow_spec, st_shadow_get_box (shadow_spec, box, &shadow_box); - cogl_color_init_from_4ub (&color, - shadow_spec->color.red * paint_opacity / 255, - shadow_spec->color.green * paint_opacity / 255, - shadow_spec->color.blue * paint_opacity / 255, - shadow_spec->color.alpha * paint_opacity / 255); + cogl_color_init_from_4f (&color, + shadow_spec->color.red / 255.0 * paint_opacity / 255.0, + shadow_spec->color.green / 255.0 * paint_opacity / 255.0, + shadow_spec->color.blue / 255.0 * paint_opacity / 255.0, + shadow_spec->color.alpha / 255.0 * paint_opacity / 255.0); cogl_color_premultiply (&color); cogl_pipeline_set_layer_combine_constant (shadow_pipeline, 0, &color); cogl_framebuffer_draw_rectangle (framebuffer, diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c index f60391945..081ccbef5 100644 --- a/src/st/st-theme-node-drawing.c +++ b/src/st/st-theme-node-drawing.c @@ -2120,11 +2120,11 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state, right += xoffset; /* Setup pipeline */ - cogl_color_init_from_4ub (&color, - box_shadow_spec->color.red * paint_opacity / 255, - box_shadow_spec->color.green * paint_opacity / 255, - box_shadow_spec->color.blue * paint_opacity / 255, - box_shadow_spec->color.alpha * paint_opacity / 255); + cogl_color_init_from_4f (&color, + box_shadow_spec->color.red / 255.0 * paint_opacity / 255.0, + box_shadow_spec->color.green / 255.0 * paint_opacity / 255.0, + box_shadow_spec->color.blue / 255.0 * paint_opacity / 255.0, + box_shadow_spec->color.alpha / 255.0 * paint_opacity / 255.0); cogl_color_premultiply (&color); cogl_pipeline_set_layer_combine_constant (state->box_shadow_pipeline, 0, &color);