Bug 1348430 - Part 3. Correct mTargetBBoxInFilterSpace. r=mstange
authorcku <cku@mozilla.com>
Wed, 22 Mar 2017 21:29:14 +0800
changeset 349023 8db840662319831281ecbde9e1b216cc5a2fba3b
parent 349022 6084537f2ecd1431e8f5f0f3b74b6cdc29f5274f
child 349024 5f8ed78861489be8477b1689afb361c3750ff263
push id88381
push usercbook@mozilla.com
push dateThu, 23 Mar 2017 12:57:41 +0000
treeherdermozilla-inbound@c1de15925579 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1348430, 1287492, 1336480
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1348430 - Part 3. Correct mTargetBBoxInFilterSpace. r=mstange 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
layout/svg/nsFilterInstance.cpp
--- 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 ||