[gegl] cubism: pass-through on infinite planes (issue #179)



commit 690c6722a05010504272cbac5623253826c78e8d
Author: Thomas Manni <thomas manni free fr>
Date:   Tue Aug 6 19:36:02 2019 +0200

    cubism: pass-through on infinite planes (issue #179)

 operations/common-gpl3+/cubism.c | 61 ++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 15 deletions(-)
---
diff --git a/operations/common-gpl3+/cubism.c b/operations/common-gpl3+/cubism.c
index 87e7101d0..26f2acd38 100644
--- a/operations/common-gpl3+/cubism.c
+++ b/operations/common-gpl3+/cubism.c
@@ -559,16 +559,12 @@ static GeglRectangle
 get_bounding_box (GeglOperation *operation)
 {
   GeglRectangle  result = {0,0,0,0};
-  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
 
-  if (!in_rect)
-    return result;
+  const GeglRectangle *in_rect =
+      gegl_operation_source_get_bounding_box (operation, "input");
 
-  gegl_rectangle_copy (&result, in_rect);
-
-#ifdef TRACE
-  g_warning ("< get_bounding_box result = %dx%d+%d+%d", result.width, result.height, result.x, result.y);
-#endif
+  if (in_rect)
+    result = *in_rect;
 
   return result;
 }
@@ -581,13 +577,13 @@ get_required_for_output (GeglOperation       *operation,
                          const gchar         *input_pad,
                          const GeglRectangle *roi)
 {
-  GeglRectangle  result = get_effective_area (operation);
+  GeglRectangle result = *roi;
 
-#ifdef TRACE
-  g_warning ("> get_required_for_output src=%dx%d+%d+%d", result.width, result.height, result.x, result.y);
-  if (roi)
-    g_warning ("  ROI == %dx%d+%d+%d", roi->width, roi->height, roi->x, roi->y);
-#endif
+  const GeglRectangle *in_rect =
+      gegl_operation_source_get_bounding_box (operation, "input");
+
+  if (in_rect && ! gegl_rectangle_is_infinite_plane (in_rect))
+    result = *in_rect;
 
   return result;
 }
@@ -596,7 +592,41 @@ static GeglRectangle
 get_cached_region (GeglOperation       *operation,
                    const GeglRectangle *roi)
 {
-  return *gegl_operation_source_get_bounding_box (operation, "input");
+  GeglRectangle result = *roi;
+
+  const GeglRectangle *in_rect =
+      gegl_operation_source_get_bounding_box (operation, "input");
+
+  if (in_rect && ! gegl_rectangle_is_infinite_plane (in_rect))
+    result = *in_rect;
+
+  return result;
+}
+
+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
@@ -610,6 +640,7 @@ gegl_op_class_init (GeglOpClass *klass)
 
   filter_class->process                    = process;
   operation_class->prepare                 = prepare;
+  operation_class->process                 = operation_process;
   operation_class->threaded                = FALSE;
   operation_class->get_bounding_box        = get_bounding_box;
   operation_class->get_required_for_output = get_required_for_output;


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