gimp r27521 - in trunk: . app/core app/vectors



Author: martinn
Date: Sun Nov  2 16:39:38 2008
New Revision: 27521
URL: http://svn.gnome.org/viewvc/gimp?rev=27521&view=rev

Log:
* app/core/gimpitem.[ch]: Move the base GeglNode here in
preparation for moving the GimpLayer gegl:shift op to here as
well. After all, the offsets are properties of GimpItem and not
GimpLayer.

* app/core/gimpdrawable.[ch]: Delegate appropriate stuff to the
GimpItem base class, like part of the visibility toggling and the
creation and destruction of the GimpItem node.

* app/core/gimplayer.c
* app/core/gimpchannel.c
* app/core/gimpdrawablestack.c: Changed accordingly, use the new
function names.

* app/core/gimpitempropundo.c
* app/vectors/gimpvectors-warp.c
* app/vectors/gimpvectorsmodundo.c: Include gegl.h instead of
glib-object.h


Modified:
   trunk/ChangeLog
   trunk/app/core/gimpchannel.c
   trunk/app/core/gimpdrawable.c
   trunk/app/core/gimpdrawable.h
   trunk/app/core/gimpdrawablestack.c
   trunk/app/core/gimpitem.c
   trunk/app/core/gimpitem.h
   trunk/app/core/gimpitempropundo.c
   trunk/app/core/gimplayer.c
   trunk/app/vectors/gimpvectors-warp.c
   trunk/app/vectors/gimpvectorsmodundo.c

Modified: trunk/app/core/gimpchannel.c
==============================================================================
--- trunk/app/core/gimpchannel.c	(original)
+++ trunk/app/core/gimpchannel.c	Sun Nov  2 16:39:38 2008
@@ -158,7 +158,7 @@
                                               GimpImageType      type,
                                               gint               offset_x,
                                               gint               offset_y);
-static GeglNode * gimp_channel_get_node      (GimpDrawable      *drawable);
+static GeglNode * gimp_channel_get_node      (GimpItem          *item);
 static void      gimp_channel_swap_pixels    (GimpDrawable      *drawable,
                                               TileManager       *tiles,
                                               gboolean           sparse,
@@ -263,6 +263,7 @@
   item_class->rotate               = gimp_channel_rotate;
   item_class->transform            = gimp_channel_transform;
   item_class->stroke               = gimp_channel_stroke;
+  item_class->get_node             = gimp_channel_get_node;
   item_class->default_name         = _("Channel");
   item_class->rename_desc          = _("Rename Channel");
   item_class->translate_desc       = _("Move Channel");
@@ -278,7 +279,6 @@
   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;
@@ -837,15 +837,16 @@
 }
 
 static GeglNode *
-gimp_channel_get_node (GimpDrawable *drawable)
+gimp_channel_get_node (GimpItem *item)
 {
-  GimpChannel *channel = GIMP_CHANNEL (drawable);
-  GeglNode    *node;
-  GeglNode    *source;
-  GeglNode    *mode_node;
-  GeglColor   *color;
+  GimpDrawable *drawable = GIMP_DRAWABLE (item);
+  GimpChannel  *channel  = GIMP_CHANNEL (item);
+  GeglNode     *node;
+  GeglNode     *source;
+  GeglNode     *mode_node;
+  GeglColor    *color;
 
-  node = GIMP_DRAWABLE_CLASS (parent_class)->get_node (drawable);
+  node = GIMP_ITEM_CLASS (parent_class)->get_node (item);
 
   source = gimp_drawable_get_source_node (drawable);
   gegl_node_add_child (node, source);

Modified: trunk/app/core/gimpdrawable.c
==============================================================================
--- trunk/app/core/gimpdrawable.c	(original)
+++ trunk/app/core/gimpdrawable.c	Sun Nov  2 16:39:38 2008
@@ -138,7 +138,7 @@
                                                     GimpImageType      type,
                                                     gint               offset_x,
                                                     gint               offset_y);
