Bug 1275451: Part 1. Respect mask-composite while composing a SVG mask layer draft
authorCJKu <cku@mozilla.com>
Thu, 26 May 2016 16:07:43 +0800
changeset 371269 72e2f78232a57e73e1275075991b1f8d61851695
parent 371122 8d0aadfe7da782d415363880008b4ca027686137
child 371270 95eb777b8c349f0e76a9b7e00ab9c1ae9e43d0ef
push id19287
push userbmo:cku@mozilla.com
push dateThu, 26 May 2016 08:58:47 +0000
bugs1275451
milestone49.0a1
Bug 1275451: Part 1. Respect mask-composite while composing a SVG mask layer MozReview-Commit-ID: 8m2xR4P30hq
layout/svg/nsSVGIntegrationUtils.cpp
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -477,38 +477,41 @@ GenerateMaskSurface(const nsSVGIntegrati
     ctx.CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
   maskContext->SetMatrix(maskSurfaceMatrix);
 
   // Multiple SVG masks interleave with image mask. Paint each layer onto maskDT
   // one at a time.
   for (int i = svgMaskFrames.Length() - 1; i >= 0 ; i--) {
     nsSVGMaskFrame *maskFrame = svgMaskFrames[i];
 
+    CompositionOp compositionOp = (i == int(svgMaskFrames.Length() - 1))
+      ? CompositionOp::OP_OVER
+      : nsCSSRendering::GetGFXCompositeMode(svgReset->mMask.mLayers[i].mComposite);
+
     // maskFrame != nullptr means we get a SVG mask.
     // maskFrame == nullptr means we get an image mask.
     if (maskFrame) {
       Matrix svgMaskMatrix;
       RefPtr<SourceSurface> svgMask =
         maskFrame->GetMaskForMaskedFrame(maskContext, aParams.frame,
                                          cssPxToDevPxMatrix, aOpacity,
                                          &svgMaskMatrix,
                                          svgReset->mMask.mLayers[i].mMaskMode);
       if (svgMask) {
         gfxContextMatrixAutoSaveRestore matRestore(maskContext);
 
         maskContext->Multiply(ThebesMatrix(svgMaskMatrix));
         Rect drawRect = IntRectToRect(IntRect(IntPoint(0, 0), svgMask->GetSize()));
-        maskDT->DrawSurface(svgMask, drawRect, drawRect);
+        maskDT->DrawSurface(svgMask, drawRect, drawRect, DrawSurfaceOptions(),
+                            DrawOptions(1.0f, compositionOp));
       }
     } else {
       gfxContextMatrixAutoSaveRestore matRestore(maskContext);
 
       maskContext->Multiply(gfxMatrix::Translation(-aOffest));
-      CompositionOp compositionOp =
-        nsCSSRendering::GetGFXCompositeMode(svgReset->mMask.mLayers[i].mComposite);
       nsRenderingContext rc(maskContext);
       nsCSSRendering::PaintBGParams  params =
         nsCSSRendering::PaintBGParams::ForSingleLayer(*aParams.frame->PresContext(),
                                                       rc, aParams.dirtyRect,
                                                       aParams.borderArea,
                                                       aParams.frame,
                                                       aParams.builder->GetBackgroundPaintFlags() |
                                                       nsCSSRendering::PAINTBG_MASK_IMAGE,