Bug 1318266 - Part 1. Paint trivial clip-path onto mask layer. draft
authorcku <cku@mozilla.com>
Fri, 04 Nov 2016 15:33:38 +0800
changeset 450595 906cf3bedd84b84d7708a148f6ac0bd3b5336e05
parent 450591 34a1ab064cb5b868fa75cb74d052e978eb34d6c1
child 450596 505648926bf44bde863bbf3703f514ca0b63842e
child 450597 7f5b268dad5abce30e6147164ae452f69c4c8a58
push id38913
push userbmo:cku@mozilla.com
push dateSat, 17 Dec 2016 05:11:10 +0000
bugs1318266
milestone53.0a1
Bug 1318266 - Part 1. Paint trivial clip-path onto mask layer. MozReview-Commit-ID: G2ghy7qGf5N
layout/painting/nsDisplayList.cpp
layout/svg/nsSVGClipPathFrame.cpp
layout/svg/nsSVGIntegrationUtils.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7348,23 +7348,22 @@ bool nsDisplayMask::ShouldPaintOnMaskLay
 {
   if (!aManager->IsCompositingCheap()) {
     return false;
   }
 
   nsSVGUtils::MaskUsage maskUsage;
   nsSVGUtils::DetermineMaskUsage(mFrame, mHandleOpacity, maskUsage);
 
-  if (!maskUsage.shouldGenerateMaskLayer &&
+  if (!maskUsage.shouldGenerateMaskLayer && !maskUsage.shouldApplyClipPath &&
       !maskUsage.shouldGenerateClipMaskLayer) {
     return false;
   }
 
-  if (maskUsage.opacity != 1.0 || maskUsage.shouldApplyClipPath ||
-      maskUsage.shouldApplyBasicShape) {
+  if (maskUsage.opacity != 1.0 || maskUsage.shouldApplyBasicShape) {
     return false;
   }
 
   if (!nsSVGIntegrationUtils::IsMaskResourceReady(mFrame)) {
     return false;
   }
 
   if (gfxPrefs::DrawMaskLayer()) {
--- a/layout/svg/nsSVGClipPathFrame.cpp
+++ b/layout/svg/nsSVGClipPathFrame.cpp
@@ -267,18 +267,16 @@ nsSVGClipPathFrame::PaintFrameIntoMask(n
 mozilla::Pair<DrawResult, RefPtr<SourceSurface>>
 nsSVGClipPathFrame::GetClipMask(gfxContext& aReferenceContext,
                                 nsIFrame* aClippedFrame,
                                 const gfxMatrix& aMatrix,
                                 Matrix* aMaskTransform,
                                 SourceSurface* aExtraMask,
                                 const Matrix& aExtraMasksTransform)
 {
-  MOZ_ASSERT(!IsTrivial(), "Caller needs to use ApplyClipPath");
-
   IntPoint offset;
   RefPtr<DrawTarget> maskDT = CreateClipMask(aReferenceContext, offset);
   if (!maskDT) {
     return MakePair(DrawResult::SUCCESS, RefPtr<SourceSurface>());
   }
 
   RefPtr<gfxContext> maskContext = gfxContext::CreateOrNull(maskDT);
   if (!maskContext) {
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -751,16 +751,17 @@ nsSVGIntegrationUtils::IsMaskResourceRea
 
 DrawResult
 nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
 {
   nsSVGUtils::MaskUsage maskUsage;
   nsSVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity,
                                  maskUsage);
   MOZ_ASSERT(maskUsage.shouldGenerateMaskLayer ||
+             maskUsage.shouldApplyClipPath ||
              maskUsage.shouldGenerateClipMaskLayer);
 
   nsIFrame* frame = aParams.frame;
   if (!ValidateSVGFrame(frame)) {
     return DrawResult::SUCCESS;
   }
 
   if (maskUsage.opacity == 0.0f) {
@@ -792,17 +793,17 @@ nsSVGIntegrationUtils::PaintMask(const P
                               firstFrame->StyleContext(), maskFrames,
                               ctx.CurrentMatrix(), offsetToUserSpace);
     if (result != DrawResult::SUCCESS) {
       return result;
     }
   }
 
   // Paint clip-path onto ctx.
-  if (maskUsage.shouldGenerateClipMaskLayer) {
+  if (maskUsage.shouldGenerateClipMaskLayer || maskUsage.shouldApplyClipPath) {
     matSR.Restore();
     matSR.SetContext(&ctx);
 
     SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
                        offsetToUserSpace, false);
     Matrix clipMaskTransform;
     gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame);