Move the base GeglNode here in preparation for moving the GimpLayer

* 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

svn path=/trunk/; revision=27521
This commit is contained in:
Martin Nordholts 2008-11-02 16:39:38 +00:00
parent b66bad37a6
commit 24fac1de0f
11 changed files with 135 additions and 70 deletions

View File

@ -1,3 +1,24 @@
2008-11-02 Martin Nordholts <martinn@svn.gnome.org>
* 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
2008-11-01 Michael Natterer <mitch@gimp.org>
* app/tools/gimprectangletool.c
@ -64,6 +85,7 @@
Soft light with a FIXME.
2008-11-01 Martin Nordholts <martinn@svn.gnome.org>
* libgimpcolor/gimphsl.c (gimp_hsl_set): Added 'Since: GIMP 2.8'.
2008-11-01 Martin Nordholts <martinn@svn.gnome.org>

View File

@ -158,7 +158,7 @@ static void gimp_channel_set_tiles (GimpDrawable *drawable,
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 @@ gimp_channel_class_init (GimpChannelClass *klass)
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 @@ gimp_channel_class_init (GimpChannelClass *klass)
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 @@ gimp_channel_set_tiles (GimpDrawable *drawable,
}
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);

View File

@ -138,7 +138,7 @@ static void gimp_drawable_real_set_tiles (GimpDrawable *drawable,
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 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
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 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
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 @@ gimp_drawable_finalize (GObject *object)
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 @@ static void
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 @@ gimp_drawable_visibility_changed (GimpItem *item)
else
{
gegl_node_disconnect (drawable->mode_node, "input");
gegl_node_connect_to (input, "output",
output, "input");
}
}
@ -778,19 +770,21 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
}
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 @@ gimp_drawable_real_get_node (GimpDrawable *drawable)
output, "input");
}
return drawable->node;
return node;
}
static void
@ -1140,24 +1134,13 @@ gimp_drawable_get_source_node (GimpDrawable *drawable)
return drawable->source_node;
}
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;
}

View File

@ -42,7 +42,6 @@ struct _GimpDrawable
GeglNode *source_node;
GeglNode *node;
GeglNode *mode_node;
gint bytes; /* bytes per pixel */
@ -98,8 +97,6 @@ struct _GimpDrawableClass
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 @@ void gimp_drawable_set_tiles_full (GimpDrawable *drawable,
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,

View File

@ -120,7 +120,7 @@ gimp_drawable_stack_remove (GimpContainer *container,
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 @@ gimp_drawable_stack_get_graph (GimpDrawableStack *stack)
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 @@ gimp_drawable_stack_add_node (GimpDrawableStack *stack,
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 @@ gimp_drawable_stack_add_node (GimpDrawableStack *stack,
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 @@ gimp_drawable_stack_add_node (GimpDrawableStack *stack,
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 @@ gimp_drawable_stack_remove_node (GimpDrawableStack *stack,
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 @@ gimp_drawable_stack_remove_node (GimpDrawableStack *stack,
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 @@ gimp_drawable_stack_remove_node (GimpDrawableStack *stack,
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",

View File

@ -77,6 +77,9 @@ static void gimp_item_finalize (GObject *object);
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 @@ static void gimp_item_real_resize (GimpItem *item,
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 @@ gimp_item_class_init (GimpItemClass *klass)
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 @@ gimp_item_class_init (GimpItemClass *klass)
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 @@ gimp_item_init (GimpItem *item)
item->visible = TRUE;
item->linked = FALSE;
item->removed = FALSE;
item->node = NULL;
}
static void
@ -257,6 +263,12 @@ gimp_item_finalize (GObject *object)
{
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 @@ gimp_item_get_memsize (GimpObject *object,
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 @@ gimp_item_real_resize (GimpItem *item,
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 @@ gimp_item_stroke (GimpItem *item,
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)
{

View File

@ -51,6 +51,9 @@ struct _GimpItem
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 @@ struct _GimpItemClass
gboolean push_undo,
GimpProgress *progress,
GError **error);
GeglNode * (* get_node) (GimpItem *item);
const gchar *default_name;
const gchar *rename_desc;
@ -220,6 +225,9 @@ gboolean gimp_item_stroke (GimpItem *item,
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);

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib-object.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -165,7 +165,7 @@ static void gimp_layer_set_tiles (GimpDrawable *drawable,
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 @@ gimp_layer_class_init (GimpLayerClass *klass)
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 @@ gimp_layer_class_init (GimpLayerClass *klass)
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 @@ gimp_layer_set_tiles (GimpDrawable *drawable,
}
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 @@ gimp_layer_add_mask (GimpLayer *layer,
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 @@ gimp_layer_apply_mask (GimpLayer *layer,
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");

View File

@ -21,7 +21,7 @@
#include "config.h"
#include <glib-object.h>
#include <gegl.h>
#include "vectors-types.h"

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib-object.h>
#include <gegl.h>
#include "vectors-types.h"