Bug 913614 - When the input is invalid, skip the work as we won't get anything useful anyway. r=jmuizelaar, a=akeybl
☠☠ backed out by 97e0d6a03696 ☠ ☠
authorMilan Sreckovic <milan@mozilla.com>
Fri, 06 Sep 2013 12:22:20 -0700
changeset 154029 5706a9c6704a0e60c3bc4208d575a5cab2b47fe4
parent 154028 478206fb256f099be927723ee8420842a2980ab5
child 154030 1708e75f93f570e9e5ce728250edaa14ed897967
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar, akeybl
bugs913614
milestone25.0a2
Bug 913614 - When the input is invalid, skip the work as we won't get anything useful anyway. r=jmuizelaar, a=akeybl
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -785,16 +785,23 @@ DrawTargetCG::FillRect(const Rect &aRect
 
   fixer.Fix(mCg);
   CGContextRestoreGState(mCg);
 }
 
 void
 DrawTargetCG::StrokeLine(const Point &p1, const Point &p2, const Pattern &aPattern, const StrokeOptions &aStrokeOptions, const DrawOptions &aDrawOptions)
 {
+  if (!std::isfinite(p1.x) ||
+      !std::isfinite(p1.y) ||
+      !std::isfinite(p2.x) ||
+      !std::isfinite(p2.y)) {
+    return;
+  }
+
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
   CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
@@ -824,16 +831,20 @@ DrawTargetCG::StrokeLine(const Point &p1
 }
 
 void
 DrawTargetCG::StrokeRect(const Rect &aRect,
                          const Pattern &aPattern,
                          const StrokeOptions &aStrokeOptions,
                          const DrawOptions &aDrawOptions)
 {
+  if (!aRect.IsFinite()) {
+    return;
+  }
+
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
   CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
@@ -873,16 +884,20 @@ DrawTargetCG::ClearRect(const Rect &aRec
   CGContextClearRect(mCg, RectToCGRect(aRect));
 
   CGContextRestoreGState(mCg);
 }
 
 void
 DrawTargetCG::Stroke(const Path *aPath, const Pattern &aPattern, const StrokeOptions &aStrokeOptions, const DrawOptions &aDrawOptions)
 {
+  if (!aPath->GetBounds().IsFinite()) {
+    return;
+  }
+
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
   CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);