diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-03-01 20:11:19 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-03-01 20:11:19 +0000 |
| commit | 12769133a57d677b2d7b5d08f2331b7613a7dd66 (patch) | |
| tree | de359824a5fac39f7d749773e9f0c8f75eea9d4c /src | |
| parent | Import layers update, spelling and modification time for files in tar (diff) | |
| download | inkscape-12769133a57d677b2d7b5d08f2331b7613a7dd66.tar.gz inkscape-12769133a57d677b2d7b5d08f2331b7613a7dd66.zip | |
Hack for when blur or offset are expressed in terms of object bounding box.
A correct fix requires restructuring the way filter primitives are handled.
(bzr r13086)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/nr-filter-gaussian.cpp | 21 | ||||
| -rw-r--r-- | src/display/nr-filter-offset.cpp | 16 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index b96e24cbc..24960af78 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -568,12 +568,21 @@ void FilterGaussian::render_cairo(FilterSlot &slot) return; } - Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); + // Handle bounding box case. + double dx = _deviation_x; + double dy = _deviation_y; + if( slot.get_units().get_primitive_units() == SP_FILTER_UNITS_OBJECTBOUNDINGBOX ) { + Geom::OptRect const bbox = slot.get_units().get_item_bbox(); + if( bbox ) { + dx *= (*bbox).width(); + dy *= (*bbox).height(); + } + } - int w_orig = ink_cairo_surface_get_width(in); - int h_orig = ink_cairo_surface_get_height(in); - double deviation_x_orig = _deviation_x * trans.expansionX(); - double deviation_y_orig = _deviation_y * trans.expansionY(); + Geom::Affine trans = slot.get_units().get_matrix_user2pb(); + + double deviation_x_orig = dx * trans.expansionX(); + double deviation_y_orig = dy * trans.expansionY(); cairo_format_t fmt = cairo_image_surface_get_format(in); int bytes_per_pixel = 0; switch (fmt) { @@ -595,6 +604,8 @@ void FilterGaussian::render_cairo(FilterSlot &slot) int x_step = 1 << _effect_subsample_step_log2(deviation_x_orig, quality); int y_step = 1 << _effect_subsample_step_log2(deviation_y_orig, quality); bool resampling = x_step > 1 || y_step > 1; + int w_orig = ink_cairo_surface_get_width(in); + int h_orig = ink_cairo_surface_get_height(in); int w_downsampled = resampling ? static_cast<int>(ceil(static_cast<double>(w_orig)/x_step))+1 : w_orig; int h_downsampled = resampling ? static_cast<int>(ceil(static_cast<double>(h_orig)/y_step))+1 : h_orig; double deviation_x = deviation_x_orig / x_step; diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index 01d6ffe56..af1081abe 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -40,8 +40,20 @@ void FilterOffset::render_cairo(FilterSlot &slot) cairo_t *ct = cairo_create(out); - Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); - Geom::Point offset(dx, dy); + // 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]; |
