|
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 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 |
|
|
Packit Service |
2781ba |
#include "gegl.h"
|
|
Packit Service |
2781ba |
#include "gegl-types-internal.h"
|
|
Packit Service |
2781ba |
#include "gegl-operation-source.h"
|
|
Packit Service |
2781ba |
#include "graph/gegl-node.h"
|
|
Packit Service |
2781ba |
#include "graph/gegl-pad.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
enum
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
PROP_0,
|
|
Packit Service |
2781ba |
PROP_OUTPUT,
|
|
Packit Service |
2781ba |
PROP_LAST
|
|
Packit Service |
2781ba |
};
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void get_property (GObject *gobject,
|
|
Packit Service |
2781ba |
guint prop_id,
|
|
Packit Service |
2781ba |
GValue *value,
|
|
Packit Service |
2781ba |
GParamSpec *pspec);
|
|
Packit Service |
2781ba |
static void set_property (GObject *gobject,
|
|
Packit Service |
2781ba |
guint prop_id,
|
|
Packit Service |
2781ba |
const GValue *value,
|
|
Packit Service |
2781ba |
GParamSpec *pspec);
|
|
Packit Service |
2781ba |
static gboolean gegl_operation_source_process
|
|
Packit Service |
2781ba |
(GeglOperation *operation,
|
|
Packit Service |
2781ba |
GeglOperationContext *context,
|
|
Packit Service |
2781ba |
const gchar *output_prop,
|
|
Packit Service |
2781ba |
const GeglRectangle *result,
|
|
Packit Service |
2781ba |
gint level);
|
|
Packit Service |
2781ba |
static void attach (GeglOperation *operation);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_DEFINE_TYPE (GeglOperationSource, gegl_operation_source, GEGL_TYPE_OPERATION)
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static GeglRectangle get_bounding_box (GeglOperation *self);
|
|
Packit Service |
2781ba |
static GeglRectangle get_required_for_output (GeglOperation *operation,
|
|
Packit Service |
2781ba |
const gchar *input_pad,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi);
|
|
Packit Service |
2781ba |
static GeglRectangle get_cached_region (GeglOperation *operation,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_operation_source_class_init (GeglOperationSourceClass * klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
Packit Service |
2781ba |
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gobject_class->set_property = set_property;
|
|
Packit Service |
2781ba |
gobject_class->get_property = get_property;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
operation_class->process = gegl_operation_source_process;
|
|
Packit Service |
2781ba |
operation_class->attach = attach;
|
|
Packit Service |
2781ba |
operation_class->get_cached_region = get_cached_region;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
operation_class->get_bounding_box = get_bounding_box;
|
|
Packit Service |
2781ba |
operation_class->get_required_for_output = get_required_for_output;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_class_install_property (gobject_class, PROP_OUTPUT,
|
|
Packit Service |
2781ba |
g_param_spec_object ("output",
|
|
Packit Service |
2781ba |
"Output",
|
|
Packit Service |
2781ba |
"Output pad for generated image buffer.",
|
|
Packit Service |
2781ba |
GEGL_TYPE_BUFFER,
|
|
Packit Service |
2781ba |
G_PARAM_READABLE |
|
|
Packit Service |
2781ba |
GEGL_PARAM_PAD_OUTPUT));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_operation_source_init (GeglOperationSource *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
attach (GeglOperation *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglOperation *operation = GEGL_OPERATION (self);
|
|
Packit Service |
2781ba |
GObjectClass *object_class = G_OBJECT_GET_CLASS (self);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_operation_create_pad (operation,
|
|
Packit Service |
2781ba |
g_object_class_find_property (object_class,
|
|
Packit Service |
2781ba |
"output"));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
get_property (GObject *object,
|
|
Packit Service |
2781ba |
guint prop_id,
|
|
Packit Service |
2781ba |
GValue *value,
|
|
Packit Service |
2781ba |
GParamSpec *pspec)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
set_property (GObject *object,
|
|
Packit Service |
2781ba |
guint prop_id,
|
|
Packit Service |
2781ba |
const GValue *value,
|
|
Packit Service |
2781ba |
GParamSpec *pspec)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static gboolean
|
|
Packit Service |
2781ba |
gegl_operation_source_process (GeglOperation *operation,
|
|
Packit Service |
2781ba |
GeglOperationContext *context,
|
|
Packit Service |
2781ba |
const gchar *output_prop,
|
|
Packit Service |
2781ba |
const GeglRectangle *result,
|
|
Packit Service |
2781ba |
gint level)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglOperationSourceClass *klass = GEGL_OPERATION_SOURCE_GET_CLASS (operation);
|
|
Packit Service |
2781ba |
GeglBuffer *output;
|
|
Packit Service |
2781ba |
gboolean success;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (strcmp (output_prop, "output"))
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
g_warning ("requested processing of %s pad on a source operation", output_prop);
|
|
Packit Service |
2781ba |
return FALSE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_assert (klass->process);
|
|
Packit Service |
2781ba |
output = gegl_operation_context_get_target (context, "output");
|
|
Packit Service |
2781ba |
success = klass->process (operation, output, result, level);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (output == GEGL_BUFFER (operation->node->cache))
|
|
Packit Service |
2781ba |
gegl_cache_computed (operation->node->cache, result);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return success;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static GeglRectangle
|
|
Packit Service |
2781ba |
get_bounding_box (GeglOperation *self)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglRectangle result = { 0, 0, 0, 0 };
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_warning ("Gegl Source '%s' does not override %s()",
|
|
Packit Service |
2781ba |
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (self)),
|
|
Packit Service |
2781ba |
G_STRFUNC);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return result;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static GeglRectangle
|
|
Packit Service |
2781ba |
get_required_for_output (GeglOperation *operation,
|
|
Packit Service |
2781ba |
const gchar *input_pad,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
return *roi;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static GeglRectangle
|
|
Packit Service |
2781ba |
get_cached_region (GeglOperation *operation,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
return *roi;
|
|
Packit Service |
2781ba |
}
|