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
--- 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();