[gimp] core: speed up gimp_image_contiguous_region_by_seed using a temporary GeglBuffer
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] core: speed up gimp_image_contiguous_region_by_seed using a temporary GeglBuffer
- Date: Sun, 7 Apr 2013 18:33:04 +0000 (UTC)
commit c204b0ac413539ee763483970a64eb437a43de3f
Author: Michael Henning <drawoc darkrefraction com>
Date: Sun Apr 7 14:27:20 2013 -0400
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.
app/core/gimpimage-contiguous-region.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpimage-contiguous-region.c b/app/core/gimpimage-contiguous-region.c
index 64edbbc..f16ba88 100644
--- a/app/core/gimpimage-contiguous-region.c
+++ b/app/core/gimpimage-contiguous-region.c
@@ -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,
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]