[gegl/threaded-base-classes: 18/22] make point composer3 not be parallelized



commit b2ad91d6a1c813463e815d4c4d02c43bdc7e75cd
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Jun 28 03:03:09 2014 +0200

    make point composer3 not be parallelized

 gegl/operation/gegl-operation-composer3.c       |    6 +-
 gegl/operation/gegl-operation-point-composer3.c |   70 +++++++++++++++++++++++
 2 files changed, 73 insertions(+), 3 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-composer3.c b/gegl/operation/gegl-operation-composer3.c
index 37f9280..6afcf8b 100644
--- a/gegl/operation/gegl-operation-composer3.c
+++ b/gegl/operation/gegl-operation-composer3.c
@@ -51,9 +51,9 @@ gegl_operation_composer3_class_init (GeglOperationComposer3Class * klass)
 {
   GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
 
-  operation_class->parallelize = FALSE; /* such composer ops do not derive benefit from
-                                         * parallelization 
-                                         */
+  operation_class->parallelize = TRUE; /* such composer ops do not derive benefit from
+                                        * parallelization 
+                                        */
   operation_class->process = gegl_operation_composer3_process;
   operation_class->attach = attach;
   operation_class->detect = detect;
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index fd0faa1..08d4f1d 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -24,8 +24,77 @@
 #include "gegl.h"
 #include "gegl-operation-point-composer3.h"
 #include "gegl-operation-context.h"
+#include "gegl-config.h"
 #include <string.h>
 
+static gboolean
+gegl_operation_composer3_process (GeglOperation        *operation,
+                                  GeglOperationContext *context,
+                                  const gchar          *output_prop,
+                                  const GeglRectangle  *result,
+                                  gint                  level)
+{
+  GeglOperationComposer3Class *klass   = GEGL_OPERATION_COMPOSER3_GET_CLASS (operation);
+  GeglOperationClass          *op_class = GEGL_OPERATION_CLASS (klass);
+  GeglBuffer                  *input;
+  GeglBuffer                  *aux;
+  GeglBuffer                  *aux2;
+  GeglBuffer                  *output;
+  gboolean                     success = FALSE;
+
+  if (strcmp (output_prop, "output"))
+    {
+      g_warning ("requested processing of %s pad on a composer", output_prop);
+      return FALSE;
+    }
+
+  if (result->width == 0 || result->height == 0)
+  {
+    output = gegl_operation_context_get_target (context, "output");
+    return TRUE;
+  }
+
+  input = gegl_operation_context_get_source (context, "input");
+
+  if (op_class->want_in_place && 
+      gegl_can_do_inplace_processing (operation, input, result))
+    {
+      output = g_object_ref (input);
+      gegl_operation_context_take_object (context, "output", G_OBJECT (output));
+    }
+  else
+    {
+      output = gegl_operation_context_get_target (context, "output");
+    }
+
+  aux   = gegl_operation_context_get_source (context, "aux");
+  aux2  = gegl_operation_context_get_source (context, "aux2");
+
+  /* A composer with a NULL aux, can still be valid, the
+   * subclass has to handle it.
+   */
+  if (input != NULL ||
+      aux != NULL ||
+      aux2 != NULL)
+    {
+      success = klass->process (operation, input, aux, aux2, output, result, level);
+
+      if (input)
+        g_object_unref (input);
+      if (aux)
+        g_object_unref (aux);
+      if (aux2)
+        g_object_unref (aux2);
+    }
+  else
+    {
+      g_warning ("%s received NULL input, aux, and aux2",
+                 gegl_node_get_operation (operation->node));
+    }
+
+  return success;
+}
+
 static gboolean gegl_operation_point_composer3_process
                               (GeglOperation       *operation,
                                GeglBuffer          *input,
@@ -54,6 +123,7 @@ gegl_operation_point_composer3_class_init (GeglOperationPointComposer3Class *kla
   GeglOperationComposer3Class *composer_class = GEGL_OPERATION_COMPOSER3_CLASS (klass);
 
   composer_class->process = gegl_operation_point_composer3_process;
+  operation_class->process = gegl_operation_composer3_process;
   operation_class->prepare = prepare;
   operation_class->no_cache =TRUE;
   operation_class->want_in_place = TRUE;


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