-static GeglNode * gimp_drawable_real_get_node      (GimpDrawable      *drawable);
+static GeglNode * gimp_drawable_get_node           (GimpItem          *item);
 
 static void       gimp_drawable_real_push_undo     (GimpDrawable      *drawable,
                                                     const gchar       *undo_desc,
@@ -213,6 +213,7 @@
   item_class->flip                   = gimp_drawable_flip;
   item_class->rotate                 = gimp_drawable_rotate;
   item_class->transform              = gimp_drawable_transform;
+  item_class->get_node               = gimp_drawable_get_node;
 
   klass->update                      = gimp_drawable_real_update;
   klass->alpha_changed               = NULL;
@@ -223,7 +224,6 @@
   klass->replace_region              = gimp_drawable_real_replace_region;
   klass->get_tiles                   = gimp_drawable_real_get_tiles;
   klass->set_tiles                   = gimp_drawable_real_set_tiles;
-  klass->get_node                    = gimp_drawable_real_get_node;
   klass->push_undo                   = gimp_drawable_real_push_undo;
   klass->swap_pixels                 = gimp_drawable_real_swap_pixels;
 }
@@ -271,12 +271,6 @@
       drawable->source_node = NULL;
     }
 
-  if (drawable->node)
-    {
-      g_object_unref (drawable->node);
-      drawable->node = NULL;
-    }
-
   if (drawable->preview_cache)
     gimp_preview_cache_invalidate (&drawable->preview_cache);
 
@@ -342,14 +336,15 @@
 gimp_drawable_visibility_changed (GimpItem *item)
 {
   GimpDrawable *drawable = GIMP_DRAWABLE (item);
+  GeglNode     *node     = gimp_item_get_node (item);
 
-  if (drawable->node)
+  if (node)
     {
       GeglNode *input;
       GeglNode *output;
 
-      input  = gegl_node_get_input_proxy  (drawable->node, "input");
-      output = gegl_node_get_output_proxy (drawable->node, "output");
+      input  = gegl_node_get_input_proxy  (node, "input");
+      output = gegl_node_get_output_proxy (node, "output");
 
       if (gimp_item_get_visible (item))
         {
@@ -361,9 +356,6 @@
       else
         {
           gegl_node_disconnect (drawable->mode_node, "input");
-
-          gegl_node_connect_to (input,  "output",
-                                output, "input");
         }
     }
 
@@ -778,19 +770,21 @@
 }
 
 static GeglNode *
-gimp_drawable_real_get_node (GimpDrawable *drawable)
+gimp_drawable_get_node (GimpItem *item)
 {
-  GeglNode  *input;
-  GeglNode  *output;
+  GimpDrawable *drawable = GIMP_DRAWABLE (item);
+  GeglNode     *node;
+  GeglNode     *input;
+  GeglNode     *output;
 
-  drawable->node = gegl_node_new ();
+  node = GIMP_ITEM_CLASS (parent_class)->get_node (item);
 
-  drawable->mode_node = gegl_node_new_child (drawable->node,
+  drawable->mode_node = gegl_node_new_child (node,
                                              "operation", "gegl:normal",
                                              NULL);
 
-  input  = gegl_node_get_input_proxy  (drawable->node, "input");
-  output = gegl_node_get_output_proxy (drawable->node, "output");
+  input  = gegl_node_get_input_proxy  (node, "input");
+  output = gegl_node_get_output_proxy (node, "output");
 
   if (gimp_item_get_visible (GIMP_ITEM (drawable)))
     {
@@ -805,7 +799,7 @@
                             output, "input");
     }
 
-  return drawable->node;
+  return node;
 }
 
 static void
@@ -1141,23 +1135,12 @@
 }
 
 GeglNode *
-gimp_drawable_get_node (GimpDrawable *drawable)
-{
-  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
-
-  if (drawable->node)
-    return drawable->node;
-
-  return GIMP_DRAWABLE_GET_CLASS (drawable)->get_node (drawable);
-}
-
-GeglNode *
 gimp_drawable_get_mode_node (GimpDrawable *drawable)
 {
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
 
   if (! drawable->mode_node)
-    gimp_drawable_get_node (drawable);
+    gimp_drawable_get_node (GIMP_ITEM (drawable));
 
   return drawable->mode_node;
 }

Modified: trunk/app/core/gimpdrawable.h
==============================================================================
--- trunk/app/core/gimpdrawable.h	(original)
+++ trunk/app/core/gimpdrawable.h	Sun Nov  2 16:39:38 2008
@@ -42,7 +42,6 @@
 
   GeglNode      *source_node;
 
-  GeglNode      *node;
   GeglNode      *mode_node;
 
   gint           bytes;              /* bytes per pixel                */
@@ -98,8 +97,6 @@
                                            GimpImageType         type,
                                            gint                  offset_x,
                                            gint                  offset_y);
