[gegl/wip/pippin/pipeline: 95/95] fnord



commit 8d5e46bf588559d8918bf42ac2af381816133e78
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Aug 8 02:47:24 2018 +0200

    fnord

 gegl/graph/gegl-node.c                   | 91 ++++++++++++++++++++++++++++++++
 gegl/graph/gegl-node.h                   |  6 +++
 gegl/operation/gegl-operation-pipeline.c | 57 +++++++++++++-------
 gegl/operation/gegl-operation.c          | 36 +++++++++++++
 gegl/operation/gegl-operation.h          |  3 ++
 5 files changed, 174 insertions(+), 19 deletions(-)
---
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 37641efbf..d7b0970f0 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -1956,6 +1956,97 @@ gegl_node_get_consumers (GeglNode      *node,
 }
 
 
+gint
+gegl_node_get_consumers2 (GeglNode      *node,
+                         const gchar   *output_pad,
+                         GeglNode    ***nodes,
+                         const gchar ***pads)
+{
+  GSList  *connections;
+  gint     n_connections;
+  GeglPad *pad;
+  gchar  **pasp = NULL;
+
+  g_return_val_if_fail (output_pad != NULL, 0);
+
+  if(node->is_graph)
+    node = gegl_node_get_input_proxy(node, "input");
+
+  g_return_val_if_fail (GEGL_IS_NODE (node), 0);
+
+  pad = gegl_node_get_pad (node, output_pad);
+
+  if (!pad)
+    {
+      g_warning ("%s: no such pad %s for %s",
+                 G_STRFUNC, output_pad, gegl_node_get_debug_name (node));
+      return 0;
+    }
+
+  connections = gegl_pad_get_connections (pad);
+  {
+    GSList *iter;
+    gint    pasp_size = 0;
+    gint    i;
+    gint    pasp_pos = 0;
+
+    n_connections = g_slist_length (connections);
+    pasp_size    += (n_connections + 1) * sizeof (gchar *);
+
+    for (iter = connections; iter; iter = g_slist_next (iter))
+      {
+        GeglConnection *connection = iter->data;
+        GeglPad        *pad        = gegl_connection_get_sink_pad (connection);
+        pasp_size += strlen (gegl_pad_get_name (pad)) + 1;
+      }
+    if (nodes)
+      *nodes = g_malloc ((n_connections + 1) * sizeof (void *));
+    if (pads)
+      {
+        pasp  = g_malloc (pasp_size);
+        *pads = (void *) pasp;
+      }
+    i        = 0;
+    pasp_pos = (n_connections + 1) * sizeof (void *);
+    for (iter = connections; iter; iter = g_slist_next (iter))
+      {
+        GeglConnection  *connection = iter->data;
+        GeglPad                 *pad        = gegl_connection_get_sink_pad (connection);
+        GeglNode        *node       = gegl_connection_get_sink_node (connection);
+        const gchar     *pad_name   = gegl_pad_get_name (pad);
+        const gchar     *name       = gegl_node_get_name(node);
+
+        gchar* proxy_name = g_strconcat("proxynop-", pad_name, NULL);
+        if(!strcmp(name, proxy_name))
+          {
+            node = g_object_get_data(G_OBJECT(node), "graph");
+            name = gegl_node_get_name(node);
+          }
+        else
+          {
+          }
+        g_free (proxy_name);
+
+        if (nodes)
+          (*nodes)[i] = node;
+        if (pasp)
+          {
+            pasp[i] = ((gchar *) pasp) + pasp_pos;
+            strcpy (pasp[i], pad_name);
+          }
+        pasp_pos += strlen (pad_name) + 1;
+        i++;
+      }
+    if (nodes)
+      (*nodes)[i] = NULL;
+    if (pads)
+      pasp[i] = NULL;
+  }
+  return n_connections;
+}
+
+
+
 void
 gegl_node_emit_computed (GeglNode *node,
                          const GeglRectangle *rect)
