[gegl/wip/pippin/pipeline: 86/95] pipeline update



commit fa72ece5b1217a7b4436888c370f3b8fc8ff2057
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jul 25 14:38:12 2018 +0200

    pipeline update

 gegl/operation/gegl-operation-pipeline.c | 156 ++++++++++++++++---------------
 gegl/operation/gegl-operation-pipeline.h |  21 +++--
 2 files changed, 96 insertions(+), 81 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-pipeline.c b/gegl/operation/gegl-operation-pipeline.c
index 63f1b4033..74b3beedc 100644
--- a/gegl/operation/gegl-operation-pipeline.c
+++ b/gegl/operation/gegl-operation-pipeline.c
@@ -14,6 +14,7 @@
 #include "gegl-types-internal.h"
 #include "gegl-buffer-private.h"
 #include "gegl-tile-storage.h"
+#include <gegl-node-private.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <string.h>
@@ -27,10 +28,9 @@ typedef struct {
   void         (*process)(void *);
   GeglBuffer    *aux;
   GeglBuffer    *aux2;
-  int            aux_handle;
-  int            aux2_handle;
+  int            aux_handle;  /* these values are deterministic */
+  int            aux2_handle; /* and can scarily be shared among processes */
   const Babl    *input_fish;
-
   const Babl    *in_format;
   const Babl    *aux_format;
   const Babl    *aux2_format;
@@ -45,7 +45,7 @@ typedef struct {
  */
 
 
-struct _PipeLine {
+struct _GeglOperationPipeLine {
   int entries;
   GeglBuffer *input;
   int buffers_used;
@@ -53,53 +53,68 @@ struct _PipeLine {
 };
 
 
-static gboolean is_pipelinable_op (GeglOperation *op)
+gboolean gegl_operation_is_pipelinable (GeglOperation *op)
 {
-  return GEGL_IS_OPERATION_POINT_FILTER (op) ||
+  gboolean ret = GEGL_IS_OPERATION_POINT_FILTER (op) ||
          GEGL_IS_OPERATION_POINT_COMPOSER (op) ||
          GEGL_IS_OPERATION_POINT_COMPOSER3 (op);
+  if (ret)
+  {
+    GeglOperationClass *op_klass = GEGL_OPERATION_GET_CLASS (op);
+    if (op_klass->want_in_place == FALSE)
+      return FALSE;
+  }
+  if (ret)
+  {
+    const char *name = gegl_operation_get_name (op);
+    if (!strcmp (name, "gimp:mask-components"))
+      return FALSE;
+  }
+  return ret;
 }
 
-#if 0
-static int in_pads_for_op (GeglOperation *op)
-{
-  if (GEGL_IS_OPERATION_POINT_FILTER (op)) return 1;
-  if (GEGL_IS_OPERATION_POINT_COMPOSER (op)) return 2;
-  if (GEGL_IS_OPERATION_POINT_COMPOSER3 (op)) return 3;
-  return 0;
-}
-#endif
-
 static GeglNode *gegl_node_get_non_nop_producer (GeglNode *n)
 {
+  // XXX: look out for forks of the data/
   GeglNode *node = gegl_node_get_producer (n, "input", NULL);
-  while (node && 
-   (!strcmp (gegl_node_get_operation (node), "gegl:nop")))
+  if (!strcmp (gegl_node_get_operation (node), "gegl:nop"))
+    return NULL;
+  return node;
+  while (node &&
+   (!strcmp (gegl_node_get_operation (node), "gegl:nop")) && !
+   node->priv->eval_manager)
   {
-    node = gegl_node_get_producer (node, "input", NULL);
+    gint n_consumers;
+    GeglNode **consumers = NULL;
+    n_consumers = gegl_node_get_consumers (node, "output", &consumers, NULL);
+    g_free (consumers);
+    if (n_consumers == 1)
+      node = gegl_node_get_producer (node, "input", NULL);
+    else
+      node = NULL;
   }
   return node;
 }
 
-PipeLine *
+GeglOperationPipeLine *
 gegl_operation_pipeline_ensure (GeglOperation        *operation,
                                 GeglOperationContext *context,
                                 GeglBuffer           *input)
 {
-  PipeLine *pipeline;
+  GeglOperationPipeLine *pipeline = NULL;
   GeglNode *source_node;
   GeglOperationContext *source_context;
   source_node = gegl_node_get_non_nop_producer (operation->node);
-  if (!source_node)
-    return FALSE;
-
-  source_context = gegl_operation_context_node_get_context (context, source_node);
-  pipeline = gegl_operation_context_get_pipeline (source_context);
-  gegl_operation_context_set_pipeline (source_context, NULL);
+  if (source_node && !source_node->priv->eval_manager)
+  {
+    source_context = gegl_operation_context_node_get_context (context, source_node);
+    pipeline = gegl_operation_context_get_pipeline (source_context);
+    gegl_operation_context_set_pipeline (source_context, NULL);
+  }
 
   if (!pipeline)
   {
-    pipeline = g_malloc0 (sizeof (PipeLine));
+    pipeline = g_malloc0 (sizeof (GeglOperationPipeLine));
     pipeline->buffers_used = 2; // input and output
   }
   gegl_operation_context_set_pipeline (context, pipeline);
@@ -116,21 +131,29 @@ gegl_operation_pipeline_ensure (GeglOperation        *operation,
  */
 gboolean
 gegl_operation_pipeline_is_intermediate_node (GeglOperation *op,
-                                              PipeLine *pipeline)
+                                              GeglOperationPipeLine *pipeline)
 {
   gboolean is_intermediate = TRUE;
   gint n_consumers;
   GeglNode *it = op->node;
   GeglNode **consumers = NULL;
 
+  if (op->node->priv->eval_manager)
+  {
+    fprintf (stderr, "chaughta a fraggel!\n");
+    return FALSE;
+  }
+
   n_consumers = gegl_node_get_consumers (it, "output", &consumers, NULL);
   it = consumers[0];
-  while (n_consumers == 1 && (!strcmp (gegl_node_get_operation (consumers[0]), "gegl:nop")))
+#if 0
+  while (n_consumers == 1 && (!strcmp (gegl_node_get_operation (consumers[0]), "gegl:nop")) && 
!consumers[0]->priv->eval_manager)
   {
     it = consumers[0];
     g_free (consumers);
     n_consumers = gegl_node_get_consumers (it, "output", &consumers, NULL);
   }
+#endif
 
   if (n_consumers == 0)
     {
@@ -140,27 +163,12 @@ gegl_operation_pipeline_is_intermediate_node (GeglOperation *op,
     {
       GeglOperation *sink = gegl_node_get_gegl_operation (consumers[0]);
 
-      if (! is_pipelinable_op (sink))
-        {
-          is_intermediate = FALSE;
-        }
-
-      if (pipeline->entries + 1 >= PIPELINE_MAX)
-        {
+      if (! gegl_operation_is_pipelinable (sink))
           is_intermediate = FALSE;
-        }
-
-#if 0 /* no longer needed with the new buffer iterator that has configurable
-         size
-*/
-      /* would blow our budget of buffer handles in buffer iterator API */
-      if (pipeline->buffers_used + (in_pads_for_op (sink)-1) >
-          GEGL_BUFFER_MAX_ITERATORS)
-        {
+      else if (pipeline->entries + 1 >= PIPELINE_MAX)
           is_intermediate = FALSE;
-        }
-#endif
-
+      else
+          is_intermediate = TRUE;
     }
   else
     is_intermediate = FALSE;
@@ -171,27 +179,7 @@ gegl_operation_pipeline_is_intermediate_node (GeglOperation *op,
 }
 
 gboolean
-gegl_operation_pipeline_is_composite_node (GeglOperation *op)
-{
-#if 0 // unused, perhaps remove?
-  GeglNode *source_node;
-  GeglOperation *source;
-  source_node = gegl_node_get_producer (op->node, "input", NULL);
-
-  if (!source_node)
-    return FALSE;
-
-  source = gegl_node_get_gegl_operation (source_node);
-
-  return (is_pipelinable_op (source) &&
-          gegl_operation_pipeline_is_intermediate_node (source));
-#endif
-  return FALSE;
-}
-
-
-gboolean
-gegl_operation_pipeline_process (PipeLine            *pipeline,
+gegl_operation_pipeline_process (GeglOperationPipeLine            *pipeline,
                                  GeglBuffer          *output,
                                  const GeglRectangle *result,
                                  gint                 level)
@@ -215,6 +203,8 @@ gegl_operation_pipeline_process (PipeLine            *pipeline,
     gint e;
     for (e = 0; e < pipeline->entries; e++)
     {
+      PipeEntry *entry = &pipeline->entry[e];
+      fprintf (stderr, "%s ", gegl_operation_get_name (entry->operation));
       switch (pipeline->entry[e].in_pads)
       {
         case 3:
@@ -235,6 +225,7 @@ gegl_operation_pipeline_process (PipeLine            *pipeline,
       }
     }
   }
+  fprintf (stderr, "\n");
 
   while (gegl_buffer_iterator_next (i))
     {
@@ -380,8 +371,18 @@ gegl_operation_pipeline_process (PipeLine            *pipeline,
   return TRUE;
 }
 
+
+gboolean
+gegl_operation_pipeline_process_threaded  (GeglOperationPipeLine            *pipeline,
+                                           GeglBuffer          *output,
+                                           const GeglRectangle *result,
+                                           gint                 level)
+{
+  return gegl_operation_pipeline_process_threaded (pipeline, output, result, level);
+}
+
 void
-gegl_operation_pipeline_add (PipeLine      *pipeline,
+gegl_operation_pipeline_add (GeglOperationPipeLine      *pipeline,
                              GeglOperation *operation,
                              gint           in_pads,
                              const Babl    *in_format,
@@ -392,10 +393,15 @@ gegl_operation_pipeline_add (PipeLine      *pipeline,
                              GeglBuffer    *aux2,
                              void *process)
 {
-  PipeEntry *entry = &pipeline->entry[pipeline->entries];
-  PipeEntry *prev_entry = pipeline->entries?&pipeline->entry[pipeline->entries-1]:NULL;
+  PipeEntry *entry;
+  PipeEntry *prev_entry;
+
+  g_assert (pipeline);
   g_assert (pipeline->entries + 1 <= PIPELINE_MAX);
 
+  entry = &pipeline->entry[pipeline->entries];
+  prev_entry = pipeline->entries?&pipeline->entry[pipeline->entries-1]:NULL;
+
   entry->operation  = operation;
   entry->in_pads    = in_pads;
   entry->in_format  = in_format;
@@ -416,14 +422,14 @@ gegl_operation_pipeline_add (PipeLine      *pipeline,
   pipeline->buffers_used += ( (aux?1:0) + (aux2?1:0));
 }
 
-int gegl_operation_pipeline_get_entries (PipeLine *pipeline)
+int gegl_operation_pipeline_get_entries (GeglOperationPipeLine *pipeline)
 {
   return pipeline->entries;
 }
 
 
 
-void gegl_operation_pipeline_set_input  (PipeLine   *pipeline,
+void gegl_operation_pipeline_set_input  (GeglOperationPipeLine   *pipeline,
                                          GeglBuffer *buffer)
 {
   pipeline->input = buffer;
diff --git a/gegl/operation/gegl-operation-pipeline.h b/gegl/operation/gegl-operation-pipeline.h
index f343f7e69..d22452fd2 100644
--- a/gegl/operation/gegl-operation-pipeline.h
+++ b/gegl/operation/gegl-operation-pipeline.h
@@ -1,27 +1,28 @@
 #ifndef _GEGL_OPERATION_PIPELINE_H
 #define _GEGL_OPERATION_PIPELINE_H
 
-int gegl_operation_pipeline_get_entries (PipeLine   *pipeline);
-void gegl_operation_pipeline_set_input  (PipeLine   *pipeline,
+
+int gegl_operation_pipeline_get_entries (GeglOperationPipeLine   *pipeline);
+void gegl_operation_pipeline_set_input  (GeglOperationPipeLine   *pipeline,
                                          GeglBuffer *buffer);
 
 gboolean
 gegl_operation_pipeline_is_intermediate_node (GeglOperation *op,
-                                              PipeLine *pipeline);
+                                              GeglOperationPipeLine *pipeline);
 gboolean gegl_operation_pipeline_is_composite_node (GeglOperation *op);
 
-gboolean gegl_operation_pipeline_process (PipeLine            *pipeline,
+gboolean gegl_operation_pipeline_process (GeglOperationPipeLine            *pipeline,
                                           GeglBuffer          *output,
                                           const GeglRectangle *result,
                                           gint                 level);
-PipeLine *
+GeglOperationPipeLine *
 gegl_operation_pipeline_ensure (GeglOperation *operation,
                                 GeglOperationContext *context,
                                 GeglBuffer           *input);
 
 
 void
-gegl_operation_pipeline_add (PipeLine *pipeline,
+gegl_operation_pipeline_add (GeglOperationPipeLine *pipeline,
                              GeglOperation *operation,
                              gint           in_pads,
                              const Babl    *in_format,
@@ -32,4 +33,12 @@ gegl_operation_pipeline_add (PipeLine *pipeline,
                              GeglBuffer    *aux2,
                              void *process);
 
+gboolean
+gegl_operation_pipeline_process_threaded  (GeglOperationPipeLine            *pipeline,
+                                           GeglBuffer          *output,
+                                           const GeglRectangle *result,
+                                           gint                 level);
+
+gboolean gegl_operation_is_pipelinable (GeglOperation *op);
+
 #endif


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