[gimp] app: improvements in code executed a lot while painting.



commit 2aa4426d4f30f576bb04c90ef573fdc4a88ee046
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Mar 29 16:50:15 2018 +0200

    app: improvements in code executed a lot while painting.
    
    This keeps the same rectangle packing behaviour, so to behave exactly as
    before for what concerns batching the updates, but should be lighter
    when looping to find the first good rectangle to use.
    
    In rtree_insert(), some conditions in the if tests are implied by
    previous conditions. And therefore the 2 successive for loops are
    actually identical.
    
    In rtree_node_insert(), it is wrong/harmful to insert zero sized
    rectangles in the tree because they can never be selected and just make
    the list longer. So rtree_node_create() should just return NULL when w
    or h are 0.
    
    See bug 694917, comments 51 to 61.

 app/display/gimpdisplayxfer.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/app/display/gimpdisplayxfer.c b/app/display/gimpdisplayxfer.c
index 3932377..1d52070 100644
--- a/app/display/gimpdisplayxfer.c
+++ b/app/display/gimpdisplayxfer.c
@@ -72,10 +72,11 @@ rtree_node_create (RTree      *rtree,
   gimp_assert (x >= 0 && x+w <= rtree->root.w);
   gimp_assert (y >= 0 && y+h <= rtree->root.h);
 
-  node = g_slice_alloc (sizeof (*node));
-  if (node == NULL)
+  if (w <= 0 || h <= 0)
     return NULL;
 
+  node = g_slice_alloc (sizeof (*node));
+
   node->children[0] = NULL;
   node->children[1] = NULL;
   node->x = x;
@@ -149,10 +150,6 @@ rtree_insert (RTree *rtree,
   RTreeNode *node, **prev;
 
   for (prev = &rtree->available; (node = *prev); prev = &node->next)
-    if (node->w >= w && w < 2 * node->w && node->h >= h && h < 2 * node->h)
-      return rtree_node_insert (rtree, prev, node, w, h);
-
-  for (prev = &rtree->available; (node = *prev); prev = &node->next)
     if (node->w >= w && node->h >= h)
       return rtree_node_insert (rtree, prev, node, w, h);
 


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