1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Gabriele
cb5d8ac8a3 Merge branch 'gabrybarbe-fix-color-area-update' into 'master'
issue #14883: make color preview update immediate

Closes #14883

See merge request GNOME/gimp!2465
2025-10-05 00:38:42 +02:00
Gabriele Barbero
9d64379b1c libgimpcolor, libgimpwidgets: make color preview update immediate
Previously, the `gimp_color_area_set_color` function compared the new color
to the current one using perceptual similarity. This caused small or gradual
color changes to be missed, resulting in a "laggy" update of the color preview
in GimpColorSelection.

Now, the check is performed on the actual color difference, and the preview
is updated every time the color changes, even for minimal variations.
This ensures the color preview is always immediate.
2025-09-13 00:44:51 +02:00
5 changed files with 38 additions and 2 deletions

View File

@@ -150,6 +150,38 @@ gimp_color_is_perceptually_identical (GeglColor *color1,
return (gimp_color_get_CIE2000_distance (color1, color2) < 0.6);
}
/**
* gimp_color_is_identical:
* @color1: a [class@Gegl.Color]
* @color2: a [class@Gegl.Color]
*
* Determine whether @color1 and @color2 are exactly the same, by comparing
* their RGBA components. If the RGBA values are the same, then the colors are
* considered identical, otherwise not.
*
* Returns: whether the 2 colors are exactly the same.
*
* Since: 3.2
**/
gboolean
gimp_color_is_identical (GeglColor *color1,
GeglColor *color2)
{
gdouble r1, g1, b1, a1;
gdouble r2, g2, b2, a2;
g_return_val_if_fail (GEGL_IS_COLOR (color1), FALSE);
g_return_val_if_fail (GEGL_IS_COLOR (color2), FALSE);
gegl_color_get_rgba (color1, &r1, &g1, &b1, &a1);
gegl_color_get_rgba (color2, &r2, &g2, &b2, &a2);
return (r1 == r2 &&
g1 == g2 &&
b1 == b2 &&
a1 == a2);
}
/**
* gimp_color_is_out_of_self_gamut:
* @color: a [class@Gegl.Color]

View File

@@ -9,6 +9,7 @@ EXPORTS
gimp_cairo_checkerboard_create
gimp_cairo_surface_create_buffer
gimp_cairo_surface_get_format
gimp_color_is_identical
gimp_color_is_out_of_gamut
gimp_color_is_out_of_self_gamut
gimp_color_is_perceptually_identical

View File

@@ -50,6 +50,9 @@ void gimp_color_set_alpha (GeglColor *color,
gboolean gimp_color_is_perceptually_identical (GeglColor *color1,
GeglColor *color2);
gboolean gimp_color_is_identical (GeglColor *color1,
GeglColor *color2);
GeglColor * gimp_color_parse_css (const gchar *css);
GeglColor * gimp_color_parse_hex (const gchar *hex);
GeglColor * gimp_color_parse_name (const gchar *name);

View File

@@ -528,7 +528,7 @@ gimp_color_area_set_color (GimpColorArea *area,
g_return_if_fail (GIMP_IS_COLOR_AREA (area));
g_return_if_fail (GEGL_IS_COLOR (color));
if (! gimp_color_is_perceptually_identical (area->color, color))
if (! gimp_color_is_identical (area->color, color))
{
area->needs_render = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (area));

View File

@@ -683,7 +683,7 @@ gimp_color_selection_notebook_changed (GimpColorSelector *selector,
selection->color = gegl_color_duplicate (color);
update = UPDATE_SCALES | UPDATE_ENTRY;
if (! gimp_color_is_perceptually_identical (color, old_color))
if (! gimp_color_is_identical (color, old_color))
update |= UPDATE_COLOR;
gimp_color_selection_update (selection, update);