Bug 1348430 - Part 3. Correct mTargetBBoxInFilterSpace.
I introduced ComputeTargetBBoxInFilterSpace[1] function in
bug 1287492.
Two reasons that I think we should not clip filter boundary by viewport
in that function:
1. The patch in
bug 1336480 can also fix
bug 1287492 and is more correct.
2. That restriction cause wrong rendering result
In this bug, reporter apply filter onto a path object in pattern element.
Before the clipping applied in [1], the boundary of filter effects region is
(x=-1, y=-1, width=10, height=10) in CSS units
After clipping by svg viewport, the boundary turns out to be
(x=0, y=0, width=9, height=9) in CSS units
which is smaller then we need for filter painting. So we should stop clip the
boundary by svg viewport. (Please refer to filter-in-pattern-02.svg in the next
patch).
[1] https://hg.mozilla.org/mozilla-central/file/dbabc189256e/layout/svg/nsFilterInstance.cpp#l235
MozReview-Commit-ID: 2d14rnyWPJs
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -231,41 +231,19 @@ nsFilterInstance::nsFilterInstance(nsIFr
mInitialized = true;
}
bool
nsFilterInstance::ComputeTargetBBoxInFilterSpace()
{
gfxRect targetBBoxInFilterSpace = UserSpaceToFilterSpace(mTargetBBox);
targetBBoxInFilterSpace.RoundOut();
- if (!gfxUtils::GfxRectToIntRect(targetBBoxInFilterSpace,
- &mTargetBBoxInFilterSpace)) {
- // The target's bbox is way too big if there is float->int overflow.
- return false;
- }
- if (!mTargetFrame || !mTargetFrame->IsFrameOfType(nsIFrame::eSVG)) {
- return true;
- }
-
- // SVG graphic elements will always be clipped by svg::svg element, so we
- // should clip mTargetBBoxInFilterSpace by the bounded parent SVG frame
- // anyway to shrink the size of surface that we are going to create later in
- // BuildSourcePaint and BuildSourceImage.
- MOZ_ASSERT(mTargetFrame->IsFrameOfType(nsIFrame::eSVG));
- nsIFrame* svgFrame = nsSVGUtils::GetNearestSVGViewport(mTargetFrame);
- if (svgFrame) {
- nscoord A2D = svgFrame->PresContext()->AppUnitsPerCSSPixel();
- nsIntRect bounds =
- svgFrame->GetVisualOverflowRect().ToOutsidePixels(A2D);
-
- mTargetBBoxInFilterSpace = mTargetBBoxInFilterSpace.Intersect(bounds);
- }
-
- return true;
+ return gfxUtils::GfxRectToIntRect(targetBBoxInFilterSpace,
+ &mTargetBBoxInFilterSpace);
}
bool
nsFilterInstance::ComputeUserSpaceToFilterSpaceScale()
{
if (mTargetFrame) {
mUserSpaceToFilterSpaceScale = mPaintTransform.ScaleFactors(true);
if (mUserSpaceToFilterSpaceScale.width <= 0.0f ||