diff --git a/gegl/graph/gegl-node.h b/gegl/graph/gegl-node.h
index fdd803379..9efb54dbb 100644
--- a/gegl/graph/gegl-node.h
+++ b/gegl/graph/gegl-node.h
@@ -696,6 +696,12 @@ void       gegl_node_progress (GeglNode *node, gdouble progress, gchar *message)
 
 const char *gegl_operation_get_op_version (const gchar *op_name);
 
+gint
+gegl_node_get_consumers2 (GeglNode      *node,
+                         const gchar   *output_pad,
+                         GeglNode    ***nodes,
+                         const gchar ***pads);
+
 G_END_DECLS
 
 #endif /* __GEGL_NODE_H__ */
diff --git a/gegl/operation/gegl-operation-pipeline.c b/gegl/operation/gegl-operation-pipeline.c
index ce76fa79e..86e3d967d 100644
--- a/gegl/operation/gegl-operation-pipeline.c
+++ b/gegl/operation/gegl-operation-pipeline.c
@@ -52,7 +52,8 @@ struct _GeglOperationPipeLine {
   PipeEntry entry[PIPELINE_MAX];
 };
 
-
+/* returns true if the passed op could be part of a pipeline
+ */
 gboolean gegl_operation_is_pipelinable (GeglOperation *op)
 {
   gboolean ret = GEGL_IS_OPERATION_POINT_FILTER (op) ||
@@ -64,7 +65,7 @@ gboolean gegl_operation_is_pipelinable (GeglOperation *op)
     if (op_klass->want_in_place == FALSE)
       return FALSE;
   }