-  GeglNode    * (* get_node)              (GimpDrawable         *drawable);
-
   void          (* push_undo)             (GimpDrawable         *drawable,
                                            const gchar          *undo_desc,
                                            TileManager          *tiles,
@@ -176,7 +173,6 @@
                                                   gint                offset_y);
 
 GeglNode      * gimp_drawable_get_source_node    (GimpDrawable       *drawable);
-GeglNode      * gimp_drawable_get_node           (GimpDrawable       *drawable);
 GeglNode      * gimp_drawable_get_mode_node      (GimpDrawable       *drawable);
 
 void            gimp_drawable_swap_pixels        (GimpDrawable       *drawable,

Modified: trunk/app/core/gimpdrawablestack.c
==============================================================================
--- trunk/app/core/gimpdrawablestack.c	(original)
+++ trunk/app/core/gimpdrawablestack.c	Sun Nov  2 16:39:38 2008
@@ -120,7 +120,7 @@
       gimp_drawable_stack_remove_node (stack, GIMP_DRAWABLE (object));
 
       gegl_node_remove_child (stack->graph,
-                              gimp_drawable_get_node (GIMP_DRAWABLE (object)));
+                              gimp_item_get_node (GIMP_ITEM (object)));
     }
 
   GIMP_CONTAINER_CLASS (parent_class)->remove (container, object);
