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