gegl r1914 - in trunk: . operations/enhance operations/render operations/svg operations/transparency
- From: kcozens svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r1914 - in trunk: . operations/enhance operations/render operations/svg operations/transparency
- Date: Fri, 25 Jan 2008 07:05:15 +0000 (GMT)
Author: kcozens
Date: Fri Jan 25 07:05:15 2008
New Revision: 1914
URL: http://svn.gnome.org/viewvc/gegl?rev=1914&view=rev
Log:
* operations/enhance/bilateral-filter.c:
* operations/enhance/snn-mean.c:
* operations/render/checkerboard.c:
* operations/render/color.c:
* operations/render/FractalExplorer.c:
* operations/render/introspect.c:
* operations/render/noise.c:
* operations/svg/svg_huerotate.c:
* operations/svg/svg_luminancetoalpha.c:
* operations/svg/svg_matrix.c:
* operations/svg/svg_saturate.c:
* operations/transparency/opacity.c: Updated to new chanting API.
Modified:
trunk/ChangeLog
trunk/operations/enhance/bilateral-filter.c
trunk/operations/enhance/snn-mean.c
trunk/operations/render/FractalExplorer.c
trunk/operations/render/checkerboard.c
trunk/operations/render/color.c
trunk/operations/render/introspect.c
trunk/operations/render/noise.c
trunk/operations/svg/svg_huerotate.c
trunk/operations/svg/svg_luminancetoalpha.c
trunk/operations/svg/svg_matrix.c
trunk/operations/svg/svg_saturate.c
trunk/operations/transparency/opacity.c
Modified: trunk/operations/enhance/bilateral-filter.c
==============================================================================
--- trunk/operations/enhance/bilateral-filter.c (original)
+++ trunk/operations/enhance/bilateral-filter.c Fri Jan 25 07:05:15 2008
@@ -17,22 +17,19 @@
* 2007 Ãyvind KolÃs <oeyvindk hig no>
*/
-#if GEGL_CHANT_PROPERTIES
-#define MAX_SAMPLES 20000 /* adapted to max level of radius */
+#ifdef GEGL_CHANT_PROPERTIES
+
gegl_chant_double (blur_radius, 0.0, 70.0, 4.0,
- "Radius of square pixel region, (width and height will be radius*2+1.")
+ "Radius of square pixel region, (width and height will be radius*2+1).")
gegl_chant_double (edge_preservation, 0.0, 70.0, 8.0, "Amount of edge preservation")
#else
-#define GEGL_CHANT_NAME bilateral_filter
-#define GEGL_CHANT_SELF "bilateral-filter.c"
-#define GEGL_CHANT_DESCRIPTION "An edge preserving blur filter that can be used for noise reduction. It is a gaussian blur where the contribution of neighbourhood pixels are weighted by the color difference from the center pixel."
-#define GEGL_CHANT_CATEGORIES "misc"
+#define GEGL_CHANT_TYPE_AREA_FILTER
+#define GEGL_CHANT_C_FILE "bilateral-filter.c"
-#define GEGL_CHANT_AREA_FILTER
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
#include <math.h>
static void
@@ -43,38 +40,39 @@
#include <stdio.h>
+static void tickle (GeglOperation *operation)
+{
+ GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+
+ area->left = area->right = area->top = area->bottom = ceil (o->blur_radius);
+}
+
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
- GeglOperationFilter *filter;
- GeglChantOperation *self;
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ GeglBuffer *temp_in;
+ GeglRectangle compute;
- filter = GEGL_OPERATION_FILTER (operation);
- self = GEGL_CHANT_OPERATION (operation);
+ compute = gegl_operation_compute_input_request (operation,
+ "input", result);
+ if (o->blur_radius < 1.0)
{
- GeglBuffer *temp_in;
- GeglRectangle compute;
-
- compute = gegl_operation_compute_input_request (operation,
- "input", result);
-
- if (self->blur_radius < 1.0)
- {
- output = g_object_ref (input);
- }
- else
- {
- temp_in = gegl_buffer_create_sub_buffer (input, &compute);
-
- bilateral_filter (temp_in, output, self->blur_radius, self->edge_preservation);
- g_object_unref (temp_in);
- }
+ output = g_object_ref (input);
+ }
+ else
+ {
+ temp_in = gegl_buffer_create_sub_buffer (input, &compute);
+ bilateral_filter (temp_in, output, o->blur_radius, o->edge_preservation);
+ g_object_unref (temp_in);
}
+
return TRUE;
}
@@ -113,7 +111,7 @@
gfloat *center_pix = src_buf + (x+(y * gegl_buffer_get_width (src))) * 4;
gfloat accumulated[4]={0,0,0,0};
gfloat count=0.0;
-
+
for (v=-radius;v<=radius;v++)
for (u=-radius;u<=radius;u++)
{
@@ -121,16 +119,16 @@
y+v >= 0 && y+v < gegl_buffer_get_height (dst))
{
gint c;
-
+
gfloat *src_pix = src_buf + ((x+u)+((y+v) * gegl_buffer_get_width (src))) * 4;
gfloat diff_map = exp (- (POW2(center_pix[0] - src_pix[0])+
POW2(center_pix[1] - src_pix[1])+
- POW2(center_pix[2] - src_pix[2])) * preserve
+ POW2(center_pix[2] - src_pix[2])) * preserve
);
gfloat gaussian_weight;
gfloat weight;
-
+
gaussian_weight = gauss[u+(int)radius+(v+(int)radius)*width];
weight = diff_map * gaussian_weight;
@@ -138,7 +136,7 @@
for (c=0;c<4;c++)
{
accumulated[c] += src_pix[c] * weight;
- }
+ }
count += weight;
}
}
@@ -153,12 +151,25 @@
g_free (dst_buf);
}
-static void tickle (GeglOperation *operation)
+
+static void
+operation_class_init (GeglChantClass *klass)
{
- GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
- GeglChantOperation *blur = GEGL_CHANT_OPERATION (operation);
- area->left = area->right = area->top = area->bottom =
- ceil (blur->blur_radius);
+ GeglOperationClass *operation_class;
+ GeglOperationFilterClass *filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
+
+ filter_class->process = process;
+ operation_class->tickle = tickle;
+
+ operation_class->name = "bilateral-filter";
+ operation_class->categories = "misc";
+ operation_class->description =
+ "An edge preserving blur filter that can be used for noise reduction."
+ " It is a gaussian blur where the contribution of neighbourhood pixels"
+ " are weighted by the color difference from the center pixel.";
}
#endif
Modified: trunk/operations/enhance/snn-mean.c
==============================================================================
--- trunk/operations/enhance/snn-mean.c (original)
+++ trunk/operations/enhance/snn-mean.c Fri Jan 25 07:05:15 2008
@@ -17,8 +17,7 @@
* 2007 Ãyvind KolÃs <oeyvindk hig no>
*/
-#if GEGL_CHANT_PROPERTIES
-#define MAX_SAMPLES 20000 /* adapted to mean level of radius */
+#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (radius, 0.0, 70.0, 8.0,
"Radius of square pixel region, (width and height will be radius*2+1.")
@@ -26,14 +25,10 @@
#else
-#define GEGL_CHANT_NAME snn_mean
-#define GEGL_CHANT_SELF "snn-mean.c"
-#define GEGL_CHANT_DESCRIPTION "Noise reducing edge enhancing blur filter based on Symmetric Nearest Neighbours"
-#define GEGL_CHANT_CATEGORIES "misc"
+#define GEGL_CHANT_TYPE_AREA_FILTER
+#define GEGL_CHANT_C_FILE "snn-mean.c"
-#define GEGL_CHANT_AREA_FILTER
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
#include <math.h>
static void
@@ -43,36 +38,39 @@
gint pairs);
+static void tickle (GeglOperation *operation)
+{
+ GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+
+ area->left = area->right = area->top = area->bottom = ceil (o->radius);
+}
+
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
- GeglOperationFilter *filter;
- GeglChantOperation *self;
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ GeglBuffer *temp_in;
+ GeglRectangle compute;
- filter = GEGL_OPERATION_FILTER (operation);
- self = GEGL_CHANT_OPERATION (operation);
+ compute = gegl_operation_compute_input_request (operation,
+ "input", result);
+ if (o->radius < 1.0)
{
- GeglBuffer *temp_in;
- GeglRectangle compute;
- compute = gegl_operation_compute_input_request (operation,
- "input", result);
-
- if (self->radius < 1.0)
- {
- output = g_object_ref (input);
- }
- else
- {
- temp_in = gegl_buffer_create_sub_buffer (input, &compute);
-
- snn_mean (temp_in, output, self->radius, self->pairs);
- g_object_unref (temp_in);
- }
+ output = g_object_ref (input);
+ }
+ else
+ {
+ temp_in = gegl_buffer_create_sub_buffer (input, &compute);
+
+ snn_mean (temp_in, output, o->radius, o->pairs);
+ g_object_unref (temp_in);
}
+
return TRUE;
}
@@ -123,8 +121,8 @@
gfloat *center_pix = src_buf + offset * 4;
gfloat accumulated[4]={0,};
gint count=0;
-
- /* iterate through the upper left quater of pixels */
+
+ /* iterate through the upper left quater of pixels */
for (v=-radius;v<=0;v++)
for (u=-radius;u<= (pairs==1?radius:0);u++)
{
@@ -165,7 +163,7 @@
for (i=0;i<4;i++)
{
accumulated[i] += selected_pix[i];
- }
+ }
count++;
if (u==0 && v==0)
@@ -181,12 +179,23 @@
g_free (dst_buf);
}
-static void tickle (GeglOperation *operation)
+
+static void
+operation_class_init (GeglChantClass *klass)
{
- GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
- GeglChantOperation *filter = GEGL_CHANT_OPERATION (operation);
- area->left = area->right = area->top = area->bottom =
- ceil (filter->radius);
+ GeglOperationClass *operation_class;
+ GeglOperationFilterClass *filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
+
+ filter_class->process = process;
+ operation_class->tickle = tickle;
+
+ operation_class->name = "snn-mean";
+ operation_class->categories = "misc";
+ operation_class->description =
+ "Noise reducing edge enhancing blur filter based on Symmetric Nearest Neighbours";
}
#endif
Modified: trunk/operations/render/FractalExplorer.c
==============================================================================
--- trunk/operations/render/FractalExplorer.c (original)
+++ trunk/operations/render/FractalExplorer.c Fri Jan 25 07:05:15 2008
@@ -22,7 +22,7 @@
#define MAXNCOLORS 8192
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_int (width, 10, 10000000, 400, "Width")
gegl_chant_int (height, 10, 10000000, 400, "Height")
@@ -52,17 +52,10 @@
#else
-#define GEGL_CHANT_NAME FractalExplorer
-#define GEGL_CHANT_SELF "FractalExplorer.c"
-#define GEGL_CHANT_DESCRIPTION "Fractal Explorer"
-#define GEGL_CHANT_CATEGORIES "render"
+#define GEGL_CHANT_TYPE_SOURCE
+#define GEGL_CHANT_C_FILE "FractalExplorer.c"
-#define GEGL_CHANT_SOURCE
-
-#define GEGL_CHANT_PREPARE
-#define GEGL_CHANT_CLASS_INIT
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
#include <math.h>
#include <stdio.h>
@@ -96,12 +89,12 @@
static void
-explorer_render_row (GeglChantOperation *self,
- gint col_start,
- gint col_end,
- gint row,
- clrmap colormap,
- guchar **dest_row)
+explorer_render_row (GeglChantO *o,
+ gint col_start,
+ gint col_end,
+ gint row,
+ clrmap colormap,
+ guchar **dest_row)
{
gint fractaltype;
gint col;
@@ -134,18 +127,18 @@
gdouble ydiff;
gdouble log2;
- fractaltype = self->fractaltype;
- xmin = self->xmin;
- ymin = self->ymin;
- cx = self->cx;
- cy = self->cy;
- iteration = self->iter;
- ncolors = self->ncolors;
- useloglog = self->useloglog;
+ fractaltype = o->fractaltype;
+ xmin = o->xmin;
+ ymin = o->ymin;
+ cx = o->cx;
+ cy = o->cy;
+ iteration = o->iter;
+ ncolors = o->ncolors;
+ useloglog = o->useloglog;
log2 = log (2.0);
- xdiff = (self->xmax - xmin) / self->width;
- ydiff = (self->ymax - ymin) / self->height;
+ xdiff = (o->xmax - xmin) / o->width;
+ ydiff = (o->ymax - ymin) / o->height;
for (col = col_start; col < col_end; col++)
{
@@ -301,7 +294,7 @@
}
static void
-make_color_map (GeglChantOperation *self, clrmap colormap)
+make_color_map (GeglChantO *o, clrmap colormap)
{
gint i;
gint r;
@@ -312,16 +305,16 @@
gdouble bluestretch;
gdouble pi = atan (1) * 4;
- redstretch = self->redstretch * 127.5;
- greenstretch = self->greenstretch * 127.5;
- bluestretch = self->bluestretch * 127.5;
+ redstretch = o->redstretch * 127.5;
+ greenstretch = o->greenstretch * 127.5;
+ bluestretch = o->bluestretch * 127.5;
- for (i = 0; i < self->ncolors; i++)
+ for (i = 0; i < o->ncolors; i++)
{
- double x = (i*2.0) / self->ncolors;
+ double x = (i*2.0) / o->ncolors;
r = gr = bl = 0;
- switch (self->redmode)
+ switch (o->redmode)
{
case SINUS:
r = (int) redstretch *(1.0 + sin((x - 1) * pi));
@@ -336,7 +329,7 @@
break;
}
- switch (self->greenmode)
+ switch (o->greenmode)
{
case SINUS:
gr = (int) greenstretch *(1.0 + sin((x - 1) * pi));
@@ -351,7 +344,7 @@
break;
}
- switch (self->bluemode)
+ switch (o->bluemode)
{
case SINUS:
bl = (int) bluestretch * (1.0 + sin ((x - 1) * pi));
@@ -370,13 +363,13 @@
gr = MIN (gr, 255);
bl = MIN (bl, 255);
- if (self->redinvert)
+ if (o->redinvert)
r = 255 - r;
- if (self->greeninvert)
+ if (o->greeninvert)
gr = 255 - gr;
- if (self->blueinvert)
+ if (o->blueinvert)
bl = 255 - bl;
colormap[i].r = r;
@@ -385,44 +378,6 @@
}
}
-static gboolean
-process (GeglOperation *operation,
- GeglNodeContext *context,
- GeglBuffer *output,
- const GeglRectangle *result)
-{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
- {
- clrmap colormap;
- guchar *buf;
- gint pxsize;
-
- make_color_map (self, colormap);
-
- g_object_get (output, "px-size", &pxsize, NULL);
-
- buf = g_new (guchar, result->width * result->height * pxsize);
- {
- guchar *dst=buf;
- gint y;
- for (y=0; y < result->height; y++)
- {
- explorer_render_row (self,
- result->x,
- result->x + result->width ,
- result->y + y,
- colormap,
- &dst);
- }
- }
-
- gegl_buffer_set (output, NULL, babl_format ("R'G'B' u8"), buf,
- GEGL_AUTO_ROWSTRIDE);
- g_free (buf);
- }
- return TRUE;
-}
-
static void
prepare (GeglOperation *operation)
{
@@ -432,19 +387,72 @@
static GeglRectangle
get_defined_region (GeglOperation *operation)
{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
- GeglRectangle result = {0,0,0,0};
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ GeglRectangle result = {0,0,0,0};
- result.width = self->width;
- result.height = self->height;
+ result.width = o->width;
+ result.height = o->height;
return result;
}
-static void class_init (GeglOperationClass *klass)
+static gboolean
+process (GeglOperation *operation,
+ GeglNodeContext *context,
+ GeglBuffer *output,
+ const GeglRectangle *result)
{
- klass->adjust_result_region = NULL;
- klass->no_cache = FALSE;
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ clrmap colormap;
+ guchar *buf;
+ gint pxsize;
+
+ make_color_map (o, colormap);
+
+ g_object_get (output, "px-size", &pxsize, NULL);
+
+ buf = g_new (guchar, result->width * result->height * pxsize);
+ {
+ guchar *dst=buf;
+ gint y;
+ for (y=0; y < result->height; y++)
+ {
+ explorer_render_row (o,
+ result->x,
+ result->x + result->width ,
+ result->y + y,
+ colormap,
+ &dst);
+ }
+ }
+
+ gegl_buffer_set (output, NULL, babl_format ("R'G'B' u8"), buf,
+ GEGL_AUTO_ROWSTRIDE);
+ g_free (buf);
+
+ return TRUE;
+}
+
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationSourceClass *source_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
+
+ source_class->process = process;
+ operation_class->get_defined_region = get_defined_region;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "FractalExplorer";
+ operation_class->categories = "render";
+ operation_class->description = "Fractal Explorer";
+
+ operation_class->no_cache = TRUE;
+ operation_class->adjust_result_region = NULL;
}
#endif
Modified: trunk/operations/render/checkerboard.c
==============================================================================
--- trunk/operations/render/checkerboard.c (original)
+++ trunk/operations/render/checkerboard.c Fri Jan 25 07:05:15 2008
@@ -15,7 +15,7 @@
*
* Copyright 2006 Ãyvind KolÃs <pippin gimp org>
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_int (x, -G_MAXINT, G_MAXINT, 16, "Horizontal width of cells pixels.")
gegl_chant_int (y, -G_MAXINT, G_MAXINT, 16, "Vertical width of cells in pixels.")
@@ -26,17 +26,10 @@
#else
-#define GEGL_CHANT_SOURCE
-#define GEGL_CHANT_NAME checkerboard
-#define GEGL_CHANT_DESCRIPTION "Checkerboard renderer."
+#define GEGL_CHANT_TYPE_SOURCE
+#define GEGL_CHANT_C_FILE "checkerboard.c"
-#define GEGL_CHANT_SELF "checkerboard.c"
-#define GEGL_CHANT_CATEGORIES "render"
-#define GEGL_CHANT_CLASS_INIT
-
-#define GEGL_CHANT_PREPARE
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
static void
prepare (GeglOperation *operation)
@@ -44,76 +37,90 @@
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
+static GeglRectangle
+get_defined_region (GeglOperation *operation)
+{
+ GeglRectangle result = {-10000000, -10000000, 20000000, 20000000};
+ return result;
+}
+
static gboolean
process (GeglOperation *operation,
GeglNodeContext *context,
GeglBuffer *output,
const GeglRectangle *result)
{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ gfloat *buf;
+ gfloat color1[4];
+ gfloat color2[4];
+ gint pxsize;
+ gint n_pixels;
+
+ gegl_color_get_rgba (o->color1,
+ &color1[0],
+ &color1[1],
+ &color1[2],
+ &color1[3]);
+
+ gegl_color_get_rgba (o->color2,
+ &color2[0],
+ &color2[1],
+ &color2[2],
+ &color2[3]);
+
+ g_object_get (output, "px-size", &pxsize,
+ "pixels", &n_pixels,
+ NULL);
+ buf = g_malloc (n_pixels * pxsize);
+ {
+ gfloat *dst=buf;
+ gint y;
+ for (y=0; y < result->height; y++)
+ {
+ gint x;
+ for (x=0; x < result->width ; x++)
+ {
+ gfloat *rgba_color;
+ gint nx,ny;
+
+ nx = ((x + result->x + o->x_offset + 100000 * o->x)/o->x) ;
+ ny = ((y + result->y + o->y_offset + 100000 * o->y)/o->y) ;
+
+ rgba_color = (nx+ny) % 2 == 0 ? color1 : color2;
+
+ memcpy (dst, rgba_color, 4*sizeof(gfloat));
+ dst += 4;
+ }
+ }
+ }
+
+ gegl_buffer_set (output, NULL, NULL, buf, GEGL_AUTO_ROWSTRIDE);
+ g_free (buf);
- {
- gfloat *buf;
- gfloat color1[4];
- gfloat color2[4];
- gint pxsize;
- gint n_pixels;
-
-
- gegl_color_get_rgba (self->color1,
- &color1[0],
- &color1[1],
- &color1[2],
- &color1[3]);
-
- gegl_color_get_rgba (self->color2,
- &color2[0],
- &color2[1],
- &color2[2],
- &color2[3]);
-
- g_object_get (output, "px-size", &pxsize,
- "pixels", &n_pixels,
- NULL);
- buf = g_malloc (n_pixels * pxsize);
- {
- gfloat *dst=buf;
- gint y;
- for (y=0; y < result->height; y++)
- {
- gint x;
- for (x=0; x < result->width ; x++)
- {
- gfloat *rgba_color;
- gint nx,ny;
-
- nx = ((x + result->x + self->x_offset + 100000 * self->x)/self->x) ;
- ny = ((y + result->y + self->y_offset + 100000 * self->y)/self->y) ;
-
- rgba_color = (nx+ny) % 2 == 0 ? color1 : color2;
-
- memcpy(dst, rgba_color, 4*sizeof(gfloat));
- dst += 4;
- }
- }
- }
- gegl_buffer_set (output, NULL, NULL, buf, GEGL_AUTO_ROWSTRIDE);
- g_free (buf);
- }
return TRUE;
}
-static GeglRectangle
-get_defined_region (GeglOperation *operation)
-{
- GeglRectangle result = {-10000000,-10000000, 20000000, 20000000};
- return result;
-}
-static void class_init (GeglOperationClass *klass)
+static void
+operation_class_init (GeglChantClass *klass)
{
- klass->no_cache = TRUE;
- klass->adjust_result_region = NULL;
+ GeglOperationClass *operation_class;
+ GeglOperationSourceClass *source_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
+
+ source_class->process = process;
+ operation_class->get_defined_region = get_defined_region;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "checkerboard";
+ operation_class->categories = "render";
+ operation_class->description = "Checkerboard renderer.";
+
+ operation_class->no_cache = TRUE;
+ operation_class->adjust_result_region = NULL;
}
#endif
Modified: trunk/operations/render/color.c
==============================================================================
--- trunk/operations/render/color.c (original)
+++ trunk/operations/render/color.c Fri Jan 25 07:05:15 2008
@@ -15,22 +15,15 @@
*
* Copyright 2006 Ãyvind KolÃs <pippin gimp org>
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_color (value, "black", "The color to render (defaults to 'black')")
#else
-#define GEGL_CHANT_SOURCE
-#define GEGL_CHANT_NAME color
-#define GEGL_CHANT_DESCRIPTION "Generates a buffer entirely filled with the specified color, crop it to get smaller dimensions."
+#define GEGL_CHANT_TYPE_SOURCE
+#define GEGL_CHANT_C_FILE "color.c"
-#define GEGL_CHANT_SELF "color.c"
-#define GEGL_CHANT_CATEGORIES "render"
-
-#define GEGL_CHANT_CLASS_INIT
-#define GEGL_CHANT_PREPARE
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
static void
prepare (GeglOperation *operation)
@@ -38,42 +31,7 @@
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
-static gboolean
-process (GeglOperation *operation,
- GeglNodeContext *context,
- GeglBuffer *output,
- const GeglRectangle *result)
-{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
-
- {
- gfloat *buf;
- gfloat color[4];
-
- gegl_color_get_rgba (self->value,
- &color[0],
- &color[1],
- &color[2],
- &color[3]);
-
- buf = g_malloc (result->width * result->height * 4 * sizeof (gfloat));
- {
- gfloat *dst=buf;
- gint i;
- for (i=0; i < result->height *result->width ; i++)
- {
- memcpy(dst, color, 4*sizeof(gfloat));
- dst += 4;
- }
- }
- gegl_buffer_set (output, NULL, NULL, buf, GEGL_AUTO_ROWSTRIDE);
- g_free (buf);
- }
- return TRUE;
-}
-
-
-static GeglRectangle
+static GeglRectangle
get_defined_region (GeglOperation *operation)
{
GeglRectangle result = {-10000000,-10000000,20000000,20000000};
@@ -88,11 +46,60 @@
return NULL;
}
-static void class_init (GeglOperationClass *klass)
+static gboolean
+process (GeglOperation *operation,
+ GeglNodeContext *context,
+ GeglBuffer *output,
+ const GeglRectangle *result)
{
- klass->detect = detect;
- klass->no_cache = TRUE;
- klass->adjust_result_region = NULL;
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ gfloat *buf;
+ gfloat color[4];
+
+ gegl_color_get_rgba (o->value,
+ &color[0],
+ &color[1],
+ &color[2],
+ &color[3]);
+
+ buf = g_malloc (result->width * result->height * 4 * sizeof (gfloat));
+ {
+ gfloat *dst=buf;
+ gint i;
+ for (i=0; i < result->height *result->width ; i++)
+ {
+ memcpy(dst, color, 4*sizeof(gfloat));
+ dst += 4;
+ }
+ }
+ gegl_buffer_set (output, NULL, NULL, buf, GEGL_AUTO_ROWSTRIDE);
+ g_free (buf);
+
+ return TRUE;
+}
+
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationSourceClass *source_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
+
+ source_class->process = process;
+ operation_class->get_defined_region = get_defined_region;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "color";
+ operation_class->categories = "render";
+ operation_class->description =
+ "Generates a buffer entirely filled with the specified color, crop it to get smaller dimensions.";
+
+ operation_class->no_cache = TRUE;
+ operation_class->detect = detect;
+ operation_class->adjust_result_region = NULL;
}
#endif
Modified: trunk/operations/render/introspect.c
==============================================================================
--- trunk/operations/render/introspect.c (original)
+++ trunk/operations/render/introspect.c Fri Jan 25 07:05:15 2008
@@ -15,26 +15,36 @@
*
* Copyright 2006 Ãyvind KolÃs <pippin gimp org>
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_object(node, "GeglNode to introspect")
gegl_chant_pointer(buf, "Buffer")
#else
-#define GEGL_CHANT_NAME introspect
-#define GEGL_CHANT_SELF "introspect.c"
-#define GEGL_CHANT_DESCRIPTION "GEGL graph vizualizer."
-#define GEGL_CHANT_CATEGORIES "render"
+#define GEGL_CHANT_TYPE_SOURCE
+#define GEGL_CHANT_C_FILE "introspect.c"
-#define GEGL_CHANT_SOURCE
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
#include "gegl-dot.h" /* XXX: internal header file */
-
#include <stdio.h>
#include <string.h>
+static GeglRectangle
+get_defined_region (GeglOperation *operation)
+{
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+
+ GeglRectangle result = {0, 0, 4096, 4096};
+// process (operation, NULL, NULL, NULL);
+
+ if (o->buf)
+ {
+ GeglBuffer *buffer = GEGL_BUFFER (o->buf);
+ result = *gegl_buffer_get_extent (buffer);
+ }
+ return result;
+}
static gboolean
process (GeglOperation *operation,
@@ -42,30 +52,27 @@
GeglBuffer *output, /* ignored */
const GeglRectangle *result)
{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- {
- if (self->buf)
- {
- if (context)
- {
- g_object_ref(self->buf); /* add an extra reference, since gegl_operation_set_data
- is stealing one */
- gegl_node_context_set_object (context, "output", G_OBJECT (self->buf));
- }
- return TRUE;
- }
- }
-
- {
- /*GeglRectangle *result = gegl_operation_result_rect (operation, context_id);*/
+ if (o->buf)
+ {
+ if (context)
+ {
+ g_object_ref (o->buf); /* add an extra reference, since gegl_operation_set_data
+ is stealing one */
+ gegl_node_context_set_object (context, "output", G_OBJECT (o->buf));
+ }
+ return TRUE;
+ }
+ {
{
- gchar *dot = gegl_to_dot ((gpointer)self->node);
+ gchar *dot = gegl_to_dot ((gpointer)o->node);
g_file_set_contents ("/tmp/gegl-temp.dot", dot, -1, NULL);
system ("dot -o/tmp/gegl-temp.png -Tpng /tmp/gegl-temp.dot");
g_free (dot);
}
+
/* FIXME: copy behavior from magick-load to fix this op */
{
@@ -76,9 +83,9 @@
defined = gegl_node_get_bounding_box (png_load);
- self->buf = gegl_buffer_new (&defined, babl_format ("R'G'B' u8"));
+ o->buf = gegl_buffer_new (&defined, babl_format ("R'G'B' u8"));
- buffer_save = gegl_node_new_child (gegl, "operation", "save-buffer", "buffer", self->buf, NULL);
+ buffer_save = gegl_node_new_child (gegl, "operation", "save-buffer", "buffer", o->buf, NULL);
gegl_node_link_many (png_load, buffer_save, NULL);
gegl_node_process (buffer_save);
@@ -88,26 +95,30 @@
if (context)
{
- g_object_ref (self->buf);
- gegl_node_context_set_object (context, "output", G_OBJECT (self->buf));
+ g_object_ref (o->buf);
+ gegl_node_context_set_object (context, "output", G_OBJECT (o->buf));
}
}
+
return TRUE;
}
-static GeglRectangle
-get_defined_region (GeglOperation *operation)
+
+static void
+operation_class_init (GeglChantClass *klass)
{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
-
- GeglRectangle result = {0,0, 4096, 4096};
- process (operation, NULL, NULL, NULL);
- if (self->buf)
- {
- GeglBuffer *buffer = GEGL_BUFFER (self->buf);
- result = *gegl_buffer_get_extent (buffer);
- }
- return result;
+ GeglOperationClass *operation_class;
+ GeglOperationSourceClass *source_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
+
+ source_class->process = process;
+ operation_class->get_defined_region = get_defined_region;
+
+ operation_class->name = "introspect";
+ operation_class->categories = "render";
+ operation_class->description = "GEGL graph vizualizer.";
}
#endif
Modified: trunk/operations/render/noise.c
==============================================================================
--- trunk/operations/render/noise.c (original)
+++ trunk/operations/render/noise.c Fri Jan 25 07:05:15 2008
@@ -15,7 +15,7 @@
*
* Copyright 2006 Ãyvind KolÃs <pippin gimp org>
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (alpha, -G_MAXDOUBLE, G_MAXDOUBLE, 1.2, "")
gegl_chant_double (scale, -G_MAXDOUBLE, G_MAXDOUBLE, 1.8, "")
@@ -25,56 +25,13 @@
#else
-#define GEGL_CHANT_NAME perlin_noise
-#define GEGL_CHANT_SELF "noise.c"
-#define GEGL_CHANT_DESCRIPTION "Perlin noise generator."
-#define GEGL_CHANT_CATEGORIES "render"
-
-#define GEGL_CHANT_SOURCE
-#define GEGL_CHANT_PREPARE
-#define GEGL_CHANT_CLASS_INIT
+#define GEGL_CHANT_TYPE_SOURCE
+#define GEGL_CHANT_C_FILE "noise.c"
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
#include "perlin/perlin.c"
#include "perlin/perlin.h"
-static gboolean
-process (GeglOperation *operation,
- GeglNodeContext *context,
- GeglBuffer *output,
- const GeglRectangle *result)
-{
- GeglChantOperation *self = GEGL_CHANT_OPERATION (operation);
- {
- gfloat *buf;
-
- buf = g_malloc (result->width * result->height * 4);
- {
- gfloat *dst=buf;
- gint y;
- for (y=0; y < result->height; y++)
- {
- gint x;
- for (x=0; x < result->width ; x++)
- {
- gfloat val;
-
- val = PerlinNoise3D ((double) (x + result->x)/50.0,
- (double) (y + result->y)/50.0,
- (double) self->zoff, self->alpha, self->scale,
- self->n);
- *dst = val * 0.5 + 0.5;
- dst ++;
- }
- }
- }
- gegl_buffer_set (output, NULL, babl_format ("Y float"), buf,
- GEGL_AUTO_ROWSTRIDE);
- g_free (buf);
- }
- return TRUE;
-}
-
static void
prepare (GeglOperation *operation)
{
@@ -88,10 +45,61 @@
return result;
}
-static void class_init (GeglOperationClass *klass)
+static gboolean
+process (GeglOperation *operation,
+ GeglNodeContext *context,
+ GeglBuffer *output,
+ const GeglRectangle *result)
+{
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ gfloat *buf;
+
+ buf = g_malloc (result->width * result->height * 4);
+ {
+ gfloat *dst=buf;
+ gint y;
+ for (y=0; y < result->height; y++)
+ {
+ gint x;
+ for (x=0; x < result->width ; x++)
+ {
+ gfloat val;
+
+ val = PerlinNoise3D ((double) (x + result->x)/50.0,
+ (double) (y + result->y)/50.0,
+ (double) o->zoff, o->alpha, o->scale,
+ o->n);
+ *dst = val * 0.5 + 0.5;
+ dst ++;
+ }
+ }
+ }
+ gegl_buffer_set (output, NULL, babl_format ("Y float"), buf,
+ GEGL_AUTO_ROWSTRIDE);
+ g_free (buf);
+
+ return TRUE;
+}
+
+static void
+operation_class_init (GeglChantClass *klass)
{
- klass->adjust_result_region = NULL;
- klass->no_cache = FALSE;
+ GeglOperationClass *operation_class;
+ GeglOperationSourceClass *source_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ source_class = GEGL_OPERATION_SOURCE_CLASS (klass);
+
+ source_class->process = process;
+ operation_class->get_defined_region = get_defined_region;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "perlin-noise";
+ operation_class->categories = "render";
+ operation_class->description = "Perlin noise generator.";
+
+ operation_class->no_cache = TRUE;
+ operation_class->adjust_result_region = NULL;
}
#endif
Modified: trunk/operations/svg/svg_huerotate.c
==============================================================================
--- trunk/operations/svg/svg_huerotate.c (original)
+++ trunk/operations/svg/svg_huerotate.c Fri Jan 25 07:05:15 2008
@@ -1,22 +1,36 @@
-/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
- *
- * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
- *
- * !!!! AUTOGENERATED FILE !!!!!
- *
+/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
+ *
+ *
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 <pippin gimp org>
+ * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
+ *
+ * !!!! AUTOGENERATED FILE !!!!!
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
+
gegl_chant_string (values, "", "list of <number>s")
+
#else
-#define GEGL_CHANT_POINT_FILTER
-#define GEGL_CHANT_NAME svg_huerotate
-#define GEGL_CHANT_DESCRIPTION "SVG color matrix operation svg_huerotate"
-#define GEGL_CHANT_CATEGORIES "compositors:svgfilter"
-#define GEGL_CHANT_SELF "svg_huerotate.c"
-#define GEGL_CHANT_PREPARE
-#include "gegl-old-chant.h"
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE "svg_huerotate.c"
+#include "gegl-chant.h"
#include <math.h>
#include <stdlib.h>
@@ -30,13 +44,14 @@
static gboolean
process (GeglOperation *op,
- void *in_buf,
- void *out_buf,
- glong n_pixels)
+ void *in_buf,
+ void *out_buf,
+ glong n_pixels)
{
- gfloat *in = in_buf;
- gfloat *out = out_buf;
- gfloat *m;
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
+ gfloat *in = in_buf;
+ gfloat *out = out_buf;
+ gfloat *m;
gfloat ma[25] = { 1.0, 0.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0,
@@ -52,19 +67,20 @@
m = ma;
- if ( GEGL_CHANT_OPERATION (op)->values != NULL )
+ if ( o->values != NULL )
{
- g_strstrip(GEGL_CHANT_OPERATION (op)->values);
- g_strdelimit (GEGL_CHANT_OPERATION (op)->values, delimiters, delimiter);
- values = g_strsplit (GEGL_CHANT_OPERATION (op)->values, &delimiter, 1);
+ g_strstrip(o->values);
+ g_strdelimit (o->values, delimiters, delimiter);
+ values = g_strsplit (o->values, &delimiter, 1);
if ( values[0] != NULL )
{
value = g_ascii_strtod(values[0], &endptr);
if (endptr != values[0])
- ma[0] = .213 + cos(value)*.787 - sin(value)*.213;
+ ma[0] = .213 + cos(value)*.787 - sin(value)*.213;
}
g_strfreev(values);
}
+
for (i=0; i<n_pixels; i++)
{
out[0] = m[0] * in[0] + m[1] * in[1] + m[2] * in[2] + m[3] * in[3] + m[4];
@@ -74,7 +90,26 @@
in += 4;
out += 4;
}
+
return TRUE;
}
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointFilterClass *point_filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ point_filter_class->process = process;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "svg-huerotate";
+ operation_class->categories = "compositors:svgfilter";
+ operation_class->description = "SVG color matrix operation svg_huerotate";
+}
+
#endif
Modified: trunk/operations/svg/svg_luminancetoalpha.c
==============================================================================
--- trunk/operations/svg/svg_luminancetoalpha.c (original)
+++ trunk/operations/svg/svg_luminancetoalpha.c Fri Jan 25 07:05:15 2008
@@ -1,22 +1,35 @@
-/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
- *
- * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
- *
- * !!!! AUTOGENERATED FILE !!!!!
- *
+/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
+ *
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 <pippin gimp org>
+ * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
+ *
+ * !!!! AUTOGENERATED FILE !!!!!
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
+
gegl_chant_string (values, "", "list of <number>s")
+
#else
-#define GEGL_CHANT_POINT_FILTER
-#define GEGL_CHANT_NAME svg_luminancetoalpha
-#define GEGL_CHANT_DESCRIPTION "SVG color matrix operation svg_luminancetoalpha"
-#define GEGL_CHANT_CATEGORIES "compositors:svgfilter"
-#define GEGL_CHANT_SELF "svg_luminancetoalpha.c"
-#define GEGL_CHANT_PREPARE
-#include "gegl-old-chant.h"
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE "svg_luminancetoalpha.c"
+#include "gegl-chant.h"
#include <math.h>
#include <stdlib.h>
@@ -28,12 +41,11 @@
gegl_operation_set_format (operation, "output", format);
}
-
static gboolean
process (GeglOperation *op,
- void *in_buf,
- void *out_buf,
- glong n_pixels)
+ void *in_buf,
+ void *out_buf,
+ glong n_pixels)
{
gfloat *in = in_buf;
gfloat *out = out_buf;
@@ -59,4 +71,23 @@
return TRUE;
}
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointFilterClass *point_filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ point_filter_class->process = process;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "svg-luminancetoalpha";
+ operation_class->categories = "compositors:svgfilter";
+ operation_class->description =
+ "SVG color matrix operation svg_luminancetoalpha";
+}
+
#endif
Modified: trunk/operations/svg/svg_matrix.c
==============================================================================
--- trunk/operations/svg/svg_matrix.c (original)
+++ trunk/operations/svg/svg_matrix.c Fri Jan 25 07:05:15 2008
@@ -1,22 +1,35 @@
-/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
- *
- * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
- *
- * !!!! AUTOGENERATED FILE !!!!!
- *
+/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
+ *
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 <pippin gimp org>
+ * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
+ *
+ * !!!! AUTOGENERATED FILE !!!!!
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
+
gegl_chant_string (values, "", "list of <number>s")
+
#else
-#define GEGL_CHANT_POINT_FILTER
-#define GEGL_CHANT_NAME svg_matrix
-#define GEGL_CHANT_DESCRIPTION "SVG color matrix operation svg_matrix"
-#define GEGL_CHANT_CATEGORIES "compositors:svgfilter"
-#define GEGL_CHANT_SELF "svg_matrix.c"
-#define GEGL_CHANT_PREPARE
-#include "gegl-old-chant.h"
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE "svg_matrix.c"
+#include "gegl-chant.h"
#include <math.h>
#include <stdlib.h>
@@ -30,19 +43,20 @@
static gboolean
process (GeglOperation *op,
- void *in_buf,
- void *out_buf,
- glong n_pixels)
+ void *in_buf,
+ void *out_buf,
+ glong n_pixels)
{
- gfloat *in = in_buf;
- gfloat *out = out_buf;
- gfloat *m;
-
- gfloat mi[25] = { 1.0, 0.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 1.0};
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
+ gfloat *in = in_buf;
+ gfloat *out = out_buf;
+ gfloat *m;
+
+ gfloat mi[25] = { 1.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 1.0};
gfloat ma[25] = { 1.0, 0.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 0.0,
@@ -57,11 +71,11 @@
m = ma;
- if ( GEGL_CHANT_OPERATION (op)->values != NULL )
+ if (o->values != NULL)
{
- g_strstrip(GEGL_CHANT_OPERATION (op)->values);
- g_strdelimit (GEGL_CHANT_OPERATION (op)->values, delimiters, delimiter);
- values = g_strsplit (GEGL_CHANT_OPERATION (op)->values, ",", 20);
+ g_strstrip(o->values);
+ g_strdelimit (o->values, delimiters, delimiter);
+ values = g_strsplit (o->values, ",", 20);
for (i = 0 ; i < 20 ; i++)
if ( values[i] != NULL )
{
@@ -69,18 +83,19 @@
if (endptr != values[i])
ma[i] = value;
else
- {
+ {
m = mi;
i = 21;
}
}
else
- {
+ {
m = mi;
i = 21;
}
- g_strfreev(values);
+ g_strfreev(values);
}
+
for (i=0; i<n_pixels; i++)
{
out[0] = m[0] * in[0] + m[1] * in[1] + m[2] * in[2] + m[3] * in[3] + m[4];
@@ -90,7 +105,26 @@
in += 4;
out += 4;
}
+
return TRUE;
}
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointFilterClass *point_filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ point_filter_class->process = process;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "svg-matrix";
+ operation_class->categories = "compositors:svgfilter";
+ operation_class->description = "SVG color matrix operation svg_matrix";
+}
+
#endif
Modified: trunk/operations/svg/svg_saturate.c
==============================================================================
--- trunk/operations/svg/svg_saturate.c (original)
+++ trunk/operations/svg/svg_saturate.c Fri Jan 25 07:05:15 2008
@@ -1,25 +1,39 @@
-/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
- *
- * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
- *
- * !!!! AUTOGENERATED FILE !!!!!
- *
+/* !!!! AUTOGENERATED FILE generated by svg-colormatrix.sh !!!!!
+ *
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 <pippin gimp org>
+ * Copyright 2006 Geert Jordaens <geert jordaens telenet be>
+ *
+ * !!!! AUTOGENERATED FILE !!!!!
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
+
gegl_chant_string (values, "", "list of <number>s")
+
#else
-#define GEGL_CHANT_POINT_FILTER
-#define GEGL_CHANT_NAME svg_saturate
-#define GEGL_CHANT_DESCRIPTION "SVG color matrix operation svg_saturate"
-#define GEGL_CHANT_CATEGORIES "compositors:svgfilter"
-#define GEGL_CHANT_SELF "svg_saturate.c"
-#define GEGL_CHANT_PREPARE
-#include "gegl-old-chant.h"
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE "svg_saturate.c"
+#include "gegl-chant.h"
#include <math.h>
#include <stdlib.h>
+
static void prepare (GeglOperation *operation)
{
Babl *format = babl_format ("RaGaBaA float");
@@ -30,13 +44,14 @@
static gboolean
process (GeglOperation *op,
- void *in_buf,
- void *out_buf,
- glong n_pixels)
+ void *in_buf,
+ void *out_buf,
+ glong n_pixels)
{
- gfloat *in = in_buf;
- gfloat *out = out_buf;
- gfloat *m;
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
+ gfloat *in = in_buf;
+ gfloat *out = out_buf;
+ gfloat *m;
gfloat ma[25] = { 1.0, 0.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0,
@@ -52,12 +67,12 @@
m = ma;
- if ( GEGL_CHANT_OPERATION (op)->values != NULL )
+ if ( o->values != NULL )
{
- g_strstrip(GEGL_CHANT_OPERATION (op)->values);
- g_strdelimit (GEGL_CHANT_OPERATION (op)->values, delimiters, delimiter);
- values = g_strsplit (GEGL_CHANT_OPERATION (op)->values, &delimiter, 1);
- if ( values[0] != NULL )
+ g_strstrip(o->values);
+ g_strdelimit (o->values, delimiters, delimiter);
+ values = g_strsplit (o->values, &delimiter, 1);
+ if (values[0] != NULL)
{
value = g_ascii_strtod(values[0], &endptr);
if (endptr != values[0])
@@ -76,6 +91,7 @@
}
g_strfreev(values);
}
+
for (i=0; i<n_pixels; i++)
{
out[0] = m[0] * in[0] + m[1] * in[1] + m[2] * in[2] + m[3] * in[3] + m[4];
@@ -85,7 +101,26 @@
in += 4;
out += 4;
}
+
return TRUE;
}
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointFilterClass *point_filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ point_filter_class->process = process;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "svg-saturate";
+ operation_class->categories = "compositors:svgfilter";
+ operation_class->description = "SVG color matrix operation svg_saturate";
+}
+
#endif
Modified: trunk/operations/transparency/opacity.c
==============================================================================
--- trunk/operations/transparency/opacity.c (original)
+++ trunk/operations/transparency/opacity.c Fri Jan 25 07:05:15 2008
@@ -15,17 +15,17 @@
*
* Copyright 2006 Ãyvind KolÃs <pippin gimp org>
*/
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
+
gegl_chant_double (value, -10.0, 10.0, 0.5, "Global opacity value, used if no auxiliary input buffer is provided.")
+
#else
-#define GEGL_CHANT_POINT_COMPOSER
-#define GEGL_CHANT_NAME opacity
-#define GEGL_CHANT_DESCRIPTION "Weights the opacity of the input with either the value of the aux input or the global value property."
-#define GEGL_CHANT_SELF "opacity.c"
-#define GEGL_CHANT_CATEGORIES "transparency"
-#define GEGL_CHANT_PREPARE
-#include "gegl-old-chant.h"
+#define GEGL_CHANT_TYPE_POINT_COMPOSER
+#define GEGL_CHANT_C_FILE "opacity.c"
+
+#include "gegl-chant.h"
+
static void prepare (GeglOperation *self)
{
@@ -36,12 +36,11 @@
static gboolean
process (GeglOperation *op,
- void *in_buf,
- void *aux_buf,
- void *out_buf,
- glong n_pixels)
+ void *in_buf,
+ void *aux_buf,
+ void *out_buf,
+ glong n_pixels)
{
-
gfloat *in = in_buf;
gfloat *out = out_buf;
gfloat *aux = aux_buf;
@@ -49,7 +48,7 @@
if (aux == NULL)
{
gint i;
- gfloat value = GEGL_CHANT_OPERATION (op)->value;
+ gfloat value = GEGL_CHANT_PROPERTIES (op)->value;
for (i=0; i<n_pixels; i++)
{
gint j;
@@ -74,4 +73,25 @@
}
return TRUE;
}
+
+
+static void
+operation_class_init (GeglChantClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointComposerClass *point_composer_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
+
+ point_composer_class->process = process;
+ operation_class->prepare = prepare;
+
+ operation_class->name = "opacity";
+ operation_class->categories = "transparency";
+ operation_class->description =
+ "Weights the opacity of the input with either the value of the aux"
+ " input or the global value property.";
+}
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]