| Index: tests/GeometryTest.cpp
|
| diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp
|
| index 17e46448570ec45ff43faf92cfbef15deb16100a..b3bbb51bc0122ac1b81395ac2ad06ea68c9fa896 100644
|
| --- a/tests/GeometryTest.cpp
|
| +++ b/tests/GeometryTest.cpp
|
| @@ -145,6 +145,45 @@ static void test_conic_tangents(skiatest::Reporter* reporter) {
|
| }
|
| }
|
|
|
| +static void test_this_conic_to_quad(skiatest::Reporter* r, const SkPoint pts[3], SkScalar w) {
|
| + SkAutoConicToQuads quadder;
|
| + const SkPoint* qpts = quadder.computeQuads(pts, w, 0.25);
|
| + const int qcount = quadder.countQuads();
|
| + const int pcount = qcount * 2 + 1;
|
| +
|
| + REPORTER_ASSERT(r, SkPointsAreFinite(qpts, pcount));
|
| +}
|
| +
|
| +/**
|
| + * We need to ensure that when a conic is approximated by quads, that we always return finite
|
| + * values in the quads.
|
| + *
|
| + * Inspired by crbug_627414
|
| + */
|
| +static void test_conic_to_quads(skiatest::Reporter* reporter) {
|
| + const SkPoint triples[] = {
|
| + { 0, 0 }, { 1, 0 }, { 1, 1 },
|
| + { 3.58732e-43f, 2.72084f }, { 3.00392f, 3.00392f },
|
| + { 0, 0 }, { 100000, 0 }, { 100000, 100000 },
|
| + { 0, 0 }, { 1e30f, 0 }, { 1e30f, 1e30f },
|
| + };
|
| + const int N = sizeof(triples) / sizeof(SkPoint);
|
| +
|
| + for (int i = 0; i < N; i += 3) {
|
| + const SkPoint* pts = &triples[i];
|
| +
|
| + SkRect bounds;
|
| + bounds.set(pts, 3);
|
| +
|
| + SkScalar w = 1e30f;
|
| + do {
|
| + w *= 2;
|
| + test_this_conic_to_quad(reporter, pts, w);
|
| + } while (SkScalarIsFinite(w));
|
| + test_this_conic_to_quad(reporter, pts, SK_ScalarNaN);
|
| + }
|
| +}
|
| +
|
| static void test_cubic_tangents(skiatest::Reporter* reporter) {
|
| SkPoint pts[] = {
|
| { 10, 20}, {10, 20}, {20, 30}, {30, 40},
|
| @@ -193,4 +232,5 @@ DEF_TEST(Geometry, reporter) {
|
| test_cubic_tangents(reporter);
|
| test_quad_tangents(reporter);
|
| test_conic_tangents(reporter);
|
| + test_conic_to_quads(reporter);
|
| }
|
|
|