Commit 3d0cbe15 authored by Øyvind Kolås's avatar Øyvind Kolås

modified meta nodes to incurr fewer repeated changes on the graph

parent dcf306a5
2006-10-07 Øyvind Kolås <pippin@gimp.org>
Modified meta nodes to incurr fewer repeated changes on the graph.
* operations/meta/dropshadow.c: (prepare):
* operations/meta/layer.c: (prepare), (dispose), (finalize),
(refresh_cache):
* operations/meta/unsharp-mask.c: (prepare):
* tools/Makefile.am:
2006-10-07 Øyvind Kolås <pippin@gimp.org>
* gegl/gegl-node.h: added dirty variable to GeglNode struct.
* gegl/gegl-node.c: (gegl_node_set_op_class), (property_changed),
......@@ -9,16 +18,6 @@
* operations/file-io/load.c: (prepare), (refresh_cache): reduce number
of changed emitted.
2006-10-07 Øyvind Kolås <pippin@gimp.org>
reviewed by: <delete if not using a buddy>
* docs/gallery/Makefile.am:
* gegl/gegl-node.c: (property_changed),
(gegl_node_set_operation_object):
* gegl/gegl-node.h:
* tools/Makefile.am:
2006-10-07 Øyvind Kolås <pippin@gimp.org>
Added four more SVG-filters from Geert Jordaens
......
......@@ -50,6 +50,11 @@ struct _Priv
GeglNode *blur;
GeglNode *darken;
GeglNode *black;
double p_opacity;
double p_x;
double p_y;
double p_radius;
};
......@@ -61,15 +66,30 @@ prepare (GeglOperation *operation)
Priv *priv;
priv = (Priv*)self->priv;
/* parameters might have changed, so set the properties again */
gegl_node_set (priv->translate, "x", self->x,
"y", self->y,
NULL);
gegl_node_set (priv->opacity, "value", self->opacity,
NULL);
gegl_node_set (priv->blur, "radius-x", self->radius,
"radius-y", self->radius,
NULL);
if (self->x != priv->p_x ||
self->y != priv->p_y)
{
gegl_node_set (priv->translate, "x", self->x,
"y", self->y,
NULL);
priv->p_x = self->x;
priv->p_y = self->y;
}
if (self->opacity != priv->p_opacity)
{
gegl_node_set (priv->opacity, "value", self->opacity,
NULL);
priv->p_opacity = self->opacity;
}
if (self->radius != priv->p_radius)
{
gegl_node_set (priv->blur, "radius-x", self->radius,
"radius-y", self->radius,
NULL);
priv->p_radius = self->radius;
}
}
/* in associate we hook into graph adding the needed nodes */
......
......@@ -50,9 +50,14 @@ struct _Priv
gchar *cached_path;
GeglBuffer *cached_buffer;
gdouble p_opacity;
gdouble p_x;
gdouble p_y;
gchar *p_composite_op;
};
static void refresh_cache (GeglChantOperation *self);
static gboolean refresh_cache (GeglChantOperation *self);
static void
prepare (GeglOperation *operation)
......@@ -66,28 +71,48 @@ prepare (GeglOperation *operation)
* for now this is evaded by just ignoring additional
* requests to be made into members of the graph
*/
gegl_node_set (priv->composite_op,
"operation", self->composite_op,
NULL);
if (self->src[0])
if (!priv->p_composite_op || strcmp (priv->p_composite_op, self->composite_op))
{
refresh_cache (self);
gegl_node_set (priv->load,
"buffer", priv->cached_buffer,
gegl_node_set (priv->composite_op,
"operation", self->composite_op,
NULL);
if (priv->p_composite_op)
g_free (priv->p_composite_op);
priv->p_composite_op = g_strdup (self->composite_op);
}
if (self->src[0])
{
if (refresh_cache (self))
{
gegl_node_set (priv->load,
"buffer", priv->cached_buffer,
NULL);
}
}
else
{
gegl_node_connect (priv->opacity, "input", priv->aux, "output");
}
gegl_node_set (priv->opacity,
"value", self->opacity,
NULL);
gegl_node_set (priv->shift,
"x", self->x,
"y", self->y,
NULL);
if (self->opacity != priv->p_opacity)
{
gegl_node_set (priv->opacity,
"value", self->opacity,
NULL);
priv->p_opacity = self->opacity;
}
if (self->x != priv->p_x ||
self->y != priv->p_y)
{
gegl_node_set (priv->shift,
"x", self->x,
"y", self->y,
NULL);
priv->p_x = self->x;
priv->p_y = self->y;
}
}
static void associate (GeglOperation *operation)
......@@ -134,11 +159,6 @@ dispose (GObject *object)
g_object_unref (priv->cached_buffer);
priv->cached_buffer = NULL;
}
if (priv->cached_path)
{
g_free (priv->cached_path);
priv->cached_path = NULL;
}
G_OBJECT_CLASS (g_type_class_peek_parent (G_OBJECT_GET_CLASS (object)))->dispose (object);
}
......@@ -148,7 +168,12 @@ static void
finalize (GObject *object)
{
GeglChantOperation *self = GEGL_CHANT_OPERATION (object);
Priv *priv = (Priv*)self->priv;
if (priv->cached_path)
g_free (priv->cached_path);
if (priv->p_composite_op)
g_free (priv->p_composite_op);
if (self->priv)
g_free (self->priv);
......@@ -164,7 +189,7 @@ static void class_init (GeglOperationClass *klass)
G_OBJECT_CLASS (klass)->finalize = finalize;
}
static void
static gboolean
refresh_cache (GeglChantOperation *self)
{
Priv *priv = (Priv*)self->priv;
......@@ -173,33 +198,35 @@ refresh_cache (GeglChantOperation *self)
((priv->cached_path && self->src) &&
strcmp (self->src, priv->cached_path)))
{
GeglNode *gegl;
GeglNode *load;
if (priv->cached_buffer)
{
g_object_unref (priv->cached_buffer);
priv->cached_buffer = NULL;
g_free (priv->cached_path);
}
gegl = g_object_new (GEGL_TYPE_NODE, NULL);
load = gegl_graph_new_node (gegl, "operation", "load",
"cache", FALSE,
"path", self->src,
NULL);
gegl_node_apply (load, "output");
gegl_node_get (load, "output", &(priv->cached_buffer), NULL);
/* we unref the buffer since we effectifly need to steal the
* contents XXX, only once here,. twice in node_blit.. since
* we do not have any more use for it there.
*/
g_object_unref (priv->cached_buffer);
g_object_unref (gegl);
priv->cached_path = g_strdup (self->src);
}
GeglNode *gegl;
GeglNode *load;
if (priv->cached_buffer)
{
g_object_unref (priv->cached_buffer);
priv->cached_buffer = NULL;
g_free (priv->cached_path);
}
gegl = g_object_new (GEGL_TYPE_NODE, NULL);
load = gegl_graph_new_node (gegl, "operation", "load",
"cache", FALSE,
"path", self->src,
NULL);
gegl_node_apply (load, "output");
gegl_node_get (load, "output", &(priv->cached_buffer), NULL);
/* we unref the buffer since we effectifly need to steal the
* contents XXX, only once here,. twice in node_blit.. since
* we do not have any more use for it there.
*/
g_object_unref (priv->cached_buffer);
g_object_unref (gegl);
priv->cached_path = g_strdup (self->src);
return TRUE;
}
return FALSE;
}
......
......@@ -43,6 +43,9 @@ struct _Priv
GeglNode *multiply;
GeglNode *subtract;
GeglNode *blur;
double p_radius;
double p_scale;
};
static void prepare (GeglOperation *operation);
......@@ -96,12 +99,20 @@ static void prepare (GeglOperation *operation)
GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
Priv *priv = (Priv*)self->priv;
gegl_node_set (priv->multiply, "value", self->scale,
NULL);
if (self->scale != priv->p_scale)
{
gegl_node_set (priv->multiply, "value", self->scale,
NULL);
priv->p_scale = self->scale;
}
gegl_node_set (priv->blur, "radius-x", self->radius,
"radius-y", self->radius,
NULL);
if (self->radius != priv->p_radius)
{
gegl_node_set (priv->blur, "radius-x", self->radius,
"radius-y", self->radius,
NULL);
priv->p_radius = self->radius;
}
}
static void class_init (GeglOperationClass *klass)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment