gimp r27230 - in trunk: . app/core



Author: mitch
Date: Sat Oct 11 10:29:19 2008
New Revision: 27230
URL: http://svn.gnome.org/viewvc/gimp?rev=27230&view=rev

Log:
2008-10-11  Michael Natterer  <mitch gimp org>

	* app/core/gimpchannel.[ch]: add a projection node and
	implement GimpDrawable::get_node(). Reconfigure the node in
	visibility_changed(), set_color(), set_opacity() and
	set_show_masked().

	* app/core/gimpimage.c (gimp_image_get_graph): enable code that
	projects the channels stack on top of the layer stack.

	* app/core/gimpprojection-construct.c: remove the call to
	gimp_projection_construct_channels() from the GEGL code path. Also
	don't touch proj->construct_flag.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpchannel.c
   trunk/app/core/gimpchannel.h
   trunk/app/core/gimpimage.c
   trunk/app/core/gimpprojection-construct.c

Modified: trunk/app/core/gimpchannel.c
==============================================================================
--- trunk/app/core/gimpchannel.c	(original)
+++ trunk/app/core/gimpchannel.c	Sat Oct 11 10:29:19 2008
@@ -65,6 +65,13 @@
 };
 
 
+#ifdef __GNUC__
+#warning FIXME: gegl_node_add_child() needs to be public
+#endif
+GeglNode * gegl_node_add_child (GeglNode *self,
+                                GeglNode *child);
+
+
 static void gimp_channel_pickable_iface_init (GimpPickableInterface *iface);
 
 static void       gimp_channel_finalize      (GObject          *object);
@@ -75,6 +82,7 @@
 static gchar  * gimp_channel_get_description (GimpViewable     *viewable,
                                               gchar           **tooltip);
 
+static void       gimp_channel_visibility_changed (GimpItem    *item);
 static gboolean   gimp_channel_is_attached   (GimpItem         *item);
 static GimpItem * gimp_channel_duplicate     (GimpItem         *item,
                                               GType             new_type);
@@ -150,6 +158,7 @@
                                               GimpImageType     type,
                                               gint              offset_x,
                                               gint              offset_y);
