[Gegl-developer] gegl scanline functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is a patch that changes all the gegl scanline functions to accept GList's of data as args.

There are a few additional changes besides:

Updated TODO.xml to reflected the added copy op.

Added two functions to the GeglImageIterator class:

gegl_image_iterator_channel_data_width
gegl_image_iterator_length

gegl_image_iterator_length returns the "lengh" of the iterator (the number of times it can be iterated before it runs of out data).

gegl_image_iterator_channel_data_width return the width of the array returned by gegl_image_iterator_*_channels?

And to GeglImageData class:

GeglImageIterator* gegl_image_data_make_iterator (GeglImageData * self); GeglImageIterator* gegl_image_data_get_iterator (GeglImageData * self);
void            gegl_image_data_set_iterator (GeglImageData * self,
GeglImageIterator * iterator);
void            gegl_image_data_remove_iterator(GeglImageData *self);


These are all pretty self explantory. gegl_image_data_make_iterator allocates and assigns the iterator for you, using image_data's own rect to initlize the iterator.


All the tests pass, and the command:
grep -l GeglScanlineFunc *.c | xargs grep -l iters
Tells me there are no more files that implement the old interface (even ones that are not tested).

Every file I modified should compile under:
gcc -Wall -pedantic -O0 -g
with no warnings.

Enjoy,
Dan
Title: Copy Op
? gegl/docs/reference/gegl/version.xml Index: gegl/docs/TODO.xml =================================================================== RCS file: /cvs/gnome/gegl/docs/TODO.xml,v retrieving revision 1.10 diff -u -p -r1.10 TODO.xml --- gegl/docs/TODO.xml 12 Feb 2003 02:59:00 -0000 1.10 +++ gegl/docs/TODO.xml 22 Mar 2003 06:00:59 -0000 @@ -154,16 +154,6 @@ there are no conversion ops that use the - - -

-Add a copy op, that just copies from input to output. -

-
- -
- - Area Op

