diff --git a/layout/reftests/svg/mask-and-clipPath-ref.html b/layout/reftests/svg/mask-and-clipPath-ref.html new file mode 100644 index 000000000000..86098fa835d4 --- /dev/null +++ b/layout/reftests/svg/mask-and-clipPath-ref.html @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/mask-and-clipPath.html b/layout/reftests/svg/mask-and-clipPath.html new file mode 100644 index 000000000000..19759a6a31d5 --- /dev/null +++ b/layout/reftests/svg/mask-and-clipPath.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index f142cfb558a9..0b8254425c68 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -216,6 +216,8 @@ fuzzy-if(skiaContent,1,5) pref(svg.marker-improvements.enabled,true) == marker-o == mask-transformed-01.svg mask-transformed-01-ref.svg == mask-transformed-02.svg pass.svg == mask-transformed-child-01.svg mask-transformed-child-01-ref.svg +# fuzzy because of the differences between clipPath and mask clipping +fuzzy(27,28) == mask-and-clipPath.html mask-and-clipPath-ref.html pref(layout.css.masking.enabled,true) fuzzy-if(d2d||skiaContent,1,6400) == mask-type-01.svg mask-type-01-ref.svg pref(layout.css.masking.enabled,true) fuzzy-if(d2d||skiaContent,1,6400) == mask-type-02.svg mask-type-01-ref.svg pref(layout.css.masking.enabled,true) fuzzy-if(d2d||skiaContent,1,6400) == mask-type-03.svg mask-type-01-ref.svg diff --git a/layout/svg/nsSVGClipPathFrame.cpp b/layout/svg/nsSVGClipPathFrame.cpp index 6a88797cccac..f99051b74931 100644 --- a/layout/svg/nsSVGClipPathFrame.cpp +++ b/layout/svg/nsSVGClipPathFrame.cpp @@ -232,16 +232,20 @@ nsSVGClipPathFrame::GetClipMask(gfxContext& aReferenceContext, mat.Invert(); if (aExtraMask) { - MOZ_ASSERT(!aExtraMasksTransform.HasNonTranslation()); - + // We could potentially due this more efficiently with OPERATOR_IN + // but that operator does not work well on CG or D2D RefPtr currentMask = maskDT->Snapshot(); + Matrix transform = maskDT->GetTransform(); maskDT->SetTransform(Matrix()); maskDT->ClearRect(Rect(0, 0, devSpaceClipExtents.width, devSpaceClipExtents.height)); - maskDT->MaskSurface(SurfacePattern(currentMask, ExtendMode::CLAMP), + maskDT->SetTransform(aExtraMasksTransform * transform); + // draw currentMask with the inverse of the transform that we just so that + // it ends up in the same spot with aExtraMask transformed by aExtraMasksTransform + maskDT->MaskSurface(SurfacePattern(currentMask, ExtendMode::CLAMP, aExtraMasksTransform.Inverse() * ToMatrix(mat)), aExtraMask, - Point(aExtraMasksTransform._31, aExtraMasksTransform._32)); + Point(0, 0)); } *aMaskTransform = ToMatrix(mat);