From: jucablues Date: Thu, 26 Jul 2007 08:02:07 +0000 (+0000) Subject: boiler plate code for feTurbulence: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e50fb78bbe0c001b3ca6040ba25ae6e75dc9385f;p=inkscape.git boiler plate code for feTurbulence: *reading attributes and setting default values same for some more attributes on convolve matrix filter alphabetical ordering on Makefile_insert and on nr-filter.cpp #includes --- diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index baeaaec62..624733a42 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -67,30 +67,32 @@ display_libspdisplay_a_SOURCES = \ display/sp-ctrlquadr.h \ display/nr-filter.cpp \ display/nr-filter.h \ - display/nr-filter-primitive.cpp \ - display/nr-filter-primitive.h \ - display/nr-filter-gaussian.cpp \ - display/nr-filter-gaussian.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ - display/nr-filter-diffuselighting.cpp \ - display/nr-filter-diffuselighting.h \ - display/nr-filter-offset.cpp \ - display/nr-filter-offset.h \ - display/nr-filter-specularlighting.cpp \ - display/nr-filter-specularlighting.h \ display/nr-filter-composite.h \ display/nr-filter-composite.cpp \ display/nr-filter-convolve-matrix.cpp \ display/nr-filter-convolve-matrix.h \ + display/nr-filter-diffuselighting.cpp \ + display/nr-filter-diffuselighting.h \ display/nr-filter-displacement-map.cpp \ display/nr-filter-displacement-map.h \ + display/nr-filter-gaussian.cpp \ + display/nr-filter-gaussian.h \ + display/nr-filter-getalpha.cpp \ + display/nr-filter-getalpha.h \ display/nr-filter-image.cpp \ display/nr-filter-image.h \ + display/nr-filter-offset.cpp \ + display/nr-filter-offset.h \ + display/nr-filter-primitive.cpp \ + display/nr-filter-primitive.h \ display/nr-filter-slot.cpp \ display/nr-filter-slot.h \ - display/nr-filter-getalpha.cpp \ - display/nr-filter-getalpha.h \ + display/nr-filter-specularlighting.cpp \ + display/nr-filter-specularlighting.h \ + display/nr-filter-turbulence.cpp \ + display/nr-filter-turbulence.h \ display/nr-filter-pixops.h \ display/nr-filter-types.h \ display/nr-filter-utils.h \ diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 75a40df70..f8a00cb4b 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -14,6 +14,9 @@ namespace NR { FilterConvolveMatrix::FilterConvolveMatrix() +: bias(0), + edgeMode(0), + preserveAlpha(false) {} FilterPrimitive * FilterConvolveMatrix::create() { @@ -123,6 +126,14 @@ void FilterConvolveMatrix::set_kernelMatrix(std::vector &km) { kernelMatrix = km; } +void FilterConvolveMatrix::set_edgeMode(int mode){ + edgeMode = mode; +} + +void FilterConvolveMatrix::set_preserveAlpha(bool pa){ + preserveAlpha = pa; +} + void FilterConvolveMatrix::area_enlarge(NRRectL &area, Matrix const &trans) { //Seems to me that since this filter's operation is resolution dependent, diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index e5b72a71f..f4a823012 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -36,13 +36,17 @@ public: void set_kernelMatrix(std::vector& km); void set_bias(double b); void set_divisor(double d); + void set_edgeMode(int mode); + void set_preserveAlpha(bool pa); private: std::vector kernelMatrix; int targetX, targetY; int orderX, orderY; gdouble divisor, bias; - int dx, dy; //kernelUnitLength + int dx, dy, kernelUnitLength; + int edgeMode; + bool preserveAlpha; }; } /* namespace NR */ diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 7d32ce2e0..8d2e6dc3c 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -58,7 +58,7 @@ int FilterDisplacementMap::render(FilterSlot &slot, Matrix const &trans) { x1 = out->area.x1; y1 = out->area.y1; width = x1 - x0; - + for (x=x0 + scale/2; x < x1 - scale/2; x++){ for (y=y0 + scale/2; y < y1 - scale/2; y++){ /* SVG spec states that pixel values must be alpha-demultiplied before processing this filter operation. diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 62a8caf20..b1a5b4d7a 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -17,6 +17,7 @@ namespace NR { FilterImage::FilterImage() { + g_warning("FilterImage::render not implemented."); /* Testing with hardcoded xlink:href : image = Gdk::Pixbuf::create_from_file("/home/felipe/images/image1.jpg"); //TODO: handle errors @@ -33,13 +34,11 @@ FilterImage::~FilterImage() {} int FilterImage::render(FilterSlot &slot, Matrix const &trans) { + return 0; /* TODO: Implement this renderer method. -Specification: http://www.w3.org/TR/SVG11/filters.html#feImage + Specification: http://www.w3.org/TR/SVG11/filters.html#feImage - It would be good to findout how to reuse sp-image.cpp code - -After implementing it, add a reference to FilterImage::create - on Filter::_create_constructor_table() (nr-filter.cpp file) + It would be good to findout how to reuse sp-image.cpp code */ /* int w,x,y; diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp new file mode 100644 index 000000000..2dbb33e65 --- /dev/null +++ b/src/display/nr-filter-turbulence.cpp @@ -0,0 +1,104 @@ +/* + * feTurbulence filter primitive renderer + * + * Authors: + * Felipe Corrêa da Silva Sanches + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-filter-turbulence.h" + +namespace NR { + +FilterTurbulence::FilterTurbulence() +: XbaseFrequency(0), + YbaseFrequency(0), + numOctaves(1), + seed(0) +{ + g_warning("FilterTurbulence::render not implemented."); +} + +FilterPrimitive * FilterTurbulence::create() { + return new FilterTurbulence(); +} + +FilterTurbulence::~FilterTurbulence() +{} + +void FilterTurbulence::set_baseFrequency(int axis, double freq){ + if (axis==0) XbaseFrequency=freq; + if (axis==1) YbaseFrequency=freq; +} + +void FilterTurbulence::set_numOctaves(int num){ + numOctaves=num; +} + +void FilterTurbulence::set_seed(double s){ + seed=s; +} + +void FilterTurbulence::set_stitchTiles(bool st){ + stitchTiles=st; +} + +void FilterTurbulence::set_type(int t){ + type=t; +} + + +int FilterTurbulence::render(FilterSlot &slot, Matrix const &trans) { +/* TODO: Implement this renderer method. + Specification: http://www.w3.org/TR/SVG11/filters.html#feTurbulence + +*/ + +/*debug: these are the available parameters + printf("XbaseFrequency = %f; ", XbaseFrequency); + printf("YbaseFrequency = %f; ", YbaseFrequency); + printf("numOctaves = %d;\n", numOctaves); + printf("seed = %f; ", seed); + printf("stitchTiles = %s; ", stitchTiles ? "stitch" : "noStitch"); + printf("type = %s;\n\n", type==0 ? "FractalNoise" : "turbulence"); +*/ + +//sample code: the following fills the whole area in semi-transparent red. + NRPixBlock *in = slot.get(_input); + NRPixBlock *out = new NRPixBlock; + int x,y; + int x0 = in->area.x0, y0 = in->area.y0; + int x1 = in->area.x1, y1 = in->area.y1; + int w = x1 - x0; + nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true); + + unsigned char *out_data = NR_PIXBLOCK_PX(out); + for (x=x0; x < x1; x++){ + for (y=y0; y < y1; y++){ + out_data[4*((x - x0)+w*(y - y0)) + 0] = 255; + out_data[4*((x - x0)+w*(y - y0)) + 1] = 0; + out_data[4*((x - x0)+w*(y - y0)) + 2] = 0; + out_data[4*((x - x0)+w*(y - y0)) + 3] = 128; + } + } + + out->empty = FALSE; + slot.set(_output, out); + return 0; +} + +} /* namespace NR */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h new file mode 100644 index 000000000..bdb52e7b7 --- /dev/null +++ b/src/display/nr-filter-turbulence.h @@ -0,0 +1,53 @@ +#ifndef __NR_FILTER_TURBULENCE_H__ +#define __NR_FILTER_TURBULENCE_H__ + +/* + * feTurbulence filter primitive renderer + * + * Authors: + * Felipe Sanches + * Niko Kiirala + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/nr-filter-primitive.h" +#include "display/nr-filter-slot.h" + +namespace NR { + +class FilterTurbulence : public FilterPrimitive { +public: + FilterTurbulence(); + static FilterPrimitive *create(); + virtual ~FilterTurbulence(); + + virtual int render(FilterSlot &slot, Matrix const &trans); + virtual void set_baseFrequency(int axis, double freq); + virtual void set_numOctaves(int num); + virtual void set_seed(double s); + virtual void set_stitchTiles(bool st); + virtual void set_type(int t); +private: + double XbaseFrequency, YbaseFrequency; + int numOctaves; + double seed; + bool stitchTiles; + int type; +}; + +} /* namespace NR */ + +#endif /* __NR_FILTER_TURBULENCE_H__ */ +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index eb6a48e6c..f09573eb4 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -21,15 +21,16 @@ #include "display/pixblock-scaler.h" #include "display/pixblock-transform.h" -#include "display/nr-filter-displacement-map.h" -#include "display/nr-filter-gaussian.h" -#include "display/nr-filter-convolve-matrix.h" #include "display/nr-filter-blend.h" -#include "display/nr-filter-offset.h" #include "display/nr-filter-composite.h" +#include "display/nr-filter-convolve-matrix.h" #include "display/nr-filter-diffuselighting.h" -#include "display/nr-filter-specularlighting.h" +#include "display/nr-filter-displacement-map.h" +#include "display/nr-filter-gaussian.h" #include "display/nr-filter-image.h" +#include "display/nr-filter-offset.h" +#include "display/nr-filter-specularlighting.h" +#include "display/nr-filter-turbulence.h" #include "display/nr-arena-item.h" #include "libnr/nr-pixblock.h" @@ -312,7 +313,9 @@ void Filter::_create_constructor_table() static bool created = false; if(created) return; - /* Filter effects not yet implemented are set to NULL */ +/* Some filter classes are not implemented yet. + Filters with constructors appearing in this table are not necessarilly already implemented. + Some of them still have only boilerplate-code.*/ _constructor[NR_FILTER_BLEND] = &FilterBlend::create; _constructor[NR_FILTER_COLORMATRIX] = NULL; _constructor[NR_FILTER_COMPONENTTRANSFER] = NULL; @@ -322,13 +325,13 @@ void Filter::_create_constructor_table() _constructor[NR_FILTER_DISPLACEMENTMAP] = &FilterDisplacementMap::create; _constructor[NR_FILTER_FLOOD] = NULL; _constructor[NR_FILTER_GAUSSIANBLUR] = &FilterGaussian::create; - _constructor[NR_FILTER_IMAGE] = NULL; + _constructor[NR_FILTER_IMAGE] = &FilterImage::create; _constructor[NR_FILTER_MERGE] = NULL; _constructor[NR_FILTER_MORPHOLOGY] = NULL; _constructor[NR_FILTER_OFFSET] = &FilterOffset::create; _constructor[NR_FILTER_SPECULARLIGHTING] = &FilterSpecularLighting::create; _constructor[NR_FILTER_TILE] = NULL; - _constructor[NR_FILTER_TURBULENCE] = NULL; + _constructor[NR_FILTER_TURBULENCE] = &FilterTurbulence::create; created = true; } diff --git a/src/sp-feconvolvematrix.cpp b/src/sp-feconvolvematrix.cpp index 4191cceec..059475e5f 100644 --- a/src/sp-feconvolvematrix.cpp +++ b/src/sp-feconvolvematrix.cpp @@ -144,6 +144,36 @@ sp_feConvolveMatrix_read_number(gchar const *value) { return ret; } +static int sp_feConvolveMatrix_read_edgeMode(gchar const *value){ + if (!value) return 0; //duplicate is default + switch(value[0]){ + case 'd': + if (strncmp(value, "duplicate", 9) == 0) return 0; + break; + case 'w': + if (strncmp(value, "wrap", 4) == 0) return 1; + break; + case 'n': + if (strncmp(value, "none", 4) == 0) return 2; + break; + } + return 0; //duplicate is default +} + + +static bool sp_feConvolveMatrix_read_bool(gchar const *value){ + if (!value) return false; //false is default + switch(value[0]){ + case 't': + if (strncmp(value, "true", 4) == 0) return true; + break; + case 'f': + if (strncmp(value, "false", 5) == 0) return false; + break; + } + return false; //false is default +} + /** * Sets a specific value in the SPFeConvolveMatrix. */ @@ -152,7 +182,10 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value) { SPFeConvolveMatrix *feConvolveMatrix = SP_FECONVOLVEMATRIX(object); (void)feConvolveMatrix; - + double read_num; + int read_int; + bool read_bool; + switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ case SP_ATTR_ORDER: @@ -164,32 +197,51 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value) object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_DIVISOR: - feConvolveMatrix->divisor = sp_feConvolveMatrix_read_number(value); - object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + read_num = sp_feConvolveMatrix_read_number(value); + if (read_num != feConvolveMatrix->divisor){ + feConvolveMatrix->divisor = read_num; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } break; case SP_ATTR_BIAS: - feConvolveMatrix->bias = sp_feConvolveMatrix_read_number(value); - object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + read_num = sp_feConvolveMatrix_read_number(value); + if (read_num != feConvolveMatrix->bias){ + feConvolveMatrix->bias = read_num; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } break; case SP_ATTR_TARGETX: - feConvolveMatrix->targetX = (int) sp_feConvolveMatrix_read_number(value); - object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + read_int = (int) sp_feConvolveMatrix_read_number(value); + if (read_int != feConvolveMatrix->targetX){ + feConvolveMatrix->targetX = read_int; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } break; case SP_ATTR_TARGETY: - feConvolveMatrix->targetY = (int) sp_feConvolveMatrix_read_number(value); - object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + read_int = (int) sp_feConvolveMatrix_read_number(value); + if (read_int != feConvolveMatrix->targetY){ + feConvolveMatrix->targetY = read_int; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } break; case SP_ATTR_EDGEMODE: - //TODO + read_int = (int) sp_feConvolveMatrix_read_edgeMode(value); + if (read_int != feConvolveMatrix->edgeMode){ + feConvolveMatrix->edgeMode = read_int; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } break; case SP_ATTR_KERNELUNITLENGTH: feConvolveMatrix->kernelUnitLength.set(value); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEALPHA: - //TODO + read_bool = sp_feConvolveMatrix_read_bool(value); + if (read_bool != feConvolveMatrix->preserveAlpha){ + feConvolveMatrix->preserveAlpha = read_bool; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } break; - default: if (((SPObjectClass *) feConvolveMatrix_parent_class)->set) ((SPObjectClass *) feConvolveMatrix_parent_class)->set(object, key, value); diff --git a/src/sp-feconvolvematrix.h b/src/sp-feconvolvematrix.h index 53ed8b741..0cb4abc67 100644 --- a/src/sp-feconvolvematrix.h +++ b/src/sp-feconvolvematrix.h @@ -30,7 +30,7 @@ struct SPFeConvolveMatrix : public SPFilterPrimitive { std::vector kernelMatrix; double divisor, bias; int targetX, targetY; - unsigned short edgeMode; + int edgeMode; NumberOptNumber kernelUnitLength; bool preserveAlpha; }; diff --git a/src/sp-feturbulence.cpp b/src/sp-feturbulence.cpp index f1f99a613..138778984 100644 --- a/src/sp-feturbulence.cpp +++ b/src/sp-feturbulence.cpp @@ -6,8 +6,10 @@ */ /* * Authors: + * Felipe Corrêa da Silva Sanches * hugo Rodrigues * + * Copyright (C) 2007 Felipe Sanches * Copyright (C) 2006 Hugo Rodrigues * * Released under GNU GPL, read the file 'COPYING' for more information @@ -21,7 +23,10 @@ #include "svg/svg.h" #include "sp-feturbulence.h" #include "xml/repr.h" +#include +#include "display/nr-filter.h" +#include "display/nr-filter-turbulence.h" /* FeTurbulence base class */ @@ -33,6 +38,7 @@ static void sp_feTurbulence_release(SPObject *object); static void sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value); static void sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); +static void sp_feTurbulence_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter); static SPFilterPrimitiveClass *feTurbulence_parent_class; @@ -61,6 +67,7 @@ static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; + SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass; feTurbulence_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); @@ -69,6 +76,8 @@ sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) sp_object_class->write = sp_feTurbulence_write; sp_object_class->set = sp_feTurbulence_set; sp_object_class->update = sp_feTurbulence_update; + + sp_primitive_class->build_renderer = sp_feTurbulence_build_renderer; } static void @@ -89,6 +98,11 @@ sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod } /*LOAD ATTRIBUTES FROM REPR HERE*/ + sp_object_read_attr(object, "baseFrequency"); + sp_object_read_attr(object, "numOctaves"); + sp_object_read_attr(object, "seed"); + sp_object_read_attr(object, "stitchTiles"); + sp_object_read_attr(object, "type"); } /** @@ -101,6 +115,46 @@ sp_feTurbulence_release(SPObject *object) ((SPObjectClass *) feTurbulence_parent_class)->release(object); } +static double +sp_feTurbulence_read_number(gchar const *value) { + if (!value) return 0; + char *end; + double ret = g_ascii_strtod(value, &end); + if (*end) { + g_warning("Unable to convert \"%s\" to number", value); + // We could leave this out, too. If strtod can't convert + // anything, it will return zero. + ret = 0; + } + return ret; +} + +static bool sp_feTurbulence_read_stitchTiles(gchar const *value){ + if (!value) return false; // 'noStitch' is default + switch(value[0]){ + case 's': + if (strncmp(value, "stitch", 6) == 0) return true; + break; + case 'n': + if (strncmp(value, "noStitch", 8) == 0) return false; + break; + } + return false; // 'noStitch' is default +} + +static int sp_feTurbulence_read_type(gchar const *value){ + if (!value) return 1; // 'turbulence' is default + switch(value[0]){ + case 'f': + if (strncmp(value, "fractalNoise", 12) == 0) return 0; + break; + case 't': + if (strncmp(value, "turbulence", 10) == 0) return 1; + break; + } + return 1; // 'turbulence' is default +} + /** * Sets a specific value in the SPFeTurbulence. */ @@ -110,8 +164,48 @@ sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) SPFeTurbulence *feTurbulence = SP_FETURBULENCE(object); (void)feTurbulence; + int read_int; + double read_num; + bool read_bool; + switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ + + case SP_ATTR_BASEFREQUENCY: + feTurbulence->baseFrequency.set(value); + //From SVG spec: If two s are provided, the first number represents a base frequency in the X direction and the second value represents a base frequency in the Y direction. If one number is provided, then that value is used for both X and Y. + if (feTurbulence->baseFrequency.getOptNumber() == -1) // -1 means "not set" + feTurbulence->baseFrequency.setOptNumber(feTurbulence->baseFrequency.getNumber()); + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + case SP_ATTR_NUMOCTAVES: + read_int = (int) sp_feTurbulence_read_number(value); + if (read_int != feTurbulence->numOctaves){ + feTurbulence->numOctaves = read_int; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } + break; + case SP_ATTR_SEED: + read_num = sp_feTurbulence_read_number(value); + if (read_num != feTurbulence->seed){ + feTurbulence->seed = read_num; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } + break; + case SP_ATTR_STITCHTILES: + read_bool = sp_feTurbulence_read_stitchTiles(value); + if (read_bool != feTurbulence->stitchTiles){ + feTurbulence->stitchTiles = read_bool; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } + break; + case SP_ATTR_TYPE: + read_int = sp_feTurbulence_read_type(value); + if (read_int != feTurbulence->type){ + feTurbulence->type = read_int; + object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + } + break; default: if (((SPObjectClass *) feTurbulence_parent_class)->set) ((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value); @@ -161,6 +255,26 @@ sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) return repr; } +static void sp_feTurbulence_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) { + g_assert(primitive != NULL); + g_assert(filter != NULL); + + SPFeTurbulence *sp_turbulence = SP_FETURBULENCE(primitive); + + int primitive_n = filter->add_primitive(NR::NR_FILTER_TURBULENCE); + NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n); + NR::FilterTurbulence *nr_turbulence = dynamic_cast(nr_primitive); + g_assert(nr_turbulence != NULL); + + sp_filter_primitive_renderer_common(primitive, nr_primitive); + + nr_turbulence->set_baseFrequency(0, sp_turbulence->baseFrequency.getNumber()); + nr_turbulence->set_baseFrequency(1, sp_turbulence->baseFrequency.getOptNumber()); + nr_turbulence->set_numOctaves(sp_turbulence->numOctaves); + nr_turbulence->set_seed(sp_turbulence->seed); + nr_turbulence->set_stitchTiles(sp_turbulence->stitchTiles); + nr_turbulence->set_type(sp_turbulence->type); +} /* Local Variables: diff --git a/src/sp-feturbulence.h b/src/sp-feturbulence.h index bf9ed2572..7f9adae13 100644 --- a/src/sp-feturbulence.h +++ b/src/sp-feturbulence.h @@ -6,6 +6,7 @@ */ /* * Authors: + * Felipe Corrêa da Silva Sanches * Hugo Rodrigues * * Copyright (C) 2006 Hugo Rodrigues @@ -15,13 +16,18 @@ #include "sp-filter.h" #include "sp-feturbulence-fns.h" +#include "number-opt-number.h" /* FeTurbulence base class */ class SPFeTurbulenceClass; struct SPFeTurbulence : public SPFilterPrimitive { /** TURBULENCE ATTRIBUTES HERE */ - + NumberOptNumber baseFrequency; + int numOctaves; + double seed; + bool stitchTiles; + int type; }; struct SPFeTurbulenceClass {