Bug 1299715 - Part 7. Correct clip region for mask surface. r=mstange

MozReview-Commit-ID: 1MZA9uxO9Oi

--HG--
extra : rebase_source : cb23768fb82339b4641602ac90194d009446e1d2
This commit is contained in:
cku 2016-10-07 14:46:41 +08:00
Родитель 0d557e384c
Коммит 07f31bbe99
1 изменённых файлов: 18 добавлений и 10 удалений

Просмотреть файл

@ -411,6 +411,22 @@ private:
nsPoint mOffset; nsPoint mOffset;
}; };
/**
* Returns true if any of the masks is an image mask (and not an SVG mask).
*/
static bool
HasNonSVGMask(const nsTArray<nsSVGMaskFrame *>& aMaskFrames)
{
for (size_t i = 0; i < aMaskFrames.Length() ; i++) {
nsSVGMaskFrame *maskFrame = aMaskFrames[i];
if (!maskFrame) {
return true;
}
}
return false;
}
typedef nsSVGIntegrationUtils::PaintFramesParams PaintFramesParams; typedef nsSVGIntegrationUtils::PaintFramesParams PaintFramesParams;
static DrawResult static DrawResult
@ -476,14 +492,7 @@ GenerateMaskSurface(const PaintFramesParams& aParams,
// Set aAppliedOpacity as true only if all mask layers are svg mask. // Set aAppliedOpacity as true only if all mask layers are svg mask.
// In this case, we will apply opacity into the final mask surface, so the // In this case, we will apply opacity into the final mask surface, so the
// caller does not need to apply it again. // caller does not need to apply it again.
aOpacityApplied = true; aOpacityApplied = !HasNonSVGMask(aMaskFrames);
for (size_t i = 0; i < aMaskFrames.Length() ; i++) {
nsSVGMaskFrame *maskFrame = aMaskFrames[i];
if (!maskFrame) {
aOpacityApplied = false;
break;
}
}
// Multiple SVG masks interleave with image mask. Paint each layer onto // Multiple SVG masks interleave with image mask. Paint each layer onto
// maskDT one at a time. // maskDT one at a time.
@ -756,12 +765,11 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
// so we setup context matrix by the position of the current frame, // so we setup context matrix by the position of the current frame,
// instead of the first continuation frame. // instead of the first continuation frame.
SetupContextMatrix(frame, aParams, offsetToBoundingBox, SetupContextMatrix(frame, aParams, offsetToBoundingBox,
offsetToUserSpace, true); offsetToUserSpace, false);
result = GenerateMaskSurface(aParams, opacity, result = GenerateMaskSurface(aParams, opacity,
firstFrame->StyleContext(), firstFrame->StyleContext(),
maskFrames, offsetToUserSpace, maskFrames, offsetToUserSpace,
maskTransform, maskSurface, opacityApplied); maskTransform, maskSurface, opacityApplied);
context.PopClip();
if (!maskSurface) { if (!maskSurface) {
// Entire surface is clipped out. // Entire surface is clipped out.
return result; return result;