app: mask colors are GeglColor.

This commit is contained in:
Jehan 2023-12-21 01:39:33 +09:00
parent 636a33aed2
commit f9c97aeb72
8 changed files with 54 additions and 35 deletions

View File

@ -523,7 +523,9 @@ gimp_display_shell_render (GimpDisplayShell *shell,
cairo_surface_mark_dirty (shell->mask_surface);
gimp_cairo_set_source_rgba (my_cr, &shell->mask_color);
gimp_cairo_set_source_color (my_cr, shell->mask_color,
GIMP_CORE_CONFIG (display_config)->color_management,
FALSE, GTK_WIDGET (shell));
cairo_mask_surface (my_cr, shell->mask_surface, x, y);
}

View File

@ -2177,12 +2177,12 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell,
GeglBuffer *mask,
gint offset_x,
gint offset_y,
const GimpRGB *color,
GeglColor *color,
gboolean inverted)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
g_return_if_fail (mask == NULL || color != NULL);
g_return_if_fail (mask == NULL || GEGL_IS_COLOR (color));
if (mask)
g_object_ref (mask);
@ -2195,8 +2195,9 @@ gimp_display_shell_set_mask (GimpDisplayShell *shell,
shell->mask_offset_x = offset_x;
shell->mask_offset_y = offset_y;
g_clear_object (&shell->mask_color);
if (mask)
shell->mask_color = *color;
shell->mask_color = gegl_color_duplicate (color);
shell->mask_inverted = inverted;

View File

@ -230,7 +230,7 @@ struct _GimpDisplayShell
GeglBuffer *mask;
gint mask_offset_x;
gint mask_offset_y;
GimpRGB mask_color;
GeglColor *mask_color;
gboolean mask_inverted;
GimpMotionBuffer *motion_buffer;
@ -356,7 +356,7 @@ void gimp_display_shell_set_mask (GimpDisplayShell *shell,
GeglBuffer *mask,
gint offset_x,
gint offset_y,
const GimpRGB *color,
GeglColor *color,
gboolean inverted);

View File

@ -57,6 +57,7 @@ enum
};
static void gimp_foreground_select_options_finalize (GObject *object);
static void gimp_foreground_select_options_set_property (GObject *object,
guint property_id,
const GValue *value,
@ -71,12 +72,15 @@ G_DEFINE_TYPE (GimpForegroundSelectOptions, gimp_foreground_select_options,
GIMP_TYPE_SELECTION_OPTIONS)
#define parent_class gimp_foreground_select_options_parent_class
static void
gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpRGB blue = {0.0, 0.0, 1.0, 0.5};
GeglColor *blue = gegl_color_new ("blue");
object_class->finalize = gimp_foreground_select_options_finalize;
object_class->set_property = gimp_foreground_select_options_set_property;
object_class->get_property = gimp_foreground_select_options_get_property;
@ -106,13 +110,14 @@ gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *kla
1, 6000, 10,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_RGB (object_class, PROP_MASK_COLOR,
"mask-color",
_("Preview color"),
_("Color of selection preview mask"),
GIMP_TYPE_RGB,
&blue,
GIMP_PARAM_STATIC_STRINGS);
gimp_color_set_alpha (blue, 0.5);
GIMP_CONFIG_PROP_COLOR (object_class, PROP_MASK_COLOR,
"mask-color",
_("Preview color"),
_("Color of selection preview mask"),
blue,
GIMP_PARAM_STATIC_STRINGS);
g_object_unref (blue);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_ENGINE,
"engine",
@ -147,6 +152,15 @@ gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *kla
static void
gimp_foreground_select_options_init (GimpForegroundSelectOptions *options)
{
options->mask_color = gegl_color_new ("blue");
}
static void
gimp_foreground_select_options_finalize (GObject *object)
{
g_clear_object (&(GIMP_FOREGROUND_SELECT_OPTIONS (object)->mask_color));
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@ -156,7 +170,6 @@ gimp_foreground_select_options_set_property (GObject *object,
GParamSpec *pspec)
{
GimpForegroundSelectOptions *options = GIMP_FOREGROUND_SELECT_OPTIONS (object);
GimpRGB *color;
switch (property_id)
{
@ -173,8 +186,8 @@ gimp_foreground_select_options_set_property (GObject *object,
break;
case PROP_MASK_COLOR:
color = g_value_get_boxed (value);
options->mask_color = *color;
g_clear_object (&options->mask_color);
options->mask_color = gegl_color_duplicate (g_value_get_object (value));
break;
case PROP_ENGINE:
@ -227,7 +240,7 @@ gimp_foreground_select_options_get_property (GObject *object,
break;
case PROP_MASK_COLOR:
g_value_set_boxed (value, &options->mask_color);
g_value_set_object (value, options->mask_color);
break;
case PROP_ENGINE:

View File

@ -36,16 +36,16 @@ typedef struct _GimpForegroundSelectOptionsClass GimpForegroundSelectOptionsClas
struct _GimpForegroundSelectOptions
{
GimpSelectionOptions parent_instance;
GimpSelectionOptions parent_instance;
GimpMattingDrawMode draw_mode;
GimpMattingPreviewMode preview_mode;
gint stroke_width;
GimpRGB mask_color;
GimpMattingEngine engine;
gint levels;
gint active_levels;
gint iterations;
GimpMattingDrawMode draw_mode;
GimpMattingPreviewMode preview_mode;
gint stroke_width;
GeglColor *mask_color;
GimpMattingEngine engine;
gint levels;
gint active_levels;
gint iterations;
};
struct _GimpForegroundSelectOptionsClass

View File

@ -1068,7 +1068,7 @@ gimp_foreground_select_tool_set_trimap (GimpForegroundSelectTool *fg_select)
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
fg_select->trimap, 0, 0,
&options->mask_color, TRUE);
options->mask_color, TRUE);
}
else
{
@ -1121,7 +1121,7 @@ gimp_foreground_select_tool_set_preview (GimpForegroundSelectTool *fg_select)
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
fg_select->mask, 0, 0,
&options->mask_color, TRUE);
options->mask_color, TRUE);
}
else
{

View File

@ -878,13 +878,15 @@ gimp_paint_select_tool_toggle_scribbles_visibility (GimpPaintSelectTool *ps_too
if (options->show_scribbles)
{
const GimpRGB black = {0.0, 0.0, 0.0, 1.0};
GeglColor *black = gegl_color_new ("black");
gimp_display_shell_set_mask (gimp_display_get_shell (tool->display),
ps_tool->trimap,
ps_tool->drawable_off_x,
ps_tool->drawable_off_y,
&black,
black,
TRUE);
g_object_unref (black);
}
else
{

View File

@ -367,9 +367,9 @@ gimp_region_select_tool_get_mask (GimpRegionSelectTool *region_sel,
{
if (region_sel->region_mask)
{
GimpRGB color = { 1.0, 0.0, 1.0, 1.0 };
gint off_x = 0;
gint off_y = 0;
GeglColor *color = gegl_color_new ("fuchsia");
gint off_x = 0;
gint off_y = 0;
if (! options->sample_merged)
{
@ -383,7 +383,8 @@ gimp_region_select_tool_get_mask (GimpRegionSelectTool *region_sel,
}
gimp_display_shell_set_mask (shell, region_sel->region_mask,
off_x, off_y, &color, FALSE);
off_x, off_y, color, FALSE);
g_object_unref (color);
}
else
{