From 644959b4eb64af3ed7b0a0d3e6f55a72d427e84f Mon Sep 17 00:00:00 2001 From: CJKu Date: Tue, 19 Apr 2016 10:55:20 +0800 Subject: [PATCH] Bug 1231643 - Part 1. Create skia-A8-surface for mask composition when backendtype of the source DrawTarget is CG; r=mstange MozReview-Commit-ID: J0oIhhTowk7 --HG-- extra : rebase_source : 0825caa3824a369d4a59a2ed8dc1c877bb4b0509 --- layout/svg/nsSVGIntegrationUtils.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index b7b4ae757ed9..1b2c8b586245 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -567,7 +567,17 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(gfxContext& aContext, clipRect = aContext.GetClipExtents(); } IntRect drawRect = RoundedOut(ToRect(clipRect)); - RefPtr targetDT = aContext.GetDrawTarget()->CreateSimilarDrawTarget(drawRect.Size(), SurfaceFormat::A8); + + // Mask composition result on CoreGraphic::A8 surface is not correct + // when mask-mode is not add(source over). Switch to skia when CG backend + // detected. + RefPtr targetDT = + (aContext.GetDrawTarget()->GetBackendType() == BackendType::COREGRAPHICS) ? + Factory::CreateDrawTarget(BackendType::SKIA, drawRect.Size(), + SurfaceFormat::A8) : + aContext.GetDrawTarget()->CreateSimilarDrawTarget(drawRect.Size(), + SurfaceFormat::A8); + if (!targetDT || !targetDT->IsValid()) { aContext.Restore(); return;