aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkDashPath.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2017-12-13 12:47:15 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-15 16:10:38 +0000
commit0b1df4b87a6d97d2a590b011e6d748eef3709cb4 (patch)
tree51ad9e2daf8db3ea8113e5513fa0cfdde9ddc48c /src/utils/SkDashPath.cpp
parent67a86d50f38d3a646ed165f7c6a7d58fda45cbab (diff)
fix zero length dashed lines
targeted fix turns zero length line into very short line. R=egdaniel@google.com Bug: skia:7387 Change-Id: Ic2a809d30d722f4e8f51d9205666dc1476a10067 Reviewed-on: https://skia-review.googlesource.com/84661 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/utils/SkDashPath.cpp')
-rw-r--r--src/utils/SkDashPath.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index d3c52daee2..cbfc8f2168 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -140,6 +140,12 @@ static bool cull_path(const SkPath& srcPath, const SkStrokeRec& rec,
pts[0].fX = minX;
pts[1].fX = maxX;
+ // If line is zero-length, bump out the end by a tiny amount
+ // to draw endcaps. The bump factor is sized so that
+ // SkPoint::Distance() computes a non-zero length.
+ if (minX == maxX) {
+ pts[1].fX += maxX * FLT_EPSILON * 32; // 16 instead of 32 does not draw; length stays zero
+ }
dstPath->moveTo(pts[0]);
dstPath->lineTo(pts[1]);
return true;