-  if (ret)
+  if (0 && ret)
   {
     const char *name = gegl_operation_get_name (op);
     if (!strcmp (name, "gimp:mask-components"))
@@ -75,20 +76,23 @@ gboolean gegl_operation_is_pipelinable (GeglOperation *op)
 
 static GeglNode *gegl_node_get_non_nop_producer (GeglNode *n)
 {
-  GeglNode *node = gegl_node_get_producer (n, "input", NULL);
+  GeglNode *node = gegl_operation_get_source_node (n->operation, "input");
+  gint n_consumers;
+  fprintf (stderr, "%s.\n", gegl_node_get_operation (n));
+  n_consumers = gegl_node_get_consumers (node, "output", NULL, NULL);
+  fprintf (stderr, ".%s %i.\n", node?gegl_node_get_operation (node):"-", n_consumers);
   while (node &&
-   (!strcmp (gegl_node_get_operation (node), "gegl:nop")) && !
+   (!strcmp (gegl_node_get_operation (node), "gegl:nop") ||
+   !strcmp (gegl_node_get_operation (node), "GraphNode"))
+   && (n_consumers == 1 /*|| n_consumers ==2*/) && !
    node->priv->eval_manager)
   {
-    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;
+    node = gegl_operation_get_source_node (node->operation, "input");
+    n_consumers = gegl_node_get_consumers (node, "output", NULL, NULL);
   }
+  if (n_consumers != 1 /*||n_consumers == 2*/)
+    node = NULL;
+  fprintf (stderr, "..%s %i\n", node?gegl_node_get_operation (node):"-", n_consumers);
   return node;
 }
 
@@ -134,26 +138,36 @@ gegl_operation_pipeline_is_intermediate_node (GeglOperation *op,
   GeglNode *it = op->node;
   GeglNode **consumers = NULL;
 
+  fprintf (stderr, "[%s\n", gegl_operation_get_name (op));
   if (op->node->priv->eval_manager)
   {
-    //fprintf (stderr, "chaughta a fraggel!\n");
+    fprintf (stderr, "chaughta a fraggel!\n");
     return FALSE;
   }
 
-  n_consumers = gegl_node_get_consumers (it, "output", &consumers, NULL);
+  n_consumers = gegl_node_get_consumers2 (it, "output", &consumers, NULL);
+
+  if (n_consumers == 0)
+    {
+      fprintf (stderr, "[[--\n");
+      is_intermediate = FALSE;
+    }
+
   it = consumers[0];
 #if 1
-  while (n_consumers == 1 && (!strcmp (gegl_node_get_operation (consumers[0]), "gegl:nop")) && 
!consumers[0]->priv->eval_manager)
+  while ((n_consumers == 1 /* || n_consumers==2*/)&& 
+       (!strcmp (gegl_node_get_operation (consumers[0]), "gegl:nop")||
+        !strcmp (gegl_node_get_operation (consumers[0]), "GraphNode")))
   {
     it = consumers[0];
     g_free (consumers);
-    n_consumers = gegl_node_get_consumers (it, "output", &consumers, NULL);
+    n_consumers = gegl_node_get_consumers2 (it, "output", &consumers, NULL);
   }
 #endif
 
-  if (n_consumers == 0)
+  if (n_consumers == 0 && it != op->node)
     {
-      is_intermediate = FALSE;
+      return TRUE;
     }
   else if (n_consumers == 1)
     {
@@ -165,9 +179,14 @@ gegl_operation_pipeline_is_intermediate_node (GeglOperation *op,
           is_intermediate = FALSE;
       else
           is_intermediate = TRUE;
+      fprintf (stderr, "[[%s %s\n", gegl_operation_get_name (sink), is_intermediate?"pipelineable":"not 
pipelineable");
     }
   else
+   {
     is_intermediate = FALSE;
+      fprintf (stderr, "[%s=--%i-\n",
+         gegl_operation_get_name (consumers[0]->operation), n_consumers);
+   }
 
   g_free (consumers);
 
@@ -421,7 +440,7 @@ gegl_operation_pipeline_process (GeglOperationPipeLine *pipeline,
 {
   gint threads = gegl_config_threads();
 
-  if (0) {
+  if (1) {
     gint e;
     fprintf (stderr, "{%i}", pipeline->entries);
     for (e = 0; e < pipeline->entries; e++)
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index de7bc9ccd..956977f88 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -381,6 +381,42 @@ gegl_operation_get_source_node (GeglOperation *operation,
   return gegl_pad_get_node (pad);
 }
 
+GeglNode *
+gegl_operation_get_target_node (GeglOperation *operation,
+                                const gchar   *output_pad_name)
+{
+  GeglNode *node;
+  GeglPad *pad;
+
+  g_return_val_if_fail (GEGL_IS_OPERATION (operation), NULL);
+  g_return_val_if_fail (GEGL_IS_NODE (operation->node), NULL);
+  g_return_val_if_fail (output_pad_name != NULL, NULL);
+
+  node = operation->node;
+#if 0
+  if (node->is_graph)
+    {
+      node = gegl_node_get_output_proxy (node, output_pad_name);
+      output_pad_name = "input";
+    }
+#endif
+
+  pad = gegl_node_get_pad (node, output_pad_name);
+
+  if (!pad)
+    return NULL;
+
+  pad = gegl_pad_get_connected_to (pad);
+
+  if (!pad)
+    return NULL;
+
+  g_assert (gegl_pad_get_node (pad));
+
+  return gegl_pad_get_node (pad);
+}
+
+
 GeglRectangle *
 gegl_operation_source_get_bounding_box (GeglOperation *operation,
                                         const gchar   *input_pad_name)
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index a48e2adc9..c5a929d91 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -300,6 +300,9 @@ void       gegl_operation_progress (GeglOperation *operation, gdouble progress,
 
 const Babl *gegl_operation_get_source_space (GeglOperation *operation, const char *in_pad);
 
+GeglNode *
+gegl_operation_get_target_node (GeglOperation *operation,
+                                const gchar   *output_pad_name);
 
 G_END_DECLS
 


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