Bug 1317636 - Part 6. Use PaintClipMask in nsSVGIntegrationUtils::PaintMask. draft
authorcku <cku@mozilla.com>
Wed, 16 Nov 2016 19:04:59 +0800
changeset 440753 e5e91aa16bd58ffd1ab47c354993e383c9712a8c
parent 440752 493b7280366767d83b1fa9f62efd146ea0c651ef
child 441060 3cf9c649c7d5efd36b1357e278733ff4850a854f
child 441113 669d68ab39cfbe59e42bf6d711b4d47adeca71fe
child 441115 17f2414502bc24bbfdee46d44aa7cea2b9f63281
child 441344 cabbde4a03a173d883287a1ac6b0c299ee3d9655
child 441357 1e9594bd55cb683c1422be1dd63ec9c51c4a1309
child 441582 05dbbe28935acf47c9d66cda94b1093fd40d3e4d
child 441640 cfbff9f60f0dd7dba7332b969be3dacb0ae5ac34
push id36315
push userbmo:cku@mozilla.com
push dateFri, 18 Nov 2016 02:41:02 +0000
bugs1317636
milestone53.0a1
Bug 1317636 - Part 6. Use PaintClipMask in nsSVGIntegrationUtils::PaintMask. MozReview-Commit-ID: 6CibljSTeNj
layout/svg/nsSVGIntegrationUtils.cpp
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -752,43 +752,22 @@ nsSVGIntegrationUtils::PaintMask(const P
     SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
                        offsetToUserSpace, false);
     Matrix clipMaskTransform;
     gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame);
 
     bool isOK = true;
     nsSVGClipPathFrame *clipPathFrame =
       effectProperties.GetClipPathFrame(&isOK);
-    // XXX Bug 1317636. Split nsSVGClipPathFrame::GetClipMask into two
-    // functions:
-    // 1. nsSVGClipPathFrame::CreateClipMask
-    //    Create an A8 surface with right size for painting clip-path mask.
-    // 2. nsSVGClipPathFrame::PaintClipMask
-    //    Paint the content of clip-path _direct_ onto a given A8 surface.
-    // With this change, we can skip one extra draw call
-    // (DrawTarget::MaskSurface) bellow.
-    RefPtr<SourceSurface> clipMaskSurface =
-      clipPathFrame->GetClipMask(ctx, frame, cssPxToDevPxMatrix,
-                                 &clipMaskTransform, nullptr,
-                                 ToMatrix(ctx.CurrentMatrix()), &result);
-
-    if (clipMaskSurface) {
-      gfxContextMatrixAutoSaveRestore matRestore(&ctx);
-      ctx.Multiply(ThebesMatrix(clipMaskTransform));
-      CompositionOp op = maskUsage.shouldGenerateMaskLayer
-                         ? CompositionOp::OP_IN : CompositionOp::OP_OVER;
-      target->MaskSurface(ColorPattern(Color(0.0, 0.0, 0.0, 1.0)),
-                          clipMaskSurface,
-                          Point(),
-                          DrawOptions(1.0, op));
-    } else {
-      // Either entire surface is clipped out, or gfx buffer allocation
-      // failure in nsSVGClipPathFrame::GetClipMask.
-      return result;
-    }
+    RefPtr<SourceSurface> maskSurface =
+      maskUsage.shouldGenerateMaskLayer ? target->Snapshot() : nullptr;
+    result =
+      clipPathFrame->PaintClipMask(ctx, frame, cssPxToDevPxMatrix,
+                                   &clipMaskTransform, maskSurface,
+                                   ToMatrix(ctx.CurrentMatrix()));
   }
 
   return result;
 }
 
 DrawResult
 nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
 {