[gimp] app: add crop_input parameter to gimp_gegl_apply_operation()
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add crop_input parameter to gimp_gegl_apply_operation()
- Date: Thu, 22 Mar 2018 17:47:34 +0000 (UTC)
commit e1b1611ec4609e948f17333f917fe8328b9a7488
Author: Ell <ell_se yahoo com>
Date: Thu Mar 22 13:31:00 2018 -0400
app: add crop_input parameter to gimp_gegl_apply_operation()
Add a crop_input parameter to gimp_gegl_apply_[cached_]operation().
When TRUE, the functions crop the op's input to the destination
rect. This is particularly useful for functions that process the
entire input in one go (by means of get_cached_region()). See the
next commit.
Pass crop_input = FALSE at all call sites for now, to keep the
current behavior.
app/core/gimpdrawable-blend.c | 5 ++-
app/core/gimpdrawable-filters.c | 2 +-
app/core/gimpdrawable-operation.c | 2 +-
app/gegl/gimp-gegl-apply-operation.c | 51 +++++++++++++++++++++++---------
app/gegl/gimp-gegl-apply-operation.h | 4 ++-
app/tools/gimpnpointdeformationtool.c | 2 +-
app/tools/gimpwarptool.c | 2 +-
7 files changed, 46 insertions(+), 22 deletions(-)
---
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index a5e7491..76311e3 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -112,7 +112,8 @@ gimp_drawable_blend (GimpDrawable *drawable,
gimp_gegl_apply_operation (shapeburst, progress, NULL,
render,
- buffer, GEGL_RECTANGLE (x, y, width, height));
+ buffer, GEGL_RECTANGLE (x, y, width, height),
+ FALSE);
g_object_unref (render);
@@ -213,7 +214,7 @@ gimp_drawable_blend_shapeburst_distmap (GimpDrawable *drawable,
gimp_gegl_apply_operation (temp_buffer, NULL, NULL,
shapeburst,
- dist_buffer, region);
+ dist_buffer, region, FALSE);
g_object_unref (shapeburst);
diff --git a/app/core/gimpdrawable-filters.c b/app/core/gimpdrawable-filters.c
index edad603..a1c7288 100644
--- a/app/core/gimpdrawable-filters.c
+++ b/app/core/gimpdrawable-filters.c
@@ -194,7 +194,7 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
progress, undo_desc,
gimp_filter_get_node (filter),
gimp_drawable_get_buffer (drawable),
- &rect,
+ &rect, FALSE,
cache, rects, n_rects,
cancellable))
{
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index 3114d57..fc38ea7 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -63,7 +63,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
gimp_gegl_apply_operation (gimp_drawable_get_buffer (drawable),
progress, undo_desc,
operation,
- dest_buffer, &rect);
+ dest_buffer, &rect, FALSE);
gimp_drawable_merge_shadow_buffer (drawable, TRUE, undo_desc);
gimp_drawable_free_shadow_buffer (drawable);
diff --git a/app/gegl/gimp-gegl-apply-operation.c b/app/gegl/gimp-gegl-apply-operation.c
index ee8131a..f560728 100644
--- a/app/gegl/gimp-gegl-apply-operation.c
+++ b/app/gegl/gimp-gegl-apply-operation.c
@@ -43,13 +43,15 @@ gimp_gegl_apply_operation (GeglBuffer *src_buffer,
const gchar *undo_desc,
GeglNode *operation,
GeglBuffer *dest_buffer,
- const GeglRectangle *dest_rect)
+ const GeglRectangle *dest_rect,
+ gboolean crop_input)
{
gimp_gegl_apply_cached_operation (src_buffer,
progress, undo_desc,
operation,
dest_buffer,
dest_rect,
+ crop_input,
NULL, NULL, 0,
FALSE);
}
@@ -68,6 +70,7 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
GeglNode *operation,
GeglBuffer *dest_buffer,
const GeglRectangle *dest_rect,
+ gboolean crop_input,
GeglBuffer *cache,
const GeglRectangle *valid_rects,
gint n_valid_rects,
@@ -124,6 +127,24 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
g_object_unref (src_buffer);
+ if (crop_input)
+ {
+ GeglNode *crop_node;
+
+ crop_node = gegl_node_new_child (gegl,
+ "operation", "gegl:crop",
+ "x", (gdouble) rect.x,
+ "y", (gdouble) rect.y,
+ "width", (gdouble) rect.width,
+ "height", (gdouble) rect.height,
+ NULL);
+
+ gegl_node_connect_to (src_node, "output",
+ crop_node, "input");
+
+ src_node = crop_node;
+ }
+
operation_src_node = gegl_node_get_producer (operation, "input", NULL);
gegl_node_connect_to (src_node, "output",
@@ -306,7 +327,7 @@ gimp_gegl_apply_dither (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -328,7 +349,7 @@ gimp_gegl_apply_flatten (GeglBuffer *src_buffer,
node = gimp_gegl_create_flatten_node (background, composite_space);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -442,7 +463,7 @@ gimp_gegl_apply_border (GeglBuffer *src_buffer,
}
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, dest_rect);
+ node, dest_buffer, dest_rect, FALSE);
g_object_unref (node);
}
@@ -468,7 +489,7 @@ gimp_gegl_apply_grow (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, dest_rect);
+ node, dest_buffer, dest_rect, FALSE);
g_object_unref (node);
}
@@ -496,7 +517,7 @@ gimp_gegl_apply_shrink (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, dest_rect);
+ node, dest_buffer, dest_rect, FALSE);
g_object_unref (node);
}
@@ -518,7 +539,7 @@ gimp_gegl_apply_flood (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, dest_rect);
+ node, dest_buffer, dest_rect, FALSE);
g_object_unref (node);
}
@@ -544,7 +565,7 @@ gimp_gegl_apply_gaussian_blur (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, dest_rect);
+ node, dest_buffer, dest_rect, FALSE);
g_object_unref (node);
}
@@ -565,7 +586,7 @@ gimp_gegl_apply_invert_gamma (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -586,7 +607,7 @@ gimp_gegl_apply_invert_linear (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -613,7 +634,7 @@ gimp_gegl_apply_opacity (GeglBuffer *src_buffer,
opacity);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -642,7 +663,7 @@ gimp_gegl_apply_scale (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -665,7 +686,7 @@ gimp_gegl_apply_set_alpha (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -688,7 +709,7 @@ gimp_gegl_apply_threshold (GeglBuffer *src_buffer,
NULL);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
@@ -715,6 +736,6 @@ gimp_gegl_apply_transform (GeglBuffer *src_buffer,
gimp_gegl_node_set_matrix (node, transform);
gimp_gegl_apply_operation (src_buffer, progress, undo_desc,
- node, dest_buffer, NULL);
+ node, dest_buffer, NULL, FALSE);
g_object_unref (node);
}
diff --git a/app/gegl/gimp-gegl-apply-operation.h b/app/gegl/gimp-gegl-apply-operation.h
index 0ba40bb..b803715 100644
--- a/app/gegl/gimp-gegl-apply-operation.h
+++ b/app/gegl/gimp-gegl-apply-operation.h
@@ -31,7 +31,8 @@ void gimp_gegl_apply_operation (GeglBuffer *src_buffer,
const gchar *undo_desc,
GeglNode *operation,
GeglBuffer *dest_buffer,
- const GeglRectangle *dest_rect);
+ const GeglRectangle *dest_rect,
+ gboolean crop_input);
gboolean gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
GimpProgress *progress,
@@ -39,6 +40,7 @@ gboolean gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
GeglNode *operation,
GeglBuffer *dest_buffer,
const GeglRectangle *dest_rect,
+ gboolean crop_input,
GeglBuffer *cache,
const GeglRectangle *valid_rects,
gint n_valid_rects,
diff --git a/app/tools/gimpnpointdeformationtool.c b/app/tools/gimpnpointdeformationtool.c
index ec51033..f0d2bd8 100644
--- a/app/tools/gimpnpointdeformationtool.c
+++ b/app/tools/gimpnpointdeformationtool.c
@@ -1004,7 +1004,7 @@ gimp_n_point_deformation_tool_apply_deformation (GimpNPointDeformationTool *npd_
gimp_gegl_apply_operation (NULL, NULL, _("N-Point Deformation"),
npd_tool->npd_node,
gimp_drawable_get_buffer (tool->drawable),
- NULL);
+ NULL, FALSE);
gimp_drawable_update (tool->drawable,
0, 0, width, height);
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index c660d0e..ecedf40 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -1144,7 +1144,7 @@ gimp_warp_tool_animate (GimpWarpTool *wt)
_("Frame"),
wt->graph,
gimp_drawable_get_buffer (GIMP_DRAWABLE (layer)),
- NULL);
+ NULL, FALSE);
gimp_image_add_layer (image, layer, NULL, 0, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]