Bug 1275451: Part 1. Respect mask-composite while composing a SVG mask layer
MozReview-Commit-ID: 8m2xR4P30hq
--- 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,