From: jucablues Date: Sat, 4 Aug 2007 04:18:36 +0000 (+0000) Subject: boilerplate code for the remaining filters. My next commits will X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=76f8b79291ff270e0602159704dc2f07024e5132;p=inkscape.git boilerplate code for the remaining filters. My next commits will probably deal with setting default attribute values for these filters --- diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index ed9eae9be..de6e64c4a 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -69,6 +69,10 @@ display_libspdisplay_a_SOURCES = \ display/nr-filter.h \ display/nr-filter-blend.cpp \ display/nr-filter-blend.h \ + display/nr-filter-colormatrix.cpp \ + display/nr-filter-colormatrix.h \ + display/nr-filter-component-transfer.cpp \ + display/nr-filter-component-transfer.h \ display/nr-filter-composite.h \ display/nr-filter-composite.cpp \ display/nr-filter-convolve-matrix.cpp \ @@ -77,6 +81,8 @@ display_libspdisplay_a_SOURCES = \ display/nr-filter-diffuselighting.h \ display/nr-filter-displacement-map.cpp \ display/nr-filter-displacement-map.h \ + display/nr-filter-flood.cpp \ + display/nr-filter-flood.h \ display/nr-filter-gaussian.cpp \ display/nr-filter-gaussian.h \ display/nr-filter-getalpha.cpp \ @@ -85,6 +91,8 @@ display_libspdisplay_a_SOURCES = \ display/nr-filter-image.h \ display/nr-filter-merge.cpp \ display/nr-filter-merge.h \ + display/nr-filter-morphology.cpp \ + display/nr-filter-morphology.h \ display/nr-filter-offset.cpp \ display/nr-filter-offset.h \ display/nr-filter-primitive.cpp \ diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp new file mode 100644 index 000000000..060703ada --- /dev/null +++ b/src/display/nr-filter-colormatrix.cpp @@ -0,0 +1,60 @@ +/* + * feColorMatrix 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-colormatrix.h" +namespace NR { + +FilterColorMatrix::FilterColorMatrix() +{ + g_warning("FilterColorMatrix::render not implemented."); +} + +FilterPrimitive * FilterColorMatrix::create() { + return new FilterColorMatrix(); +} + +FilterColorMatrix::~FilterColorMatrix() +{} + +int FilterColorMatrix::render(FilterSlot &slot, Matrix const &trans) { + NRPixBlock *in = slot.get(_input); + NRPixBlock *out = new NRPixBlock; + + nr_pixblock_setup_fast(out, in->mode, + in->area.x0, in->area.y0, in->area.x1, in->area.y1, + true); + + unsigned char *in_data = NR_PIXBLOCK_PX(in); + unsigned char *out_data = NR_PIXBLOCK_PX(out); + +//IMPLEMENT ME! + + out->empty = FALSE; + slot.set(_output, out); + return 0; +} + +void FilterColorMatrix::area_enlarge(NRRectL &area, Matrix const &trans) +{ +} + +} /* 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-colormatrix.h b/src/display/nr-filter-colormatrix.h new file mode 100644 index 000000000..cf93a75cb --- /dev/null +++ b/src/display/nr-filter-colormatrix.h @@ -0,0 +1,42 @@ +#ifndef __NR_FILTER_COLOR_MATRIX_H__ +#define __NR_FILTER_COLOR_MATRIX_H__ + +/* + * feColorMatrix 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-primitive.h" +#include "display/nr-filter-slot.h" + +namespace NR { + +class FilterColorMatrix : public FilterPrimitive { +public: + FilterColorMatrix(); + static FilterPrimitive *create(); + virtual ~FilterColorMatrix(); + + virtual int render(FilterSlot &slot, Matrix const &trans); + virtual void area_enlarge(NRRectL &area, Matrix const &trans); +}; + +} /* namespace NR */ + +#endif /* __NR_FILTER_COLOR_MATRIX_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-flood.cpp b/src/display/nr-filter-flood.cpp new file mode 100644 index 000000000..5bd346637 --- /dev/null +++ b/src/display/nr-filter-flood.cpp @@ -0,0 +1,60 @@ +/* + * feFlood 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-flood.h" +namespace NR { + +FilterFlood::FilterFlood() +{ + g_warning("FilterFlood::render not implemented."); +} + +FilterPrimitive * FilterFlood::create() { + return new FilterFlood(); +} + +FilterFlood::~FilterFlood() +{} + +int FilterFlood::render(FilterSlot &slot, Matrix const &trans) { + NRPixBlock *in = slot.get(_input); + NRPixBlock *out = new NRPixBlock; + + nr_pixblock_setup_fast(out, in->mode, + in->area.x0, in->area.y0, in->area.x1, in->area.y1, + true); + + unsigned char *in_data = NR_PIXBLOCK_PX(in); + unsigned char *out_data = NR_PIXBLOCK_PX(out); + +//IMPLEMENT ME! + + out->empty = FALSE; + slot.set(_output, out); + return 0; +} + +void FilterFlood::area_enlarge(NRRectL &area, Matrix const &trans) +{ +} + +} /* 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-flood.h b/src/display/nr-filter-flood.h new file mode 100644 index 000000000..548711164 --- /dev/null +++ b/src/display/nr-filter-flood.h @@ -0,0 +1,42 @@ +#ifndef __NR_FILTER_FLOOD_H__ +#define __NR_FILTER_FLOOD_H__ + +/* + * feFlood 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-primitive.h" +#include "display/nr-filter-slot.h" + +namespace NR { + +class FilterFlood : public FilterPrimitive { +public: + FilterFlood(); + static FilterPrimitive *create(); + virtual ~FilterFlood(); + + virtual int render(FilterSlot &slot, Matrix const &trans); + virtual void area_enlarge(NRRectL &area, Matrix const &trans); +}; + +} /* namespace NR */ + +#endif /* __NR_FILTER_FLOOD_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-morphology.cpp b/src/display/nr-filter-morphology.cpp new file mode 100644 index 000000000..9660d61ef --- /dev/null +++ b/src/display/nr-filter-morphology.cpp @@ -0,0 +1,60 @@ +/* + * feMorphology 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-morphology.h" +namespace NR { + +FilterMorphology::FilterMorphology() +{ + g_warning("FilterMorphology::render not implemented."); +} + +FilterPrimitive * FilterMorphology::create() { + return new FilterMorphology(); +} + +FilterMorphology::~FilterMorphology() +{} + +int FilterMorphology::render(FilterSlot &slot, Matrix const &trans) { + NRPixBlock *in = slot.get(_input); + NRPixBlock *out = new NRPixBlock; + + nr_pixblock_setup_fast(out, in->mode, + in->area.x0, in->area.y0, in->area.x1, in->area.y1, + true); + + unsigned char *in_data = NR_PIXBLOCK_PX(in); + unsigned char *out_data = NR_PIXBLOCK_PX(out); + +//IMPLEMENT ME! + + out->empty = FALSE; + slot.set(_output, out); + return 0; +} + +void FilterMorphology::area_enlarge(NRRectL &area, Matrix const &trans) +{ +} + +} /* 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-morphology.h b/src/display/nr-filter-morphology.h new file mode 100644 index 000000000..5f89688d0 --- /dev/null +++ b/src/display/nr-filter-morphology.h @@ -0,0 +1,42 @@ +#ifndef __NR_FILTER_MORPHOLOGY_H__ +#define __NR_FILTER_MORPHOLOGY_H__ + +/* + * feMorphology 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-primitive.h" +#include "display/nr-filter-slot.h" + +namespace NR { + +class FilterMorphology : public FilterPrimitive { +public: + FilterMorphology(); + static FilterPrimitive *create(); + virtual ~FilterMorphology(); + + virtual int render(FilterSlot &slot, Matrix const &trans); + virtual void area_enlarge(NRRectL &area, Matrix const &trans); +}; + +} /* namespace NR */ + +#endif /* __NR_FILTER_MORPHOLOGY_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 31c3478a2..34a33e2b8 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -24,11 +24,15 @@ #include "display/nr-filter-blend.h" #include "display/nr-filter-composite.h" #include "display/nr-filter-convolve-matrix.h" +#include "display/nr-filter-colormatrix.h" +#include "display/nr-filter-component-transfer.h" #include "display/nr-filter-diffuselighting.h" #include "display/nr-filter-displacement-map.h" +#include "display/nr-filter-flood.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-image.h" #include "display/nr-filter-merge.h" +#include "display/nr-filter-morphology.h" #include "display/nr-filter-offset.h" #include "display/nr-filter-specularlighting.h" #include "display/nr-filter-tile.h" @@ -316,20 +320,19 @@ void Filter::_create_constructor_table() if(created) return; /* 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.*/ + Some of them still have only boilerplate code.*/ _constructor[NR_FILTER_BLEND] = &FilterBlend::create; - _constructor[NR_FILTER_COLORMATRIX] = NULL; - _constructor[NR_FILTER_COMPONENTTRANSFER] = NULL; + _constructor[NR_FILTER_COLORMATRIX] = &FilterColorMatrix::create; + _constructor[NR_FILTER_COMPONENTTRANSFER] = &FilterComponentTransfer::create; _constructor[NR_FILTER_COMPOSITE] = &FilterComposite::create; _constructor[NR_FILTER_CONVOLVEMATRIX] = &FilterConvolveMatrix::create; _constructor[NR_FILTER_DIFFUSELIGHTING] = &FilterDiffuseLighting::create; _constructor[NR_FILTER_DISPLACEMENTMAP] = &FilterDisplacementMap::create; - _constructor[NR_FILTER_FLOOD] = NULL; + _constructor[NR_FILTER_FLOOD] = &FilterFlood::create; _constructor[NR_FILTER_GAUSSIANBLUR] = &FilterGaussian::create; _constructor[NR_FILTER_IMAGE] = &FilterImage::create; _constructor[NR_FILTER_MERGE] = &FilterMerge::create; - _constructor[NR_FILTER_MORPHOLOGY] = NULL; + _constructor[NR_FILTER_MORPHOLOGY] = &FilterMorphology::create; _constructor[NR_FILTER_OFFSET] = &FilterOffset::create; _constructor[NR_FILTER_SPECULARLIGHTING] = &FilterSpecularLighting::create; _constructor[NR_FILTER_TILE] = &FilterTile::create; diff --git a/src/sp-fecolormatrix.cpp b/src/sp-fecolormatrix.cpp index 747ceeb4f..f8378135a 100644 --- a/src/sp-fecolormatrix.cpp +++ b/src/sp-fecolormatrix.cpp @@ -33,6 +33,7 @@ static void sp_feColorMatrix_release(SPObject *object); static void sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *value); static void sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); +static void sp_feColorMatrix_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter); static SPFilterPrimitiveClass *feColorMatrix_parent_class; @@ -61,7 +62,8 @@ static void sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; - + SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; + feColorMatrix_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feColorMatrix_build; @@ -69,6 +71,7 @@ sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) sp_object_class->write = sp_feColorMatrix_write; sp_object_class->set = sp_feColorMatrix_set; sp_object_class->update = sp_feColorMatrix_update; + sp_primitive_class->build_renderer = sp_feColorMatrix_build_renderer; } static void @@ -161,6 +164,19 @@ sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) return repr; } +static void sp_feColorMatrix_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) { + g_assert(primitive != NULL); + g_assert(filter != NULL); + + SPFeColorMatrix *sp_colormatrix = SP_FECOLORMATRIX(primitive); + + int primitive_n = filter->add_primitive(NR::NR_FILTER_COLORMATRIX); + NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n); + NR::FilterColorMatrix *nr_colormatrix = dynamic_cast(nr_primitive); + g_assert(nr_colormatrix != NULL); + + sp_filter_primitive_renderer_common(primitive, nr_primitive); +} /* Local Variables: diff --git a/src/sp-fecolormatrix.h b/src/sp-fecolormatrix.h index 85623c680..6dc0b6966 100644 --- a/src/sp-fecolormatrix.h +++ b/src/sp-fecolormatrix.h @@ -16,6 +16,8 @@ #include "sp-filter.h" #include "sp-fecolormatrix-fns.h" +#include "display/nr-filter.h" +#include "display/nr-filter-colormatrix.h" /* FeColorMatrix base class */ class SPFeColorMatrixClass; diff --git a/src/sp-feflood.cpp b/src/sp-feflood.cpp index 924fb8f64..837ccf4ae 100644 --- a/src/sp-feflood.cpp +++ b/src/sp-feflood.cpp @@ -33,6 +33,7 @@ static void sp_feFlood_release(SPObject *object); static void sp_feFlood_set(SPObject *object, unsigned int key, gchar const *value); static void sp_feFlood_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feFlood_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); +static void sp_feFlood_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter); static SPFilterPrimitiveClass *feFlood_parent_class; @@ -61,7 +62,8 @@ static void sp_feFlood_class_init(SPFeFloodClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; - + SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; + feFlood_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feFlood_build; @@ -69,6 +71,7 @@ sp_feFlood_class_init(SPFeFloodClass *klass) sp_object_class->write = sp_feFlood_write; sp_object_class->set = sp_feFlood_set; sp_object_class->update = sp_feFlood_update; + sp_primitive_class->build_renderer = sp_feFlood_build_renderer; } static void @@ -161,6 +164,20 @@ sp_feFlood_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) return repr; } +static void sp_feFlood_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) { + g_assert(primitive != NULL); + g_assert(filter != NULL); + + SPFeFlood *sp_flood = SP_FEFLOOD(primitive); + + int primitive_n = filter->add_primitive(NR::NR_FILTER_FLOOD); + NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n); + NR::FilterFlood *nr_flood = dynamic_cast(nr_primitive); + g_assert(nr_flood != NULL); + + sp_filter_primitive_renderer_common(primitive, nr_primitive); +} + /* Local Variables: diff --git a/src/sp-feflood.h b/src/sp-feflood.h index 87d674ab7..c0df0d312 100644 --- a/src/sp-feflood.h +++ b/src/sp-feflood.h @@ -16,6 +16,9 @@ #include "sp-filter.h" #include "sp-feflood-fns.h" +#include "display/nr-filter.h" +#include "display/nr-filter-flood.h" + /* FeFlood base class */ class SPFeFloodClass; diff --git a/src/sp-femorphology.cpp b/src/sp-femorphology.cpp index 78b7bbaf4..980d77968 100644 --- a/src/sp-femorphology.cpp +++ b/src/sp-femorphology.cpp @@ -33,6 +33,7 @@ static void sp_feMorphology_release(SPObject *object); static void sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value); static void sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags); static Inkscape::XML::Node *sp_feMorphology_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); +static void sp_feMorphology_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter); static SPFilterPrimitiveClass *feMorphology_parent_class; @@ -61,7 +62,8 @@ static void sp_feMorphology_class_init(SPFeMorphologyClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; - + SPFilterPrimitiveClass *sp_primitive_class = (SPFilterPrimitiveClass *)klass; + feMorphology_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass); sp_object_class->build = sp_feMorphology_build; @@ -69,6 +71,7 @@ sp_feMorphology_class_init(SPFeMorphologyClass *klass) sp_object_class->write = sp_feMorphology_write; sp_object_class->set = sp_feMorphology_set; sp_object_class->update = sp_feMorphology_update; + sp_primitive_class->build_renderer = sp_feMorphology_build_renderer; } static void @@ -161,6 +164,19 @@ sp_feMorphology_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) return repr; } +static void sp_feMorphology_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) { + g_assert(primitive != NULL); + g_assert(filter != NULL); + + SPFeMorphology *sp_morphology = SP_FEMORPHOLOGY(primitive); + + int primitive_n = filter->add_primitive(NR::NR_FILTER_MORPHOLOGY); + NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n); + NR::FilterMorphology *nr_morphology = dynamic_cast(nr_primitive); + g_assert(nr_morphology != NULL); + + sp_filter_primitive_renderer_common(primitive, nr_primitive); +} /* Local Variables: diff --git a/src/sp-femorphology.h b/src/sp-femorphology.h index b3196fe08..11206b2da 100644 --- a/src/sp-femorphology.h +++ b/src/sp-femorphology.h @@ -16,6 +16,10 @@ #include "sp-filter.h" #include "sp-femorphology-fns.h" +#include "display/nr-filter.h" +#include "display/nr-filter-morphology.h" + + /* FeMorphology base class */ class SPFeMorphologyClass;