Bug 1231643 - Part 1. Create skia-A8-surface for mask composition when backendtype of the source DrawTarget is CG; r=mstange draft
authorCJKu <cku@mozilla.com>
Tue, 19 Apr 2016 10:55:20 +0800
changeset 353001 0825caa3824a369d4a59a2ed8dc1c877bb4b0509
parent 353000 8b071443fc720f9dbd497fdc9a03f102531c3263
child 353002 f859a5d774f332bcd0e6d71687dc8129d21efdb3
push id15856
push usercku@mozilla.com
push dateTue, 19 Apr 2016 03:10:06 +0000
reviewersmstange
bugs1231643
milestone48.0a1
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
layout/svg/nsSVGIntegrationUtils.cpp
--- 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()));