[gegl/soc-2011-warp] gegl:warp: don't stamp if oustide the roi



commit e518676a41b7b1dc24b429f6b4e4dbf686bbe103
Author: Michael Murà <batolettre gmail com>
Date:   Thu Jul 28 14:19:12 2011 +0200

    gegl:warp: don't stamp if oustide the roi

 operations/workshop/warp.c |   39 ++++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/operations/workshop/warp.c b/operations/workshop/warp.c
index c1c0686..c662789 100644
--- a/operations/workshop/warp.c
+++ b/operations/workshop/warp.c
@@ -175,9 +175,10 @@ get_influence (GeglChantO *o,
 }
 
 static void
-stamp (GeglChantO *o,
-       gdouble     x,
-       gdouble     y)
+stamp (GeglChantO          *o,
+       const GeglRectangle *result,
+       gdouble              x,
+       gdouble              y)
 {
   WarpPrivate         *priv = (WarpPrivate*) o->chant_data;
   GeglBufferIterator  *it;
@@ -200,6 +201,10 @@ stamp (GeglChantO *o,
       return;
     }
 
+  /* don't stamp if outside the roi treated */
+  if (!gegl_rectangle_intersect (NULL, result, &area))
+    return;
+
   format = babl_format_n (babl_type ("float"), 2);
 
   /* If needed, compute the mean deformation */
@@ -298,8 +303,8 @@ process (GeglOperation       *operation,
          GeglBuffer          *output,
          const GeglRectangle *result)
 {
-  GeglChantO           *o = GEGL_CHANT_PROPERTIES (operation);
-  WarpPrivate          *priv = (WarpPrivate*) o->chant_data;
+  GeglChantO          *o = GEGL_CHANT_PROPERTIES (operation);
+  WarpPrivate         *priv = (WarpPrivate*) o->chant_data;
   gdouble              dist;
   gdouble              stamps;
   gdouble              spacing = MAX (o->size * 0.01, 0.5); /*1% spacing for starters*/
@@ -324,19 +329,19 @@ process (GeglOperation       *operation,
       stamps = dist / spacing;
 
       if (stamps < 1)
-       {
-        stamp (o, next.x, next.y);
-        prev = next;
-       }
+        {
+          stamp (o, result, next.x, next.y);
+          prev = next;
+        }
       else
-       {
-        for (i = 0; i < stamps; i++)
-          {
-            point_lerp (&lerp, &prev, &next, (i * spacing) / dist);
-            stamp (o, lerp.x, lerp.y);
-          }
-         prev = lerp;
-       }
+        {
+          for (i = 0; i < stamps; i++)
+            {
+              point_lerp (&lerp, &prev, &next, (i * spacing) / dist);
+              stamp (o, result, lerp.x, lerp.y);
+            }
+          prev = lerp;
+        }
     }
 
   /* Affect the output buffer */



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