add virtual function GimpDrawable::get_node() which returns a node to be
2008-10-10 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: add virtual function GimpDrawable::get_node() which returns a node to be plugged into the projection. * app/core/gimplayer.[ch]: remove public get_node() api and implement the virtual function instead. * app/core/gimpimage.c: changed accordingly. svn path=/trunk/; revision=27211
This commit is contained in:
parent
ac745422b9
commit
b479b7b346
6 changed files with 124 additions and 91 deletions
11
ChangeLog
11
ChangeLog
|
|
@ -1,3 +1,14 @@
|
|||
2008-10-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpdrawable.[ch]: add virtual function
|
||||
GimpDrawable::get_node() which returns a node to be plugged into
|
||||
the projection.
|
||||
|
||||
* app/core/gimplayer.[ch]: remove public get_node() api and
|
||||
implement the virtual function instead.
|
||||
|
||||
* app/core/gimpimage.c: changed accordingly.
|
||||
|
||||
2008-10-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimpmovetool.c (gimp_move_tool_button_release): flush
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ 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 = NULL;
|
||||
klass->push_undo = gimp_drawable_real_push_undo;
|
||||
klass->swap_pixels = gimp_drawable_real_swap_pixels;
|
||||
}
|
||||
|
|
@ -1066,6 +1067,17 @@ 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 (GIMP_DRAWABLE_GET_CLASS (drawable)->get_node)
|
||||
return GIMP_DRAWABLE_GET_CLASS (drawable)->get_node (drawable);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_swap_pixels (GimpDrawable *drawable,
|
||||
TileManager *tiles,
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ struct _GimpDrawableClass
|
|||
GimpImageType type,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
GeglNode * (* get_node) (GimpDrawable *drawable);
|
||||
|
||||
void (* push_undo) (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
|
|
@ -172,6 +173,7 @@ 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);
|
||||
|
||||
void gimp_drawable_swap_pixels (GimpDrawable *drawable,
|
||||
TileManager *tiles,
|
||||
|
|
|
|||
|
|
@ -2576,8 +2576,8 @@ gimp_image_get_graph (GimpImage *image)
|
|||
|
||||
for (list = reverse_list; list; list = g_list_next (list))
|
||||
{
|
||||
GimpLayer *layer = list->data;
|
||||
GeglNode *node = gimp_layer_get_node (layer);
|
||||
GimpDrawable *layer = list->data;
|
||||
GeglNode *node = gimp_drawable_get_node (layer);
|
||||
|
||||
gegl_node_add_child (image->graph, node);
|
||||
|
||||
|
|
@ -2612,7 +2612,7 @@ gimp_image_add_layer_node (GimpImage *image,
|
|||
|
||||
index = gimp_image_get_layer_index (image, layer);
|
||||
|
||||
node = gimp_layer_get_node (layer);
|
||||
node = gimp_drawable_get_node (GIMP_DRAWABLE (layer));
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
|
|
@ -2630,7 +2630,7 @@ gimp_image_add_layer_node (GimpImage *image,
|
|||
|
||||
layer_above = gimp_image_get_layer_by_index (image, index - 1);
|
||||
|
||||
node_above = gimp_layer_get_node (layer_above);
|
||||
node_above = gimp_drawable_get_node (GIMP_DRAWABLE (layer_above));
|
||||
|
||||
gegl_node_connect_to (node, "output",
|
||||
node_above, "input");
|
||||
|
|
@ -2640,7 +2640,7 @@ gimp_image_add_layer_node (GimpImage *image,
|
|||
|
||||
if (layer_below)
|
||||
{
|
||||
GeglNode *node_below = gimp_layer_get_node (layer_below);
|
||||
GeglNode *node_below = gimp_drawable_get_node (GIMP_DRAWABLE (layer_below));
|
||||
|
||||
gegl_node_connect_to (node_below, "output",
|
||||
node, "input");
|
||||
|
|
@ -2658,7 +2658,7 @@ gimp_image_remove_layer_node (GimpImage *image,
|
|||
|
||||
index = gimp_image_get_layer_index (image, layer);
|
||||
|
||||
node = gimp_layer_get_node (layer);
|
||||
node = gimp_drawable_get_node (GIMP_DRAWABLE (layer));
|
||||
|
||||
layer_below = gimp_image_get_layer_by_index (image, index + 1);
|
||||
|
||||
|
|
@ -2666,9 +2666,11 @@ gimp_image_remove_layer_node (GimpImage *image,
|
|||
{
|
||||
if (layer_below)
|
||||
{
|
||||
GeglNode *node_below = gimp_layer_get_node (layer_below);
|
||||
GeglNode *node_below;
|
||||
GeglNode *output;
|
||||
|
||||
node_below = gimp_drawable_get_node (GIMP_DRAWABLE (layer_below));
|
||||
|
||||
output = gegl_node_get_output_proxy (image->graph, "output");
|
||||
|
||||
gegl_node_disconnect (node, "input");
|
||||
|
|
@ -2682,11 +2684,14 @@ gimp_image_remove_layer_node (GimpImage *image,
|
|||
GeglNode *node_above;
|
||||
|
||||
layer_above = gimp_image_get_layer_by_index (image, index - 1);
|
||||
node_above = gimp_layer_get_node (layer_above);
|
||||
|
||||
node_above = gimp_drawable_get_node (GIMP_DRAWABLE (layer_above));
|
||||
|
||||
if (layer_below)
|
||||
{
|
||||
GeglNode *node_below = gimp_layer_get_node (layer_below);
|
||||
GeglNode *node_below;
|
||||
|
||||
node_below = gimp_drawable_get_node (GIMP_DRAWABLE (layer_below));
|
||||
|
||||
gegl_node_disconnect (node, "input");
|
||||
gegl_node_connect_to (node_below, "output",
|
||||
|
|
@ -3172,7 +3177,8 @@ gimp_image_remove_layer (GimpImage *image,
|
|||
{
|
||||
gimp_image_remove_layer_node (image, layer);
|
||||
|
||||
gegl_node_remove_child (image->graph, gimp_layer_get_node (layer));
|
||||
gegl_node_remove_child (image->graph,
|
||||
gimp_drawable_get_node (GIMP_DRAWABLE (layer)));
|
||||
}
|
||||
|
||||
gimp_container_remove (image->layers, GIMP_OBJECT (layer));
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ 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 gint gimp_layer_get_opacity_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
|
|
@ -275,6 +277,7 @@ 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;
|
||||
|
|
@ -513,6 +516,86 @@ gimp_layer_set_tiles (GimpDrawable *drawable,
|
|||
floating_sel_rigor (layer, FALSE);
|
||||
}
|
||||
|
||||
static GeglNode *
|
||||
gimp_layer_get_node (GimpDrawable *drawable)
|
||||
{
|
||||
GimpLayer *layer = GIMP_LAYER (drawable);
|
||||
GeglNode *source;
|
||||
gint off_x, off_y;
|
||||
GeglNode *input;
|
||||
GeglNode *output;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
||||
|
||||
if (layer->node)
|
||||
return layer->node;
|
||||
|
||||
layer->node = gegl_node_new ();
|
||||
|
||||
source = gimp_drawable_get_source_node (GIMP_DRAWABLE (layer));
|
||||
gegl_node_add_child (layer->node, source);
|
||||
|
||||
if (layer->mask)
|
||||
{
|
||||
GeglNode *mask;
|
||||
|
||||
mask = gimp_drawable_get_source_node (GIMP_DRAWABLE (layer->mask));
|
||||
|
||||
layer->mask_node = gegl_node_new_child (layer->node,
|
||||
"operation", "opacity",
|
||||
NULL);
|
||||
gegl_node_connect_to (mask, "output",
|
||||
layer->mask_node, "aux");
|
||||
gegl_node_connect_to (source, "output",
|
||||
layer->mask_node, "input");
|
||||
}
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
|
||||
layer->shift_node = gegl_node_new_child (layer->node,
|
||||
"operation", "shift",
|
||||
"x", (gdouble) off_x,
|
||||
"y", (gdouble) off_y,
|
||||
NULL);
|
||||
|
||||
if (layer->mask_node)
|
||||
gegl_node_connect_to (layer->mask_node, "output",
|
||||
layer->shift_node, "input");
|
||||
else
|
||||
gegl_node_connect_to (source, "output",
|
||||
layer->shift_node, "input");
|
||||
|
||||
layer->opacity_node = gegl_node_new_child (layer->node,
|
||||
"operation", "opacity",
|
||||
"value", layer->opacity,
|
||||
NULL);
|
||||
gegl_node_connect_to (layer->shift_node, "output",
|
||||
layer->opacity_node, "input");
|
||||
|
||||
layer->mode_node = gegl_node_new_child (layer->node,
|
||||
"operation", gimp_layer_mode_to_gegl_operation (layer->mode),
|
||||
NULL);
|
||||
gegl_node_connect_to (layer->opacity_node, "output",
|
||||
layer->mode_node, "aux");
|
||||
|
||||
input = gegl_node_get_input_proxy (layer->node, "input");
|
||||
output = gegl_node_get_output_proxy (layer->node, "output");
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (layer)))
|
||||
{
|
||||
gegl_node_connect_to (input, "output",
|
||||
layer->mode_node, "input");
|
||||
gegl_node_connect_to (layer->mode_node, "output",
|
||||
output, "input");
|
||||
}
|
||||
else
|
||||
{
|
||||
gegl_node_connect_to (input, "output",
|
||||
output, "input");
|
||||
}
|
||||
|
||||
return layer->node;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_removed (GimpItem *item)
|
||||
{
|
||||
|
|
@ -1934,85 +2017,6 @@ gimp_layer_is_floating_sel (const GimpLayer *layer)
|
|||
return (layer->fs.drawable != NULL);
|
||||
}
|
||||
|
||||
GeglNode *
|
||||
gimp_layer_get_node (GimpLayer *layer)
|
||||
{
|
||||
GeglNode *source;
|
||||
gint off_x, off_y;
|
||||
GeglNode *input;
|
||||
GeglNode *output;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
||||
|
||||
if (layer->node)
|
||||
return layer->node;
|
||||
|
||||
layer->node = gegl_node_new ();
|
||||
|
||||
source = gimp_drawable_get_source_node (GIMP_DRAWABLE (layer));
|
||||
gegl_node_add_child (layer->node, source);
|
||||
|
||||
if (layer->mask)
|
||||
{
|
||||
GeglNode *mask;
|
||||
|
||||
mask = gimp_drawable_get_source_node (GIMP_DRAWABLE (layer->mask));
|
||||
|
||||
layer->mask_node = gegl_node_new_child (layer->node,
|
||||
"operation", "opacity",
|
||||
NULL);
|
||||
gegl_node_connect_to (mask, "output",
|
||||
layer->mask_node, "aux");
|
||||
gegl_node_connect_to (source, "output",
|
||||
layer->mask_node, "input");
|
||||
}
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
|
||||
layer->shift_node = gegl_node_new_child (layer->node,
|
||||
"operation", "shift",
|
||||
"x", (gdouble) off_x,
|
||||
"y", (gdouble) off_y,
|
||||
NULL);
|
||||
|
||||
if (layer->mask_node)
|
||||
gegl_node_connect_to (layer->mask_node, "output",
|
||||
layer->shift_node, "input");
|
||||
else
|
||||
gegl_node_connect_to (source, "output",
|
||||
layer->shift_node, "input");
|
||||
|
||||
layer->opacity_node = gegl_node_new_child (layer->node,
|
||||
"operation", "opacity",
|
||||
"value", layer->opacity,
|
||||
NULL);
|
||||
gegl_node_connect_to (layer->shift_node, "output",
|
||||
layer->opacity_node, "input");
|
||||
|
||||
layer->mode_node = gegl_node_new_child (layer->node,
|
||||
"operation", gimp_layer_mode_to_gegl_operation (layer->mode),
|
||||
NULL);
|
||||
gegl_node_connect_to (layer->opacity_node, "output",
|
||||
layer->mode_node, "aux");
|
||||
|
||||
input = gegl_node_get_input_proxy (layer->node, "input");
|
||||
output = gegl_node_get_output_proxy (layer->node, "output");
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (layer)))
|
||||
{
|
||||
gegl_node_connect_to (input, "output",
|
||||
layer->mode_node, "input");
|
||||
gegl_node_connect_to (layer->mode_node, "output",
|
||||
output, "input");
|
||||
}
|
||||
else
|
||||
{
|
||||
gegl_node_connect_to (input, "output",
|
||||
output, "input");
|
||||
}
|
||||
|
||||
return layer->node;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_layer_set_opacity (GimpLayer *layer,
|
||||
gdouble opacity,
|
||||
|
|
|
|||
|
|
@ -127,8 +127,6 @@ GimpLayerMask * gimp_layer_get_mask (const GimpLayer *layer);
|
|||
|
||||
gboolean gimp_layer_is_floating_sel (const GimpLayer *layer);
|
||||
|
||||
GeglNode * gimp_layer_get_node (GimpLayer *layer);
|
||||
|
||||
void gimp_layer_set_opacity (GimpLayer *layer,
|
||||
gdouble opacity,
|
||||
gboolean push_undo);
|
||||
|
|
|
|||
Loading…
Reference in a new issue