From f3e28e14b8c9e58bd65893d7b507e04e33679b80 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Thu, 15 Apr 2010 21:14:51 +0200 Subject: [PATCH] filterUnits and primitiveUnits are now actually read/set, percentages for primitiveUnits are still problematic though --- src/display/nr-filter.cpp | 8 ++++++++ src/sp-filter.cpp | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index d0e0ec11e..3b19ff69b 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -223,6 +223,14 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) return 0; } +void Filter::set_filter_units(SPFilterUnits unit) { + _filter_units = unit; +} + +void Filter::set_primitive_units(SPFilterUnits unit) { + _primitive_units = unit; +} + void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const { for (int i = 0 ; i < _primitive_count ; i++) { if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm); diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 7197c1ec9..4cbafe50c 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -108,7 +108,7 @@ sp_filter_init(SPFilter *filter) filter->height = 0; filter->filterUnits = SP_FILTER_UNITS_OBJECTBOUNDINGBOX; - filter->primitiveUnits = SP_FILTER_UNITS_OBJECTBOUNDINGBOX; + filter->primitiveUnits = SP_FILTER_UNITS_USERSPACEONUSE; filter->filterUnits_set = FALSE; filter->primitiveUnits_set = FALSE; @@ -204,14 +204,14 @@ sp_filter_set(SPObject *object, unsigned int key, gchar const *value) break; case SP_ATTR_PRIMITIVEUNITS: if (value) { - if (!strcmp(value, "userSpaceOnUse")) { - filter->primitiveUnits = SP_FILTER_UNITS_USERSPACEONUSE; - } else { + if (!strcmp(value, "objectBoundingBox")) { filter->primitiveUnits = SP_FILTER_UNITS_OBJECTBOUNDINGBOX; + } else { + filter->primitiveUnits = SP_FILTER_UNITS_USERSPACEONUSE; } filter->primitiveUnits_set = TRUE; } else { - filter->primitiveUnits = SP_FILTER_UNITS_OBJECTBOUNDINGBOX; + filter->primitiveUnits = SP_FILTER_UNITS_USERSPACEONUSE; filter->primitiveUnits_set = FALSE; } object->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -322,11 +322,11 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N if ((flags & SP_OBJECT_WRITE_ALL) || filter->primitiveUnits_set) { switch (filter->primitiveUnits) { - case SP_FILTER_UNITS_USERSPACEONUSE: - repr->setAttribute("primitiveUnits", "userSpaceOnUse"); + case SP_FILTER_UNITS_OBJECTBOUNDINGBOX: + repr->setAttribute("primitiveUnits", "objectBoundingBox"); break; default: - repr->setAttribute("primitiveUnits", "objectBoundingBox"); + repr->setAttribute("primitiveUnits", "userSpaceOnUse"); break; } } @@ -446,6 +446,8 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr sp_filter->_renderer = nr_filter; + nr_filter->set_filter_units(sp_filter->filterUnits); + nr_filter->set_primitive_units(sp_filter->primitiveUnits); nr_filter->set_x(sp_filter->x); nr_filter->set_y(sp_filter->y); nr_filter->set_width(sp_filter->width); -- 2.30.2