Bug 1325865 - Part 1. Remove double transform. draft
authorcku <cku@mozilla.com>
Fri, 13 Jan 2017 17:02:09 +0800
changeset 460991 97671036ade528573c4dc063a963c3ff325d760e
parent 460990 8a43d22ed38e343a63edec572ac9a299e50712df
child 460992 41286b14ae918e21c9387d5bec07cccc0c2b56d0
push id41546
push userbmo:cku@mozilla.com
push dateSat, 14 Jan 2017 17:46:11 +0000
bugs1325865
milestone53.0a1
Bug 1325865 - Part 1. Remove double transform. 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/SVGGeometryFrame.cpp
layout/svg/nsSVGMaskFrame.cpp
--- a/layout/svg/SVGGeometryFrame.cpp
+++ b/layout/svg/SVGGeometryFrame.cpp
@@ -279,19 +279,26 @@ SVGGeometryFrame::BuildDisplayList(nsDis
 DrawResult
 SVGGeometryFrame::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);
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -257,17 +257,17 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(Ma
     // 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);
     }
     result = nsSVGUtils::PaintFrameWithEffects(kid, *tmpCtx, m);
     if (result != DrawResult::SUCCESS) {
       return MakePair(result, RefPtr<SourceSurface>());
     }
   }
 
   RefPtr<SourceSurface> maskSnapshot = maskDT->Snapshot();