canvas->translate(4, 4);
canvas->drawPath(path2, paint);
}
+
+DEF_SIMPLE_GM(bug591993, canvas, 40, 140) {
+ SkPaint p;
+ p.setColor(SK_ColorRED);
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeCap(SkPaint::kRound_Cap);
+ p.setStrokeWidth(10);
+ SkScalar intervals[] = { 100, 100 };
+ SkPathEffect* dash = SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 100);
+ p.setPathEffect(dash)->unref();
+ canvas->drawLine(20, 20, 120, 20, p);
+}
static SkScalar find_first_interval(const SkScalar intervals[], SkScalar phase,
int32_t* index, int count) {
for (int i = 0; i < count; ++i) {
- if (phase > intervals[i]) {
- phase -= intervals[i];
+ SkScalar gap = intervals[i];
+ if (phase > gap || (phase == gap && gap)) {
+ phase -= gap;
} else {
*index = i;
- return intervals[i] - phase;
+ return gap - phase;
}
}
// If we get here, phase "appears" to be larger than our length. This