[gegl] whirl-pinch: pass-through for infinite planes (issue #179)



commit 57f3ea8e9858de1dd4c4fba43dd065302c1036a3
Author: Thomas Manni <thomas manni free fr>
Date:   Tue Jul 30 17:20:10 2019 +0200

    whirl-pinch: pass-through for infinite planes (issue #179)

 operations/common-gpl3+/whirl-pinch.c | 40 +++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)
---
diff --git a/operations/common-gpl3+/whirl-pinch.c b/operations/common-gpl3+/whirl-pinch.c
index 112ac5764..787fb43c1 100644
--- a/operations/common-gpl3+/whirl-pinch.c
+++ b/operations/common-gpl3+/whirl-pinch.c
@@ -200,9 +200,15 @@ get_required_for_output (GeglOperation       *operation,
                          const gchar         *input_pad,
                          const GeglRectangle *roi)
 {
-  GeglRectangle *result = gegl_operation_source_get_bounding_box (operation, "input");
+  const GeglRectangle *in_rect =
+            gegl_operation_source_get_bounding_box (operation, "input");
 
-  return *result;
+  if (! in_rect || gegl_rectangle_is_infinite_plane (in_rect))
+    {
+      return *roi;
+    }
+
+  return *in_rect;
 }
 
 /* Specify the input and output buffer formats.
@@ -243,6 +249,31 @@ process (GeglOperation       *operation,
   return TRUE;
 }
 
+static gboolean
+operation_process (GeglOperation        *operation,
+                   GeglOperationContext *context,
+                   const gchar          *output_prop,
+                   const GeglRectangle  *result,
+                   gint                  level)
+{
+  GeglOperationClass  *operation_class;
+
+  const GeglRectangle *in_rect =
+    gegl_operation_source_get_bounding_box (operation, "input");
+
+  if (in_rect && gegl_rectangle_is_infinite_plane (in_rect))
+    {
+      gpointer in = gegl_operation_context_get_object (context, "input");
+      gegl_operation_context_take_object (context, "output",
+                                          g_object_ref (G_OBJECT (in)));
+      return TRUE;
+    }
+
+  operation_class = GEGL_OPERATION_CLASS (gegl_op_parent_class);
+
+  return operation_class->process (operation, context, output_prop, result,
+                                   gegl_operation_context_get_level (context));
+}
 
 static void
 gegl_op_class_init (GeglOpClass *klass)
@@ -253,8 +284,9 @@ gegl_op_class_init (GeglOpClass *klass)
   operation_class = GEGL_OPERATION_CLASS (klass);
   filter_class    = GEGL_OPERATION_FILTER_CLASS (klass);
 
-  filter_class->process = process;
-  operation_class->prepare = prepare;
+  filter_class->process                    = process;
+  operation_class->prepare                 = prepare;
+  operation_class->process                 = operation_process;
   operation_class->get_required_for_output = get_required_for_output;
 
   gegl_operation_class_set_keys (operation_class,


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