Commit e1b1611e authored by Ell's avatar Ell

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.
parent 45802855
......@@ -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);
......
......@@ -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))
{
......
......@@ -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);
......
......@@ -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);
}
......@@ -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,
......
......@@ -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);
......
......@@ -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);
}
......
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