Commit c204b0ac authored by Michael Henning's avatar Michael Henning

core: speed up gimp_image_contiguous_region_by_seed using a temporary GeglBuffer

By creating a temporary GeglBuffer of the correct format, we avoid a lot of
babl conversions. This is about four times faster than the previous code.
parent c9533681
......@@ -113,11 +113,10 @@ gimp_image_contiguous_region_by_seed (GimpImage *image,
src_buffer = gimp_pickable_get_buffer (pickable);
mask = gimp_channel_new_mask (image,
gegl_buffer_get_width (src_buffer),
gegl_buffer_get_height (src_buffer));
mask_buffer = gegl_buffer_new (gegl_buffer_get_extent (src_buffer),
babl_format ("Y float"));
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
gegl_buffer_clear (mask_buffer, NULL);
gegl_buffer_sample (src_buffer, x, y, NULL, start_col, src_format,
......@@ -145,6 +144,15 @@ gimp_image_contiguous_region_by_seed (GimpImage *image,
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));
gimp_drawable_set_buffer (GIMP_DRAWABLE (mask), FALSE, "", mask_buffer);
g_object_unref (mask_buffer);
return mask;
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