[gimp] app: set paint_mode and opacity separately on mode nodes



commit a93eaa9122bc884ac52e359cab772ee580c32972
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 22 22:53:07 2013 +0200

    app: set paint_mode and opacity separately on mode nodes
    
    so we don't constantly change the operation only because the opacity
    varies during painting.

 app/core/gimplayer.c       | 24 ++++++++++++------------
 app/gegl/gimp-gegl-nodes.c | 18 +++++++++++++-----
 app/gegl/gimp-gegl-nodes.h |  5 +++--
 app/gegl/gimpapplicator.c  | 25 ++++++++++++++++---------
 4 files changed, 44 insertions(+), 28 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 4fdc4bb..42b79df 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -494,9 +494,9 @@ gimp_layer_notify (GObject    *object,
 
       mode_node = gimp_drawable_get_mode_node (GIMP_DRAWABLE (layer));
 
-      gimp_gegl_mode_node_set (mode_node,
-                               gimp_layer_get_visible_mode (layer),
-                               layer->opacity, FALSE);
+      gimp_gegl_mode_node_set_mode (mode_node,
+                                    gimp_layer_get_visible_mode (layer),
+                                    FALSE);
 
       gimp_drawable_update (GIMP_DRAWABLE (layer),
                             0, 0,
@@ -594,9 +594,11 @@ gimp_layer_get_node (GimpFilter *filter)
    */
   mode_node = gimp_drawable_get_mode_node (drawable);
 
-  gimp_gegl_mode_node_set (mode_node,
-                           gimp_layer_get_visible_mode (layer),
-                           layer->opacity, FALSE);
+  gimp_gegl_mode_node_set_mode (mode_node,
+                                gimp_layer_get_visible_mode (layer),
+                                FALSE);
+  gimp_gegl_mode_node_set_opacity (mode_node,
+                                   layer->opacity);
 
   /* the layer's offset node */
   layer->layer_offset_node = gegl_node_new_child (node,
@@ -1984,9 +1986,7 @@ gimp_layer_set_opacity (GimpLayer *layer,
 
           mode_node = gimp_drawable_get_mode_node (GIMP_DRAWABLE (layer));
 
-          gimp_gegl_mode_node_set (mode_node,
-                                   gimp_layer_get_visible_mode (layer),
-                                   layer->opacity, FALSE);
+          gimp_gegl_mode_node_set_opacity (mode_node, layer->opacity);
         }
 
       gimp_drawable_update (GIMP_DRAWABLE (layer),
@@ -2031,9 +2031,9 @@ gimp_layer_set_mode (GimpLayer            *layer,
 
           mode_node = gimp_drawable_get_mode_node (GIMP_DRAWABLE (layer));
 
-          gimp_gegl_mode_node_set (mode_node,
-                                   gimp_layer_get_visible_mode (layer),
-                                   layer->opacity, FALSE);
+          gimp_gegl_mode_node_set_mode (mode_node,
+                                        gimp_layer_get_visible_mode (layer),
+                                        FALSE);
         }
 
       gimp_drawable_update (GIMP_DRAWABLE (layer),
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index 05494b3..5bd1f1b 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -139,10 +139,9 @@ gimp_gegl_add_buffer_source (GeglNode   *parent,
 }
 
 void
-gimp_gegl_mode_node_set (GeglNode             *node,
-                         GimpLayerModeEffects  mode,
-                         gdouble               opacity,
-                         gboolean              linear)
+gimp_gegl_mode_node_set_mode (GeglNode             *node,
+                              GimpLayerModeEffects  mode,
+                              gboolean              linear)
 {
   const gchar *operation = "gimp:normal-mode";
 
@@ -182,11 +181,20 @@ gimp_gegl_mode_node_set (GeglNode             *node,
 
   gegl_node_set (node,
                  "operation", operation,
-                 "opacity",   opacity,
                  "linear",    linear,
                  NULL);
 }
 
+gimp_gegl_mode_node_set_opacity (GeglNode *node,
+                                 gdouble   opacity)
+{
+  g_return_if_fail (GEGL_IS_NODE (node));
+
+  gegl_node_set (node,
+                 "opacity", opacity,
+                 NULL);
+}
+
 void
 gimp_gegl_node_set_matrix (GeglNode          *node,
                            const GimpMatrix3 *matrix)
diff --git a/app/gegl/gimp-gegl-nodes.h b/app/gegl/gimp-gegl-nodes.h
index a3bf092..ba7ae70 100644
--- a/app/gegl/gimp-gegl-nodes.h
+++ b/app/gegl/gimp-gegl-nodes.h
@@ -32,10 +32,11 @@ GeglNode * gimp_gegl_add_buffer_source         (GeglNode             *parent,
                                                 gint                  offset_x,
                                                 gint                  offset_y);
 
-void       gimp_gegl_mode_node_set             (GeglNode             *node,
+void       gimp_gegl_mode_node_set_mode        (GeglNode             *node,
                                                 GimpLayerModeEffects  mode,
-                                                gdouble               opacity,
                                                 gboolean              linear);
+void       gimp_gegl_mode_node_set_opacity     (GeglNode             *node,
+                                                gdouble               opacity);
 void       gimp_gegl_node_set_matrix           (GeglNode             *node,
                                                 const GimpMatrix3    *matrix);
 
diff --git a/app/gegl/gimpapplicator.c b/app/gegl/gimpapplicator.c
index 90787a9..32f4d0a 100644
--- a/app/gegl/gimpapplicator.c
+++ b/app/gegl/gimpapplicator.c
@@ -131,10 +131,11 @@ gimp_applicator_new (GeglNode *parent)
                                                "operation", "gimp:normal-mode",
                                                NULL);
 
-  gimp_gegl_mode_node_set (applicator->mode_node,
-                           applicator->paint_mode,
-                           applicator->opacity,
-                           FALSE);
+  gimp_gegl_mode_node_set_mode (applicator->mode_node,
+                                applicator->paint_mode,
+                                FALSE);
+  gimp_gegl_mode_node_set_opacity (applicator->mode_node,
+                                   applicator->opacity);
 
   gegl_node_connect_to (applicator->input_node, "output",
                         applicator->mode_node,  "input");
@@ -376,14 +377,20 @@ gimp_applicator_set_mode (GimpApplicator       *applicator,
                           gdouble               opacity,
                           GimpLayerModeEffects  paint_mode)
 {
-  if (applicator->opacity    != opacity ||
-      applicator->paint_mode != paint_mode)
+  if (applicator->opacity != opacity)
+    {
+      applicator->opacity = opacity;
+
+      gimp_gegl_mode_node_set_opacity (applicator->mode_node,
+                                       opacity);
+    }
+
+  if (applicator->paint_mode != paint_mode)
     {
-      applicator->opacity    = opacity;
       applicator->paint_mode = paint_mode;
 
-      gimp_gegl_mode_node_set (applicator->mode_node,
-                               paint_mode, opacity, FALSE);
+      gimp_gegl_mode_node_set_mode (applicator->mode_node,
+                                    paint_mode, FALSE);
     }
 }
 


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