Index: src/sp-item.cpp =================================================================== --- src/sp-item.cpp (Revision 22378) +++ src/sp-item.cpp (Arbeitskopie) @@ -803,39 +803,57 @@ if (SP_FILTER(filter)->height._set) h = SP_FILTER(filter)->height.computed; - double dx0 = 0; - double dx1 = 0; - double dy0 = 0; - double dy1 = 0; - if (filter_is_single_gaussian_blur(SP_FILTER(filter))) { - // if this is a single blur, use 2.4*radius - // which may be smaller than the default area; - // see set_filter_area for why it's 2.4 - double r = get_single_gaussian_blur_radius (SP_FILTER(filter)); - dx0 = -2.4 * r; - dx1 = 2.4 * r; - dy0 = -2.4 * r; - dy1 = 2.4 * r; - } else { - // otherwise, calculate expansion from relative to absolute units: - dx0 = x * (temp_bbox.x1 - temp_bbox.x0); - dx1 = (w + x - 1) * (temp_bbox.x1 - temp_bbox.x0); - dy0 = y * (temp_bbox.y1 - temp_bbox.y0); - dy1 = (h + y - 1) * (temp_bbox.y1 - temp_bbox.y0); - } + if(SP_FILTER(filter)->filterUnits_set) { + if(SP_FILTER(filter)->filterUnits == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) { + double dx0 = 0; + double dx1 = 0; + double dy0 = 0; + double dy1 = 0; + if (filter_is_single_gaussian_blur(SP_FILTER(filter))) { + // if this is a single blur, use 2.4*radius + // which may be smaller than the default area; + // see set_filter_area for why it's 2.4 + double r = get_single_gaussian_blur_radius (SP_FILTER(filter)); + dx0 = -2.4 * r; + dx1 = 2.4 * r; + dy0 = -2.4 * r; + dy1 = 2.4 * r; + } else { + // otherwise, calculate expansion from relative to absolute units: + dx0 = x * (temp_bbox.x1 - temp_bbox.x0); + dx1 = (w + x - 1) * (temp_bbox.x1 - temp_bbox.x0); + dy0 = y * (temp_bbox.y1 - temp_bbox.y0); + dy1 = (h + y - 1) * (temp_bbox.y1 - temp_bbox.y0); + } - // transform the expansions by the item's transform: - Geom::Matrix i2d(sp_item_i2d_affine (item)); - dx0 *= i2d.expansionX(); - dx1 *= i2d.expansionX(); - dy0 *= i2d.expansionY(); - dy1 *= i2d.expansionY(); + // transform the expansions by the item's transform: + Geom::Matrix i2d(sp_item_i2d_affine (item)); + dx0 *= i2d.expansionX(); + dx1 *= i2d.expansionX(); + dy0 *= i2d.expansionY(); + dy1 *= i2d.expansionY(); - // expand the bbox - temp_bbox.x0 += dx0; - temp_bbox.x1 += dx1; - temp_bbox.y0 += dy0; - temp_bbox.y1 += dy1; + // expand the bbox + temp_bbox.x0 += dx0; + temp_bbox.x1 += dx1; + temp_bbox.y0 += dy0; + temp_bbox.y1 += dy1; + } else if(SP_FILTER(filter)->filterUnits == SP_FILTER_UNITS_USERSPACEONUSE) { + double blur_margin = 0.0; + if (filter_is_single_gaussian_blur(SP_FILTER(filter))) { + blur_margin = 2.4 * get_single_gaussian_blur_radius (SP_FILTER(filter)); + } + Geom::Rect filter_rect(Geom::Point(x - blur_margin, y - blur_margin), Geom::Point(x + w + blur_margin, y + h + blur_margin)); + filter_rect = filter_rect * transform; + + temp_bbox.x0 = filter_rect.min()[Geom::X]; + temp_bbox.y0 = filter_rect.min()[Geom::Y]; + temp_bbox.x1 = filter_rect.max()[Geom::X]; + temp_bbox.y1 = filter_rect.max()[Geom::Y]; + } else { + g_warning("Error in Inkscape::Filters::FilterUnits::get_matrix_user2units: unrecognized unit type (%d)", SP_FILTER(filter)->filterUnits); + } + } } } if (item->clip_ref->getObject()) {