[gimp] app: create the offset node in GimpLayer, and manage its offset in GimpItem
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: create the offset node in GimpLayer, and manage its offset in GimpItem
- Date: Tue, 15 May 2012 20:26:43 +0000 (UTC)
commit c73bcac2d01d74837ca4154aa9edd3d257922957
Author: Michael Natterer <mitch gimp org>
Date: Tue May 15 22:25:12 2012 +0200
app: create the offset node in GimpLayer, and manage its offset in GimpItem
app/core/gimpitem.c | 80 ++++++++++++++++++++++++++++++--------------------
app/core/gimpitem.h | 5 ++-
app/core/gimplayer.c | 13 +++++---
app/core/gimplayer.h | 1 +
4 files changed, 61 insertions(+), 38 deletions(-)
---
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index a7a142d..0c18e7b 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -92,7 +92,7 @@ struct _GimpItemPrivate
GeglNode *node; /* the GEGL node to plug
into the graph */
- GeglNode *offset_node; /* the offset as a node */
+ GList *offset_nodes; /* offset nodes to manage */
};
#define GET_PRIVATE(item) G_TYPE_INSTANCE_GET_PRIVATE (item, \
@@ -145,7 +145,6 @@ static void gimp_item_real_resize (GimpItem *item,
gint offset_x,
gint offset_y);
static GeglNode * gimp_item_real_get_node (GimpItem *item);
-static void gimp_item_sync_offset_node (GimpItem *item);
G_DEFINE_TYPE (GimpItem, gimp_item, GIMP_TYPE_VIEWABLE)
@@ -309,8 +308,6 @@ gimp_item_init (GimpItem *item)
private->linked = FALSE;
private->lock_content = FALSE;
private->removed = FALSE;
- private->node = NULL;
- private->offset_node = NULL;
}
static void
@@ -336,6 +333,13 @@ gimp_item_finalize (GObject *object)
private->node = NULL;
}
+ if (private->offset_nodes)
+ {
+ g_list_free_full (private->offset_nodes,
+ (GDestroyNotify) g_object_unref);
+ private->offset_nodes = NULL;
+ }
+
if (private->image && private->image->gimp)
{
gimp_id_table_remove (private->image->gimp->item_table, private->ID);
@@ -625,18 +629,6 @@ gimp_item_real_get_node (GimpItem *item)
return private->node;
}
-static void
-gimp_item_sync_offset_node (GimpItem *item)
-{
- GimpItemPrivate *private = GET_PRIVATE (item);
-
- if (private->offset_node)
- gegl_node_set (private->offset_node,
- "x", (gdouble) private->offset_x,
- "y", (gdouble) private->offset_y,
- NULL);
-}
-
/* public functions */
@@ -1050,6 +1042,7 @@ gimp_item_set_offset (GimpItem *item,
gint offset_y)
{
GimpItemPrivate *private;
+ GList *list;
g_return_if_fail (GIMP_IS_ITEM (item));
@@ -1069,7 +1062,15 @@ gimp_item_set_offset (GimpItem *item,
g_object_notify (G_OBJECT (item), "offset-y");
}
- gimp_item_sync_offset_node (item);
+ for (list = private->offset_nodes; list; list = g_list_next (list))
+ {
+ GeglNode *node = list->data;
+
+ gegl_node_set (node,
+ "x", (gdouble) private->offset_x,
+ "y", (gdouble) private->offset_y,
+ NULL);
+ }
g_object_thaw_notify (G_OBJECT (item));
}
@@ -1559,28 +1560,43 @@ gimp_item_peek_node (GimpItem *item)
return GET_PRIVATE (item)->node;
}
-GeglNode *
-gimp_item_get_offset_node (GimpItem *item)
+void
+gimp_item_add_offset_node (GimpItem *item,
+ GeglNode *node)
{
GimpItemPrivate *private;
- g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
+ g_return_if_fail (GIMP_IS_ITEM (item));
+ g_return_if_fail (GEGL_IS_NODE (node));
private = GET_PRIVATE (item);
- if (! private->offset_node)
- {
- GeglNode *node = gimp_item_get_node (item);
-
- private->offset_node =
- gegl_node_new_child (node,
- "operation", "gegl:translate",
- "x", (gdouble) private->offset_x,
- "y", (gdouble) private->offset_y,
- NULL);
- }
+ g_return_if_fail (g_list_find (private->offset_nodes, node) == NULL);
+
+ gegl_node_set (node,
+ "x", (gdouble) private->offset_x,
+ "y", (gdouble) private->offset_y,
+ NULL);
+
+ private->offset_nodes = g_list_append (private->offset_nodes,
+ g_object_ref (node));
+}
+
+void
+gimp_item_remove_offset_node (GimpItem *item,
+ GeglNode *node)
+{
+ GimpItemPrivate *private;
+
+ g_return_if_fail (GIMP_IS_ITEM (item));
+ g_return_if_fail (GEGL_IS_NODE (node));
+
+ private = GET_PRIVATE (item);
+
+ g_return_if_fail (g_list_find (private->offset_nodes, node) != NULL);
- return private->offset_node;
+ private->offset_nodes = g_list_append (private->offset_nodes, node);
+ g_object_unref (node);
}
gint
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index cc6f01b..22d854e 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -254,8 +254,11 @@ void gimp_item_to_selection (GimpItem *item,
GeglNode * gimp_item_get_node (GimpItem *item);
GeglNode * gimp_item_peek_node (GimpItem *item);
-GeglNode * gimp_item_get_offset_node (GimpItem *item);
+void gimp_item_add_offset_node (GimpItem *item,
+ GeglNode *node);
+void gimp_item_remove_offset_node (GimpItem *item,
+ GeglNode *node);
gint gimp_item_get_ID (GimpItem *item);
GimpItem * gimp_item_get_by_ID (Gimp *gimp,
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 16c568d..d0b9d32 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -854,7 +854,6 @@ gimp_layer_get_node (GimpItem *item)
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpLayer *layer = GIMP_LAYER (item);
GeglNode *node;
- GeglNode *offset_node;
GeglNode *source;
GeglNode *mode_node;
gboolean source_node_hijacked = FALSE;
@@ -874,6 +873,7 @@ gimp_layer_get_node (GimpItem *item)
gegl_node_add_child (node, source);
g_warn_if_fail (layer->opacity_node == NULL);
+ g_warn_if_fail (layer->offset_node == NULL);
layer->opacity_node = gegl_node_new_child (node,
"operation", "gegl:opacity",
@@ -905,10 +905,13 @@ gimp_layer_get_node (GimpItem *item)
}
}
- offset_node = gimp_item_get_offset_node (GIMP_ITEM (layer));
+ layer->offset_node = gegl_node_new_child (node,
+ "operation", "gegl:translate",
+ NULL);
+ gimp_item_add_offset_node (GIMP_ITEM (layer), layer->offset_node);
gegl_node_connect_to (layer->opacity_node, "output",
- offset_node, "input");
+ layer->offset_node, "input");
mode_node = gimp_drawable_get_mode_node (drawable);
@@ -916,8 +919,8 @@ gimp_layer_get_node (GimpItem *item)
layer->mode,
TRUE);
- gegl_node_connect_to (offset_node, "output",
- mode_node, "aux");
+ gegl_node_connect_to (layer->offset_node, "output",
+ mode_node, "aux");
return node;
}
diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h
index 67d6d7b..d0da2b6 100644
--- a/app/core/gimplayer.h
+++ b/app/core/gimplayer.h
@@ -46,6 +46,7 @@ struct _GimpLayer
gboolean show_mask; /* show mask or layer? */
GeglNode *opacity_node;
+ GeglNode *offset_node;
/* Floating selections */
struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]