|
Packit Service |
2781ba |
/* This file is part of GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2003 Calvin Williamson
|
|
Packit Service |
2781ba |
* 2006 Øyvind Kolås
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <string.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include <glib-object.h>
|
|
Packit Service |
2781ba |
#include <gobject/gvaluecollector.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-types-internal.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl.h"
|
|
Packit Service |
2781ba |
#include "gegl-apply.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "graph/gegl-node.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "operation/gegl-operation.h"
|
|
Packit Service |
2781ba |
#include "operation/gegl-operations.h"
|
|
Packit Service |
2781ba |
#include "operation/gegl-operation-meta.h"
|
|
Packit Service |
2781ba |
#include "operation/gegl-operation-point-filter.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "process/gegl-eval-mgr.h"
|
|
Packit Service |
2781ba |
#include "process/gegl-have-visitor.h"
|
|
Packit Service |
2781ba |
#include "process/gegl-prepare-visitor.h"
|
|
Packit Service |
2781ba |
#include "process/gegl-finish-visitor.h"
|
|
Packit Service |
2781ba |
#include "process/gegl-processor.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_node_set_props (GeglNode *node,
|
|
Packit Service |
2781ba |
va_list var_args)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
const char *property_name;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_freeze_notify (G_OBJECT (node));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
property_name = va_arg (var_args, gchar *);
|
|
Packit Service |
2781ba |
while (property_name)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GValue value = { 0, };
|
|
Packit Service |
2781ba |
GParamSpec *pspec = NULL;
|
|
Packit Service |
2781ba |
gchar *error = NULL;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (!strcmp (property_name, "name"))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
pspec = g_object_class_find_property (
|
|
Packit Service |
2781ba |
G_OBJECT_GET_CLASS (G_OBJECT (node)), property_name);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
Packit Service |
2781ba |
G_VALUE_COLLECT (&value, var_args, 0, &error);
|
|
Packit Service |
2781ba |
if (error)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s: %s", G_STRFUNC, error);
|
|
Packit Service |
2781ba |
g_free (error);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_set_property (G_OBJECT (node), property_name, &value);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
else
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
if (node->operation)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
pspec = g_object_class_find_property (
|
|
Packit Service |
2781ba |
G_OBJECT_GET_CLASS (G_OBJECT (node->operation)), property_name);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
if (!pspec)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s:%s has no property named: '%s'",
|
|
Packit Service |
2781ba |
G_STRFUNC,
|
|
Packit Service |
2781ba |
gegl_node_get_debug_name (node), property_name);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
if (!(pspec->flags & G_PARAM_WRITABLE))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s: property (%s of operation class '%s' is not writable",
|
|
Packit Service |
2781ba |
G_STRFUNC,
|
|
Packit Service |
2781ba |
pspec->name,
|
|
Packit Service |
2781ba |
G_OBJECT_TYPE_NAME (node->operation));
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
Packit Service |
2781ba |
G_VALUE_COLLECT (&value, var_args, 0, &error);
|
|
Packit Service |
2781ba |
if (error)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("%s: %s", G_STRFUNC, error);
|
|
Packit Service |
2781ba |
g_free (error);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
break;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_set_property (G_OBJECT (node->operation), property_name, &value);
|
|
Packit Service |
2781ba |
g_value_unset (&value);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
property_name = va_arg (var_args, gchar *);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_thaw_notify (G_OBJECT (node));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
void
|
|
Packit Service |
2781ba |
gegl_apply_op (GeglBuffer *buffer,
|
|
Packit Service |
2781ba |
const gchar *first_property_name,
|
|
Packit Service |
2781ba |
...)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
va_list var_args;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
va_start (var_args, first_property_name);
|
|
Packit Service |
2781ba |
gegl_apply_op_valist (buffer, first_property_name, var_args);
|
|
Packit Service |
2781ba |
va_end (var_args);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
void
|
|
Packit Service |
2781ba |
gegl_apply_op_valist (GeglBuffer *buffer,
|
|
Packit Service |
2781ba |
const gchar *first_property_name,
|
|
Packit Service |
2781ba |
va_list var_args)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglBuffer *tempbuf = NULL;
|
|
Packit Service |
2781ba |
GeglNode *node;
|
|
Packit Service |
2781ba |
GeglNode *source;
|
|
Packit Service |
2781ba |
GeglNode *sink;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_ref (buffer);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
source = gegl_node_new_child (NULL, "operation", "gegl:buffer-source",
|
|
Packit Service |
2781ba |
"buffer", buffer,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
node = gegl_node_new_child (NULL, "operation", first_property_name, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (!GEGL_IS_OPERATION_POINT_FILTER (node->operation))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
tempbuf = gegl_buffer_new (gegl_buffer_get_extent (buffer), gegl_buffer_get_format (buffer));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
sink = gegl_node_new_child (NULL, "operation", "gegl:write-buffer",
|
|
Packit Service |
2781ba |
"buffer", tempbuf,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
else
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
sink = gegl_node_new_child (NULL, "operation", "gegl:write-buffer",
|
|
Packit Service |
2781ba |
"buffer", buffer,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_link_many (source, node, sink, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_set_props (node, var_args);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_process (sink);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_unref (source);
|
|
Packit Service |
2781ba |
g_object_unref (node);
|
|
Packit Service |
2781ba |
g_object_unref (sink);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (tempbuf)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gegl_buffer_copy (tempbuf, NULL, buffer, NULL);
|
|
Packit Service |
2781ba |
g_object_unref (tempbuf);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_unref (buffer);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglBuffer *gegl_filter_op_valist (GeglBuffer *buffer,
|
|
Packit Service |
2781ba |
const gchar *first_property_name,
|
|
Packit Service |
2781ba |
va_list var_args)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglBuffer *tempbuf = NULL;
|
|
Packit Service |
2781ba |
GeglNode *node;
|
|
Packit Service |
2781ba |
GeglNode *source;
|
|
Packit Service |
2781ba |
GeglNode *sink;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
//g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (buffer)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_object_ref (buffer);
|
|
Packit Service |
2781ba |
source = gegl_node_new_child (NULL, "operation", "gegl:buffer-source",
|
|
Packit Service |
2781ba |
"buffer", buffer,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
node = gegl_node_new_child (NULL, "operation", first_property_name, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
sink = gegl_node_new_child (NULL, "operation", "gegl:buffer-sink",
|
|
Packit Service |
2781ba |
"buffer", &tempbuf,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (buffer)
|
|
Packit Service |
2781ba |
gegl_node_link_many (source, node, sink, NULL);
|
|
Packit Service |
2781ba |
else
|
|
Packit Service |
2781ba |
gegl_node_link_many (node, sink, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_set_props (node, var_args);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_process (sink);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (buffer)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_object_unref (source);
|
|
Packit Service |
2781ba |
g_object_unref (buffer);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_unref (node);
|
|
Packit Service |
2781ba |
g_object_unref (sink);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return tempbuf;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
GeglBuffer *gegl_filter_op (GeglBuffer *buffer,
|
|
Packit Service |
2781ba |
const gchar *first_property_name,
|
|
Packit Service |
2781ba |
...)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglBuffer *ret;
|
|
Packit Service |
2781ba |
va_list var_args;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
//g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
va_start (var_args, first_property_name);
|
|
Packit Service |
2781ba |
ret = gegl_filter_op_valist (buffer, first_property_name, var_args);
|
|
Packit Service |
2781ba |
va_end (var_args);
|
|
Packit Service |
2781ba |
return ret;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
void
|
|
Packit Service |
2781ba |
gegl_render_op (GeglBuffer *source_buffer,
|
|
Packit Service |
2781ba |
GeglBuffer *target_buffer,
|
|
Packit Service |
2781ba |
const gchar *first_property_name,
|
|
Packit Service |
2781ba |
...)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
va_list var_args;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_return_if_fail (GEGL_IS_BUFFER (source_buffer));
|
|
Packit Service |
2781ba |
g_return_if_fail (GEGL_IS_BUFFER (target_buffer));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
va_start (var_args, first_property_name);
|
|
Packit Service |
2781ba |
gegl_render_op_valist (source_buffer, target_buffer,
|
|
Packit Service |
2781ba |
first_property_name, var_args);
|
|
Packit Service |
2781ba |
va_end (var_args);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
void
|
|
Packit Service |
2781ba |
gegl_render_op_valist (GeglBuffer *source_buffer,
|
|
Packit Service |
2781ba |
GeglBuffer *target_buffer,
|
|
Packit Service |
2781ba |
const gchar *first_property_name,
|
|
Packit Service |
2781ba |
va_list var_args)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglNode *node;
|
|
Packit Service |
2781ba |
GeglNode *source;
|
|
Packit Service |
2781ba |
GeglNode *sink;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_return_if_fail (GEGL_IS_BUFFER (source_buffer));
|
|
Packit Service |
2781ba |
g_return_if_fail (GEGL_IS_BUFFER (target_buffer));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_ref (source_buffer);
|
|
Packit Service |
2781ba |
g_object_ref (target_buffer);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
source = gegl_node_new_child (NULL, "operation", "gegl:buffer-source",
|
|
Packit Service |
2781ba |
"buffer", source_buffer,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
node = gegl_node_new_child (NULL, "operation", first_property_name, NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
sink = gegl_node_new_child (NULL, "operation", "gegl:write-buffer",
|
|
Packit Service |
2781ba |
"buffer", target_buffer,
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_node_link_many (source, node, sink, NULL);
|
|
Packit Service |
2781ba |
gegl_node_set_props (node, var_args);
|
|
Packit Service |
2781ba |
gegl_node_process (sink);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_unref (source);
|
|
Packit Service |
2781ba |
g_object_unref (node);
|
|
Packit Service |
2781ba |
g_object_unref (sink);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_unref (source_buffer);
|
|
Packit Service |
2781ba |
g_object_unref (target_buffer);
|
|
Packit Service |
2781ba |
}
|