Bug 1325865 - Part 1. Remove double transform. r=longsonr, a=jcristau
authorcku <cku@mozilla.com>
Fri, 13 Jan 2017 17:02:09 +0800
changeset 353707 0935fdad7f1f7fd9cff888b7bcacc0d0d0b756b0
parent 353706 b40c51bcd2086366cf4e69ca94309868f737f015
child 353708 e61d9658f6204021dfe837fd6870e6666290c1d7
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr, jcristau
bugs1325865
milestone52.0a2
Bug 1325865 - Part 1. Remove double transform. r=longsonr, a=jcristau For an SVG container element(such as g/svg etc) used in mask, we apply transform of it twice: 1. The first time is in nsSVGMaskFrame::GetMaskForMaskedFrame. We apply transform by eAllTransforms(= eUserSpaceToParent + eChildToUserSpace) 2. The second time is in nsSVGDisplayContainerFrame::PaintSVG. We apply transform by eChildToUserSpace So, totally we apply 1 * eUserSpaceToParent + 2 * eChildToUserSpace. This patch is trying to remove this one extra eChildToUserSpace. MozReview-Commit-ID: 2pQCsrCIPNA
layout/svg/nsSVGMaskFrame.cpp
layout/svg/nsSVGPathGeometryFrame.cpp
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -259,17 +259,17 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gf
     // The CTM of each frame referencing us can be different
     nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
     if (SVGFrame) {
       SVGFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
     }
     gfxMatrix m = mMatrixForChildren;
     if (kid->GetContent()->IsSVGElement()) {
       m = static_cast<nsSVGElement*>(kid->GetContent())->
-            PrependLocalTransformsTo(m);
+            PrependLocalTransformsTo(m, eUserSpaceToParent);
     }
     DrawResult result = nsSVGUtils::PaintFrameWithEffects(kid, *tmpCtx, m);
     if (result != DrawResult::SUCCESS) {
       return nullptr;
     }
   }
 
   RefPtr<SourceSurface> maskSnapshot = maskDT->Snapshot();
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -277,19 +277,26 @@ nsSVGPathGeometryFrame::BuildDisplayList
 DrawResult
 nsSVGPathGeometryFrame::PaintSVG(gfxContext& aContext,
                                  const gfxMatrix& aTransform,
                                  const nsIntRect* aDirtyRect)
 {
   if (!StyleVisibility()->IsVisible())
     return DrawResult::SUCCESS;
 
+  gfxMatrix childToUserSpace = aTransform;
+  if (GetContent()->IsSVGElement()) {
+    childToUserSpace = static_cast<const nsSVGElement*>(GetContent())->
+                         PrependLocalTransformsTo(childToUserSpace,
+                                                  eChildToUserSpace);
+  }
+
   // Matrix to the geometry's user space:
   gfxMatrix newMatrix =
-    aContext.CurrentMatrix().PreMultiply(aTransform).NudgeToIntegers();
+    aContext.CurrentMatrix().PreMultiply(childToUserSpace).NudgeToIntegers();
   if (newMatrix.IsSingular()) {
     return DrawResult::BAD_ARGS;
   }
 
   uint32_t paintOrder = StyleSVG()->mPaintOrder;
   if (paintOrder == NS_STYLE_PAINT_ORDER_NORMAL) {
     Render(&aContext, eRenderFill | eRenderStroke, newMatrix);
     PaintMarkers(aContext, aTransform);