[gimp] app: in gimp:offset, fix OFFSET_TRANSPARENT fast-path for chunked input



commit 533091055ee75ea406f335a99f6d0b397bab1d31
Author: Ell <ell_se yahoo com>
Date:   Fri Jun 7 03:45:17 2019 -0400

    app: in gimp:offset, fix OFFSET_TRANSPARENT fast-path for chunked input

 app/operations/gimpoperationoffset.c | 41 ++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/app/operations/gimpoperationoffset.c b/app/operations/gimpoperationoffset.c
index 660962cefb..f0a6afcf07 100644
--- a/app/operations/gimpoperationoffset.c
+++ b/app/operations/gimpoperationoffset.c
@@ -301,22 +301,31 @@ gimp_operation_offset_parent_process (GeglOperation        *operation,
 
       if (input)
         {
-          const GeglRectangle *extent;
-
-          extent = gegl_buffer_get_extent (GEGL_BUFFER (input));
-
-          output = g_object_new (GEGL_TYPE_BUFFER,
-            "source", input,
-            "x",      extent->x,
-            "y",      extent->y,
-            "width",  extent->width,
-            "height", extent->height,
-            "shift-x", -x,
-            "shift-y", -y,
-            NULL);
-
-          if (gegl_object_get_has_forked (input))
-            gegl_object_set_has_forked (output);
+          GeglRectangle bounds;
+          GeglRectangle extent;
+
+          bounds = gegl_operation_get_bounding_box (GEGL_OPERATION (offset));
+
+          extent = *gegl_buffer_get_extent (GEGL_BUFFER (input));
+
+          extent.x += x;
+          extent.y += y;
+
+          if (gegl_rectangle_intersect (&extent, &extent, &bounds))
+            {
+              output = g_object_new (GEGL_TYPE_BUFFER,
+                "source", input,
+                "x",      extent.x,
+                "y",      extent.y,
+                "width",  extent.width,
+                "height", extent.height,
+                "shift-x", -x,
+                "shift-y", -y,
+                NULL);
+
+              if (gegl_object_get_has_forked (input))
+                gegl_object_set_has_forked (output);
+            }
         }
 
       gegl_operation_context_take_object (context, "output", output);


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