Bug 913614 - When the input is invalid, skip the work as we won't get anything useful anyway. r=jmuizelaar
authorMilan Sreckovic <milan@mozilla.com>
Fri, 06 Sep 2013 12:22:20 -0700
changeset 146452 03dbb211fd6b89f61c6e7dfd44d8545d178d741f
parent 146451 e77fba8de25f7a722aa2eda7a39f93380351f08d
child 146453 1585fa81edfc8e8aa4880ec470efd12e5f2919f4
push id25260
push userryanvm@gmail.com
push dateWed, 11 Sep 2013 00:29:30 +0000
treeherdermozilla-central@f73bed2856a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs913614
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 913614 - When the input is invalid, skip the work as we won't get anything useful anyway. r=jmuizelaar
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);