+static GeglNode * gimp_channel_get_node      (GimpDrawable     *drawable);
 static void      gimp_channel_swap_pixels    (GimpDrawable     *drawable,
                                               TileManager      *tiles,
                                               gboolean          sparse,
@@ -244,31 +253,33 @@
   viewable_class->get_description  = gimp_channel_get_description;
   viewable_class->default_stock_id = "gimp-channel";
 
-  item_class->is_attached    = gimp_channel_is_attached;
-  item_class->duplicate      = gimp_channel_duplicate;
-  item_class->convert        = gimp_channel_convert;
-  item_class->translate      = gimp_channel_translate;
-  item_class->scale          = gimp_channel_scale;
-  item_class->resize         = gimp_channel_resize;
-  item_class->flip           = gimp_channel_flip;
-  item_class->rotate         = gimp_channel_rotate;
-  item_class->transform      = gimp_channel_transform;
-  item_class->stroke         = gimp_channel_stroke;
-  item_class->default_name   = _("Channel");
-  item_class->rename_desc    = _("Rename Channel");
-  item_class->translate_desc = _("Move Channel");
-  item_class->scale_desc     = _("Scale Channel");
-  item_class->resize_desc    = _("Resize Channel");
-  item_class->flip_desc      = _("Flip Channel");
-  item_class->rotate_desc    = _("Rotate Channel");
-  item_class->transform_desc = _("Transform Channel");
-  item_class->stroke_desc    = _("Stroke Channel");
+  item_class->visibility_changed   = gimp_channel_visibility_changed;
+  item_class->is_attached          = gimp_channel_is_attached;
+  item_class->duplicate            = gimp_channel_duplicate;
+  item_class->convert              = gimp_channel_convert;
+  item_class->translate            = gimp_channel_translate;
+  item_class->scale                = gimp_channel_scale;
+  item_class->resize               = gimp_channel_resize;
+  item_class->flip                 = gimp_channel_flip;
+  item_class->rotate               = gimp_channel_rotate;
+  item_class->transform            = gimp_channel_transform;
+  item_class->stroke               = gimp_channel_stroke;
+  item_class->default_name         = _("Channel");
+  item_class->rename_desc          = _("Rename Channel");
+  item_class->translate_desc       = _("Move Channel");
+  item_class->scale_desc           = _("Scale Channel");
+  item_class->resize_desc          = _("Resize Channel");
+  item_class->flip_desc            = _("Flip Channel");
+  item_class->rotate_desc          = _("Rotate Channel");
+  item_class->transform_desc       = _("Transform Channel");
+  item_class->stroke_desc          = _("Stroke Channel");
 
   drawable_class->invalidate_boundary   = gimp_channel_invalidate_boundary;
   drawable_class->get_active_components = gimp_channel_get_active_components;
   drawable_class->apply_region          = gimp_channel_apply_region;
   drawable_class->replace_region        = gimp_channel_replace_region;
   drawable_class->set_tiles             = gimp_channel_set_tiles;
+  drawable_class->get_node              = gimp_channel_get_node;
   drawable_class->swap_pixels           = gimp_channel_swap_pixels;
 
   klass->boundary       = gimp_channel_real_boundary;
@@ -325,6 +336,12 @@
 {
   GimpChannel *channel = GIMP_CHANNEL (object);
 
+  if (channel->node)
+    {
+      g_object_unref (channel->node);
+      channel->node = NULL;
+    }
+
   if (channel->segs_in)
     {
       g_free (channel->segs_in);
@@ -366,6 +383,39 @@
                                                               tooltip);
 }
 
+static void
+gimp_channel_visibility_changed (GimpItem *item)
+{
+  GimpChannel *channel = GIMP_CHANNEL (item);
+
+  if (channel->node)
+    {
+      GeglNode *input;
+      GeglNode *output;
+
+      input  = gegl_node_get_input_proxy (channel->node, "input");
+      output = gegl_node_get_output_proxy (channel->node, "output");
+
+      if (gimp_item_get_visible (item))
+        {
+          gegl_node_connect_to (input,              "output",
+                                channel->mode_node, "input");
+          gegl_node_connect_to (channel->mode_node, "output",
+                                output,             "input");
+        }
+      else
+        {
+          gegl_node_disconnect (channel->mode_node, "input");
+
+          gegl_node_connect_to (input,  "output",
+                                output, "input");
+        }
+    }
+
+  if (GIMP_ITEM_CLASS (parent_class)->visibility_changed)
+    GIMP_ITEM_CLASS (parent_class)->visibility_changed (item);
+}
+
 static gboolean
 gimp_channel_is_attached (GimpItem *item)
 {
@@ -822,6 +872,89 @@
   GIMP_CHANNEL (drawable)->bounds_known = FALSE;
 }
 
+static GeglNode *
+gimp_channel_get_node (GimpDrawable *drawable)
+{
+  GimpChannel *channel = GIMP_CHANNEL (drawable);
+  GeglNode    *source;
+  GeglNode    *input;
+  GeglNode    *output;
+  GeglColor   *color;
+
+  g_printerr ("%s 1\n", G_STRFUNC);
+
+  if (channel->node)
+    return channel->node;
+
+  g_printerr ("%s 2\n", G_STRFUNC);
+
+  channel->node = gegl_node_new ();
+
+  source = gimp_drawable_get_source_node (drawable);
+  gegl_node_add_child (channel->node, source);
+
+  color = gegl_color_new (NULL);
+  gegl_color_set_rgba (color,
+                       channel->color.r,
+                       channel->color.g,
+                       channel->color.b,
+                       channel->color.a);
+
+  channel->color_node = gegl_node_new_child (channel->node,
+                                             "operation", "color",
+                                             "value",     color,
+                                             NULL);
+
+  g_object_unref (color);
+
+  channel->mask_node = gegl_node_new_child (channel->node,
+                                            "operation", "opacity",
+                                            NULL);
+  gegl_node_connect_to (channel->color_node, "output",
+                        channel->mask_node,  "input");
+
+  channel->invert_node = gegl_node_new_child (channel->node,
+                                              "operation", "invert",
+                                              NULL);
+
+  if (channel->show_masked)
+    {
+      gegl_node_connect_to (source,               "output",
+                            channel->invert_node, "input");
+      gegl_node_connect_to (channel->invert_node, "output",
+                            channel->mask_node,   "aux");
+    }
+  else
+    {
+      gegl_node_connect_to (source,             "output",
+                            channel->mask_node, "aux");
+    }
+
+  channel->mode_node = gegl_node_new_child (channel->node,
+                                            "operation", "normal",
+                                            NULL);
+  gegl_node_connect_to (channel->mask_node, "output",
+                        channel->mode_node, "aux");
+
+  input  = gegl_node_get_input_proxy (channel->node, "input");
+  output = gegl_node_get_output_proxy (channel->node, "output");
+
+  if (gimp_item_get_visible (GIMP_ITEM (channel)))
+    {
+      gegl_node_connect_to (input,              "output",
+                            channel->mode_node, "input");
+      gegl_node_connect_to (channel->mode_node, "output",
+                            output,             "input");
+    }
+  else
+    {
+      gegl_node_connect_to (input,  "output",
+                            output, "input");
+    }
+
+  return channel->node;
+}
+
 static void
 gimp_channel_swap_pixels (GimpDrawable *drawable,
                           TileManager  *tiles,
@@ -1634,6 +1767,24 @@
 
       channel->color = *color;
 
+      if (channel->color_node)
+        {
+          GeglColor *gegl_color;
+
+          gegl_color = gegl_color_new (NULL);
+          gegl_color_set_rgba (gegl_color,
+                               channel->color.r,
+                               channel->color.g,
+                               channel->color.b,
+                               channel->color.a);
+
+          gegl_node_set (channel->color_node,
+                         "value", gegl_color,
+                         NULL);
+
+          g_object_unref (gegl_color);
+        }
+
       gimp_drawable_update (GIMP_DRAWABLE (channel),
                             0, 0,
                             gimp_item_width  (GIMP_ITEM (channel)),
@@ -1682,6 +1833,24 @@
 
       channel->color.a = opacity;
 
+      if (channel->color_node)
+        {
+          GeglColor *gegl_color;
+
+          gegl_color = gegl_color_new (NULL);
+          gegl_color_set_rgba (gegl_color,
+                               channel->color.r,
+                               channel->color.g,
+                               channel->color.b,
+                               channel->color.a);
+
+          gegl_node_set (channel->color_node,
+                         "value", gegl_color,
+                         NULL);
+
+          g_object_unref (gegl_color);
+        }
+
       gimp_drawable_update (GIMP_DRAWABLE (channel),
                             0, 0,
                             gimp_item_width  (GIMP_ITEM (channel)),
@@ -1709,6 +1878,28 @@
     {
       channel->show_masked = show_masked ? TRUE : FALSE;
 
+      if (channel->invert_node)
+        {
+          GeglNode *source;
+
+          source = gimp_drawable_get_source_node (GIMP_DRAWABLE (channel));
+
+          if (channel->show_masked)
+            {
+              gegl_node_connect_to (source,               "output",
+                                    channel->invert_node, "input");
+              gegl_node_connect_to (channel->invert_node, "output",
+                                    channel->mask_node,   "aux");
+            }
+          else
+            {
+              gegl_node_disconnect (channel->invert_node, "input");
+
+              gegl_node_connect_to (source,             "output",
+                                    channel->mask_node, "aux");
+            }
+        }
+
       gimp_drawable_update (GIMP_DRAWABLE (channel),
                             0, 0,
                             gimp_item_width  (GIMP_ITEM (channel)),

Modified: trunk/app/core/gimpchannel.h
==============================================================================
--- trunk/app/core/gimpchannel.h	(original)
+++ trunk/app/core/gimpchannel.h	Sat Oct 11 10:29:19 2008
@@ -40,6 +40,12 @@
   gboolean      show_masked;       /*  Show masked areas--as          */
                                    /*  opposed to selected areas      */
 
+  GeglNode     *node;
+  GeglNode     *color_node;
+  GeglNode     *invert_node;
+  GeglNode     *mask_node;
+  GeglNode     *mode_node;
+
   /*  Selection mask variables  */
   gboolean      boundary_known;    /*  is the current boundary valid  */
   BoundSeg     *segs_in;           /*  outline of selected region     */

Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c	(original)
+++ trunk/app/core/gimpimage.c	Sat Oct 11 10:29:19 2008
@@ -2549,10 +2549,8 @@
 gimp_image_get_graph (GimpImage *image)
 {
   GeglNode *layers_node;
-#if 0
   GeglNode *channels_node;
   GeglNode *blend_node;
-#endif
   GeglNode *output;
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
@@ -2567,7 +2565,6 @@
 
   gegl_node_add_child (image->graph, layers_node);
 
-#if 0
   channels_node =
     gimp_drawable_stack_get_graph (GIMP_DRAWABLE_STACK (image->channels));
 
@@ -2581,17 +2578,11 @@
                         blend_node,    "input");
   gegl_node_connect_to (channels_node, "output",
                         blend_node,    "aux");
-#endif
 
   output = gegl_node_get_output_proxy (image->graph, "output");
 
-#if 0
   gegl_node_connect_to (blend_node, "output",
                         output,     "input");
-#else
-  gegl_node_connect_to (layers_node, "output",
-                        output,      "input");
-#endif
 
   return image->graph;
 }

Modified: trunk/app/core/gimpprojection-construct.c
==============================================================================
--- trunk/app/core/gimpprojection-construct.c	(original)
+++ trunk/app/core/gimpprojection-construct.c	Sat Oct 11 10:29:19 2008
@@ -143,8 +143,6 @@
     }
 #endif
 
-  proj->construct_flag = FALSE;
-
   /*  First, determine if the projection image needs to be
    *  initialized--this is the case when there are no visible
    *  layers that cover the entire canvas--either because layers
@@ -156,11 +154,16 @@
    *  the list of channels
    */
   if (FALSE)
-    gimp_projection_construct_gegl (proj, x, y, w, h);
+    {
+      gimp_projection_construct_gegl (proj, x, y, w, h);
+    }
   else
-    gimp_projection_construct_layers (proj, x, y, w, h);
+    {
+      proj->construct_flag = FALSE;
 
-  gimp_projection_construct_channels (proj, x, y, w, h);
+      gimp_projection_construct_layers (proj, x, y, w, h);
+      gimp_projection_construct_channels (proj, x, y, w, h);
+    }
 }
 
 
@@ -189,8 +192,6 @@
   while (gegl_processor_work (processor, NULL));
 
   g_object_unref (processor);
-
-  proj->construct_flag = TRUE;
 }
 
 static void



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