Bug 1324174 - Simplify context management logic in nsSVGIntegrationUtils::PaintMask. r=mstange

MozReview-Commit-ID: BwPSFlfqN8e

--HG--
extra : rebase_source : b16bad5f5baee1a469237b72ea6a23c341ebdb25
This commit is contained in:
cku 2016-12-30 02:07:04 +08:00
Родитель df5d3987d6
Коммит ccf62e0161
1 изменённых файлов: 13 добавлений и 21 удалений

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

@ -750,9 +750,9 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
return DrawResult::SUCCESS;
}
if (maskUsage.opacity == 0.0f) {
return DrawResult::SUCCESS;
}
// XXX Bug 1323912.
MOZ_ASSERT(maskUsage.opacity == 1.0,
"nsSVGIntegrationUtils::PaintMask can not handle opacity now.");
gfxContext& ctx = aParams.ctx;
nsIFrame* firstFrame =
@ -761,10 +761,7 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
nsSVGEffects::GetEffectProperties(firstFrame);
DrawResult result = DrawResult::SUCCESS;
nsPoint offsetToBoundingBox;
nsPoint offsetToUserSpace;
gfxContextMatrixAutoSaveRestore matSR;
RefPtr<DrawTarget> maskTarget = ctx.GetDrawTarget();
RefPtr<DrawTarget> maskTarget = ctx.GetDrawTarget();
if (maskUsage.shouldGenerateMaskLayer &&
maskUsage.shouldGenerateClipMaskLayer) {
@ -778,19 +775,25 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
SurfaceFormat::A8);
}
gfxContextMatrixAutoSaveRestore matSR;
nsPoint offsetToBoundingBox;
nsPoint offsetToUserSpace;
// Paint clip-path-basic-shape onto ctx
gfxContextAutoSaveRestore basicShapeSR;
if (maskUsage.shouldApplyBasicShape) {
matSR.SetContext(&ctx);
SetupContextMatrix(firstFrame, aParams, offsetToBoundingBox,
offsetToUserSpace);
basicShapeSR.SetContext(&ctx);
nsCSSClipPathInstance::ApplyBasicShapeClip(ctx, frame);
if (!maskUsage.shouldGenerateMaskLayer) {
// Only have basic-shape clip-path effect. Fill clipped region by
// opaque white.
ctx.SetColor(Color(0.0, 0.0, 0.0, 1.0));
ctx.SetColor(Color(1.0, 1.0, 1.0, 1.0));
ctx.Fill();
ctx.PopClip();
return result;
}
@ -804,26 +807,15 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
offsetToUserSpace);
nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
// XXX Bug 1323912.
MOZ_ASSERT(maskUsage.opacity == 1.0,
"nsSVGIntegrationUtils::PaintMask can not handle opacity now.");
result = PaintMaskSurface(aParams, maskTarget, 1.0,
firstFrame->StyleContext(), maskFrames,
ctx.CurrentMatrix(), offsetToUserSpace);
if (result != DrawResult::SUCCESS) {
if (maskUsage.shouldApplyBasicShape) {
ctx.PopClip();
}
return result;
}
}
if (maskUsage.shouldApplyBasicShape) {
ctx.PopClip();
return result;
}
// Paint clip-path onto ctx.
if (maskUsage.shouldGenerateClipMaskLayer || maskUsage.shouldApplyClipPath) {
matSR.Restore();