Bug 1151145 - Make sure we don't call CGContextSaveGState without calling CGContextRestoreGState in DrawTargetCG::StrokeRect. r=jrmuizel, a=lizzard
authorMarkus Stange <mstange@themasta.com>
Sat, 04 Apr 2015 18:06:35 -0400
changeset 254978 c4248bd6b7c3
parent 254977 c77a62b27a08
child 254979 969ad710b89e
push id7914
push userryanvm@gmail.com
push date2015-04-13 18:28 +0000
treeherdermozilla-aurora@428734cf3a67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, lizzard
bugs1151145
milestone39.0a2
Bug 1151145 - Make sure we don't call CGContextSaveGState without calling CGContextRestoreGState in DrawTargetCG::StrokeRect. r=jrmuizel, a=lizzard
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -1222,39 +1222,39 @@ DrawTargetCG::StrokeRect(const Rect &aRe
   if (MOZ2D_ERROR_IF(!mCg)) {
     return;
   }
 
   if (!aRect.IsFinite()) {
     return;
   }
 
-  MarkChanged();
-
-  CGContextSaveGState(mCg);
-
-  UnboundnessFixer fixer;
-  CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
-  if (MOZ2D_ERROR_IF(!cg)) {
-    return;
-  }
-
   // Stroking large rectangles with dashes is expensive with CG (fixed
   // overhead based on the number of dashes, regardless of whether the dashes
   // are visible), so we try to reduce the size of the stroked rectangle as
   // much as possible before passing it on to CG.
   Rect rect = aRect;
   if (!rect.IsEmpty()) {
     Rect deviceClip(0, 0, mSize.width, mSize.height);
     rect = ShrinkClippedStrokedRect(rect, deviceClip, mTransform, aStrokeOptions);
     if (rect.IsEmpty()) {
       return;
     }
   }
 
+  MarkChanged();
+
+  CGContextSaveGState(mCg);
+
+  UnboundnessFixer fixer;
+  CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
+  if (MOZ2D_ERROR_IF(!cg)) {
+    return;
+  }
+
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
 
   // Work around Quartz bug where antialiasing causes corner pixels to be off by
   // 1 channel value (e.g. rgb(1,1,1) values appear at the corner of solid
   // black stroke), by turning off antialiasing when the edges of the stroke
   // are pixel-aligned. Note that when a transform's components are all
   // integers, it maps integers coordinates to integer coordinates.