fix teeny dashed path bug
authorcaryclark <caryclark@google.com>
Fri, 29 Jan 2016 17:54:20 +0000 (09:54 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 29 Jan 2016 17:54:20 +0000 (09:54 -0800)
If the path dashed is sufficiently small, there may be no
segments generated to dash. Check for an empty segment list.

R=reed@google.com
BUG=skia:4871
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1645613006

Review URL: https://codereview.chromium.org/1645613006

src/core/SkPathMeasure.cpp
tests/DashPathEffectTest.cpp

index b06bef7..c0d9792 100644 (file)
@@ -652,6 +652,9 @@ bool SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst,
     if (startD > stopD) {
         return false;
     }
+    if (!fSegments.count()) {
+        return false;
+    }
 
     SkPoint  p;
     SkScalar startT, stopT;
index f55bcf8..68fce9a 100644 (file)
@@ -87,3 +87,20 @@ DEF_TEST(DashPathEffectTest_asPoints, r) {
         }
     }
 }
+
+DEF_TEST(DashPath_bug4871, r) {
+    SkPath path;
+    path.moveTo(30, 24);
+    path.cubicTo(30.002f, 24, 30, 24, 30, 24);
+    path.close();
+
+    SkScalar intervals[2] = { 1, 1 };
+    SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
+
+    SkPaint paint;
+    paint.setStyle(SkPaint::kStroke_Style);
+    paint.setPathEffect(dash);
+
+    SkPath fill;
+    paint.getFillPath(path, &fill);
+}