Commit 46f74d9f authored by Michael Natterer's avatar Michael Natterer 😴

app: return GeglBuffer from gimp_image_contiguous_region_foo()

now all intermediate masks should be in "Y float" and avoid all
conversions.
parent ddc4a057
......@@ -498,7 +498,7 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
gdouble feather_radius_y)
{
GimpItem *item;
GimpChannel *add_on;
GeglBuffer *add_on;
gint add_on_x = 0;
gint add_on_y = 0;
......@@ -520,7 +520,7 @@ gimp_channel_select_fuzzy (GimpChannel *channel,
if (! sample_merged)
gimp_item_get_offset (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
gimp_channel_select_channel (channel, C_("undo-type", "Fuzzy Select"),
gimp_channel_select_buffer (channel, C_("undo-type", "Fuzzy Select"),
add_on, add_on_x, add_on_y,
op,
feather,
......@@ -544,7 +544,7 @@ gimp_channel_select_by_color (GimpChannel *channel,
gdouble feather_radius_y)
{
GimpItem *item;
GimpChannel *add_on;
GeglBuffer *add_on;
gint add_on_x = 0;
gint add_on_y = 0;
......@@ -567,7 +567,7 @@ gimp_channel_select_by_color (GimpChannel *channel,
if (! sample_merged)
gimp_item_get_offset (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
gimp_channel_select_channel (channel, C_("undo-type", "Select by Color"),
gimp_channel_select_buffer (channel, C_("undo-type", "Select by Color"),
add_on, add_on_x, add_on_y,
op,
feather,
......
......@@ -28,10 +28,11 @@
#include "core-types.h"
#include "gegl/gimp-gegl-apply-operation.h"
#include "gegl/gimp-gegl-mask.h"
#include "gegl/gimp-gegl-mask-combine.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
#include "gimpchannel.h"
#include "gimpchannel-combine.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
......@@ -136,7 +137,6 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
GimpPattern *pattern)
{
GimpImage *image;
GimpChannel *mask;
GeglBuffer *buffer;
GeglBuffer *mask_buffer;
gint x1, y1, x2, y2;
......@@ -164,7 +164,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
* contiguous region. If there is a selection, calculate the
* intersection of this region with the existing selection.
*/
mask = gimp_image_contiguous_region_by_seed (image, drawable,
mask_buffer = gimp_image_contiguous_region_by_seed (image, drawable,
sample_merged,
TRUE,
threshold,
......@@ -175,20 +175,22 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
if (selection)
{
GimpDrawable *sel;
gint off_x = 0;
gint off_y = 0;
if (! sample_merged)
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
gimp_channel_combine_mask (mask, gimp_image_get_mask (image),
sel = GIMP_DRAWABLE (gimp_image_get_mask (image));
gimp_gegl_mask_combine_buffer (mask_buffer,
gimp_drawable_get_buffer (sel),
GIMP_CHANNEL_OP_INTERSECT,
-off_x, -off_y);
}
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
gimp_channel_bounds (mask, &x1, &y1, &x2, &y2);
gimp_gegl_mask_bounds (mask_buffer, &x1, &y1, &x2, &y2);
/* make sure we handle the mask correctly if it was sample-merged */
if (sample_merged)
......@@ -249,7 +251,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable *drawable,
-mask_offset_x,
-mask_offset_y,
1.0);
g_object_unref (mask);
g_object_unref (mask_buffer);
/* Apply it to the image */
gimp_drawable_apply_buffer (drawable, buffer,
......
......@@ -30,7 +30,7 @@
#include "gegl/gimp-babl.h"
#include "gimpchannel.h"
#include "gimpdrawable.h"
#include "gimpimage.h"
#include "gimpimage-contiguous-region.h"
#include "gimppickable.h"
......@@ -81,7 +81,7 @@ static void find_contiguous_region_helper (GeglBuffer *src_buffer,
/* public functions */
GimpChannel *
GeglBuffer *
gimp_image_contiguous_region_by_seed (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
......@@ -94,7 +94,6 @@ gimp_image_contiguous_region_by_seed (GimpImage *image,
{
GimpPickable *pickable;
GeglBuffer *src_buffer;
GimpChannel *mask;
GeglBuffer *mask_buffer;
const Babl *format;
gint n_components;
......@@ -138,28 +137,16 @@ gimp_image_contiguous_region_by_seed (GimpImage *image,
mask_buffer = gegl_buffer_new (gegl_buffer_get_extent (src_buffer),
babl_format ("Y float"));
gegl_buffer_clear (mask_buffer, NULL);
find_contiguous_region_helper (src_buffer, mask_buffer,
format, n_components, has_alpha,
select_transparent, select_criterion,
antialias, threshold,
x, y, start_col);
/* wrap mask_buffer in a drawable and return it */
mask = gimp_channel_new_mask (image,
gegl_buffer_get_width (mask_buffer),
gegl_buffer_get_height (mask_buffer));
gegl_buffer_copy (mask_buffer, NULL,
gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)), NULL);
g_object_unref (mask_buffer);
return mask;
return mask_buffer;
}
GimpChannel *
GeglBuffer *
gimp_image_contiguous_region_by_color (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
......@@ -177,7 +164,6 @@ gimp_image_contiguous_region_by_color (GimpImage *image,
*/
GeglBufferIterator *iter;
GimpPickable *pickable;
GimpChannel *mask;
GeglBuffer *src_buffer;
GeglBuffer *mask_buffer;
const Babl *format;
......@@ -218,11 +204,8 @@ gimp_image_contiguous_region_by_color (GimpImage *image,
select_transparent = FALSE;
}
mask = gimp_channel_new_mask (image,
gegl_buffer_get_width (src_buffer),
gegl_buffer_get_height (src_buffer));
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
mask_buffer = gegl_buffer_new (gegl_buffer_get_extent (src_buffer),
babl_format ("Y float"));
iter = gegl_buffer_iterator_new (src_buffer,
NULL, 0, format,
......@@ -253,7 +236,7 @@ gimp_image_contiguous_region_by_color (GimpImage *image,
}
}
return mask;
return mask_buffer;
}
......
......@@ -19,7 +19,7 @@
#define __GIMP_IMAGE_CONTIGUOUS_REGION_H__
GimpChannel * gimp_image_contiguous_region_by_seed (GimpImage *image,
GeglBuffer * gimp_image_contiguous_region_by_seed (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
......@@ -29,7 +29,7 @@ GimpChannel * gimp_image_contiguous_region_by_seed (GimpImage *image,
gint x,
gint y);
GimpChannel * gimp_image_contiguous_region_by_color (GimpImage *image,
GeglBuffer * gimp_image_contiguous_region_by_color (GimpImage *image,
GimpDrawable *drawable,
gboolean sample_merged,
gboolean antialias,
......
......@@ -45,7 +45,7 @@
#include "gimp-intl.h"
static GimpChannel * gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
static GeglBuffer * gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display);
......@@ -91,7 +91,7 @@ gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_HAND);
}
static GimpChannel *
static GeglBuffer *
gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display)
{
......
......@@ -43,7 +43,7 @@
#include "gimp-intl.h"
static GimpChannel * gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
static GeglBuffer * gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display);
......@@ -90,7 +90,7 @@ gimp_fuzzy_select_tool_init (GimpFuzzySelectTool *fuzzy_select)
GIMP_TOOL_CURSOR_FUZZY_SELECT);
}
static GimpChannel *
static GeglBuffer *
gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display)
{
......
......@@ -217,7 +217,7 @@ gimp_region_select_tool_button_release (GimpTool *tool,
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
}
gimp_channel_select_channel (gimp_image_get_mask (image),
gimp_channel_select_buffer (gimp_image_get_mask (image),
GIMP_REGION_SELECT_TOOL_GET_CLASS (tool)->undo_desc,
region_sel->region_mask,
off_x,
......@@ -343,7 +343,6 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
gint *n_segs)
{
GimpDisplayShell *shell = gimp_display_get_shell (display);
GeglBuffer *buffer;
GimpBoundSeg *segs;
gimp_display_shell_set_override_cursor (shell, GDK_WATCH);
......@@ -366,14 +365,12 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
/* calculate and allocate a new segment array which represents the
* boundary of the contiguous region
*/
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (region_sel->region_mask));
segs = gimp_boundary_find (buffer, NULL,
segs = gimp_boundary_find (region_sel->region_mask, NULL,
babl_format ("Y float"),
GIMP_BOUNDARY_WITHIN_BOUNDS,
0, 0,
gimp_item_get_width (GIMP_ITEM (region_sel->region_mask)),
gimp_item_get_height (GIMP_ITEM (region_sel->region_mask)),
gegl_buffer_get_width (region_sel->region_mask),
gegl_buffer_get_height (region_sel->region_mask),
GIMP_BOUNDARY_HALF_WAY,
n_segs);
......
......@@ -44,7 +44,7 @@ struct _GimpRegionSelectTool
gint x, y;
gdouble saved_threshold;
GimpChannel *region_mask;
GeglBuffer *region_mask;
GimpBoundSeg *segs;
gint n_segs;
};
......@@ -55,7 +55,7 @@ struct _GimpRegionSelectToolClass
const gchar * undo_desc;
GimpChannel * (* get_mask) (GimpRegionSelectTool *region_tool,
GeglBuffer * (* get_mask) (GimpRegionSelectTool *region_tool,
GimpDisplay *display);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment