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>
This commit is contained in:
parent
67a86d50f3
commit
0b1df4b87a
@ -518,3 +518,18 @@ DEF_GM( return new Strokes5GM; )
|
||||
|
||||
DEF_GM( return new ZeroLenStrokesGM; )
|
||||
DEF_GM( return new TeenyStrokesGM; )
|
||||
|
||||
DEF_SIMPLE_GM(zerolinedash, canvas, 256, 256) {
|
||||
canvas->clear(SK_ColorWHITE);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setColor(SkColorSetARGB(255, 0, 0, 0));
|
||||
paint.setStrokeWidth(11);
|
||||
paint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
paint.setStrokeJoin(SkPaint::kBevel_Join);
|
||||
|
||||
SkScalar dash_pattern[] = {1, 5};
|
||||
paint.setPathEffect(SkDashPathEffect::Make(dash_pattern, 2, 0));
|
||||
|
||||
canvas->drawLine(100, 100, 100, 100, paint);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user