Backed out changeset b3ad53915c5e (bug 1323912)
authorIris Hsiao <ihsiao@mozilla.com>
Wed, 04 Jan 2017 21:47:01 -0500
changeset 456654 ccfc8fca30309958be5cf0fa8125b965a8b481de
parent 456653 e7eebf3aeb34b51c958a2cbcdb187d5ddd8ad484
child 456655 4c1ac1c54bdda6d945cf34f18abdc9f6ca484209
push id40575
push userjwwang@mozilla.com
push dateFri, 06 Jan 2017 02:27:46 +0000
bugs1323912
milestone53.0a1
backs outb3ad53915c5ea058c352b992457ca1b1edfd75b0
Backed out changeset b3ad53915c5e (bug 1323912)
layout/painting/nsDisplayList.cpp
layout/svg/nsSVGIntegrationUtils.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7346,19 +7346,21 @@ bool nsDisplayMask::ShouldPaintOnMaskLay
 {
   if (!aManager->IsCompositingCheap()) {
     return false;
   }
 
   nsSVGUtils::MaskUsage maskUsage;
   nsSVGUtils::DetermineMaskUsage(mFrame, mHandleOpacity, maskUsage);
 
+  // XXX Bug 1323912. nsSVGIntegrationUtils::PaintMask can not handle opacity
+  // correctly. Turn it off before bug fixed.
   // XXX Temporary disable paint clip-path onto mask before figure out
   // performance regression(bug 1325550).
-  if (maskUsage.shouldApplyClipPath) {
+  if (maskUsage.opacity != 1.0 || maskUsage.shouldApplyClipPath) {
     return false;
   }
 
   if (!nsSVGIntegrationUtils::IsMaskResourceReady(mFrame)) {
     return false;
   }
 
   if (gfxPrefs::DrawMaskLayer()) {
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -720,47 +720,32 @@ nsSVGIntegrationUtils::IsMaskResourceRea
       return false;
     }
   }
 
   // Either all mask resources are ready, or no mask resource is needed.
   return true;
 }
 
-class AutoPopGroup
-{
-public:
-  AutoPopGroup() : mContext(nullptr) { }
-
-  ~AutoPopGroup() {
-    if (mContext) {
-      mContext->PopGroupAndBlend();
-    }
-  }
-
-  void SetContext(gfxContext* aContext) {
-    mContext = aContext;
-  }
-
-private:
-  gfxContext* mContext;
-};
-
 DrawResult
 nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
 {
   nsSVGUtils::MaskUsage maskUsage;
   nsSVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity,
                                  maskUsage);
 
   nsIFrame* frame = aParams.frame;
   if (!ValidateSVGFrame(frame)) {
     return DrawResult::SUCCESS;
   }
 
+  // XXX Bug 1323912.
+  MOZ_ASSERT(maskUsage.opacity == 1.0,
+             "nsSVGIntegrationUtils::PaintMask can not handle opacity now.");
+
   gfxContext& ctx = aParams.ctx;
   nsIFrame* firstFrame =
     nsLayoutUtils::FirstContinuationOrIBSplitSibling(frame);
   nsSVGEffects::EffectProperties effectProperties =
     nsSVGEffects::GetEffectProperties(firstFrame);
 
   DrawResult result = DrawResult::SUCCESS;
   RefPtr<DrawTarget> maskTarget = ctx.GetDrawTarget();
@@ -772,25 +757,16 @@ nsSVGIntegrationUtils::PaintMask(const P
     //
     // Create one extra draw target for drawing positioned mask, so that we do
     // not have to copy the content of maskTarget before painting
     // clip-path into it.
     maskTarget = maskTarget->CreateSimilarDrawTarget(maskTarget->GetSize(),
                                                      SurfaceFormat::A8);
   }
 
-  nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
-  AutoPopGroup autoPop;
-  bool shouldPushOpacity = (maskUsage.opacity != 1.0) &&
-                           (maskFrames.Length() != 1);
-  if (shouldPushOpacity) {
-    ctx.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, maskUsage.opacity);
-    autoPop.SetContext(&ctx);
-  }
-
   gfxContextMatrixAutoSaveRestore matSR;
   nsPoint offsetToBoundingBox;
   nsPoint offsetToUserSpace;
 
   // Paint clip-path-basic-shape onto ctx
   gfxContextAutoSaveRestore basicShapeSR;
   if (maskUsage.shouldApplyBasicShape) {
     matSR.SetContext(&ctx);
@@ -812,18 +788,19 @@ nsSVGIntegrationUtils::PaintMask(const P
 
   // Paint mask onto ctx.
   if (maskUsage.shouldGenerateMaskLayer) {
     matSR.Restore();
     matSR.SetContext(&ctx);
 
     SetupContextMatrix(frame, aParams, offsetToBoundingBox,
                        offsetToUserSpace);
-    result = PaintMaskSurface(aParams, maskTarget,
-                              shouldPushOpacity ?  1.0 : maskUsage.opacity,
+    nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
+
+    result = PaintMaskSurface(aParams, maskTarget, 1.0,
                               firstFrame->StyleContext(), maskFrames,
                               ctx.CurrentMatrix(), offsetToUserSpace);
     if (result != DrawResult::SUCCESS) {
       return result;
     }
   }
 
   // Paint clip-path onto ctx.