[gimp] app: align projection update area to coarse grid



commit 49285463e6c0cc03c361902df4e3006fa135dde3
Author: Ell <ell_se yahoo com>
Date:   Sat Mar 31 08:13:36 2018 -0400

    app: align projection update area to coarse grid
    
    When adding a rectangle to a projection's update area, align the
    rectangle to a coarse grid, to reduce the complexity of the overall
    area.  We currently align the rectangle to a 32x32 grid, which
    seems to be a good tradeoff between the overhead of processing a
    complex area, and the overhead of processing a large area.

 app/core/gimpprojection.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index e531124..fcf330a 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -25,6 +25,7 @@
 #include <gegl.h>
 
 #include "libgimpbase/gimpbase.h"
+#include "libgimpmath/gimpmath.h"
 
 #include "core-types.h"
 
@@ -48,6 +49,10 @@
 static gint GIMP_PROJECTION_CHUNK_WIDTH  = 256;
 static gint GIMP_PROJECTION_CHUNK_HEIGHT = 128;
 
+/*  chunk size for area updates  */
+static gint GIMP_PROJECTION_UPDATE_CHUNK_WIDTH  = 32;
+static gint GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT = 32;
+
 /*  how much time, in seconds, do we allow chunk rendering to take,
  *  aiming for 15fps
  */
@@ -679,6 +684,17 @@ gimp_projection_add_update_area (GimpProjection *proj,
   x -= off_x;
   y -= off_y;
 
+  /*  align the rectangle to the UPDATE_CHUNK_WIDTH x UPDATE_CHUNK_HEIGHT grid,
+   *  to decrease the complexity of the update area.
+   */
+  w = ceil  ((gdouble) (x + w) / GIMP_PROJECTION_UPDATE_CHUNK_WIDTH ) * GIMP_PROJECTION_UPDATE_CHUNK_WIDTH;
+  h = ceil  ((gdouble) (y + h) / GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT) * GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT;
+  x = floor ((gdouble) x       / GIMP_PROJECTION_UPDATE_CHUNK_WIDTH ) * GIMP_PROJECTION_UPDATE_CHUNK_WIDTH;
+  y = floor ((gdouble) y       / GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT) * GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT;
+
+  w -= x;
+  h -= y;
+
   if (gimp_rectangle_intersect (x, y, w, h,
                                 0, 0, width, height,
                                 &rect.x, &rect.y, &rect.width, &rect.height))


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