Bug 1324809 - Part 1. Fix wrong clip region while painting filter. r=mstange

MozReview-Commit-ID: Cqjo7VwtnlK

--HG--
extra : rebase_source : 0473eb6a9297d0cf0dee3e2e7b1e5f1ac8740bb1
This commit is contained in:
cku 2016-12-21 16:21:23 +08:00
Родитель 950d0c704a
Коммит d25e2f154e
1 изменённых файлов: 9 добавлений и 20 удалений

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

@ -665,13 +665,10 @@ ValidateSVGFrame(nsIFrame* aFrame)
* and the bounding box of aFrame.
* @oaram aOffsetToUserSpace returns the offset between the reference frame and
* the user space coordinate of aFrame.
* @param aClipCtx indicate whether clip aParams.ctx by visual overflow rect of
* aFrame or not.
*/
static void
SetupContextMatrix(nsIFrame* aFrame, const PaintFramesParams& aParams,
nsPoint& aOffsetToBoundingBox, nsPoint& aOffsetToUserSpace,
bool aClipCtx)
nsPoint& aOffsetToBoundingBox, nsPoint& aOffsetToUserSpace)
{
aOffsetToBoundingBox = aParams.builder->ToReferenceFrame(aFrame) -
nsSVGIntegrationUtils::GetOffsetToBoundingBox(aFrame);
@ -691,7 +688,7 @@ SetupContextMatrix(nsIFrame* aFrame, const PaintFramesParams& aParams,
// frame's BBox lives.
// SVG geometry frames and foreignObject frames apply their own offsets, so
// their position is relative to their user space. So for these frame types,
// if we want aCtx to be in user space, we first need to subtract the
// if we want aParams.ctx to be in user space, we first need to subtract the
// frame's position so that SVG painting can later add it again and the
// frame is painted in the right place.
@ -713,14 +710,6 @@ SetupContextMatrix(nsIFrame* aFrame, const PaintFramesParams& aParams,
aFrame->PresContext()->AppUnitsPerDevPixel());
gfxContext& context = aParams.ctx;
context.SetMatrix(context.CurrentMatrix().Translate(devPixelOffsetToUserSpace));
if (aClipCtx) {
nsRect clipRect =
aParams.frame->GetVisualOverflowRectRelativeToSelf() + toUserSpace;
context.Clip(NSRectToSnappedRect(clipRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*context.GetDrawTarget()));
}
}
bool
@ -797,7 +786,7 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
matSR.SetContext(&ctx);
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
offsetToUserSpace, false);
offsetToUserSpace);
nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
bool opacityApplied = !HasNonSVGMask(maskFrames);
result = PaintMaskSurface(aParams, maskTarget,
@ -815,7 +804,7 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
matSR.SetContext(&ctx);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
offsetToUserSpace, false);
offsetToUserSpace);
Matrix clipMaskTransform;
gfxMatrix cssPxToDevPxMatrix = GetCSSPxToDevPxMatrix(frame);
@ -904,7 +893,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
// so we setup context matrix by the position of the current frame,
// instead of the first continuation frame.
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
offsetToUserSpace, false);
offsetToUserSpace);
MaskPaintResult paintResult =
CreateAndPaintMaskSurface(aParams, maskUsage.opacity,
firstFrame->StyleContext(),
@ -929,7 +918,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
matSR.SetContext(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
offsetToUserSpace, false);
offsetToUserSpace);
Matrix clipMaskTransform;
DrawResult clipMaskResult;
RefPtr<SourceSurface> clipMaskSurface;
@ -957,7 +946,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
matSR.SetContext(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
offsetToUserSpace, false);
offsetToUserSpace);
shouldPushMask = true;
}
@ -984,7 +973,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
gfxContextMatrixAutoSaveRestore matSR(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
offsetToUserSpace, false);
offsetToUserSpace);
MOZ_ASSERT(!maskUsage.shouldApplyClipPath ||
!maskUsage.shouldApplyBasicShape);
@ -1062,7 +1051,7 @@ nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
gfxContextAutoSaveRestore autoSR(&context);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
offsetToUserSpace, true);
offsetToUserSpace);
if (opacity != 1.0f) {
context.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, opacity,