diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2017-11-04 13:29:26 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2017-11-04 13:29:26 +0000 |
| commit | 8f44cbb000a8abc0ada09a3d13f78c33dd510925 (patch) | |
| tree | 5e13f8dfbc0193727e6f9fa85a0ff3e3fa0a6efe /src | |
| parent | Remove need to restart Inkscape when changing tile multiplier. (diff) | |
| download | inkscape-8f44cbb000a8abc0ada09a3d13f78c33dd510925.tar.gz inkscape-8f44cbb000a8abc0ada09a3d13f78c33dd510925.zip | |
Fix FilterUnits::get_matrix_units2pb() for bounding box case.
Fixes scaling in FilterMorphology when bounding box is used.
Update FilterOffset to also use function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/nr-filter-offset.cpp | 22 | ||||
| -rw-r--r-- | src/display/nr-filter-units.cpp | 15 |
2 files changed, 7 insertions, 30 deletions
diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index 93bab7d39..718dc4e2c 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -42,25 +42,11 @@ void FilterOffset::render_cairo(FilterSlot &slot) Geom::Rect vp = filter_primitive_area( slot.get_units() ); slot.set_primitive_area(_output, vp); // Needed for tiling - // Handle bounding box case - double x = dx; - double y = dy; - if( slot.get_units().get_primitive_units() == SP_FILTER_UNITS_OBJECTBOUNDINGBOX ) { - Geom::OptRect bbox = slot.get_units().get_item_bbox(); - if( bbox ) { - x *= (*bbox).width(); - y *= (*bbox).height(); - } - } - - Geom::Affine trans = slot.get_units().get_matrix_user2pb(); - - Geom::Point offset(x, y); - offset *= trans; - offset[X] -= trans[4]; - offset[Y] -= trans[5]; + Geom::Affine p2pb = slot.get_units().get_matrix_primitiveunits2pb(); + double x = dx * p2pb.expansionX(); + double y = dy * p2pb.expansionY(); - cairo_set_source_surface(ct, in, offset[X], offset[Y]); + cairo_set_source_surface(ct, in, x, y); cairo_paint(ct); cairo_destroy(ct); diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp index 369deeb00..e242e3963 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -83,24 +83,15 @@ Geom::Affine FilterUnits::get_matrix_user2pb() const { Geom::Affine FilterUnits::get_matrix_units2pb(SPFilterUnits units) const { if ( item_bbox && (units == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) ) { + Geom::Affine u2pb = get_matrix_user2pb(); - Geom::Point origo(item_bbox->min()); - origo *= u2pb; - Geom::Point i_end(item_bbox->max()[X], item_bbox->min()[Y]); - i_end *= u2pb; - Geom::Point j_end(item_bbox->min()[X], item_bbox->max()[Y]); - j_end *= u2pb; - - double len_i = sqrt((origo[X] - i_end[X]) * (origo[X] - i_end[X]) - + (origo[Y] - i_end[Y]) * (origo[Y] - i_end[Y])); - double len_j = sqrt((origo[X] - j_end[X]) * (origo[X] - j_end[X]) - + (origo[Y] - j_end[Y]) * (origo[Y] - j_end[Y])); /* TODO: make sure that user coordinate system (0,0) is in correct * place in pixblock coordinates */ - Geom::Scale scaling(1.0 / len_i, 1.0 / len_j); + Geom::Scale scaling(item_bbox->width(), item_bbox->height()); u2pb *= scaling; return u2pb; + } else if (units == SP_FILTER_UNITS_USERSPACEONUSE) { return get_matrix_user2pb(); } else { |
