Commit b2c8aa0d authored by Kevin Cozens's avatar Kevin Cozens

Updated to new chanting API.

	* operations/core/clone.c:
	* operations/core/convert-format.c:
	* operations/core/crop.c:
	* operations/core/shift.c:
	* operations/io/jpg-load.c:
	* operations/io/pixbuf.c:
	* operations/io/png-load.c:
	* operations/io/png-save.c:
	* operations/io/save-buffer.c:
	* operations/io/save-pixbuf.c:
	* operations/io/svg-load.c: Updated to new chanting API.

	* operations/blur/box-blur.c:
	* operations/blur/gaussian-blur.c:
	* operations/color/brightness-contrast.c
	* operations/color/invert.c
	* operations/color/mono-mixer.c
	* operations/color/stretch-contrast.c
	* operations/core/nop.c: Formatting changes.

svn path=/trunk/; revision=1918
parent 530fd639
2008-01-27 Kevin Cozens <kcozens@cvs.gnome.org>
* operations/core/clone.c:
* operations/core/convert-format.c:
* operations/core/crop.c:
* operations/core/shift.c:
* operations/io/jpg-load.c:
* operations/io/pixbuf.c:
* operations/io/png-load.c:
* operations/io/png-save.c:
* operations/io/save-buffer.c:
* operations/io/save-pixbuf.c:
* operations/io/svg-load.c: Updated to new chanting API.
* operations/blur/box-blur.c:
* operations/blur/gaussian-blur.c:
* operations/color/brightness-contrast.c
* operations/color/invert.c
* operations/color/mono-mixer.c
* operations/color/stretch-contrast.c
* operations/core/nop.c: Formatting changes.
2008-01-27 Øyvind Kolås <pippin@gimp.org>
Got rid of tickling, prepare should suffice for now.
......
......@@ -22,9 +22,11 @@ gegl_chant_double (radius, 0.0, 200.0, 4.0, "Radius of square pixel region, (wid
#else
#define GEGL_CHANT_TYPE_AREA_FILTER
#define GEGL_CHANT_C_FILE "box-blur.c"
#define GEGL_CHANT_C_FILE "box-blur.c"
#include "gegl-chant.h"
#include <stdio.h>
#include <math.h>
static void hor_blur (GeglBuffer *src,
GeglBuffer *dst,
......@@ -34,42 +36,6 @@ static void ver_blur (GeglBuffer *src,
GeglBuffer *dst,
gint radius);
#include <stdio.h>
#include <math.h>
static void prepare (GeglOperation *operation)
{
GeglChantO *o;
GeglOperationAreaFilter *op_area;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
o = GEGL_CHANT_PROPERTIES (operation);
op_area->left =
op_area->right =
op_area->top =
op_area->bottom = ceil (o->radius);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RaGaBaA float"));
hor_blur (input, temp, o->radius);
ver_blur (temp, output, o->radius);
g_object_unref (temp);
return TRUE;
}
#ifdef USE_DEAD_CODE
static inline float
get_mean_component (gfloat *buf,
......@@ -238,7 +204,38 @@ ver_blur (GeglBuffer *src,
g_free (dst_buf);
}
#include <math.h>
static void prepare (GeglOperation *operation)
{
GeglChantO *o;
GeglOperationAreaFilter *op_area;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
o = GEGL_CHANT_PROPERTIES (operation);
op_area->left =
op_area->right =
op_area->top =
op_area->bottom = ceil (o->radius);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RaGaBaA float"));
hor_blur (input, temp, o->radius);
ver_blur (temp, output, o->radius);
g_object_unref (temp);
return TRUE;
}
static void
......@@ -247,14 +244,14 @@ operation_class_init (GeglChantClass *klass)
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->categories = "blur";
operation_class->name = "box-blur";
operation_class->categories = "blur";
operation_class->name = "box-blur";
operation_class->description =
"Performs an averaging of a square box of pixels.";
}
......
......@@ -34,8 +34,8 @@ gegl_chant_string (filter, NULL,
#define GEGL_CHANT_TYPE_AREA_FILTER
#define GEGL_CHANT_C_FILE "gaussian-blur.c"
#include "gegl-chant.h"
#include "gegl-chant.h"
#include <math.h>
#include <stdio.h>
......@@ -78,64 +78,6 @@ fir_ver_blur (GeglBuffer *src,
gint offsetY);
static void prepare (GeglOperation *operation)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
area->left = area->right = ceil (o->std_dev_x * RADIUS_SCALE);
area->top = area->bottom = ceil (o->std_dev_y * RADIUS_SCALE);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
gdouble B, b[4];
gdouble *cmatrix;
gint cmatrix_len;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RaGaBaA float"));
gboolean force_iir = o->filter && !strcmp (o->filter, "iir");
gboolean force_fir = o->filter && !strcmp (o->filter, "fir");
if ((force_iir || o->std_dev_x > 1.0) && !force_fir)
{
iir_young_find_constants (o->std_dev_x, &B, b);
iir_young_hor_blur (input, temp, B, b);
}
else
{
cmatrix_len =
fir_gen_convolve_matrix (o->std_dev_x, &cmatrix);
fir_hor_blur (input, temp, cmatrix, cmatrix_len);
g_free (cmatrix);
}
if ((force_iir || o->std_dev_y > 1.0) && !force_fir)
{
iir_young_find_constants (o->std_dev_y, &B, b);
iir_young_ver_blur (temp, output, B, b,
o->std_dev_x * RADIUS_SCALE);
}
else
{
cmatrix_len =
fir_gen_convolve_matrix (o->std_dev_y, &cmatrix);
fir_ver_blur (temp, output, cmatrix, cmatrix_len,
o->std_dev_x * RADIUS_SCALE,
o->std_dev_y * RADIUS_SCALE);
g_free (cmatrix);
}
g_object_unref (temp);
return TRUE;
}
static void
iir_young_find_constants (gfloat sigma,
gdouble *B,
......@@ -451,7 +393,63 @@ fir_ver_blur (GeglBuffer *src,
g_free (dst_buf);
}
#include <math.h>
static void prepare (GeglOperation *operation)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
area->left = area->right = ceil (o->std_dev_x * RADIUS_SCALE);
area->top = area->bottom = ceil (o->std_dev_y * RADIUS_SCALE);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
gdouble B, b[4];
gdouble *cmatrix;
gint cmatrix_len;
temp = gegl_buffer_new (gegl_buffer_get_extent (input),
babl_format ("RaGaBaA float"));
gboolean force_iir = o->filter && !strcmp (o->filter, "iir");
gboolean force_fir = o->filter && !strcmp (o->filter, "fir");
if ((force_iir || o->std_dev_x > 1.0) && !force_fir)
{
iir_young_find_constants (o->std_dev_x, &B, b);
iir_young_hor_blur (input, temp, B, b);
}
else
{
cmatrix_len =
fir_gen_convolve_matrix (o->std_dev_x, &cmatrix);
fir_hor_blur (input, temp, cmatrix, cmatrix_len);
g_free (cmatrix);
}
if ((force_iir || o->std_dev_y > 1.0) && !force_fir)
{
iir_young_find_constants (o->std_dev_y, &B, b);
iir_young_ver_blur (temp, output, B, b,
o->std_dev_x * RADIUS_SCALE);
}
else
{
cmatrix_len =
fir_gen_convolve_matrix (o->std_dev_y, &cmatrix);
fir_ver_blur (temp, output, cmatrix, cmatrix_len,
o->std_dev_x * RADIUS_SCALE,
o->std_dev_y * RADIUS_SCALE);
g_free (cmatrix);
}
g_object_unref (temp);
return TRUE;
}
static void
......@@ -460,14 +458,14 @@ operation_class_init (GeglChantClass *klass)
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->categories = "blur";
operation_class->name = "gaussian-blur";
operation_class->categories = "blur";
operation_class->name = "gaussian-blur";
operation_class->description =
"Performs an averaging of neighbouring pixels with the normal distribution as weighting.";
}
......
......@@ -50,6 +50,13 @@ gegl_chant_double (brightness, -3.0, 3.0, 0.0, "Amount to increase brightness")
*/
#include "gegl-chant.h"
static void prepare (GeglOperation *operation)
{
/* set the babl format this operation prefers to work on */
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
/* GeglOperationPointFilter gives us a linear buffer to operate on
* in our requested pixel format
*/
......@@ -80,13 +87,6 @@ process (GeglOperation *op,
}
static void prepare (GeglOperation *operation)
{
/* set the babl format this operation prefers to work on */
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static void
operation_class_init (GeglChantClass *klass)
{
......
......@@ -64,11 +64,11 @@ operation_class_init (GeglChantClass *klass)
point_filter_class->process = process;
operation_class->name = "invert";
operation_class->categories = "color";
operation_class->name = "invert";
operation_class->categories = "color";
operation_class->description =
"Inverts the components (except alpha), the result is the "
"corresponding \"negative\" image.";
"Inverts the components (except alpha), the result is the"
" corresponding \"negative\" image.";
}
#endif
......@@ -43,11 +43,9 @@ process (GeglOperation *operation,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gfloat red = o->red;
gfloat green = o->green;
gfloat blue = o->blue;
gfloat *in_buf;
gfloat *out_buf;
......
......@@ -80,6 +80,15 @@ static void prepare (GeglOperation *operation)
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static GeglRectangle
compute_input_request (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *roi)
{
GeglRectangle result = *gegl_operation_source_get_defined_region (operation, "input");
return result;
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
......@@ -117,17 +126,7 @@ process (GeglOperation *operation,
return TRUE;
}
static GeglRectangle
compute_input_request (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *roi)
{
GeglRectangle result = *gegl_operation_source_get_defined_region (operation, "input");
return result;
}
/* This is called at the end of the gobject class_init function, the
* GEGL_CHANT_CLASS_INIT was needed to make this happen
/* This is called at the end of the gobject class_init function.
*
* Here we override the standard passthrough options for the rect
* computations.
......@@ -138,18 +137,19 @@ operation_class_init (GeglChantClass *klass)
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
operation_class->prepare = prepare;
operation_class->compute_input_request = compute_input_request;
operation_class->name = "stretch-contrast";
operation_class->categories = "color:enhance";
operation_class->name = "stretch-contrast";
operation_class->categories = "color:enhance";
operation_class->description =
"Scales the components of the buffer to be in the 0.0-1.0 range. This improves images that makes poor use of the available contrast (little contrast, very dark, or very bright images).";
operation_class->compute_input_request = compute_input_request;
"Scales the components of the buffer to be in the 0.0-1.0 range."
" This improves images that makes poor use of the available contrast"
" (little contrast, very dark, or very bright images).";
}
#endif
/* This file is part of GEGL
/* This file is an image processing operation for GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -13,199 +13,24 @@
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2006 Øyvind Kolås
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#ifndef __GEGL_OPERATION_CLONE_H__
#define __GEGL_OPERATION_CLONE_H__
#ifdef GEGL_CHANT_PROPERTIES
#include <gegl-plugin.h>
gegl_chant_string (ref, "ID", "The reference ID used as input (for use in XML).")
G_BEGIN_DECLS
#else
#define GEGL_TYPE_OPERATION_CLONE (gegl_operation_clone_get_type ())
#define GEGL_OPERATION_CLONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_CLONE, GeglOperationClone))
#define GEGL_OPERATION_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_OPERATION_CLONE, GeglOperationCloneClass))
#define GEGL_IS_OPERATION_CLONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_CLONE))
#define GEGL_IS_OPERATION_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_OPERATION_CLONE))
#define GEGL_OPERATION_CLONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_OPERATION_CLONE, GeglOperationCloneClass))
#define GEGL_CHANT_TYPE_FILTER
#define GEGL_CHANT_C_FILE "clone.c"
typedef struct _GeglOperationClone GeglOperationClone;
typedef struct _GeglOperationCloneClass GeglOperationCloneClass;
struct _GeglOperationClone
{
GeglOperation parent_instance;
gchar *ref;
};
struct _GeglOperationCloneClass
{
GeglOperationClass parent_class;
};
GType gegl_operation_clone_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GEGL_OPERATION_CLONE_H__ */
/***************************************************************************/
#include "graph/gegl-pad.h"
#include "gegl-chant.h"
#include "graph/gegl-node.h"
#include <math.h>
#include <string.h>
enum
{
PROP_0,
PROP_OUTPUT,
PROP_INPUT,
PROP_REF
};
static gboolean process (GeglOperation *operation,
GeglNodeContext *context,
const gchar *output_prop,
const GeglRectangle *result);
static void attach (GeglOperation *operation);
static GeglNode * detect (GeglOperation *operation,
gint x,
gint y);
static GeglRectangle get_defined_region (GeglOperation *operation);
static GeglRectangle compute_input_request (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *roi);
static GeglRectangle compute_affected_region (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *input_region);
static void get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
G_DEFINE_DYNAMIC_TYPE (GeglOperationClone, gegl_operation_clone, GEGL_TYPE_OPERATION)
static void
gegl_operation_clone_class_init (GeglOperationCloneClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
object_class->get_property = get_property;
object_class->set_property = set_property;
operation_class->categories = "core";
operation_class->no_cache = TRUE;
operation_class->process = process;
operation_class->attach = attach;
operation_class->detect = detect;
operation_class->get_defined_region = get_defined_region;
operation_class->compute_input_request = compute_input_request;
operation_class->compute_affected_region = compute_affected_region;
gegl_operation_class_set_name (operation_class, "clone");
g_object_class_install_property (object_class, PROP_OUTPUT,
g_param_spec_object ("output",
"Output",
"Ouput pad for generated image buffer.",
GEGL_TYPE_BUFFER,
G_PARAM_READABLE |
GEGL_PARAM_PAD_OUTPUT));
g_object_class_install_property (object_class, PROP_INPUT,
g_param_spec_object ("input",
"Input",
"Input pad, for image buffer input.",
GEGL_TYPE_BUFFER,
G_PARAM_READWRITE |
GEGL_PARAM_PAD_INPUT));
g_object_class_install_property (object_class, PROP_REF,
g_param_spec_string ("ref",
"Reference",
"The reference ID used as input (for use in XML).",
"",
G_PARAM_READWRITE |
GEGL_PARAM_PAD_INPUT));
}
static void
gegl_operation_clone_class_finalize (GeglOperationCloneClass *klass)
{
}
static void
gegl_operation_clone_init (GeglOperationClone *self)
{
self->ref = NULL;
}
static void
get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GeglOperationClone *self = GEGL_OPERATION_CLONE (object);
switch (property_id)
{
case PROP_REF:
g_value_set_string (value, self->ref);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GeglOperationClone *self = GEGL_OPERATION_CLONE (object);
switch (property_id)
{
case PROP_REF:
if (self->ref)
g_free (self->ref);
self->ref = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
attach (GeglOperation *operation)
{
GObjectClass *object_class = G_OBJECT_GET_CLASS (operation);
gegl_operation_create_pad (operation,
g_object_class_find_property (object_class,
"output"));
gegl_operation_create_pad (operation,
g_object_class_find_property (object_class,
"input"));
}
static GeglNode *
detect (GeglOperation *operation,
gint x,
......@@ -213,16 +38,30 @@ detect (GeglOperation *operation,
{
GeglNode *node = operation->node;
if (x>=node->have_rect.x &&
y>=node->have_rect.y &&
x<node->have_rect.width &&
y<node->have_rect.height )
if (x >= node->have_rect.x &&
y >= node->have_rect.y &&
x < node->have_rect.width &&
y < node->have_rect.height)
{
return node;
}
return NULL;
}
static GeglRectangle
get_defined_region (GeglOperation *operation)
{
GeglRectangle result = { 0, 0, 0, 0 };
GeglRectangle *in_rect;
in_rect = gegl_operation_source_get_defined_region (operation, "input");
if (in_rect)
{
result = *in_rect;
}
return result;
}
static gboolean
process (GeglOperation *operation,
......@@ -248,52 +87,22 @@ process (GeglOperation *operation,
return TRUE;
}
static GeglRectangle
get_defined_region (GeglOperation *operation)
{
GeglRectangle result = { 0, 0, 0, 0 };
GeglRectangle *in_rect;
in_rect = gegl_operation_source_get_defined_region (operation, "input");
if (in_rect)
{
result = *in_rect;
}
return result;
}
static GeglRectangle
compute_affected_region (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *input_region)
static void
operation_class_init (GeglChantClass *klass)
{
return *input_region;
}
GeglOperationClass *operation_class;
static GeglRectangle
compute_input_request (GeglOperation *operation,
const gchar *input_pad,
const GeglRectangle *roi)
{
return *roi;
}
operation_class = GEGL_OPERATION_CLASS (klass);
operation_class->process = process;
operation_class->get_defined_region = get_defined_region;
operation_class->detect = detect;
static const GeglModuleInfo modinfo =
{
GEGL_MODULE_ABI_VERSION, "clone", "", ""
};
operation_class->name = "clone";
operation_class->categories = "core";
operation_class->description = "Clone a buffer";
G_MODULE_EXPORT const GeglModuleInfo *
gegl_module_query (GTypeModule *module)
{
return &modinfo;
operation_class->no_cache = TRUE;
}
G_MODULE_EXPORT gboolean
gegl_module_register (GTypeModule *module)
{
gegl_operation_clone_register_type (module);
return TRUE;
}
#endif
......@@ -18,26 +18,25 @@
*
* This operation is just a forked grey op with format parameters.
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_string(format, "RGBA float", "Babl ouput format string")
#else