From 987d9e2800bcf3cdd403866a0ea7f58aebca7349 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 1 Jun 2014 18:35:18 +0200 Subject: [PATCH] app: add a gegl:copy-buffer to GimpApplicator which allows to get a buffer copy of the result of the applied operation without the overhead of running the entire graph again just for this purpose. --- app/gegl/gimpapplicator.c | 47 +++++++++++++++++---------------------- app/gegl/gimpapplicator.h | 2 ++ app/sanity.c | 1 + 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/app/gegl/gimpapplicator.c b/app/gegl/gimpapplicator.c index fdff8bd80e..fc85be8259 100644 --- a/app/gegl/gimpapplicator.c +++ b/app/gegl/gimpapplicator.c @@ -150,8 +150,16 @@ gimp_applicator_new (GeglNode *parent, gegl_node_connect_to (applicator->aux_node, "output", applicator->apply_offset_node, "input"); - gegl_node_connect_to (applicator->apply_offset_node, "output", - applicator->mode_node, "aux"); + + applicator->dup_apply_buffer_node = + gegl_node_new_child (applicator->node, + "operation", "gegl:copy-buffer", + NULL); + + gegl_node_connect_to (applicator->apply_offset_node, "output", + applicator->dup_apply_buffer_node, "input"); + gegl_node_connect_to (applicator->dup_apply_buffer_node, "output", + applicator->mode_node, "aux"); applicator->mask_node = gegl_node_new_child (applicator->node, @@ -423,37 +431,22 @@ gimp_applicator_dup_apply_buffer (GimpApplicator *applicator, const GeglRectangle *rect) { GeglBuffer *buffer; - GeglNode *offset; - GeglNode *dest; + GeglBuffer *shifted; buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, rect->width, rect->height), babl_format ("RGBA float")); - offset = gegl_node_new_child (applicator->node, - "operation", "gegl:translate", - "x", - (gdouble) - applicator->apply_offset_x - rect->x, - "y", - (gdouble) - applicator->apply_offset_y - rect->y, - NULL); + shifted = g_object_new (GEGL_TYPE_BUFFER, + "source", buffer, + "shift-x", -rect->x, + "shift-y", -rect->y, + NULL); - dest = gegl_node_new_child (applicator->node, - "operation", "gegl:write-buffer", - "buffer", buffer, - NULL); + gegl_node_set (applicator->dup_apply_buffer_node, + "buffer", shifted, + NULL); - gegl_node_link_many (applicator->apply_offset_node, - offset, - dest, - NULL); - - gegl_node_blit (dest, 1.0, GEGL_RECTANGLE (0, 0, rect->width, rect->height), - NULL, NULL, 0, GEGL_BLIT_DEFAULT); - - gegl_node_disconnect (offset, "input"); - - gegl_node_remove_child (applicator->node, offset); - gegl_node_remove_child (applicator->node, dest); + g_object_unref (shifted); return buffer; } diff --git a/app/gegl/gimpapplicator.h b/app/gegl/gimpapplicator.h index 73f3720432..f434bc898a 100644 --- a/app/gegl/gimpapplicator.h +++ b/app/gegl/gimpapplicator.h @@ -48,6 +48,8 @@ struct _GimpApplicator gint apply_offset_y; GeglNode *apply_offset_node; + GeglNode *dup_apply_buffer_node; + gdouble opacity; GimpLayerModeEffects paint_mode; gboolean linear; diff --git a/app/sanity.c b/app/sanity.c index 91cdea9e24..e923a257ef 100644 --- a/app/sanity.c +++ b/app/sanity.c @@ -485,6 +485,7 @@ sanity_check_gegl_ops (void) "gegl:color-temperature", "gegl:color-to-alpha", "gegl:convolution-matrix", + "gegl:copy-buffer", "gegl:crop", "gegl:cubism", "gegl:deinterlace",