[gegl] apply-lens: pass-through for infinite planes (issue #179)



commit b38addf53fc97b33bd3432d0c062fd8de5373ac3
Author: Thomas Manni <thomas manni free fr>
Date:   Tue Jul 30 17:18:02 2019 +0200

    apply-lens: pass-through for infinite planes (issue #179)

 operations/common-gpl3+/apply-lens.c | 43 ++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/operations/common-gpl3+/apply-lens.c b/operations/common-gpl3+/apply-lens.c
index 9d9c1f071..3dbcaa41b 100644
--- a/operations/common-gpl3+/apply-lens.c
+++ b/operations/common-gpl3+/apply-lens.c
@@ -111,7 +111,7 @@ prepare (GeglOperation *operation)
 
   whole_region = gegl_operation_source_get_bounding_box (operation, "input");
 
-  if (whole_region)
+  if (whole_region && ! gegl_rectangle_is_infinite_plane (whole_region))
     {
       params->a = 0.5 * whole_region->width;
       params->b = 0.5 * whole_region->height;
@@ -147,13 +147,15 @@ get_required_for_output (GeglOperation       *operation,
                          const gchar         *input_pad,
                          const GeglRectangle *roi)
 {
-  GeglRectangle  result = {0,0,0,0};
-  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
+  const GeglRectangle *in_rect =
+            gegl_operation_source_get_bounding_box (operation, "input");
 
-  if (!in_rect)
-    return result;
-  else
-    return *in_rect;
+  if (! in_rect || gegl_rectangle_is_infinite_plane (in_rect))
+    {
+      return *roi;
+    }
+
+  return *in_rect;
 }
 
 static gboolean
@@ -236,6 +238,32 @@ 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)
 {
@@ -266,6 +294,7 @@ gegl_op_class_init (GeglOpClass *klass)
   object_class->finalize                   = finalize;
   operation_class->prepare                 = prepare;
   operation_class->get_required_for_output = get_required_for_output;
+  operation_class->process                 = operation_process;
   filter_class->process                    = process;
 
   gegl_operation_class_set_keys (operation_class,


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