diff options
author | caryclark <caryclark@google.com> | 2016-01-29 09:54:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-29 09:54:20 -0800 |
commit | 703348f5fac69dbedf22cda2ce264d2c9683bcf3 (patch) | |
tree | 2d8dffcb9a19873ec2593098ffdc999f05e32526 | |
parent | f2b340fc885ad2a12d2d73974eff9c8f4c94192c (diff) |
fix teeny dashed path bug
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
-rw-r--r-- | src/core/SkPathMeasure.cpp | 3 | ||||
-rw-r--r-- | tests/DashPathEffectTest.cpp | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp index b06bef7fc5..c0d97924cb 100644 --- a/src/core/SkPathMeasure.cpp +++ b/src/core/SkPathMeasure.cpp @@ -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; diff --git a/tests/DashPathEffectTest.cpp b/tests/DashPathEffectTest.cpp index f55bcf8a85..68fce9a142 100644 --- a/tests/DashPathEffectTest.cpp +++ b/tests/DashPathEffectTest.cpp @@ -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); +} |