Fix loopIndex in chopCubicAtLoopIntersection

A recent change broke the case where the entire bezier is inside the
loop segment.

Bug: skia:4410
Change-Id: Ib534d459eaa4461d6760e894a8826e3019584ee8
Reviewed-on: https://skia-review.googlesource.com/19333
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2017-06-09 12:51:56 -06:00 committed by Skia Commit-Bot
parent 744d3c59be
commit b58194a90e

View File

@ -837,13 +837,16 @@ int GrPathUtils::chopCubicAtLoopIntersection(const SkPoint src[4], SkPoint dst[1
t[1] /= s[1]; t[1] /= s[1];
SkASSERT(t[0] <= t[1]); // Technically t0 != t1 in a loop, but there may be FP error. SkASSERT(t[0] <= t[1]); // Technically t0 != t1 in a loop, but there may be FP error.
if (t[0] > 0 && t[0] < 1) { if (t[0] < 1 && t[1] > 0) {
chops.push_back(t[0]); *loopIndex = 0;
*loopIndex = 1; if (t[0] > 0) {
} chops.push_back(t[0]);
if (t[1] > 0 && t[1] < 1) { *loopIndex = 1;
chops.push_back(t[1]); }
*loopIndex = chops.count() - 1; if (t[1] < 1) {
chops.push_back(t[1]);
*loopIndex = chops.count() - 1;
}
} }
} }