From 8c4d3b68e4a5727b2205ec136d6fb5f50289d1e9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 22 Dec 2012 17:43:07 +0100 Subject: Add support for color-interpolation-filters = linearRGB. (bzr r11972) --- src/sp-filter.cpp | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/sp-filter.cpp') diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index a20856f53..c7dce3850 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -130,11 +130,8 @@ sp_filter_init(SPFilter *filter) static void sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) filter_parent_class)->build) { - ((SPObjectClass *) filter_parent_class)->build(object, document, repr); - } - //Read values of key attributes from XML nodes into object. + object->readAttr( "style" ); // struct not derived from SPItem, we need to do this ourselves. object->readAttr( "filterUnits" ); object->readAttr( "primitiveUnits" ); object->readAttr( "x" ); @@ -144,6 +141,10 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep object->readAttr( "filterRes" ); object->readAttr( "xlink:href" ); + if (((SPObjectClass *) filter_parent_class)->build) { + ((SPObjectClass *) filter_parent_class)->build(object, document, repr); + } + //is this necessary? document->addResource("filter", object); } @@ -366,25 +367,6 @@ 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). - // 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"); - - // Actually, the above line is not correct as the attribute is only allowed on filter - // primitives and not objects. However, it is allowed as a property in a style - // attribute. Note, this property must also be set in sp-filter-chemistry, filter_new() as the - // code here is not necessarily called when a new filter is created. 29 Aug 2011 Tav. - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_set_property(css, "color-interpolation-filters", "sRGB"); - sp_repr_css_change(repr, css, "style"); - sp_repr_css_attr_unref(css); - if (((SPObjectClass *) filter_parent_class)->write) { ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags); } -- cgit v1.2.3 From 1615436543169f305d1df4d830ed8f5ec5dc75ed Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 19:33:04 +0000 Subject: More GObject boilerplate reduction (bzr r12065) --- src/sp-filter.cpp | 58 ++++++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) (limited to 'src/sp-filter.cpp') diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index c7dce3850..e3a44d8bb 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -38,10 +38,6 @@ using std::pair; #include "display/nr-filter.h" /* Filter base class */ - -static void sp_filter_class_init(SPFilterClass *klass); -static void sp_filter_init(SPFilter *filter); - static void sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_filter_release(SPObject *object); static void sp_filter_set(SPObject *object, unsigned int key, gchar const *value); @@ -55,37 +51,13 @@ static Inkscape::XML::Node *sp_filter_write(SPObject *object, Inkscape::XML::Doc static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); -static SPObjectClass *filter_parent_class; - -GType -sp_filter_get_type() -{ - static GType filter_type = 0; - - if (!filter_type) { - GTypeInfo filter_info = { - sizeof(SPFilterClass), - NULL, NULL, - (GClassInitFunc) sp_filter_class_init, - NULL, NULL, - sizeof(SPFilter), - 16, - (GInstanceInitFunc) sp_filter_init, - NULL, /* value_table */ - }; - filter_type = g_type_register_static(SP_TYPE_OBJECT, "SPFilter", &filter_info, (GTypeFlags)0); - } - return filter_type; -} +G_DEFINE_TYPE(SPFilter, sp_filter, SP_TYPE_OBJECT); static void sp_filter_class_init(SPFilterClass *klass) { - SPObjectClass *sp_object_class = (SPObjectClass *)klass; - filter_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); - sp_object_class->build = sp_filter_build; sp_object_class->release = sp_filter_release; sp_object_class->write = sp_filter_write; @@ -141,8 +113,8 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep object->readAttr( "filterRes" ); object->readAttr( "xlink:href" ); - if (((SPObjectClass *) filter_parent_class)->build) { - ((SPObjectClass *) filter_parent_class)->build(object, document, repr); + if (((SPObjectClass *) sp_filter_parent_class)->build) { + ((SPObjectClass *) sp_filter_parent_class)->build(object, document, repr); } //is this necessary? @@ -174,8 +146,8 @@ static void sp_filter_release(SPObject *object) filter->modified_connection.~connection(); delete filter->_image_name; - if (((SPObjectClass *) filter_parent_class)->release) - ((SPObjectClass *) filter_parent_class)->release(object); + if (((SPObjectClass *) sp_filter_parent_class)->release) + ((SPObjectClass *) sp_filter_parent_class)->release(object); } /** @@ -249,8 +221,8 @@ sp_filter_set(SPObject *object, unsigned int key, gchar const *value) break; default: // See if any parents need this value. - if (((SPObjectClass *) filter_parent_class)->set) { - ((SPObjectClass *) filter_parent_class)->set(object, key, value); + if (((SPObjectClass *) sp_filter_parent_class)->set) { + ((SPObjectClass *) sp_filter_parent_class)->set(object, key, value); } break; } @@ -271,8 +243,8 @@ sp_filter_update(SPObject *object, SPCtx *ctx, guint flags) } - if (((SPObjectClass *) filter_parent_class)->update) { - ((SPObjectClass *) filter_parent_class)->update(object, ctx, flags); + if (((SPObjectClass *) sp_filter_parent_class)->update) { + ((SPObjectClass *) sp_filter_parent_class)->update(object, ctx, flags); } } @@ -367,8 +339,8 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N g_free(uri_string); } - if (((SPObjectClass *) filter_parent_class)->write) { - ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags); + if (((SPObjectClass *) sp_filter_parent_class)->write) { + ((SPObjectClass *) sp_filter_parent_class)->write(object, doc, repr, flags); } return repr; @@ -407,8 +379,8 @@ sp_filter_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XM { //SPFilter *f = SP_FILTER(object); - if (((SPObjectClass *) filter_parent_class)->child_added) - (* ((SPObjectClass *) filter_parent_class)->child_added)(object, child, ref); + if (((SPObjectClass *) sp_filter_parent_class)->child_added) + (* ((SPObjectClass *) sp_filter_parent_class)->child_added)(object, child, ref); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -421,8 +393,8 @@ sp_filter_remove_child(SPObject *object, Inkscape::XML::Node *child) { // SPFilter *f = SP_FILTER(object); - if (((SPObjectClass *) filter_parent_class)->remove_child) - (* ((SPObjectClass *) filter_parent_class)->remove_child)(object, child); + if (((SPObjectClass *) sp_filter_parent_class)->remove_child) + (* ((SPObjectClass *) sp_filter_parent_class)->remove_child)(object, child); object->requestModified(SP_OBJECT_MODIFIED_FLAG); } -- cgit v1.2.3 From c8a761256b40300761c7ff6a0d642ac75b6f541a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 11 Feb 2013 23:34:59 +0000 Subject: A couple of forward declarations (bzr r12119) --- src/sp-filter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-filter.cpp') diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index e3a44d8bb..bce86c465 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -22,6 +22,7 @@ using std::map; using std::pair; +#include #include "attributes.h" #include "document.h" #include "sp-filter.h" -- cgit v1.2.3