summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-02-28 10:09:32 +0000
committertavmjong-free <tavmjong@free.fr>2014-02-28 10:09:32 +0000
commit2b00f3b9bdfa55829ce5521f3de15b83b14b654a (patch)
treedf8d56211500d95f496b7a1d1cc0f8c28441e1b0 /src
parentCopy event with gdk_event_copy instead of assigning to structure by value. (diff)
downloadinkscape-2b00f3b9bdfa55829ce5521f3de15b83b14b654a.tar.gz
inkscape-2b00f3b9bdfa55829ce5521f3de15b83b14b654a.zip
Use viewport when calculating filter region when filterUnits set to "userSpaceOnUse", fixes #229246.
(bzr r13073)
Diffstat (limited to 'src')
-rw-r--r--src/display/nr-filter.cpp23
-rw-r--r--src/sp-filter.cpp28
2 files changed, 43 insertions, 8 deletions
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index 11984ba76..90b233fbc 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -222,14 +222,19 @@ void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item
Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox)
{
Geom::Point minp, maxp;
- double len_x = bbox ? bbox->width() : 0;
- double len_y = bbox ? bbox->height() : 0;
- /* TODO: fetch somehow the object ex and em lengths */
- _region_x.update(12, 6, len_x);
- _region_y.update(12, 6, len_y);
- _region_width.update(12, 6, len_x);
- _region_height.update(12, 6, len_y);
+
if (_filter_units == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) {
+
+ double len_x = bbox ? bbox->width() : 0;
+ double len_y = bbox ? bbox->height() : 0;
+ /* TODO: fetch somehow the object ex and em lengths */
+
+ // Update for em, ex, and % values
+ _region_x.update(12, 6, len_x);
+ _region_y.update(12, 6, len_y);
+ _region_width.update(12, 6, len_x);
+ _region_height.update(12, 6, len_y);
+
if (!bbox) return Geom::OptRect();
if (_region_x.unit == SVGLength::PERCENT) {
@@ -254,7 +259,7 @@ Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox)
maxp[Y] = minp[Y] + _region_height.computed * len_y;
}
} else if (_filter_units == SP_FILTER_UNITS_USERSPACEONUSE) {
- /* TODO: make sure bbox and fe region are in same coordinate system */
+ // Region already set in sp-filter.cpp
minp[X] = _region_x.computed;
maxp[X] = minp[X] + _region_width.computed;
minp[Y] = _region_y.computed;
@@ -262,7 +267,9 @@ Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox)
} else {
g_warning("Error in Inkscape::Filters::Filter::filter_effect_area: unrecognized value of _filter_units");
}
+
Geom::OptRect area(minp, maxp);
+ // std::cout << "Filter::filter_effect_area: area: " << *area << std::endl;
return area;
}
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index c3e7d217e..0e3d2d5ce 100644
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
@@ -28,6 +28,7 @@ using std::pair;
#include "sp-filter.h"
#include "sp-filter-reference.h"
#include "sp-filter-primitive.h"
+#include "sp-item.h"
#include "uri.h"
#include "xml/repr.h"
#include <cstring>
@@ -206,6 +207,33 @@ void SPFilter::update(SPCtx *ctx, guint flags) {
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
+ SPItemCtx *ictx = (SPItemCtx *) ctx;
+
+ // Do here since we know viewport (Bounding box case handled during rendering)
+ // Note: This only works for root viewport since this routine is not called after
+ // setting a new viewport. A true fix requires a strategy like SPItemView or SPMarkerView.
+ if(this->filterUnits == SP_FILTER_UNITS_USERSPACEONUSE) {
+ std::cout << " userSpaceOnUse" << std::endl;
+ if (this->x.unit == SVGLength::PERCENT) {
+ this->x._set = true;
+ this->x.computed = this->x.value * ictx->viewport.width();
+ }
+
+ if (this->y.unit == SVGLength::PERCENT) {
+ this->y._set = true;
+ this->y.computed = this->y.value * ictx->viewport.height();
+ }
+
+ if (this->width.unit == SVGLength::PERCENT) {
+ this->width._set = true;
+ this->width.computed = this->width.value * ictx->viewport.width();
+ }
+
+ if (this->height.unit == SVGLength::PERCENT) {
+ this->height._set = true;
+ this->height.computed = this->height.value * ictx->viewport.height();
+ }
+ }
/* do something to trigger redisplay, updates? */
}