Bug 1224207 - Part 5. Fine tune nsFilterInstance::BuildSourcePaint. r=mstange
authorcku <cku@mozilla.com>
Tue, 24 Jan 2017 23:10:31 +0800
changeset 480860 3484e9368176bdaae0fc8705a77dd2454bb4686a
parent 480859 7dfb1483b48ebf72bf6da943e5419093376a8be9
child 480861 b1fb2a174fbf045a8ca8fe00eb80117a2cb6d441
push id44667
push userbmo:tschneider@mozilla.com
push dateThu, 09 Feb 2017 00:31:11 +0000
reviewersmstange
bugs1224207
milestone54.0a1
Bug 1224207 - Part 5. Fine tune nsFilterInstance::BuildSourcePaint. r=mstange 1. Rename gfx->sourceCtx. 2. Since sourceCtx is discarded immidiately, there is no need of save/restore. MozReview-Commit-ID: CM2MMBYWp3W
layout/svg/nsFilterInstance.cpp
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -378,33 +378,31 @@ nsFilterInstance::BuildSourcePaint(Sourc
   DebugOnly<bool> invertible = deviceToFilterSpace.Invert();
   MOZ_ASSERT(invertible,
              "The returning matix of GetFilterSpaceToDeviceSpaceTransform must"
              "be an invertible matrix(not a singular one), since we already"
              "checked it and early return if it's not from the caller side"
              "(nsFilterInstance::Render)");
 
   if (!mPaintTransform.IsSingular()) {
-    RefPtr<gfxContext> gfx = gfxContext::CreateOrNull(offscreenDT);
-    MOZ_ASSERT(gfx); // already checked the draw target above
-    gfx->Save();
-    gfx->Multiply(mPaintTransform *
+    RefPtr<gfxContext> sourceCtx = gfxContext::CreateOrNull(offscreenDT);
+    MOZ_ASSERT(sourceCtx); // already checked the draw target above
+    sourceCtx->Multiply(mPaintTransform *
                   deviceToFilterSpace *
                   gfxMatrix::Translation(-neededRect.TopLeft()));
     GeneralPattern pattern;
     if (aSource == &mFillPaint) {
-      nsSVGUtils::MakeFillPatternFor(mTargetFrame, gfx, &pattern);
+      nsSVGUtils::MakeFillPatternFor(mTargetFrame, sourceCtx, &pattern);
     } else if (aSource == &mStrokePaint) {
-      nsSVGUtils::MakeStrokePatternFor(mTargetFrame, gfx, &pattern);
+      nsSVGUtils::MakeStrokePatternFor(mTargetFrame, sourceCtx, &pattern);
     }
     if (pattern.GetPattern()) {
       offscreenDT->FillRect(ToRect(FilterSpaceToUserSpace(ThebesRect(neededRect))),
                             pattern);
     }
-    gfx->Restore();
   }
 
   aSource->mSourceSurface = offscreenDT->Snapshot();
   aSource->mSurfaceRect = neededRect;
 
   return DrawResult::SUCCESS;
 }