Bug 1318266 - Part 1. Paint trivial clip-path onto mask layer. r=mstange
☠☠ backed out by a7b0bf1ba2c1 ☠ ☠
authorcku <cku@mozilla.com>
Fri, 04 Nov 2016 15:33:38 +0800
changeset 450767 55790893cab48a081059bf0b8748694605562be4
parent 450766 595b31738fd03af659c11ba133836061354fa6b1
child 450768 00bb4e2f5a3c3879c6a375348cdb6ec7cdf9d7f5
push id38944
push userbmo:leftysolara@gmail.com
push dateSun, 18 Dec 2016 16:01:15 +0000
reviewersmstange
bugs1318266
milestone53.0a1
Bug 1318266 - Part 1. Paint trivial clip-path onto mask layer. r=mstange 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);