app/widgets: Remove GimpRGB from gimpwidgets-utils.c

The colors are assumed to be sRGB since they come from a
pre-defined array and are used for the item color tags in the
GUI. This replaces the call to gimp_rgb_composite () with the
direct implementation of the GIMP_RGB_COMPOSITE_NORMAL
code.
It also ensures that only one call is made to gegl_color_set_rgba (),
rather than two if the color is inherited.
This commit is contained in:
Alx Sa
2024-09-03 03:24:10 +00:00
parent fc7c3d0666
commit ece9929996

View File

@ -1123,25 +1123,25 @@ gimp_get_color_tag_color (GimpColorTag color_tag,
if (color_tag > GIMP_COLOR_TAG_NONE) if (color_tag > GIMP_COLOR_TAG_NONE)
{ {
gegl_color_set_rgba (color,
colors[color_tag].r / 255.0f,
colors[color_tag].g / 255.0f,
colors[color_tag].b / 255.0f,
1.0f);
if (inherited) if (inherited)
{ {
/* TODO: Replace once gimp_rgb_composite () is replaced with /* Composite color on top of white (20% opacity) */
* GeglColor composite function */ gdouble opacity = 0.2f;
GimpRGB temp_color; gdouble factor = 1.0f - opacity;
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), gegl_color_set_rgba (color,
&temp_color); (colors[color_tag].r / 255.0f) * factor + opacity,
gimp_rgb_set_alpha (&temp_color, 1.0f); (colors[color_tag].g / 255.0f) * factor + opacity,
gimp_rgb_composite (&temp_color, &(GimpRGB) {1.0, 1.0, 1.0, 0.2}, (colors[color_tag].b / 255.0f) * factor + opacity,
GIMP_RGB_COMPOSITE_NORMAL); 1.0f);
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), }
&temp_color); else
{
gegl_color_set_rgba (color,
colors[color_tag].r / 255.0f,
colors[color_tag].g / 255.0f,
colors[color_tag].b / 255.0f,
1.0f);
} }
return TRUE; return TRUE;