@@ -185,7 +185,7 @@
   for (list = reverse_list; list; list = g_list_next (list))
     {
       GimpDrawable *drawable = list->data;
-      GeglNode     *node     = gimp_drawable_get_node (drawable);
+      GeglNode     *node     = gimp_item_get_node (GIMP_ITEM (drawable));
 
       gegl_node_add_child (stack->graph, node);
 
@@ -219,7 +219,7 @@
   GeglNode     *node;
   gint          index;
 
-  node = gimp_drawable_get_node (drawable);
+  node = gimp_item_get_node (GIMP_ITEM (drawable));
 
   index = gimp_container_get_child_index (GIMP_CONTAINER (stack),
                                           GIMP_OBJECT (drawable));
@@ -235,7 +235,7 @@
       drawable_above = (GimpDrawable *)
         gimp_container_get_child_by_index (GIMP_CONTAINER (stack), index - 1);
 
-      node_above = gimp_drawable_get_node (drawable_above);
+      node_above = gimp_item_get_node (GIMP_ITEM (drawable_above));
     }
 
   gegl_node_connect_to (node,       "output",
@@ -246,7 +246,7 @@
 
   if (drawable_below)
     {
-      GeglNode *node_below = gimp_drawable_get_node (drawable_below);
+      GeglNode *node_below = gimp_item_get_node (GIMP_ITEM (drawable_below));
 
       gegl_node_connect_to (node_below, "output",
                             node,       "input");
@@ -262,7 +262,7 @@
   GeglNode     *node;
   gint          index;
 
-  node = gimp_drawable_get_node (drawable);
+  node = gimp_item_get_node (GIMP_ITEM (drawable));
 
   index = gimp_container_get_child_index (GIMP_CONTAINER (stack),
                                           GIMP_OBJECT (drawable));
@@ -278,7 +278,7 @@
       drawable_above = (GimpDrawable *)
         gimp_container_get_child_by_index (GIMP_CONTAINER (stack), index - 1);
 
-      node_above = gimp_drawable_get_node (drawable_above);
+      node_above = gimp_item_get_node (GIMP_ITEM (drawable_above));
     }
 
   drawable_below = (GimpDrawable *)
@@ -286,7 +286,7 @@
 
   if (drawable_below)
     {
-      GeglNode *node_below = gimp_drawable_get_node (drawable_below);
+      GeglNode *node_below = gimp_item_get_node (GIMP_ITEM (drawable_below));
 
       gegl_node_disconnect (node,       "input");
       gegl_node_connect_to (node_below, "output",

Modified: trunk/app/core/gimpitem.c
==============================================================================
--- trunk/app/core/gimpitem.c	(original)
+++ trunk/app/core/gimpitem.c	Sun Nov  2 16:39:38 2008
@@ -77,6 +77,9 @@
 static gint64     gimp_item_get_memsize       (GimpObject    *object,
                                                gint64        *gui_size);
 
+static void       gimp_item_real_visibility_changed
+                                              (GimpItem      *item);
+
 static GimpItem * gimp_item_real_duplicate    (GimpItem      *item,
                                                GType          new_type);
 static void       gimp_item_real_convert      (GimpItem      *item,
@@ -102,6 +105,7 @@
                                                gint           new_height,
                                                gint           offset_x,
                                                gint           offset_y);
+static GeglNode * gimp_item_real_get_node     (GimpItem      *item);
 
 
 G_DEFINE_TYPE (GimpItem, gimp_item, GIMP_TYPE_VIEWABLE)
@@ -155,7 +159,7 @@
   viewable_class->get_popup_size   = gimp_item_get_popup_size;
 
   klass->removed                   = NULL;
-  klass->visibility_changed        = NULL;
+  klass->visibility_changed        = gimp_item_real_visibility_changed;
   klass->linked_changed            = NULL;
 
   klass->is_attached               = NULL;
@@ -169,6 +173,7 @@
   klass->rotate                    = NULL;
   klass->transform                 = NULL;
   klass->stroke                    = NULL;
+  klass->get_node                  = gimp_item_real_get_node;
 
   klass->default_name              = NULL;
   klass->rename_desc               = NULL;
@@ -211,6 +216,7 @@
   item->visible   = TRUE;
   item->linked    = FALSE;
   item->removed   = FALSE;
+  item->node      = NULL;
 }
 
 static void
@@ -257,6 +263,12 @@
 {
   GimpItem *item = GIMP_ITEM (object);
 
+  if (item->node)
+    {
+      g_object_unref (item->node);
+      item->node = NULL;
+    }
+
   if (item->image && item->image->gimp)
     {
       g_hash_table_remove (item->image->gimp->item_table,
@@ -286,6 +298,29 @@
                                                                   gui_size);
 }
 
+static void
+gimp_item_real_visibility_changed (GimpItem *item)
+{
+  if (! item->node)
+    return;
+
+  if (gimp_item_get_visible (item))
+    {
+      /* Leave this up to subclasses */
+    }
+  else
+    {
+      GeglNode *input;
+      GeglNode *output;
+
+      input  = gegl_node_get_input_proxy  (item->node, "input");
+      output = gegl_node_get_output_proxy (item->node, "output");
+
+      gegl_node_connect_to (input,  "output",
+                            output, "input");
+    }
+}
+
 static GimpItem *
 gimp_item_real_duplicate (GimpItem *item,
                           GType     new_type)
@@ -410,6 +445,14 @@
   g_object_notify (G_OBJECT (item), "height");
 }
 
+static GeglNode *
+gimp_item_real_get_node (GimpItem *item)
+{
+  item->node = gegl_node_new ();
+
+  return item->node;
+}
+
 /**
  * gimp_item_remove:
  * @item: the #GimpItem to remove.
@@ -1049,6 +1092,17 @@
   return retval;
 }
 
+GeglNode *
+gimp_item_get_node (GimpItem *item)
+{
+  g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
+
+  if (item->node)
+    return item->node;
+
+  return GIMP_ITEM_GET_CLASS (item)->get_node (item);
+}
+
 gint
 gimp_item_get_ID (GimpItem *item)
 {

Modified: trunk/app/core/gimpitem.h
==============================================================================
--- trunk/app/core/gimpitem.h	(original)
+++ trunk/app/core/gimpitem.h	Sun Nov  2 16:39:38 2008
@@ -51,6 +51,9 @@
   gboolean          linked;             /*  control linkage          */
 
   gboolean          removed;            /*  removed from the image?  */
+
+  GeglNode         *node;               /*  the GEGL node to plug
+                                            into the graph           */
 };
 
 struct _GimpItemClass
@@ -114,6 +117,8 @@
                                gboolean                push_undo,
                                GimpProgress           *progress,
                                GError                **error);
+  GeglNode * (* get_node)     (GimpItem               *item);
+
 
   const gchar *default_name;
   const gchar *rename_desc;
@@ -220,6 +225,9 @@
                                             GimpProgress       *progress,
                                             GError            **error);
 
+GeglNode      * gimp_item_get_node         (GimpItem           *item);
+
+
 gint            gimp_item_get_ID           (GimpItem           *item);
 GimpItem      * gimp_item_get_by_ID        (Gimp               *gimp,
                                             gint                id);

