app: add GimpDrawable::get_source_node() vfunc

For pass-through groups, we want to use the group's layer-stack
graph directly in its filter node, in place of the drawable's
buffer-source node.  Add a get_source_node() vfunc to GimpDrawable,
which defaults to returning the buffer-source node, and use it in
gimp_drawable_get_source_node() instead of using the buffer-source
node directly.  We'll later override this function for
GimpGroupLayer.
This commit is contained in:
Ell 2017-04-21 15:21:10 -04:00
parent 440d8d6855
commit 785a0834a2
2 changed files with 26 additions and 7 deletions

View File

@ -181,6 +181,7 @@ static void gimp_drawable_real_swap_pixels (GimpDrawable *drawable,
GeglBuffer *buffer,
gint x,
gint y);
static GeglNode * gimp_drawable_real_get_source_node (GimpDrawable *drawable);
G_DEFINE_TYPE_WITH_CODE (GimpDrawable, gimp_drawable, GIMP_TYPE_ITEM,
@ -260,6 +261,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
klass->set_buffer = gimp_drawable_real_set_buffer;
klass->push_undo = gimp_drawable_real_push_undo;
klass->swap_pixels = gimp_drawable_real_swap_pixels;
klass->get_source_node = gimp_drawable_real_get_source_node;
g_object_class_override_property (object_class, PROP_BUFFER, "buffer");
@ -317,6 +319,7 @@ gimp_drawable_finalize (GObject *object)
gimp_drawable_free_shadow_buffer (drawable);
g_clear_object (&drawable->private->source_node);
g_clear_object (&drawable->private->buffer_source_node);
g_clear_object (&drawable->private->filter_stack);
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -906,6 +909,20 @@ gimp_drawable_real_swap_pixels (GimpDrawable *drawable,
gimp_drawable_update (drawable, x, y, width, height);
}
static GeglNode *
gimp_drawable_real_get_source_node (GimpDrawable *drawable)
{
g_warn_if_fail (drawable->private->buffer_source_node == NULL);
drawable->private->buffer_source_node =
gegl_node_new_child (NULL,
"operation", "gegl:buffer-source",
"buffer", gimp_drawable_get_buffer (drawable),
NULL);
return g_object_ref (drawable->private->buffer_source_node);
}
/* public functions */
@ -1209,6 +1226,7 @@ gimp_drawable_set_buffer_full (GimpDrawable *drawable,
GeglNode *
gimp_drawable_get_source_node (GimpDrawable *drawable)
{
GeglNode *source;
GeglNode *filter;
GeglNode *output;
@ -1219,17 +1237,17 @@ gimp_drawable_get_source_node (GimpDrawable *drawable)
drawable->private->source_node = gegl_node_new ();
drawable->private->buffer_source_node =
gegl_node_new_child (drawable->private->source_node,
"operation", "gegl:buffer-source",
"buffer", gimp_drawable_get_buffer (drawable),
NULL);
source = GIMP_DRAWABLE_GET_CLASS (drawable)->get_source_node (drawable);
gegl_node_add_child (drawable->private->source_node, source);
g_object_unref (source);
filter = gimp_filter_stack_get_graph (GIMP_FILTER_STACK (drawable->private->filter_stack));
gegl_node_add_child (drawable->private->source_node, filter);
gegl_node_connect_to (drawable->private->buffer_source_node, "output",
gegl_node_connect_to (source, "output",
filter, "input");
output = gegl_node_get_output_proxy (drawable->private->source_node, "output");

View File

@ -110,6 +110,7 @@ struct _GimpDrawableClass
GeglBuffer *buffer,
gint x,
gint y);
GeglNode * (* get_source_node) (GimpDrawable *drawable);
};