[gegl] process: destroy node cache, instead of clearing, when new bounding box is smaller



commit caae2071353deff42fe720c857d1163d9b3f82a8
Author: Ell <ell_se yahoo com>
Date:   Mon Jan 6 22:20:52 2020 +0200

    process: destroy node cache, instead of clearing, when new bounding box is smaller
    
    When a node's bounding box changes, if the old tile-aligned
    bounding box is not contained within the new tile-aligned bounding
    box, destroy the node's cache, instead of clearing the now-out-of-
    bounds region.  The problem with the latter is that the node's
    bounding box can be arbitrarily large, even without actually having
    been rendered; if the bounding box then becomes much smaller,
    clearing the difference can take a long time, even if the cache
    doesn't have any actual tiles in this region.  Destroying the
    cache, on the other hand, is much faster.

 gegl/process/gegl-graph-traversal.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/gegl/process/gegl-graph-traversal.c b/gegl/process/gegl-graph-traversal.c
index 2914ae3ff..38e1a7566 100644
--- a/gegl/process/gegl-graph-traversal.c
+++ b/gegl/process/gegl-graph-traversal.c
@@ -200,22 +200,16 @@ gegl_graph_prepare (GeglGraphTraversal *path)
           {
             GeglRectangle old_rect;
             GeglRectangle new_rect;
-            GeglRectangle diff_rects[4];
-            gint          n_diff_rects;
-            gint          i;
 
             gegl_rectangle_align_to_buffer (&old_rect, cache_extent, cache,
                                             GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
             gegl_rectangle_align_to_buffer (&new_rect, &node->have_rect, cache,
                                             GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
 
-            n_diff_rects = gegl_rectangle_subtract (diff_rects,
-                                                    &old_rect, &new_rect);
-
-            for (i = 0; i < n_diff_rects; i++)
-              gegl_buffer_clear (cache, &diff_rects[i]);
-
-            gegl_buffer_set_extent (cache, &node->have_rect);
+            if (gegl_rectangle_contains (&new_rect, &old_rect))
+              gegl_buffer_set_extent (cache, &node->have_rect);
+            else
+              g_clear_object (&node->cache);
           }
       }
 


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