Modified: trunk/app/core/gimpitempropundo.c
==============================================================================
--- trunk/app/core/gimpitempropundo.c	(original)
+++ trunk/app/core/gimpitempropundo.c	Sun Nov  2 16:39:38 2008
@@ -18,7 +18,7 @@
 
 #include "config.h"
 
-#include <glib-object.h>
+#include <gegl.h>
 
 #include "libgimpbase/gimpbase.h"
 

Modified: trunk/app/core/gimplayer.c
==============================================================================
--- trunk/app/core/gimplayer.c	(original)
+++ trunk/app/core/gimplayer.c	Sun Nov  2 16:39:38 2008
@@ -165,7 +165,7 @@
                                                  GimpImageType       type,
                                                  gint                offset_x,
                                                  gint                offset_y);
-static GeglNode * gimp_layer_get_node           (GimpDrawable       *drawable);
+static GeglNode * gimp_layer_get_node           (GimpItem           *item);
 
 static gint    gimp_layer_get_opacity_at        (GimpPickable       *pickable,
                                                  gint                x,
@@ -262,6 +262,7 @@
   item_class->flip                    = gimp_layer_flip;
   item_class->rotate                  = gimp_layer_rotate;
   item_class->transform               = gimp_layer_transform;
+  item_class->get_node                = gimp_layer_get_node;
   item_class->default_name            = _("Layer");
   item_class->rename_desc             = _("Rename Layer");
   item_class->translate_desc          = _("Move Layer");
@@ -275,7 +276,6 @@
   drawable_class->invalidate_boundary   = gimp_layer_invalidate_boundary;
   drawable_class->get_active_components = gimp_layer_get_active_components;
   drawable_class->set_tiles             = gimp_layer_set_tiles;
-  drawable_class->get_node              = gimp_layer_get_node;
 
   klass->opacity_changed              = NULL;
   klass->mode_changed                 = NULL;
@@ -509,15 +509,16 @@
 }
 
 static GeglNode *
-gimp_layer_get_node (GimpDrawable *drawable)
+gimp_layer_get_node (GimpItem *item)
 {
-  GimpLayer *layer = GIMP_LAYER (drawable);
-  GeglNode  *node;
-  GeglNode  *source;
-  GeglNode  *mode_node;
-  gint       off_x, off_y;
+  GimpDrawable *drawable = GIMP_DRAWABLE (item);
+  GimpLayer    *layer    = GIMP_LAYER (item);
+  GeglNode     *node;
+  GeglNode     *source;
+  GeglNode     *mode_node;
+  gint          off_x, off_y;
 
-  node = GIMP_DRAWABLE_CLASS (parent_class)->get_node (drawable);
+  node = GIMP_ITEM_CLASS (parent_class)->get_node (item);
 
   source = gimp_drawable_get_source_node (drawable);
   gegl_node_add_child (node, source);
@@ -1379,7 +1380,7 @@
       GeglNode *source;
       GeglNode *mask;
 
-      node = gimp_drawable_get_node (GIMP_DRAWABLE (layer));
+      node = gimp_item_get_node (GIMP_ITEM (layer));
 
       layer->mask_node = gegl_node_new_child (node,
                                               "operation", "gegl:opacity",
@@ -1726,7 +1727,7 @@
       GeglNode *node;
       GeglNode *source;
 
-      node = gimp_drawable_get_node (GIMP_DRAWABLE (layer));
+      node = gimp_item_get_node (GIMP_ITEM (layer));
 
       gegl_node_disconnect (layer->mask_node, "input");
       gegl_node_disconnect (layer->mask_node, "aux");

Modified: trunk/app/vectors/gimpvectors-warp.c
==============================================================================
--- trunk/app/vectors/gimpvectors-warp.c	(original)
+++ trunk/app/vectors/gimpvectors-warp.c	Sun Nov  2 16:39:38 2008
@@ -21,7 +21,7 @@
 
 #include "config.h"
 
-#include <glib-object.h>
+#include <gegl.h>
 
 #include "vectors-types.h"
 

Modified: trunk/app/vectors/gimpvectorsmodundo.c
==============================================================================
--- trunk/app/vectors/gimpvectorsmodundo.c	(original)
+++ trunk/app/vectors/gimpvectorsmodundo.c	Sun Nov  2 16:39:38 2008
@@ -18,7 +18,7 @@
 
 #include "config.h"
 
-#include <glib-object.h>
+#include <gegl.h>
 
 #include "vectors-types.h"
 



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