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
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -562,17 +562,27 @@ nsSVGIntegrationUtils::PaintFramesWithEf
gfxRect clipRect = aContext.GetClipExtents();
{
gfxContextMatrixAutoSaveRestore matRestore(&aContext);
aContext.SetMatrix(gfxMatrix());
clipRect = aContext.GetClipExtents();
}
IntRect drawRect = RoundedOut(ToRect(clipRect));
- RefPtr<DrawTarget> 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<DrawTarget> 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;
}
RefPtr<gfxContext> target = gfxContext::ForDrawTarget(targetDT);
MOZ_ASSERT(target); // alrady checked the draw target above
target->SetMatrix(matrixAutoSaveRestore.Matrix() * gfxMatrix::Translation(-drawRect.TopLeft()));