Don't pass NaN to SkChopQuadAt in SkChopQuadAtMaxCurvature.
Bug: chromium:1202417 Change-Id: Ie6a31b2a9999280c9771a3c8d8fa92d77c01cf03 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402259 Auto-Submit: Brian Salomon <bsalomon@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
9230fc59b7
commit
1c42fcfdd2
@ -346,12 +346,12 @@ SkScalar SkFindQuadMaxCurvature(const SkPoint src[3]) {
|
||||
|
||||
int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5]) {
|
||||
SkScalar t = SkFindQuadMaxCurvature(src);
|
||||
if (t == 0 || t == 1) {
|
||||
memcpy(dst, src, 3 * sizeof(SkPoint));
|
||||
return 1;
|
||||
} else {
|
||||
if (t > 0 && t < 1) {
|
||||
SkChopQuadAt(src, dst, t);
|
||||
return 2;
|
||||
} else {
|
||||
memcpy(dst, src, 3 * sizeof(SkPoint));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -621,6 +621,13 @@ DEF_TEST(Geometry, reporter) {
|
||||
int count = SkChopQuadAtMaxCurvature(pts, pts); // Ensure src and dst can be the same pointer.
|
||||
REPORTER_ASSERT(reporter, count == 1 || count == 2);
|
||||
|
||||
// This previously crashed because the computed t of max curvature is NaN and SkChopQuadAt
|
||||
// asserts that the passed t is in 0..1. Passes by not asserting.
|
||||
pts[0].set(15.1213f, 7.77647f);
|
||||
pts[1].set(6.2168e+19f, 1.51338e+20f);
|
||||
pts[2].set(1.4579e+19f, 1.55558e+21f);
|
||||
count = SkChopQuadAtMaxCurvature(pts, pts);
|
||||
|
||||
pts[0].set(0, 0);
|
||||
pts[1].set(3, 0);
|
||||
pts[2].set(3, 3);
|
||||
|
Loading…
Reference in New Issue
Block a user