Bug 1228280 - Part 6. Single SVG mask optimization;
MozReview-Commit-ID: wFfyVvZUrB
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -438,16 +438,27 @@ GenerateMaskSurface(const nsSVGIntegrati
nsTArray<nsSVGMaskFrame *> svgMaskFrames = aEffectProperties.GetMaskFrames();
MOZ_ASSERT(svgMaskFrames.Length() == svgReset->mMask.mImageCount);
gfxMatrix cssPxToDevPxMatrix =
nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aParams.frame);
gfxContext& ctx = aParams.ctx;
+
+ // There is only one mask. And that mask is a SVG mask.
+ if ((svgMaskFrames.Length() == 1) && svgMaskFrames[0]) {
+ aOutMaskSurface =
+ svgMaskFrames[0]->GetMaskForMaskedFrame(&ctx, aParams.frame,
+ cssPxToDevPxMatrix, aOpacity,
+ &aOutMaskTransform,
+ svgReset->mMask.mLayers[0].mMaskMode);
+ return;
+ }
+
ctx.Save();
ctx.SetMatrix(gfxMatrix());
gfxRect clipExtents = ctx.GetClipExtents();
IntRect maskSurfaceRect = RoundedOut(ToRect(clipExtents));
ctx.Restore();
// Mask composition result on CoreGraphic::A8 surface is not correct
// when mask-mode is not add(source over). Switch to skia when CG backend