X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsp-filter.cpp;h=7197c1ec93539c53810f0d0db80ac58703a24882;hb=530f7fc7cfa4351ec33163abd795460bbc351609;hp=2a971ccc673745aac90c9edbc6bc3d282a2504a3;hpb=d9a7c806ee7f408ddb61ff4f233c9d96111ee2b5;p=inkscape.git diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 2a971ccc6..7197c1ec9 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -284,9 +284,29 @@ static Inkscape::XML::Node * sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { SPFilter *filter = SP_FILTER(object); - - if (!repr) { - repr = SP_OBJECT_REPR(object)->duplicate(doc); + SPObject *child; + Inkscape::XML::Node *crepr; + + /* Original from sp-item-group.cpp */ + if (flags & SP_OBJECT_WRITE_BUILD) { + GSList *l; + if (!repr) { + repr = doc->createElement("svg:filter"); + } + l = NULL; + for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { + crepr = child->updateRepr(doc, NULL, flags); + if (crepr) l = g_slist_prepend (l, crepr); + } + while (l) { + repr->addChild((Inkscape::XML::Node *) l->data, NULL); + Inkscape::GC::release((Inkscape::XML::Node *) l->data); + l = g_slist_remove (l, l->data); + } + } else { + for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + child->updateRepr(flags); + } } if ((flags & SP_OBJECT_WRITE_ALL) || filter->filterUnits_set) { @@ -349,6 +369,15 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N g_free(uri_string); } + // TODO: This is evil, correctly implement support for color-interpolation-filters!!! + // The color-interpolation-filters attribute is initially set to linearRGB according to the SVG standard. + // However, Inkscape completely ignores it and implicitly assumes that it is sRGB (like color-interpolation-filters). + // This results in a discrepancy between Inkscape and other renderers in how they render filters. + // To mitigate this problem I've (Jasper van de Gronde,th.v.d.gronde@hccnet.nl) added this to ensure that at least + // any filters written by Inkscape will henceforth be rendered the same in other renderers. + // In the future Inkscape should have proper support for the color-interpolation properties and this should be changed. + repr->setAttribute("color-interpolation-filters", "sRGB"); + if (((SPObjectClass *) filter_parent_class)->write) { ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags); } @@ -479,6 +508,42 @@ int sp_filter_set_image_name(SPFilter *filter, gchar const *name) { return value; } +gchar const *sp_filter_name_for_image(SPFilter const *filter, int const image) { + switch (image) { + case Inkscape::Filters::NR_FILTER_SOURCEGRAPHIC: + return "SourceGraphic"; + break; + case Inkscape::Filters::NR_FILTER_SOURCEALPHA: + return "SourceAlpha"; + break; + case Inkscape::Filters::NR_FILTER_BACKGROUNDIMAGE: + return "BackgroundImage"; + break; + case Inkscape::Filters::NR_FILTER_BACKGROUNDALPHA: + return "BackgroundAlpha"; + break; + case Inkscape::Filters::NR_FILTER_STROKEPAINT: + return "StrokePaint"; + break; + case Inkscape::Filters::NR_FILTER_FILLPAINT: + return "FillPaint"; + break; + case Inkscape::Filters::NR_FILTER_SLOT_NOT_SET: + case Inkscape::Filters::NR_FILTER_UNNAMED_SLOT: + return 0; + break; + default: + for (map::const_iterator i + = filter->_image_name->begin() ; + i != filter->_image_name->end() ; i++) { + if (i->second == image) { + return i->first; + } + } + } + return 0; +} + Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { g_assert(filter != NULL); int largest = 0;