Bug 1248223 - verify that stroke widths are finite for Skia. r=jmuizelaar
authorLee Salzman <lsalzman@mozilla.com>
Tue, 23 Feb 2016 18:09:03 -0500
changeset 285569 7ab8341b7e7a9f2880309a031722e12cd79488f3
parent 285568 4b043b29bb042320fa0be83d30aff95ac5903f22
child 285570 66a7d72ae7705dc26b0cfcf251618ae887f5d0c7
push id17831
push userkwierso@gmail.com
push dateThu, 25 Feb 2016 22:42:17 +0000
treeherderfx-team@8e34b12969bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs1248223
milestone47.0a1
Bug 1248223 - verify that stroke widths are finite for Skia. r=jmuizelaar
gfx/2d/HelpersSkia.h
gfx/2d/PathSkia.cpp
--- a/gfx/2d/HelpersSkia.h
+++ b/gfx/2d/HelpersSkia.h
@@ -137,17 +137,18 @@ JoinStyleToSkiaJoin(JoinStyle aJoin)
   return SkPaint::kDefault_Join;
 }
 
 static inline bool
 StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
 {
   // Skia renders 0 width strokes with a width of 1 (and in black),
   // so we should just skip the draw call entirely.
-  if (!aOptions.mLineWidth) {
+  // Skia does not handle non-finite line widths.
+  if (!aOptions.mLineWidth || !IsFinite(aOptions.mLineWidth)) {
     return false;
   }
   aPaint.setStrokeWidth(SkFloatToScalar(aOptions.mLineWidth));
   aPaint.setStrokeMiter(SkFloatToScalar(aOptions.mMiterLimit));
   aPaint.setStrokeCap(CapStyleToSkiaCap(aOptions.mLineCap));
   aPaint.setStrokeJoin(JoinStyleToSkiaJoin(aOptions.mLineJoin));
 
   if (aOptions.mDashLength > 0) {
--- a/gfx/2d/PathSkia.cpp
+++ b/gfx/2d/PathSkia.cpp
@@ -185,17 +185,19 @@ PathSkia::StrokeContainsPoint(const Stro
                               const Point &aPoint,
                               const Matrix &aTransform) const
 {
   if (!mPath.isFinite()) {
     return false;
   }
 
   SkPaint paint;
-  StrokeOptionsToPaint(paint, aStrokeOptions);
+  if (!StrokeOptionsToPaint(paint, aStrokeOptions)) {
+    return false;
+  }
 
   SkPath strokePath;
   paint.getFillPath(mPath, &strokePath);
 
   return SkPathContainsPoint(strokePath, aPoint, aTransform);
 }
 
 Rect
@@ -213,18 +215,20 @@ Rect
 PathSkia::GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                            const Matrix &aTransform) const
 {
   if (!mPath.isFinite()) {
     return Rect();
   }
 
   SkPaint paint;
-  StrokeOptionsToPaint(paint, aStrokeOptions);
-  
+  if (!StrokeOptionsToPaint(paint, aStrokeOptions)) {
+    return Rect();
+  }
+
   SkPath result;
   paint.getFillPath(mPath, &result);
 
   Rect bounds = SkRectToRect(result.getBounds());
   return aTransform.TransformBounds(bounds);
 }
 
 void