[gimp/wip/passthrough: 30/32] app: implement {begin, end}_render() for GimpGroupLayer



commit c18d8fbcdb2c97a1abe0f895599afe8aa2242bcc
Author: Ell <ell_se yahoo com>
Date:   Sat Apr 22 14:28:54 2017 -0400

    app: implement {begin,end}_render() for GimpGroupLayer
    
    Use them to connect/disconnect the stack graph when the group is
    in pass-through mode.

 app/core/gimpgrouplayer.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index b09381f..3bbacf5 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -153,6 +153,9 @@ static void            gimp_group_layer_mode_changed (GimpLayer         *layer);
 
 static const Babl    * gimp_group_layer_get_format   (GimpProjectable *projectable);
 static GeglNode      * gimp_group_layer_get_graph    (GimpProjectable *projectable);
+static void            gimp_group_layer_begin_render (GimpProjectable *projectable);
+static void            gimp_group_layer_end_render   (GimpProjectable *projectable);
+
 static gdouble       gimp_group_layer_get_opacity_at (GimpPickable    *pickable,
                                                       gint             x,
                                                       gint             y);
@@ -257,6 +260,8 @@ gimp_projectable_iface_init (GimpProjectableInterface *iface)
   iface->get_offset         = (void (*) (GimpProjectable*, gint*, gint*)) gimp_item_get_offset;
   iface->get_size           = (void (*) (GimpProjectable*, gint*, gint*)) gimp_viewable_get_size;
   iface->get_graph          = gimp_group_layer_get_graph;
+  iface->begin_render       = gimp_group_layer_begin_render;
+  iface->end_render         = gimp_group_layer_end_render;
   iface->invalidate_preview = (void (*) (GimpProjectable*)) gimp_viewable_invalidate_preview;
 }
 
@@ -1064,6 +1069,41 @@ gimp_group_layer_get_graph (GimpProjectable *projectable)
   return private->graph;
 }
 
+static void
+gimp_group_layer_begin_render (GimpProjectable *projectable)
+{
+  GimpGroupLayerPrivate *private = GET_PRIVATE (projectable);
+
+  if (private->source_node == NULL)
+    return;
+
+  if (gimp_layer_get_mode (GIMP_LAYER (projectable)) ==
+      GIMP_LAYER_MODE_PASS_THROUGH)
+    {
+      gegl_node_disconnect (private->graph, "input");
+    }
+}
+
+static void
+gimp_group_layer_end_render (GimpProjectable *projectable)
+{
+  GimpGroupLayerPrivate *private = GET_PRIVATE (projectable);
+
+  if (private->source_node == NULL)
+    return;
+
+  if (gimp_layer_get_mode (GIMP_LAYER (projectable)) ==
+      GIMP_LAYER_MODE_PASS_THROUGH)
+    {
+      GeglNode *input;
+
+      input = gegl_node_get_input_proxy (private->source_node, "input");
+
+      gegl_node_connect_to (input,          "output",
+                            private->graph, "input");
+    }
+}
+
 static gdouble
 gimp_group_layer_get_opacity_at (GimpPickable *pickable,
                                  gint          x,


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