Bug 1349741 - Part 1. Correct the transform matrix of a context that pass to nsFilterInstance::PaintFilteredFrame. r=mstange
☠☠ backed out by 62ab9e400f3c ☠ ☠
authorcku <cku@mozilla.com>
Thu, 13 Apr 2017 11:10:58 +0800
changeset 352970 f6a3307c3a8d2f462c46cc449bbba9e3cac55df4
parent 352969 7784662797115c9befe0f09bea2013a843740645
child 352971 7995aed69c677ab8ce193e303b1b8c48485fde62
push id89185
push userkwierso@gmail.com
push dateFri, 14 Apr 2017 00:33:57 +0000
treeherdermozilla-inbound@945c45613592 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1349741
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 1349741 - Part 1. Correct the transform matrix of a context that pass to nsFilterInstance::PaintFilteredFrame. r=mstange MozReview-Commit-ID: 9BISQehlSgG
layout/svg/nsFilterInstance.cpp
layout/svg/nsSVGIntegrationUtils.cpp
layout/svg/nsSVGUtils.cpp
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -498,24 +498,18 @@ nsFilterInstance::Render(DrawTarget* aDr
 
   nsIntRect filterRect =
     mPostFilterDirtyRegion.GetBounds().Intersect(OutputFilterSpaceBounds());
   if (filterRect.IsEmpty() || mPaintTransform.IsSingular()) {
     return DrawResult::SUCCESS;
   }
 
   AutoRestoreTransform autoRestoreTransform(aDrawTarget);
-  gfxMatrix filterSpaceToUserSpace = mPaintTransform;
-  DebugOnly<bool> invertible = filterSpaceToUserSpace.Invert();
-  MOZ_ASSERT(invertible);
-  filterSpaceToUserSpace *= nsSVGUtils::GetCSSPxToDevPxMatrix(mTargetFrame);
-
   Matrix newTM =
-    ToMatrix(filterSpaceToUserSpace).PreTranslate(filterRect.x, filterRect.y) *
-    aDrawTarget->GetTransform();
+    aDrawTarget->GetTransform().PreTranslate(filterRect.x, filterRect.y);
   aDrawTarget->SetTransform(newTM);
 
   ComputeNeededBoxes();
 
   DrawResult result = BuildSourceImage();
   if (result != DrawResult::SUCCESS){
     return result;
   }
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -1088,16 +1088,21 @@ nsSVGIntegrationUtils::PaintFilter(const
   /* Paint the child and apply filters */
   RegularFramePaintCallback callback(aParams.builder, aParams.layerManager,
                                      offsets.offsetToUserSpaceInDevPx);
   nsRegion dirtyRegion = aParams.dirtyRect - offsets.offsetToBoundingBox;
   gfxSize scaleFactors = context.CurrentMatrix().ScaleFactors(true);
   gfxMatrix scaleMatrix(scaleFactors.width, 0.0f,
                         0.0f, scaleFactors.height,
                         0.0f, 0.0f);
+  gfxMatrix reverseScaleMatrix = scaleMatrix;
+  DebugOnly<bool> invertible = reverseScaleMatrix.Invert();
+  MOZ_ASSERT(invertible);
+  context.SetMatrix(reverseScaleMatrix * context.CurrentMatrix());
+
   gfxMatrix tm =
     scaleMatrix * nsSVGUtils::GetCSSPxToDevPxMatrix(frame);
   DrawResult result =
     nsFilterInstance::PaintFilteredFrame(frame, context.GetDrawTarget(),
                                          tm, &callback, &dirtyRegion);
 
   if (opacity != 1.0f) {
     context.PopGroupAndBlend();
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -878,22 +878,16 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
                                       aDirtyRect->width, aDirtyRect->height));
       tmpDirtyRegion =
         nsLayoutUtils::RoundGfxRectToAppRect(
           dirtyBounds, aFrame->PresContext()->AppUnitsPerCSSPixel()) -
         aFrame->GetPosition();
       dirtyRegion = &tmpDirtyRegion;
     }
 
-    gfxContextMatrixAutoSaveRestore saver(target);
-    gfxMatrix devPxToCssPxTM = nsSVGUtils::GetCSSPxToDevPxMatrix(aFrame);
-    DebugOnly<bool> invertible = devPxToCssPxTM.Invert();
-    MOZ_ASSERT(invertible);
-    target->SetMatrix(aTransform * devPxToCssPxTM);
-
     SVGPaintCallback paintCallback(aFlags);
     result =
       nsFilterInstance::PaintFilteredFrame(aFrame, target->GetDrawTarget(),
                                            aTransform, &paintCallback,
                                            dirtyRegion);
   } else {
     result = svgFrame->PaintSVG(*target, aTransform, aDirtyRect, aFlags);
   }