[gimp/gimp-2-10] app: avoid dropping cached data when committing filters



commit 97c549198e19010c3107594aaf4a5274311f0ff0
Author: Ell <ell_se yahoo com>
Date:   Thu Oct 3 19:58:53 2019 +0300

    app: avoid dropping cached data when committing filters
    
    In gimp_gegl_apply_cached_operation(), add a boolean
    connect_src_buffer parameter, which determines whether to connect
    the source buffer to the operation-node's input, or to use its
    existing input.  In gimp_drawable_merge_filter(), pass FALSE for
    connect_src_buffer, so that the existing filter-node input is used.
    This produces an equivalent result, however, it avoids invalidating
    the filter node, and dropping cached data as a result.  In
    operations that cache larger areas than the ROI, this avoids
    reprocessing already-cached data when processing the rest of the
    operation.
    
    Additionally, in gimp_gegl_apply_cached_operation(), use an empty
    input for the operation if src_buffer is NULL and
    connect_src_buffer is TRUE; previously, we'd use the operation-
    node's existing input when src_buffer was NULL.  Furthermore, crop
    the operation-node's input to the destination rect when crop_input
    is TRUE, even if connect_src_buffer is FALSE.
    
    (cherry picked from commit 11629fde660a97c695c04801f8997caedfdcc389)

 app/core/gimpdrawable-filters.c      |  2 +-
 app/gegl/gimp-gegl-apply-operation.c | 21 ++++++++++++++-------
 app/gegl/gimp-gegl-apply-operation.h |  1 +
 3 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/app/core/gimpdrawable-filters.c b/app/core/gimpdrawable-filters.c
index ee23eb3f74..c786c3d228 100644
--- a/app/core/gimpdrawable-filters.c
+++ b/app/core/gimpdrawable-filters.c
@@ -217,7 +217,7 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
 
   if (gimp_gegl_apply_cached_operation (gimp_drawable_get_buffer (drawable),
                                         progress, undo_desc,
-                                        gimp_filter_get_node (filter),
+                                        gimp_filter_get_node (filter), FALSE,
                                         dest_buffer, &rect, FALSE,
                                         cache, rects, n_rects,
                                         cancellable))
diff --git a/app/gegl/gimp-gegl-apply-operation.c b/app/gegl/gimp-gegl-apply-operation.c
index b0b485247a..64cb0ce660 100644
--- a/app/gegl/gimp-gegl-apply-operation.c
+++ b/app/gegl/gimp-gegl-apply-operation.c
@@ -62,6 +62,7 @@ gimp_gegl_apply_operation (GeglBuffer          *src_buffer,
   gimp_gegl_apply_cached_operation (src_buffer,
                                     progress, undo_desc,
                                     operation,
+                                    TRUE,
                                     dest_buffer,
                                     dest_rect,
                                     crop_input,
@@ -81,6 +82,7 @@ gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
                                   GimpProgress        *progress,
                                   const gchar         *undo_desc,
                                   GeglNode            *operation,
+                                  gboolean             connect_src_buffer,
                                   GeglBuffer          *dest_buffer,
                                   const GeglRectangle *dest_rect,
                                   gboolean             crop_input,
@@ -226,14 +228,21 @@ gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
 
   effect = operation;
 
-  if (src_buffer)
+  if (connect_src_buffer || crop_input)
     {
       GeglNode *src_node;
 
-      src_node = gegl_node_new_child (gegl,
-                                      "operation", "gegl:buffer-source",
-                                      "buffer",    src_buffer,
-                                      NULL);
+      operation_src_node = gegl_node_get_producer (operation, "input", NULL);
+
+      src_node = operation_src_node;
+
+      if (connect_src_buffer)
+        {
+          src_node = gegl_node_new_child (gegl,
+                                          "operation", "gegl:buffer-source",
+                                          "buffer",    src_buffer,
+                                          NULL);
+        }
 
       if (crop_input)
         {
@@ -253,8 +262,6 @@ gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
           src_node = crop_node;
         }
 
-      operation_src_node = gegl_node_get_producer (operation, "input", NULL);
-
       if (! gegl_node_has_pad (operation, "input"))
         {
           effect = gegl_node_new_child (gegl,
diff --git a/app/gegl/gimp-gegl-apply-operation.h b/app/gegl/gimp-gegl-apply-operation.h
index 985ebe3d29..3b19ee045c 100644
--- a/app/gegl/gimp-gegl-apply-operation.h
+++ b/app/gegl/gimp-gegl-apply-operation.h
@@ -38,6 +38,7 @@ gboolean   gimp_gegl_apply_cached_operation (GeglBuffer          *src_buffer,
                                              GimpProgress        *progress,
                                              const gchar         *undo_desc,
                                              GeglNode            *operation,
+                                             gboolean             connect_src_buffer,
                                              GeglBuffer          *dest_buffer,
                                              const GeglRectangle *dest_rect,
                                              gboolean             crop_input,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]