From 05af8c91c1dea69b9ef310a0011895546d84d319 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 19 Mar 2024 04:40:14 +0000 Subject: [PATCH] widgets: Minor GimpRGB to GeglColor ports Mainly fixing GimpRGB comments and parameters that are unused (or in unused functions). GimpCircle and GimpGradientChooser have color conversions ported to use GeglColor exclusively. --- app/tools/gimpoffsettool.c | 4 ++-- app/widgets/gimpcircle.c | 17 ++++++++--------- app/widgets/gimpcolormapselection.c | 4 ++-- app/widgets/gimppropwidgets.c | 2 +- libgimp/gimpgradientchooser.c | 11 ++++++----- libgimpwidgets/gimpcolorselect.c | 4 ++-- libgimpwidgets/gimpscrolledpreview.c | 5 +++-- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/app/tools/gimpoffsettool.c b/app/tools/gimpoffsettool.c index ce7f00309a..b270a1bf58 100644 --- a/app/tools/gimpoffsettool.c +++ b/app/tools/gimpoffsettool.c @@ -101,7 +101,7 @@ static void gimp_offset_tool_edge_behavior_toggled (GtkToggleButton GimpOffsetTool *offset_tool); static void gimp_offset_tool_background_changed (GimpContext *context, - const GimpRGB *color, + GeglColor *color, GimpOffsetTool *offset_tool); static gint gimp_offset_tool_get_width (GimpOffsetTool *offset_tool); @@ -636,7 +636,7 @@ gimp_offset_tool_edge_behavior_toggled (GtkToggleButton *toggle, static void gimp_offset_tool_background_changed (GimpContext *context, - const GimpRGB *color, + GeglColor *color, GimpOffsetTool *offset_tool) { GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (offset_tool); diff --git a/app/widgets/gimpcircle.c b/app/widgets/gimpcircle.c index e3b53bebce..b9cc815ba0 100644 --- a/app/widgets/gimpcircle.c +++ b/app/widgets/gimpcircle.c @@ -508,17 +508,16 @@ gimp_circle_background_hsv (gdouble angle, gdouble distance, guchar *rgb) { - GimpHSV hsv; - GimpRGB color; + gdouble hsv[3]; + GeglColor *color = gegl_color_new ("black"); - gimp_hsv_set (&hsv, - angle / (2.0 * G_PI), - distance, - 1 - sqrt (distance) / 4 /* it just looks nicer this way */); + hsv[0] = angle / (2.0 * G_PI); + hsv[1] = distance; + hsv[2] = 1 - sqrt (distance) / 4; - gimp_hsv_to_rgb (&hsv, &color); - - gimp_rgb_get_uchar (&color, rgb, rgb + 1, rgb + 2); + gegl_color_set_pixel (color, babl_format ("HSV double"), hsv); + gegl_color_get_pixel (color, babl_format ("R'G'B' u8"), rgb); + g_object_unref (color); } static void diff --git a/app/widgets/gimpcolormapselection.c b/app/widgets/gimpcolormapselection.c index 8094db9b39..b329810760 100644 --- a/app/widgets/gimpcolormapselection.c +++ b/app/widgets/gimpcolormapselection.c @@ -108,7 +108,7 @@ static void gimp_colormap_selection_entry_activated (GimpPaletteView *vi GimpColormapSelection *selection); static void gimp_colormap_selection_color_dropped (GimpPaletteView *view, GimpPaletteEntry *entry, - const GimpRGB *color, + GeglColor *color, GimpColormapSelection *selection); static void gimp_colormap_adjustment_changed (GtkAdjustment *adjustment, @@ -661,7 +661,7 @@ gimp_colormap_selection_entry_activated (GimpPaletteView *view, static void gimp_colormap_selection_color_dropped (GimpPaletteView *view, GimpPaletteEntry *entry, - const GimpRGB *color, + GeglColor *color, GimpColormapSelection *selection) { } diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c index 11763e01fa..d6acfbbb66 100644 --- a/app/widgets/gimppropwidgets.c +++ b/app/widgets/gimppropwidgets.c @@ -422,7 +422,7 @@ gimp_prop_color_button_new (GObject *config, * @height: Height of color button. * @type: How transparency is represented. * - * Creates a #GimpColorPanel to set and display the value of a #GimpRGB + * Creates a #GimpColorPanel to set and display the value of a #GeglColor * property. Pressing the button brings up a color selector dialog. * If @title is %NULL, the @property_name's nick will be used as label * of the returned widget. diff --git a/libgimp/gimpgradientchooser.c b/libgimp/gimpgradientchooser.c index 557536123b..06b45064db 100644 --- a/libgimp/gimpgradientchooser.c +++ b/libgimp/gimpgradientchooser.c @@ -278,13 +278,14 @@ gimp_gradient_select_preview_draw (cairo_t *cr, x < src_width; x++, src += 4, dest += 4) { - GimpRGB color; - guchar r, g, b, a; + GeglColor *color = gegl_color_new ("black"); + guchar rgba[4]; - gimp_rgba_set (&color, src[0], src[1], src[2], src[3]); - gimp_rgba_get_uchar (&color, &r, &g, &b, &a); + gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), src); + gegl_color_get_pixel (color, babl_format ("R'G'B'A u8"), rgba); - GIMP_CAIRO_ARGB32_SET_PIXEL (dest, r, g, b, a); + GIMP_CAIRO_ARGB32_SET_PIXEL (dest, rgba[0], rgba[1], rgba[2], rgba[3]); + g_object_unref (color); } cairo_surface_mark_dirty (surface); diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c index d10e3c5245..d207645edc 100644 --- a/libgimpwidgets/gimpcolorselect.c +++ b/libgimpwidgets/gimpcolorselect.c @@ -219,7 +219,7 @@ static void gimp_color_select_update_pos (GimpColorSelect static void gimp_color_select_drop_color (GtkWidget *widget, gint x, gint y, - const GimpRGB *color, + GeglColor *color, gpointer data); #endif @@ -1036,7 +1036,7 @@ static void gimp_color_select_drop_color (GtkWidget *widget, gint x, gint y, - const GimpRGB *color, + GeglColor *color, gpointer data) { GimpColorSelect *select = GIMP_COLOR_SELECT (data); diff --git a/libgimpwidgets/gimpscrolledpreview.c b/libgimpwidgets/gimpscrolledpreview.c index 1fdecf1a7a..4f9e3d8c7b 100644 --- a/libgimpwidgets/gimpscrolledpreview.c +++ b/libgimpwidgets/gimpscrolledpreview.c @@ -20,6 +20,7 @@ #include "config.h" +#include #include #include "libgimpmath/gimpmath.h" @@ -546,8 +547,8 @@ gimp_scrolled_preview_nav_button_press (GtkWidget *widget, GdkCursor *cursor; GtkBorder border; GimpCheckType check_type; - GimpRGB check_custom_color1; - GimpRGB check_custom_color2; + GeglColor *check_custom_color1; + GeglColor *check_custom_color2; gint area_width; gint area_height; gint x, y;