Index: gegl/gegl/gegl-add.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-add.c,v retrieving revision 1.8 diff -u -p -r1.8 gegl-add.c --- gegl/gegl/gegl-add.c 12 Feb 2003 01:39:10 -0000 1.8 +++ gegl/gegl/gegl-add.c 22 Mar 2003 06:01:00 -0000 @@ -1,4 +1,5 @@ #include "gegl-add.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-color-model.h" #include "gegl-param-specs.h" @@ -24,8 +25,8 @@ static void validate_inputs (GeglFilter static GeglScanlineFunc get_scanline_func(GeglUnary * unary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void add_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void add_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void add_float (GeglFilter * filter, GList* data_outputs, GList* data_inputs); +static void add_uint8 (GeglFilter * filter, GList* data_outputs, GList* data_inputs); static gpointer parent_class = NULL; @@ -237,22 +238,51 @@ get_scanline_func(GeglUnary * unary, return scanline_funcs[type]; } +/* input order is input image , constant color */ +/* output order is output image */ + static void add_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList* data_outputs, + GList* data_inputs) { GeglAdd * self = GEGL_ADD(filter); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglAdd->add_float","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + gfloat* data = "">constant); - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gint alpha_mask = 0x0; @@ -274,8 +304,7 @@ add_float (GeglFilter * filter, { case 3: *d2++ = *a2++ + data[2]; case 2: *d1++ = *a1++ + data[1]; - case 1: *d0++ = *a0++ + data[0]; - case 0: + case 1: *d0++ = *a0++ + data[0]; } if(alpha_mask == GEGL_A_ALPHA) @@ -291,20 +320,46 @@ add_float (GeglFilter * filter, static void add_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - GeglAdd * self = GEGL_ADD(filter); + GList* data_outputs, + GList* data_inputs) +{ + GeglAdd * self = GEGL_ADD(filter); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglAdd->add_float","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + guint8* data = "">constant); - guint8 **d = (guint8**)gegl_image_iterator_color_channels(iters[0]); - guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - guint8 **a = (guint8**)gegl_image_iterator_color_channels(iters[1]); - guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + guint8 **d = (guint8**)gegl_image_iterator_color_channels(output_iterator); + guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + guint8 **a = (guint8**)gegl_image_iterator_color_channels(input_iterator); + guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gint alpha_mask = 0x0; @@ -330,7 +385,6 @@ add_uint8 (GeglFilter * filter, a1++; case 1: *d0++ = CLAMP(*a0 + data[0], 0, 255); a0++; - case 0: } if(alpha_mask == GEGL_A_ALPHA) Index: gegl/gegl/gegl-atop.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-atop.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-atop.c --- gegl/gegl/gegl-atop.c 12 Feb 2003 01:39:10 -0000 1.4 +++ gegl/gegl/gegl-atop.c 22 Mar 2003 06:01:00 -0000 @@ -1,12 +1,15 @@ #include "gegl-atop.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" static void class_init (GeglAtopClass * klass); static void init (GeglAtop * self, GeglAtopClass * klass); static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_atop_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_atop_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -72,20 +75,43 @@ get_scanline_func(GeglComp * comp, static void fg_atop_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -118,8 +144,7 @@ fg_atop_bg_float (GeglFilter * filter, case 3: *d2++ = *f2++; case 2: *d1++ = *f1++; case 1: *d0++ = *f0++; - case 0: - } + } } } break; @@ -134,8 +159,7 @@ fg_atop_bg_float (GeglFilter * filter, case 3: *d2++ = a * *b2++ + *f2++; case 2: *d1++ = a * *b1++ + *f1++; case 1: *d0++ = a * *b0++ + *f0++; - case 0: - } + } *da++ = 1.0; } @@ -152,8 +176,7 @@ fg_atop_bg_float (GeglFilter * filter, case 3: *d2++ = b * *f2++; case 2: *d1++ = b * *f1++; case 1: *d0++ = b * *f0++; - case 0: - } + } *da++ = b; } @@ -172,8 +195,7 @@ fg_atop_bg_float (GeglFilter * filter, case 3: *d2++ = a * *b2++ + b * *f2++; case 2: *d1++ = a * *b1++ + b * *f1++; case 1: *d0++ = a * *b0++ + b * *f0++; - case 0: - } + } *da++ = b; } Index: gegl/gegl/gegl-color.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-color.c,v retrieving revision 1.6 diff -u -p -r1.6 gegl-color.c --- gegl/gegl/gegl-color.c 12 Feb 2003 01:39:10 -0000 1.6 +++ gegl/gegl/gegl-color.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-color.h" #include "gegl-scanline-processor.h" #include "gegl-color-model.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-pixel-value-types.h" #include "gegl-pixel-data.h" @@ -30,9 +31,15 @@ static GeglColorModel * compute_color_mo static GeglScanlineFunc get_scanline_func(GeglNoInput * no_input, GeglColorSpaceType space, GeglChannelSpaceType type); -static void color_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void color_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void color_u16 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void color_float(GeglFilter * filter, + GList* data_outputs, + GList* data_inputs); +static void color_uint8 (GeglFilter * filter, + GList* data_outputs, + GList* data_inputs); +static void color_u16 (GeglFilter * filter, + GList* data_outputs, + GList* data_inputs); static gpointer parent_class = NULL; @@ -352,18 +359,49 @@ get_scanline_func(GeglNoInput * no_input return scanline_funcs[type]; } +/* input order is pixel, width, height. */ +/* there is only one output */ + static void color_float(GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList* data_outputs, + GList* data_inputs) { GeglColor * self = GEGL_COLOR(filter); - gfloat *pixel = (gfloat*)g_value_pixel_get_data(self->pixel); - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); + + g_return_if_fail(g_list_length(data_outputs) >= 1); + + /* + All this code is wrong. :-( in the future, pixel data, widht and + height will be retrieved from the list of inputs. For new they + are retrieved from the "default" values contained in the object + + g_return_if_fail(g_list_length(data_inputs) >= 3); + + GeglPixelData *pixel_data=(GeglPixelData*)g_list_nth_data(data_inputs,0); + GeglScalarData *width_data=(GeglScalarData*)g_list_nth_data(data_inputs,1); + GeglScalarData *height_data=(GeglScalarData*)g_list_nth_data(data_inputs,2); + + g_return_if_fail(GEGL_IS_PIXEL_DATA(pixel_data)); + g_return_if_fail(GEGL_IS_SCALAR_DATA(width_data)); + g_return_if_fail(GEGL_IS_SCALAR_DATA(height_data)); + */ + + GeglImageData* image_data=g_list_nth_data(data_outputs,0); + GeglImageIterator* iterator = gegl_image_data_get_iterator(image_data); + + if (iterator == NULL) { + LOG_DEBUG("GeglColor->color_float","the iterator retrieved for the output image is null. This should never have happened"); + return; + } + + gfloat* pixel =(gfloat*)g_value_pixel_get_data(self->pixel); + gfloat** d = (gfloat**)gegl_image_iterator_color_channels(iterator); + float *da = (gfloat*)gegl_image_iterator_alpha_channel(iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(iterator); gboolean has_alpha = da ? TRUE: FALSE; gint alpha = d_color_chans; /* should get from color model */ + gint width = gegl_image_iterator_channel_data_width(iterator); { gfloat *d0 = (d_color_chans > 0) ? d[0]: NULL; @@ -374,7 +412,7 @@ color_float(GeglFilter * filter, g_print("pixel color called %f %f %f \n", pixel[0], pixel[1], pixel[2]); g_print("color dest addresses are %p %p %p \n", d0, d1, d2); #endif - + while(width--) { switch(d_color_chans) @@ -382,12 +420,12 @@ color_float(GeglFilter * filter, case 3: *d2++ = pixel[2]; case 2: *d1++ = pixel[1]; case 1: *d0++ = pixel[0]; - case 0: } if(has_alpha) *da++ = pixel[alpha]; } + } g_free(d); @@ -395,16 +433,28 @@ color_float(GeglFilter * filter, static void color_u16 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList* data_outputs, + GList* data_inputs) { GeglColor * self = GEGL_COLOR(filter); - guint16 *pixel = (guint16*)g_value_pixel_get_data(self->pixel); - guint16 **d = (guint16**)gegl_image_iterator_color_channels(iters[0]); - guint16 *da = (guint16*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); + + g_return_if_fail(g_list_length(data_outputs) >= 1); + + GeglImageData* image_data=g_list_nth_data(data_outputs,0); + GeglImageIterator* iterator = gegl_image_data_get_iterator(image_data); + + if (iterator == NULL) { + LOG_DEBUG("GeglColor->color_u16","the iterator retrieved for the output image is null. This should never have happened"); + return; + } + + guint16* pixel =(guint16*)g_value_pixel_get_data(self->pixel); + guint16** d = (guint16**)gegl_image_iterator_color_channels(iterator); + guint16 *da = (guint16*)gegl_image_iterator_alpha_channel(iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(iterator); gboolean has_alpha = da ? TRUE: FALSE; gint alpha = d_color_chans; /* should get from color model */ + gint width = gegl_image_iterator_channel_data_width(iterator); { guint16 *d0 = (d_color_chans > 0) ? d[0]: NULL; @@ -418,7 +468,6 @@ color_u16 (GeglFilter * filter, case 3: *d2++ = pixel[2]; case 2: *d1++ = pixel[1]; case 1: *d0++ = pixel[0]; - case 0: } if(has_alpha) @@ -431,16 +480,29 @@ color_u16 (GeglFilter * filter, static void color_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList* data_outputs, + GList* data_inputs) { GeglColor * self = GEGL_COLOR(filter); - guint8 *pixel = (guint8*)g_value_pixel_get_data(self->pixel); - guint8 **d = (guint8**)gegl_image_iterator_color_channels(iters[0]); - guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); + + + g_return_if_fail(g_list_length(data_outputs) >= 1); + + GeglImageData* image_data=g_list_nth_data(data_outputs,0); + GeglImageIterator* iterator = gegl_image_data_get_iterator(image_data); + + if (iterator == NULL) { + LOG_DEBUG("GeglColor->color_u8","the iterator retrieved for the output image is null. This should never have happened"); + return; + } + + guint8* pixel =(guint8*)g_value_pixel_get_data(self->pixel); + guint8** d = (guint8**)gegl_image_iterator_color_channels(iterator); + guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(iterator); gboolean has_alpha = da ? TRUE: FALSE; gint alpha = d_color_chans; /* should get from color model */ + gint width = gegl_image_iterator_channel_data_width(iterator); { guint8 *d0 = (d_color_chans > 0) ? d[0]: NULL; @@ -453,8 +515,7 @@ color_uint8 (GeglFilter * filter, { case 3: *d2++ = pixel[2]; case 2: *d1++ = pixel[1]; - case 1: *d0++ = pixel[0]; - case 0: + case 1: *d0++ = pixel[0]; } if(has_alpha) Index: gegl/gegl/gegl-copy.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-copy.c,v retrieving revision 1.8 diff -u -p -r1.8 gegl-copy.c --- gegl/gegl/gegl-copy.c 25 Feb 2003 05:01:12 -0000 1.8 +++ gegl/gegl/gegl-copy.c 22 Mar 2003 06:01:00 -0000 @@ -5,6 +5,7 @@ */ #include "gegl-copy.h" #include "gegl-scanline-processor.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-scalar-data.h" #include "gegl-value-types.h" @@ -18,10 +19,16 @@ static void class_init (GeglCopyClass * static GeglScanlineFunc get_scanline_func(GeglUnary * unary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void copy_general (GeglFilter * filter, GeglImageIterator ** iters, gint byte_width); -inline static void copy_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -inline static void copy_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); -inline static void copy_uint16 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void copy_general (GeglFilter * filter, GList* data_output, GList* data_input, size_t type_width); +inline static void copy_float (GeglFilter * filter, + GList * data_output, + GList * data_input); +inline static void copy_uint8 (GeglFilter * filter, + GList * data_output, + GList * data_input); +inline static void copy_uint16 (GeglFilter * filter, + GList * data_output, + GList * data_input); static gpointer parent_class = NULL; @@ -83,16 +90,44 @@ get_scanline_func(GeglUnary * unary, static void copy_general (GeglFilter * filter, - GeglImageIterator ** iters, - gint byte_width) -{ - gpointer * d = gegl_image_iterator_color_channels(iters[0]); - gpointer da = gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gpointer * a = gegl_image_iterator_color_channels(iters[1]); - gpointer aa = gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + GList * data_outputs, + GList * data_inputs, + size_t type_width) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + + gpointer * d = gegl_image_iterator_color_channels(output_iterator); + gpointer da = gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gpointer * a = gegl_image_iterator_color_channels(input_iterator); + gpointer aa = gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gint alpha_mask = 0x0; @@ -113,13 +148,12 @@ copy_general (GeglFilter * filter, many color channels as the destination. I will check that before adding special cases. */ - + gint byte_width=width*type_width; switch(d_color_chans) { case 3: memcpy(d2,a2,byte_width); case 2: memcpy(d1,a1,byte_width); case 1: memcpy(d0,a0,byte_width); - case 0: } if(alpha_mask == GEGL_A_ALPHA) @@ -132,26 +166,27 @@ copy_general (GeglFilter * filter, g_free(a); } + inline static void copy_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { - copy_general(filter,iters,width * sizeof(gfloat)); + copy_general(filter,data_outputs,data_inputs,sizeof(gfloat)); } inline static void copy_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { - copy_general(filter,iters,width * sizeof(guint8)); + copy_general(filter,data_outputs,data_inputs,sizeof(guint8)); } inline static void copy_uint16 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { - copy_general(filter,iters,width * sizeof(guint16)); + copy_general(filter,data_outputs,data_inputs,sizeof(guint16)); } Index: gegl/gegl/gegl-darken.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-darken.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-darken.c --- gegl/gegl/gegl-darken.c 12 Feb 2003 01:39:10 -0000 1.4 +++ gegl/gegl/gegl-darken.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-darken.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglDarkenClass * klass); @@ -8,7 +9,9 @@ static void init (GeglDarken * self, Geg static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_darken_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_darken_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,43 @@ get_scanline_func(GeglComp * comp, static void fg_darken_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat *fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -125,8 +151,7 @@ fg_darken_bg_float (GeglFilter * filter, case 1: *d0++ = MIN(*f0, *b0); f0++; b0++; - case 0: - } + } } break; case GEGL_FG_ALPHA: @@ -154,10 +179,11 @@ fg_darken_bg_float (GeglFilter * filter, case 1: *d0++ = MIN(a * *b0 + *f0, b * *f0 + *b0); f0++; b0++; - case 0: - } + } - *da++ = *fa + *ba - *ba++ * *fa++; + *da++ = *fa + *ba - *ba * *fa; + ba++; + fa++; } } break; Index: gegl/gegl/gegl-difference.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-difference.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-difference.c --- gegl/gegl/gegl-difference.c 12 Feb 2003 01:39:10 -0000 1.4 +++ gegl/gegl/gegl-difference.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-difference.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglDifferenceClass * klass); @@ -8,7 +9,9 @@ static void init (GeglDifference * self, static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_difference_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_difference_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,42 @@ get_scanline_func(GeglComp * comp, static void fg_difference_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -127,8 +152,7 @@ fg_difference_bg_float (GeglFilter * fil *d1++ = (diff1 >= 0.0) ? diff1 : -diff1; case 1: diff0 = *b0++ - *f0++; *d0++ = (diff0 >= 0.0) ? diff0 : -diff0; - case 0: - } + } } } break; @@ -160,11 +184,12 @@ fg_difference_bg_float (GeglFilter * fil *d1++ = (diff1 >= 0.0) ? *b1 + a * *f1 : *f1++ + b * *b1++; case 1: diff0 = *fa * *b0 - *ba * *f0; *d0++ = (diff0 >= 0.0) ? *b0 + a * *f0 : *f0++ + b * *b0++; - case 0: - } + } - *da++ = *fa + *ba - *ba++ * *fa++; - } + *da++ = *fa + *ba - *ba * *fa; + ba++; + fa++; + } } break; } Index: gegl/gegl/gegl-fade.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-fade.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-fade.c --- gegl/gegl/gegl-fade.c 12 Feb 2003 01:39:10 -0000 1.4 +++ gegl/gegl/gegl-fade.c 22 Mar 2003 06:01:00 -0000 @@ -1,5 +1,6 @@ #include "gegl-fade.h" #include "gegl-scanline-processor.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-scalar-data.h" #include "gegl-value-types.h" @@ -21,8 +22,12 @@ static void set_property (GObject *gobje static GeglScanlineFunc get_scanline_func(GeglUnary * unary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fade_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void fade_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fade_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); +static void fade_uint8 (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -171,18 +176,45 @@ get_scanline_func(GeglUnary * unary, static void fade_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ + GList * data_outputs, + GList * data_inputs) +{ + GeglFade * self = GEGL_FADE(filter); - - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + + g_return_if_fail(GEGL_IS_FADE(self)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gfloat multiplier = self->multiplier; gint alpha_mask = 0x0; @@ -206,7 +238,6 @@ fade_float (GeglFilter * filter, case 3: *d2++ = multiplier * *a2++; case 2: *d1++ = multiplier * *a1++; case 1: *d0++ = multiplier * *a0++; - case 0: } if(alpha_mask == GEGL_A_ALPHA) @@ -222,18 +253,45 @@ fade_float (GeglFilter * filter, static void fade_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { GeglFade * self = GEGL_FADE(filter); + + g_return_if_fail(GEGL_IS_FADE(self)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } - guint8 **d = (guint8**)gegl_image_iterator_color_channels(iters[0]); - guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - guint8 **a = (guint8**)gegl_image_iterator_color_channels(iters[1]); - guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + guint8 **d = (guint8**)gegl_image_iterator_color_channels(output_iterator); + guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + guint8 **a = (guint8**)gegl_image_iterator_color_channels(input_iterator); + guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gfloat multiplier = self->multiplier; @@ -260,8 +318,7 @@ fade_uint8 (GeglFilter * filter, case 2: *d1++ = CLAMP((gint)(multiplier * *a1 + .5), 0, 255); a1++; case 1: *d0++ = CLAMP((gint)(multiplier * *a0 + .5), 0, 255); - a0++; - case 0: + a0++; } if(alpha_mask == GEGL_A_ALPHA) Index: gegl/gegl/gegl-i-add.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-i-add.c,v retrieving revision 1.3 diff -u -p -r1.3 gegl-i-add.c --- gegl/gegl/gegl-i-add.c 12 Feb 2003 01:39:10 -0000 1.3 +++ gegl/gegl/gegl-i-add.c 22 Mar 2003 06:01:00 -0000 @@ -1,5 +1,6 @@ #include "gegl-i-add.h" #include "gegl-scanline-processor.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-utils.h" @@ -8,8 +9,12 @@ static void init (GeglIAdd * self, GeglI static GeglScanlineFunc get_scanline_func(GeglBinary * binary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void a_iadd_b_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void a_iadd_b_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void a_iadd_b_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); +static void a_iadd_b_uint8 (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,22 +79,45 @@ get_scanline_func(GeglBinary * binary, static void a_iadd_b_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ + GList * data_outputs, + GList * data_inputs) +{ GeglBinary * binary = GEGL_BINARY(filter); - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + g_return_if_fail(GEGL_IS_BINARY(binary)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_a_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; gfloat fade = binary->fade; @@ -119,7 +147,6 @@ a_iadd_b_float (GeglFilter * filter, case 3: *d2++ = fade * *a2++ + *b2++; case 2: *d1++ = fade * *a1++ + *b1++; case 1: *d0++ = fade * *a0++ + *b0++; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) @@ -136,22 +163,45 @@ a_iadd_b_float (GeglFilter * filter, static void a_iadd_b_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ + GList * data_outputs, + GList * data_inputs) +{ GeglBinary * binary = GEGL_BINARY(filter); - guint8 **d = (guint8**)gegl_image_iterator_color_channels(iters[0]); - guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - guint8 **b = (guint8**)gegl_image_iterator_color_channels(iters[1]); - guint8 *ba = (guint8*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - guint8 **a = (guint8**)gegl_image_iterator_color_channels(iters[2]); - guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + g_return_if_fail(GEGL_IS_BINARY(binary)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + guint8 **d = (guint8**)gegl_image_iterator_color_channels(output_iterator); + guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + guint8 **b = (guint8**)gegl_image_iterator_color_channels(input_b_iterator); + guint8 *ba = (guint8*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + guint8 **a = (guint8**)gegl_image_iterator_color_channels(input_a_iterator); + guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; gfloat fade = binary->fade; @@ -187,7 +237,6 @@ a_iadd_b_uint8 (GeglFilter * filter, case 1: *d0++ = CLAMP((gint)(fade * *a0 + *b0 + .5), 0, 255); a0++; b0++; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) Index: gegl/gegl/gegl-i-mult.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-i-mult.c,v retrieving revision 1.3 diff -u -p -r1.3 gegl-i-mult.c --- gegl/gegl/gegl-i-mult.c 12 Feb 2003 01:39:10 -0000 1.3 +++ gegl/gegl/gegl-i-mult.c 22 Mar 2003 06:01:00 -0000 @@ -1,5 +1,6 @@ #include "gegl-i-mult.h" #include "gegl-scanline-processor.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-utils.h" @@ -8,8 +9,12 @@ static void init (GeglIMult * self, Gegl static GeglScanlineFunc get_scanline_func(GeglBinary * binary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void a_imult_b_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void a_imult_b_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void a_imult_b_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); +static void a_imult_b_uint8 (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,22 +79,45 @@ get_scanline_func(GeglBinary * binary, static void a_imult_b_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { GeglBinary * binary = GEGL_BINARY(filter); - - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + + g_return_if_fail(GEGL_IS_BINARY(binary)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_a_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; gfloat fade = binary->fade; @@ -119,7 +147,6 @@ a_imult_b_float (GeglFilter * filter, case 3: *d2++ = fade * *a2++ * *b2++; case 2: *d1++ = fade * *a1++ * *b1++; case 1: *d0++ = fade * *a0++ * *b0++; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) @@ -136,22 +163,45 @@ a_imult_b_float (GeglFilter * filter, static void a_imult_b_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { GeglBinary * binary = GEGL_BINARY(filter); - guint8 **d = (guint8**)gegl_image_iterator_color_channels(iters[0]); - guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - guint8 **b = (guint8**)gegl_image_iterator_color_channels(iters[1]); - guint8 *ba = (guint8*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - guint8 **a = (guint8**)gegl_image_iterator_color_channels(iters[2]); - guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + g_return_if_fail(GEGL_IS_BINARY(binary)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + guint8 **d = (guint8**)gegl_image_iterator_color_channels(output_iterator); + guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + guint8 **b = (guint8**)gegl_image_iterator_color_channels(input_b_iterator); + guint8 *ba = (guint8*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + guint8 **a = (guint8**)gegl_image_iterator_color_channels(input_a_iterator); + guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; guint8 fade = CLAMP((gint)(binary->fade * 255 + .5), 0, 255); @@ -188,7 +238,6 @@ a_imult_b_uint8 (GeglFilter * filter, case 1: *d0++ = INT_MULT(INT_MULT(fade, *a0, t), *b0, s); a0++; b0++; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) Index: gegl/gegl/gegl-image-data.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-image-data.c,v retrieving revision 1.3 diff -u -p -r1.3 gegl-image-data.c --- gegl/gegl/gegl-image-data.c 12 Feb 2003 01:39:10 -0000 1.3 +++ gegl/gegl/gegl-image-data.c 22 Mar 2003 06:01:00 -0000 @@ -69,3 +69,71 @@ gegl_image_data_set_rect (GeglImageData gegl_rect_copy(&self->rect,rect); } + +GeglImageIterator* +gegl_image_data_make_iterator(GeglImageData * self) +{ + GeglData* data="" + GValue *value=NULL; + GeglImage* image=NULL; + + g_return_val_if_fail(GEGL_IS_DATA(data),NULL); + g_return_val_if_fail(GEGL_IS_IMAGE_DATA(self),NULL); + + if (self->iterator!=NULL) + { + g_object_unref(self->iterator); + self->iterator=NULL; + } + + value=gegl_data_get_value(data); + + g_return_val_if_fail(value!=NULL,NULL); + + image=g_value_get_object(value); + + self->iterator=g_object_new (GEGL_TYPE_IMAGE_ITERATOR, + "image", image, + "area", &(self->rect), + NULL); + return self->iterator; +} + + +GeglImageIterator* +gegl_image_data_get_iterator(GeglImageData * self) +{ + g_return_val_if_fail(self != NULL,NULL); + g_return_val_if_fail(GEGL_IS_IMAGE_DATA(self),NULL); + return self->iterator; + +} + +void +gegl_image_data_set_iterator(GeglImageData * self, + GeglImageIterator * iterator) +{ + + g_return_if_fail(GEGL_IS_IMAGE_DATA(self)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(iterator)); + + g_object_ref(iterator); + if (self->iterator != NULL) + { + g_object_unref(self->iterator); + self->iterator=NULL; + } + self->iterator=iterator; +} + +void +gegl_image_data_remove_iterator(GeglImageData *self) +{ + g_return_if_fail(GEGL_IS_IMAGE_DATA(self)); + + if (self->iterator !=NULL) + { + g_object_unref(self->iterator); + } + self->iterator=NULL; +} Index: gegl/gegl/gegl-image-data.h =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-image-data.h,v retrieving revision 1.3 diff -u -p -r1.3 gegl-image-data.h --- gegl/gegl/gegl-image-data.h 12 Feb 2003 01:39:10 -0000 1.3 +++ gegl/gegl/gegl-image-data.h 22 Mar 2003 06:01:00 -0000 @@ -2,6 +2,7 @@ #define __GEGL_IMAGE_DATA_H__ #include "gegl-color-data.h" +#include "gegl-image-iterator.h" #ifdef __cplusplus extern "C" { @@ -21,6 +22,7 @@ struct _GeglImageData /*< private >*/ GeglRect rect; + GeglImageIterator * iterator; }; typedef struct _GeglImageDataClass GeglImageDataClass; @@ -34,6 +36,11 @@ void gegl_image_data_get_rect GeglRect * rect); void gegl_image_data_set_rect (GeglImageData * self, GeglRect * rect); +GeglImageIterator* gegl_image_data_make_iterator (GeglImageData * self); +GeglImageIterator* gegl_image_data_get_iterator (GeglImageData * self); +void gegl_image_data_set_iterator (GeglImageData * self, + GeglImageIterator * iterator); +void gegl_image_data_remove_iterator(GeglImageData *self); #ifdef __cplusplus } Index: gegl/gegl/gegl-image-iterator.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-image-iterator.c,v retrieving revision 1.1 diff -u -p -r1.1 gegl-image-iterator.c --- gegl/gegl/gegl-image-iterator.c 12 Feb 2003 01:39:10 -0000 1.1 +++ gegl/gegl/gegl-image-iterator.c 22 Mar 2003 06:01:00 -0000 @@ -359,3 +359,21 @@ gegl_image_iterator_alpha_channel(GeglIm return alpha_pointer; } + +gint +gegl_image_iterator_channel_data_width(GeglImageIterator *self) +{ + g_return_val_if_fail(self !=NULL, NULL); + g_return_val_if_fail(GEGL_IS_IMAGE_ITERATOR(self),NULL); + return self->rect.w; +} + +gint +gegl_image_iterator_length(GeglImageIterator *self) +{ + + g_return_val_if_fail(self!=NULL,0); + g_return_val_if_fail(GEGL_IS_IMAGE_ITERATOR(self), 0); + + return self->rect.h; +} Index: gegl/gegl/gegl-image-iterator.h =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-image-iterator.h,v retrieving revision 1.1 diff -u -p -r1.1 gegl-image-iterator.h --- gegl/gegl/gegl-image-iterator.h 12 Feb 2003 01:39:10 -0000 1.1 +++ gegl/gegl/gegl-image-iterator.h 22 Mar 2003 06:01:00 -0000 @@ -47,6 +47,7 @@ gboolean gegl_image_iterator_is_d gpointer * gegl_image_iterator_color_channels(GeglImageIterator *self); gpointer gegl_image_iterator_alpha_channel(GeglImageIterator *self); +gint gegl_image_iterator_channel_data_width(GeglImageIterator *self); /* protected */ void gegl_image_iterator_set_rect (GeglImageIterator * self, @@ -56,6 +57,7 @@ void gegl_image_iterator_set_ void gegl_image_iterator_set_scanline (GeglImageIterator * self, gint y); +gint gegl_image_iterator_length (GeglImageIterator * self); #ifdef __cplusplus } #endif /* __cplusplus */ Index: gegl/gegl/gegl-inside.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-inside.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-inside.c --- gegl/gegl/gegl-inside.c 12 Feb 2003 01:39:10 -0000 1.4 +++ gegl/gegl/gegl-inside.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-inside.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglInsideClass * klass); @@ -8,7 +9,9 @@ static void init (GeglInside * self, Geg static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_inside_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_inside_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,19 +77,42 @@ get_scanline_func(GeglComp * comp, static void fg_inside_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -115,8 +141,7 @@ fg_inside_bg_float (GeglFilter * filter, case 3: *d2++ = *f2++; case 2: *d1++ = *f1++; case 1: *d0++ = *f0++; - case 0: - } + } } } break; @@ -129,8 +154,7 @@ fg_inside_bg_float (GeglFilter * filter, case 3: *d2++ = *f2++; case 2: *d1++ = *f1++; case 1: *d0++ = *f0++; - case 0: - } + } *da++ = *fa++; } @@ -147,8 +171,7 @@ fg_inside_bg_float (GeglFilter * filter, case 3: *d2++ = b * *f2++; case 2: *d1++ = b * *f1++; case 1: *d0++ = b * *f0++; - case 0: - } + } *da++ = b; } @@ -164,8 +187,7 @@ fg_inside_bg_float (GeglFilter * filter, case 3: *d2++ = b * *f2++; case 2: *d1++ = b * *f1++; case 1: *d0++ = b * *f0++; - case 0: - } + } *da++ = b * *fa++; } Index: gegl/gegl/gegl-lighten.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-lighten.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-lighten.c --- gegl/gegl/gegl-lighten.c 12 Feb 2003 01:39:11 -0000 1.4 +++ gegl/gegl/gegl-lighten.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-lighten.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglLightenClass * klass); @@ -8,7 +9,9 @@ static void init (GeglLighten * self, Ge static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_lighten_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_lighten_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,43 @@ get_scanline_func(GeglComp * comp, static void fg_lighten_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -125,8 +151,7 @@ fg_lighten_bg_float (GeglFilter * filter case 1: *d0++ = MAX(*f0, *b0); f0++; b0++; - case 0: - } + } } break; case GEGL_FG_ALPHA: @@ -154,11 +179,12 @@ fg_lighten_bg_float (GeglFilter * filter case 1: *d0++ = MAX(a * *b0 + *f0, b * *f0 + *b0); f0++; b0++; - case 0: - } + } - *da++ = *fa + *ba - *ba++ * *fa++; - } + *da++ = *fa + *ba - *ba * *fa; + ba++; + fa++; + } } break; } Index: gegl/gegl/gegl-max.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-max.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-max.c --- gegl/gegl/gegl-max.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-max.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-max.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglMaxClass * klass); @@ -8,7 +9,9 @@ static void init (GeglMax * self, GeglMa static GeglScanlineFunc get_scanline_func(GeglBinary * binary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void a_max_b_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void a_max_b_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -73,22 +76,43 @@ get_scanline_func(GeglBinary * binary, static void a_max_b_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ + GList * data_outputs, + GList * data_inputs) +{ GeglBinary * binary = GEGL_BINARY(filter); - - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_a_iterator); + gfloat * aa = (gfloat*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; gfloat fade = binary->fade; @@ -124,7 +148,6 @@ a_max_b_float (GeglFilter * filter, case 1: *d0++ = MAX(*a0, fade * *b0); a0++; b0++; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) Index: gegl/gegl/gegl-min.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-min.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-min.c --- gegl/gegl/gegl-min.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-min.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-min.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglMinClass * klass); @@ -8,7 +9,9 @@ static void init (GeglMin * self, GeglMi static GeglScanlineFunc get_scanline_func(GeglBinary * binary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void a_min_b_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void a_min_b_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -73,22 +76,44 @@ get_scanline_func(GeglBinary * binary, static void a_min_b_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { GeglBinary * binary = GEGL_BINARY(filter); - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_a_iterator); + gfloat * aa = (gfloat*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; gfloat fade = binary->fade; @@ -124,7 +149,6 @@ a_min_b_float (GeglFilter * filter, case 1: *d0++ = MIN(*a0, fade * *b0); a0++; b0++; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) Index: gegl/gegl/gegl-mult.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-mult.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-mult.c --- gegl/gegl/gegl-mult.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-mult.c 22 Mar 2003 06:01:00 -0000 @@ -1,5 +1,6 @@ #include "gegl-mult.h" #include "gegl-scanline-processor.h" +#include "gegl-image-data.h" #include "gegl-image-iterator.h" #include "gegl-scalar-data.h" #include "gegl-value-types.h" @@ -23,8 +24,12 @@ static void set_property (GObject *gobje static GeglScanlineFunc get_scanline_func(GeglUnary * unary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void mult_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); -static void mult_uint8 (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void mult_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); +static void mult_uint8 (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -226,20 +231,47 @@ get_scanline_func(GeglUnary * unary, static void mult_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { GeglMult * self = GEGL_MULT(filter); + g_return_if_fail(GEGL_IS_MULT(self)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + gfloat mult[4] = { self->mult[0], self->mult[1], self->mult[2], self->mult[3] }; - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gint alpha_mask = 0x0; @@ -264,7 +296,6 @@ mult_float (GeglFilter * filter, case 3: *d2++ = mult[2] * *a2++; case 2: *d1++ = mult[1] * *a1++; case 1: *d0++ = mult[0] * *a0++; - case 0: } if(alpha_mask == GEGL_A_ALPHA) @@ -280,20 +311,47 @@ mult_float (GeglFilter * filter, static void mult_uint8 (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ + GList * data_outputs, + GList * data_inputs) +{ GeglMult * self = GEGL_MULT(filter); + g_return_if_fail(GEGL_IS_MULT(self)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + gfloat mult[4] = {self->mult[0], self->mult[1], self->mult[2], self->mult[3]}; - guint8 **d = (guint8**)gegl_image_iterator_color_channels(iters[0]); - guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - guint8 **a = (guint8**)gegl_image_iterator_color_channels(iters[1]); - guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + guint8 **d = (guint8**)gegl_image_iterator_color_channels(output_iterator); + guint8 *da = (guint8*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + guint8 **a = (guint8**)gegl_image_iterator_color_channels(input_iterator); + guint8 *aa = (guint8*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gint alpha_mask = 0x0; @@ -321,7 +379,6 @@ mult_uint8 (GeglFilter * filter, a1++; case 1: *d0++ = CLAMP((gint)(mult[0] * *a0 + .5), 0, 255); a0++; - case 0: } if(alpha_mask == GEGL_A_ALPHA) Index: gegl/gegl/gegl-multiply.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-multiply.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-multiply.c --- gegl/gegl/gegl-multiply.c 12 Feb 2003 01:39:11 -0000 1.4 +++ gegl/gegl/gegl-multiply.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-multiply.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglMultiplyClass * klass); @@ -8,7 +9,9 @@ static void init (GeglMultiply * self, G static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_multiply_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_multiply_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,43 @@ get_scanline_func(GeglComp * comp, static void fg_multiply_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -119,8 +145,7 @@ fg_multiply_bg_float (GeglFilter * filte case 3: *d2++ = *f2++ * *b2++; case 2: *d1++ = *f1++ * *b1++; case 1: *d0++ = *f0++ * *b0++; - case 0: - } + } } break; case GEGL_FG_ALPHA: @@ -134,8 +159,7 @@ fg_multiply_bg_float (GeglFilter * filte case 3: *d2++ = (a + *f2++) * *b2++; case 2: *d1++ = (a + *f1++) * *b1++; case 1: *d0++ = (a + *f0++) * *b0++; - case 0: - } + } *da++ = 1.0; } @@ -152,8 +176,7 @@ fg_multiply_bg_float (GeglFilter * filte case 3: *d2++ = (b + *b2++) * *f2++; case 2: *d1++ = (b + *b1++) * *f1++; case 1: *d0++ = (b + *b0++) * *f0++; - case 0: - } + } *da++ = 1.0; } @@ -169,14 +192,21 @@ fg_multiply_bg_float (GeglFilter * filte b = 1.0 - *ba; switch(d_color_chans) { - case 3: *d2++ = a * *b2 + b * *f2 + *b2++ * *f2++; - case 2: *d1++ = a * *b1 + b * *f1 + *b1++ * *f1++; - case 1: *d0++ = a * *b0 + b * *f0 + *b0++ * *f0++; - case 0: - } - - *da++ = *fa + *ba - *ba++ * *fa++; - } + case 3: *d2++ = a * *b2 + b * *f2 + *b2 * *f2; + b2++; + f2++; + case 2: *d1++ = a * *b1 + b * *f1 + *b1 * *f1; + f1++; + b1++; + case 1: *d0++ = a * *b0 + b * *f0 + *b0 * *f0; + b0++; + f0++; + } + + *da++ = *fa + *ba - *ba * *fa; + fa++; + ba++; + } } break; } Index: gegl/gegl/gegl-outside.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-outside.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-outside.c --- gegl/gegl/gegl-outside.c 12 Feb 2003 01:39:11 -0000 1.4 +++ gegl/gegl/gegl-outside.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-outside.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglOutsideClass * klass); @@ -8,7 +9,9 @@ static void init (GeglOutside * self, Ge static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_outside_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_outside_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,19 +77,43 @@ get_scanline_func(GeglComp * comp, static void fg_outside_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + //gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -115,8 +142,7 @@ fg_outside_bg_float (GeglFilter * filter case 3: *d2++ = 0; case 2: *d1++ = 0; case 1: *d0++ = 0; - case 0: - } + } } } break; @@ -129,8 +155,7 @@ fg_outside_bg_float (GeglFilter * filter case 3: *d2++ = 0; case 2: *d1++ = 0; case 1: *d0++ = 0; - case 0: - } + } *da++ = 0; } @@ -147,8 +172,7 @@ fg_outside_bg_float (GeglFilter * filter case 3: *d2++ = b * *f2++; case 2: *d1++ = b * *f1++; case 1: *d0++ = b * *f0++; - case 0: - } + } *da++ = b; } @@ -165,8 +189,7 @@ fg_outside_bg_float (GeglFilter * filter case 3: *d2++ = b * *f2++; case 2: *d1++ = b * *f1++; case 1: *d0++ = b * *f0++; - case 0: - } + } *da++ = b * *fa++; } Index: gegl/gegl/gegl-over.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-over.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-over.c --- gegl/gegl/gegl-over.c 12 Feb 2003 01:39:11 -0000 1.4 +++ gegl/gegl/gegl-over.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-over.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglOverClass * klass); @@ -8,7 +9,9 @@ static void init (GeglOver * self, GeglO static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_over_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_over_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,43 @@ get_scanline_func(GeglComp * comp, static void fg_over_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -120,8 +146,7 @@ fg_over_bg_float (GeglFilter * filter, case 3: *d2++ = *f2++; case 2: *d1++ = *f1++; case 1: *d0++ = *f0++; - case 0: - } + } } } break; @@ -136,8 +161,7 @@ fg_over_bg_float (GeglFilter * filter, case 3: *d2++ = a * *b2++ + *f2++; case 2: *d1++ = a * *b1++ + *f1++; case 1: *d0++ = a * *b0++ + *f0++; - case 0: - } + } *da++ = 1.0; } @@ -152,8 +176,7 @@ fg_over_bg_float (GeglFilter * filter, case 3: *d2++ = *f2++; case 2: *d1++ = *f1++; case 1: *d0++ = *f0++; - case 0: - } + } *da++ = 1.0; } @@ -170,8 +193,7 @@ fg_over_bg_float (GeglFilter * filter, case 3: *d2++ = a * *b2++ + *f2++; case 2: *d1++ = a * *b1++ + *f1++; case 1: *d0++ = a * *b0++ + *f0++; - case 0: - } + } *da++ = a * *ba++ + *fa++; } Index: gegl/gegl/gegl-premult.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-premult.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-premult.c --- gegl/gegl/gegl-premult.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-premult.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-premult.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglPremultClass * klass); @@ -8,7 +9,9 @@ static void init (GeglPremult * self, Ge static GeglScanlineFunc get_scanline_func(GeglUnary * unary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void premult_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void premult_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -75,16 +78,41 @@ get_scanline_func(GeglUnary * unary, static void premult_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); { gfloat *d0 = (d_color_chans > 0) ? d[0]: NULL; @@ -102,7 +130,6 @@ premult_float (GeglFilter * filter, case 3: *d2++ = *aa * *a2++; case 2: *d1++ = *aa * *a1++; case 1: *d0++ = *aa * *a0++; - case 0: } *da++ = *aa++; Index: gegl/gegl/gegl-print.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-print.c,v retrieving revision 1.12 diff -u -p -r1.12 gegl-print.c --- gegl/gegl/gegl-print.c 12 Feb 2003 01:39:11 -0000 1.12 +++ gegl/gegl/gegl-print.c 22 Mar 2003 06:01:00 -0000 @@ -20,7 +20,9 @@ static void finish (GeglFilter * filter, static GeglScanlineFunc get_scanline_func(GeglPipe * pipe, GeglColorSpaceType space, GeglChannelSpaceType type); static void print (GeglPrint * self, gchar * format, ...); -static void print_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void print_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -181,13 +183,27 @@ get_scanline_func(GeglPipe *pipe, static void print_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) + GList * data_outputs, + GList * data_inputs) { GeglPrint *self = GEGL_PRINT(filter); - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + + g_return_if_fail(GEGL_IS_PRINT(self)); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + + gint width = gegl_image_iterator_channel_data_width(input_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); gint alpha_mask = 0x0; @@ -219,7 +235,6 @@ print_float (GeglFilter * filter, case 1: print(self, "%.3f ", *a0++); break; - case 0: } if(alpha_mask == GEGL_A_ALPHA) Index: gegl/gegl/gegl-scanline-processor.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-scanline-processor.c,v retrieving revision 1.8 diff -u -p -r1.8 gegl-scanline-processor.c --- gegl/gegl/gegl-scanline-processor.c 12 Feb 2003 01:39:11 -0000 1.8 +++ gegl/gegl/gegl-scanline-processor.c 22 Mar 2003 06:01:00 -0000 @@ -10,6 +10,10 @@ static void class_init (GeglScanlineProcessorClass * klass); static gpointer parent_class = NULL; +static inline void make_iterator(gpointer data, gpointer user_data); +static inline void advance_iterator(gpointer data, gpointer user_data); +static inline void remove_iterator(gpointer data, gpointer user_data); + GType gegl_scanline_processor_get_type (void) { @@ -59,17 +63,16 @@ gegl_scanline_processor_process (GeglSca GList *data_outputs, GList *data_inputs) { - gint i,j; - GeglRect rect; - GeglImage *image; - gint width, height; - gint num_inputs = g_list_length(data_inputs); - gint num_outputs = g_list_length(data_outputs); - GeglData *data = "" - GValue *value = gegl_data_get_value(data); - GeglImageData *image_data = GEGL_IMAGE_DATA(data); - GeglImageIterator **iters = g_new (GeglImageIterator*, num_inputs + num_outputs); - + gint i; + gint length; + gint num_inputs = 0; + gint num_outputs = 0; + + g_return_if_fail((data_outputs != NULL) || (data_inputs != NULL) ); + + num_inputs = g_list_length(data_inputs); + num_outputs = g_list_length(data_outputs); + #if 1 LOG_DEBUG("processor_process", "%s %p", G_OBJECT_TYPE_NAME(self->op), self->op); @@ -77,107 +80,113 @@ gegl_scanline_processor_process (GeglSca LOG_DEBUG("processor_process", "inputs %d outputs %d", num_inputs, num_outputs); #endif - + + GArray * iterator_lengths=g_array_sized_new(FALSE,TRUE,sizeof(gint),num_inputs+num_outputs); /* Get image iterators for outputs. */ - if (num_outputs == 1) + g_list_foreach(data_outputs,make_iterator,iterator_lengths); + /* Get image iterators for inputs. */ + g_list_foreach(data_inputs,make_iterator,iterator_lengths); + /* If itertor_lengths is null, it means there are no image inputs or outputs, + * I wonder if we should be here in that case, but I'll pretend things are ok. + */ + + /* We should check to make sure that all the interators have the + same length. They all should. (this should have been checked in + validate_(in)|(out)puts, but it never hurts to check + */ + length=0; + if (iterator_lengths->len==0) { - /* - LOG_DEBUG("processor_process", - "getting image iterator for output %d", - i); - */ - - image = (GeglImage*)g_value_get_object(value); - gegl_image_data_get_rect(image_data, &rect); - - /* Get the image, if it is not NULL */ - if(image) - { - LOG_DEBUG("processor_process", - "output value image is %p", - image); - - iters[0] = g_object_new (GEGL_TYPE_IMAGE_ITERATOR, - "image", image, - "area", &rect, - NULL); - - gegl_image_iterator_first (iters[0]); - } + length=0; } - - /* Get image iterators for inputs. */ - for (i = 0; i < num_inputs; i++) + else { - /* - LOG_DEBUG("processor_process", - "getting image iterator for input %d", - i); - */ - - - GeglData *data_input = (GeglData*)g_list_nth_data(data_inputs,i); - GeglImageData *image_data_input = GEGL_IMAGE_DATA(data_input); - GValue *data_input_value = gegl_data_get_value(data_input); - image = (GeglImage*)g_value_get_object(data_input_value); - gegl_image_data_get_rect(image_data_input, &rect); + length=g_array_index(iterator_lengths,gint,0); + for (i=0;ilen;i++) + { + if (length != g_array_index(iterator_lengths,gint,i)) + { + LOG_DEBUG("processor_process", + "image iterators are of unequal length."); + g_array_free(iterator_lengths,FALSE); + return; + } + } + } + g_array_free(iterator_lengths,FALSE); + LOG_DEBUG("processor_process", "length: %d", length); - /* Get the image, if it is not NULL */ - if(image) - { - LOG_DEBUG("processor_process", - "input value image is %p", - image); + /* Now iterate over the scanlines */ + /* Since we have checked that all the iterators have exactly the + * same length, we can just use length + */ + for (i=0;ifunc)(self->op, data_outputs,data_inputs); + g_list_foreach(data_inputs,advance_iterator,NULL); + g_list_foreach(data_outputs,advance_iterator,NULL); + } + /* Free the iterators */ + g_list_foreach(data_inputs,remove_iterator,NULL); + g_list_foreach(data_outputs,remove_iterator,NULL); - iters[i + num_outputs] = g_object_new (GEGL_TYPE_IMAGE_ITERATOR, - "image", image, - "area", &rect, - NULL); + +} - gegl_image_iterator_first (iters[i + num_outputs]); - } - else - iters[i + num_outputs] = NULL; +static inline void +make_iterator(gpointer element, + gpointer user_data) +{ + GeglData * data="" + GeglImageData * image_data=element; + GeglImageIterator * image_iterator=NULL; + GArray * iterator_lengths=user_data; + + g_return_if_fail(data!=NULL); + + /* Don't check IS_IMAGE_DATA in a g_return_if_fail 'cause + * g_return_if_fail causes a fatal error in the testing sequence + */ + if (GEGL_IS_IMAGE_DATA(image_data)) + { + image_iterator=gegl_image_data_make_iterator(image_data); } + if ((image_iterator != NULL)&&(iterator_lengths != NULL)) + { + gint length=gegl_image_iterator_length(image_iterator); + g_array_append_val(iterator_lengths,length); + } +} - /* Get the height and width of dest rect we want to process */ - - image = (GeglImage*)g_value_get_object(value); - gegl_image_data_get_rect(image_data, &rect); - width = rect.w; - height = rect.h; - - LOG_DEBUG("processor_process", "width height %d %d", width, height); +static inline void +advance_iterator(gpointer element, + gpointer user_data) +{ + GeglImageData * image_data=element; + GeglImageIterator * image_iterator=NULL; - /* Now iterate over the scanlines */ - for(j=0; j < height; j++) + if (!GEGL_IS_IMAGE_DATA(image_data)) { - /* - LOG_DEBUG("processor_process", - "doing scanline %d", - j); - */ - - /* Call the subclass scanline func. */ - (self->func)(self->op, iters, width); - - /* Advance all the scanlines. */ - for (i = 0; i < num_inputs + num_outputs; i++) - { - if(iters[i]) - gegl_image_iterator_next(iters[i]); - } + return; + } + image_iterator=gegl_image_data_get_iterator(image_data); + if (image_iterator != NULL) + { + gegl_image_iterator_next(image_iterator); + } +} - } - /* Free the iterators */ - for (i = 0; i < num_inputs + num_outputs; i++) +static inline void +remove_iterator(gpointer element, + gpointer user_data) +{ + GeglImageData * image_data=element; + + if(!GEGL_IS_IMAGE_DATA(image_data)) { - if (iters[i]) - g_object_unref (iters[i]); + return; } - - /* Free the array of iterator pointers */ - g_free (iters); + gegl_image_data_remove_iterator(image_data); } Index: gegl/gegl/gegl-scanline-processor.h =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-scanline-processor.h,v retrieving revision 1.8 diff -u -p -r1.8 gegl-scanline-processor.h --- gegl/gegl/gegl-scanline-processor.h 12 Feb 2003 01:39:11 -0000 1.8 +++ gegl/gegl/gegl-scanline-processor.h 22 Mar 2003 06:01:00 -0000 @@ -17,8 +17,8 @@ extern "C" { #define GEGL_SCANLINE_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_SCANLINE_PROCESSOR, GeglScanlineProcessorClass)) typedef void (*GeglScanlineFunc)(GeglFilter *op, - GeglImageIterator ** iters, - gint width); + GList *data_outputs, + GList *data_inputs); typedef struct _GeglScanlineProcessor GeglScanlineProcessor; struct _GeglScanlineProcessor Index: gegl/gegl/gegl-screen.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-screen.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-screen.c --- gegl/gegl/gegl-screen.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-screen.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-screen.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglScreenClass * klass); @@ -8,7 +9,9 @@ static void init (GeglScreen * self, Geg static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_screen_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_screen_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,43 @@ get_scanline_func(GeglComp * comp, static void fg_screen_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -113,17 +139,26 @@ fg_screen_bg_float (GeglFilter * filter, { switch(d_color_chans) { - case 3: *d2++ = *b2 + *f2 + *b2++ * *f2++; - case 2: *d1++ = *b1 + *f1 + *b1++ * *f1++; - case 1: *d0++ = *b0 + *f0 + *b0++ * *f0++; - case 0: + case 3: *d2++ = *b2 + *f2 + *b2 * *f2; + f2++; + b2++; + case 2: *d1++ = *b1 + *f1 + *b1 * *f1; + b1++; + f1++; + case 1: *d0++ = *b0 + *f0 + *b0 * *f0; + b0++; + f0++; } if(alpha_mask == GEGL_FG_ALPHA || alpha_mask == GEGL_BG_ALPHA) *da++ = 1; else if (alpha_mask == GEGL_FG_BG_ALPHA) - *da++ = *fa + *ba - *ba++ * *fa++; - + { + *da++ = *fa + *ba - *ba * *fa; + ba++; + fa++; + } + } } Index: gegl/gegl/gegl-subtract.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-subtract.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-subtract.c --- gegl/gegl/gegl-subtract.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-subtract.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-subtract.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglSubtractClass * klass); @@ -8,7 +9,9 @@ static void init (GeglSubtract * self, G static GeglScanlineFunc get_scanline_func(GeglBinary * binary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void a_subtract_b_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void a_subtract_b_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -73,22 +76,44 @@ get_scanline_func(GeglBinary * binary, static void a_subtract_b_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ + GList * data_outputs, + GList * data_inputs) +{ GeglBinary * binary = GEGL_BINARY(filter); - - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + g_return_if_fail(GEGL_IS_BINARY(binary)); + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_a=g_list_nth_data(data_inputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_a)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_a_iterator=gegl_image_data_get_iterator(input_a); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_a_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_a_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_a_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_a_iterator); gint alpha_mask = 0x0; gfloat fade = binary->fade; @@ -122,7 +147,6 @@ a_subtract_b_float (GeglFilter * filter, *d1++ = diff < 0.0 ? 0.0 : diff; case 1: diff = *a0++ - fade * *b0++; *d0++ = diff < 0.0 ? 0.0 : diff; - case 0: } if(alpha_mask == GEGL_A_B_ALPHA) Index: gegl/gegl/gegl-unpremult.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-unpremult.c,v retrieving revision 1.7 diff -u -p -r1.7 gegl-unpremult.c --- gegl/gegl/gegl-unpremult.c 12 Feb 2003 01:39:11 -0000 1.7 +++ gegl/gegl/gegl-unpremult.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-unpremult.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglUnpremultClass * klass); @@ -8,7 +9,9 @@ static void init (GeglUnpremult * self, static GeglScanlineFunc get_scanline_func(GeglUnary * unary, GeglColorSpaceType space, GeglChannelSpaceType type); -static void unpremult_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void unpremult_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -75,16 +78,42 @@ get_scanline_func(GeglUnary * unary, static void unpremult_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **a = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint a_color_chans = gegl_image_iterator_get_num_colors(iters[1]); + GList * data_outputs, + GList * data_inputs) +{ + + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=1); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input=g_list_nth_data(data_inputs,0); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input)); + + GeglImageIterator* input_iterator=gegl_image_data_get_iterator(input); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths should have already been checked. Make an error if they + are different */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + if (width != gegl_image_iterator_channel_data_width(input_iterator)) + { + LOG_DEBUG("GeglCopy->copy_general","input and output channel data widths are unequal"); + /*Since things are now wacky, it is best to return and do nothing*/ + return; + } + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **a = (gfloat**)gegl_image_iterator_color_channels(input_iterator); + gfloat *aa = (gfloat*)gegl_image_iterator_alpha_channel(input_iterator); + gint a_color_chans = gegl_image_iterator_get_num_colors(input_iterator); { gfloat *d0 = (d_color_chans > 0) ? d[0]: NULL; @@ -104,8 +133,7 @@ unpremult_float (GeglFilter * filter, case 3: *d2++ = *a2++; case 2: *d1++ = *a1++; case 1: *d0++ = *a0++; - case 0: - } + } *da++ = *aa++; } @@ -119,8 +147,7 @@ unpremult_float (GeglFilter * filter, a1++; case 1: *d0++ = 0.0; a0++; - case 0: - } + } *da++ = *aa++; } else @@ -130,8 +157,7 @@ unpremult_float (GeglFilter * filter, case 3: *d2++ = *a2++ / *aa; case 2: *d1++ = *a1++ / *aa; case 1: *d0++ = *a0++ / *aa; - case 0: - } + } *da++ = *aa++; } Index: gegl/gegl/gegl-xor.c =================================================================== RCS file: /cvs/gnome/gegl/gegl/gegl-xor.c,v retrieving revision 1.4 diff -u -p -r1.4 gegl-xor.c --- gegl/gegl/gegl-xor.c 12 Feb 2003 01:39:11 -0000 1.4 +++ gegl/gegl/gegl-xor.c 22 Mar 2003 06:01:00 -0000 @@ -1,6 +1,7 @@ #include "gegl-xor.h" #include "gegl-scanline-processor.h" #include "gegl-image-iterator.h" +#include "gegl-image-data.h" #include "gegl-utils.h" static void class_init (GeglXorClass * klass); @@ -8,7 +9,9 @@ static void init (GeglXor * self, GeglXo static GeglScanlineFunc get_scanline_func(GeglComp * comp, GeglColorSpaceType space, GeglChannelSpaceType type); -static void fg_xor_bg_float (GeglFilter * filter, GeglImageIterator ** iters, gint width); +static void fg_xor_bg_float (GeglFilter * filter, + GList * data_outputs, + GList * data_inputs); static gpointer parent_class = NULL; @@ -74,20 +77,42 @@ get_scanline_func(GeglComp * comp, static void fg_xor_bg_float (GeglFilter * filter, - GeglImageIterator ** iters, - gint width) -{ - gfloat **d = (gfloat**)gegl_image_iterator_color_channels(iters[0]); - gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(iters[0]); - gint d_color_chans = gegl_image_iterator_get_num_colors(iters[0]); - - gfloat **b = (gfloat**)gegl_image_iterator_color_channels(iters[1]); - gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(iters[1]); - gint b_color_chans = gegl_image_iterator_get_num_colors(iters[1]); - - gfloat **f = (gfloat**)gegl_image_iterator_color_channels(iters[2]); - gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(iters[2]); - gint f_color_chans = gegl_image_iterator_get_num_colors(iters[2]); + GList * data_outputs, + GList * data_inputs) +{ + g_return_if_fail(g_list_length(data_outputs) >=1); + g_return_if_fail(g_list_length(data_inputs) >=2); + + GeglImageData* output=g_list_nth_data(data_outputs,0); + GeglImageData* input_b=g_list_nth_data(data_inputs,0); + GeglImageData* input_f=g_list_nth_data(data_inputs,1); + + g_return_if_fail(GEGL_IS_IMAGE_DATA(output)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_f)); + g_return_if_fail(GEGL_IS_IMAGE_DATA(input_b)); + + GeglImageIterator* input_f_iterator=gegl_image_data_get_iterator(input_f); + GeglImageIterator* input_b_iterator=gegl_image_data_get_iterator(input_b); + GeglImageIterator* output_iterator=gegl_image_data_get_iterator(output); + + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_f_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(input_b_iterator)); + g_return_if_fail(GEGL_IS_IMAGE_ITERATOR(output_iterator)); + + /*widths are already checked. Safe to assume the are all the same */ + gint width = gegl_image_iterator_channel_data_width(output_iterator); + + gfloat **d = (gfloat**)gegl_image_iterator_color_channels(output_iterator); + gfloat *da = (gfloat*)gegl_image_iterator_alpha_channel(output_iterator); + gint d_color_chans = gegl_image_iterator_get_num_colors(output_iterator); + + gfloat **b = (gfloat**)gegl_image_iterator_color_channels(input_b_iterator); + gfloat *ba = (gfloat*)gegl_image_iterator_alpha_channel(input_b_iterator); + gint b_color_chans = gegl_image_iterator_get_num_colors(input_b_iterator); + + gfloat **f = (gfloat**)gegl_image_iterator_color_channels(input_f_iterator); + gfloat * fa = (gfloat*)gegl_image_iterator_alpha_channel(input_f_iterator); + gint f_color_chans = gegl_image_iterator_get_num_colors(input_f_iterator); gint alpha_mask = 0x0; @@ -120,8 +145,7 @@ fg_xor_bg_float (GeglFilter * filter, case 3: *d2++ = 0; case 2: *d1++ = 0; case 1: *d0++ = 0; - case 0: - } + } } } break; @@ -136,8 +160,7 @@ fg_xor_bg_float (GeglFilter * filter, case 3: *d2++ = a * *b2++; case 2: *d1++ = a * *b1++; case 1: *d0++ = a * *b0++; - case 0: - } + } *da++ = a; } @@ -154,8 +177,7 @@ fg_xor_bg_float (GeglFilter * filter, case 3: *d2++ = b * *f2++; case 2: *d1++ = b * *f1++; case 1: *d0++ = b * *f0++; - case 0: - } + } *da++ = b * *fa++; } @@ -174,8 +196,7 @@ fg_xor_bg_float (GeglFilter * filter, case 3: *d2++ = a * *b2++ + b * *f2++; case 2: *d1++ = a * *b1++ + b * *f1++; case 1: *d0++ = a * *b0++ + b * *f0++; - case 0: - } + } *da++ = a * *ba++ + b * *fa++; }


[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux