19166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com/*
29166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com * Copyright 2012 Google Inc.
39166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com *
49166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com * Use of this source code is governed by a BSD-style license that can be
59166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com * found in the LICENSE file.
69166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com */
78d0a524a4847bc7e1cc63a93b78922739466c201caryclark@google.com#include "PathOpsTestCommon.h"
89166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com#include "SkIntersections.h"
99166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com#include "SkPathOpsCubic.h"
109166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com#include "SkPathOpsLine.h"
119166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com#include "SkReduceOrder.h"
129166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com#include "Test.h"
139166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com
1491fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.orgstruct lineCubic {
159166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com    SkDCubic cubic;
169166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com    SkDLine line;
1791fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org};
1891fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org
1991fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.orgstatic lineCubic failLineCubicTests[] = {
2091fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    {{{{37.5273438,-1.44140625}, {37.8736992,-1.69921875}, {38.1640625,-2.140625},
2191fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org            {38.3984375,-2.765625}}},
2291fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org            {{{40.625,-5.7890625}, {37.7109375,1.3515625}}}},
2391fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org};
2491fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org
2591fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.orgstatic const size_t failLineCubicTests_count = SK_ARRAY_COUNT(failLineCubicTests);
2691fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org
2791fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.orgstatic void testFail(skiatest::Reporter* reporter, int iIndex) {
2891fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    const SkDCubic& cubic = failLineCubicTests[iIndex].cubic;
2991fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    SkASSERT(ValidCubic(cubic));
3091fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    const SkDLine& line = failLineCubicTests[iIndex].line;
3191fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    SkASSERT(ValidLine(line));
3291fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    SkReduceOrder reduce1;
3391fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    SkReduceOrder reduce2;
3491fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics);
3591fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    int order2 = reduce2.reduce(line);
3691fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    if (order1 < 4) {
3791fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
3891fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        REPORTER_ASSERT(reporter, 0);
3991fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    }
4091fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    if (order2 < 2) {
4191fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        SkDebugf("[%d] line order=%d\n", iIndex, order2);
4291fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        REPORTER_ASSERT(reporter, 0);
4391fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    }
4491fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    if (order1 == 4 && order2 == 2) {
4591fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        SkIntersections i;
4691fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        int roots = i.intersect(cubic, line);
4791fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        REPORTER_ASSERT(reporter, roots == 0);
4891fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    }
4991fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org}
5091fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org
5191fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.orgstatic lineCubic lineCubicTests[] = {
522db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    {{{{-634.60540771484375, -481.262939453125}, {266.2696533203125, -752.70867919921875},
532db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org            {-751.8370361328125, -317.37921142578125}, {-969.7427978515625, 824.7255859375}}},
542db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org            {{{-287.9506133720805678, -557.1376476615772617},
552db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org            {-285.9506133720805678, -557.1376476615772617}}}},
562db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org
572db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    {{{{36.7184372,0.888650894}, {36.7184372,0.888650894}, {35.1233864,0.554015458},
582db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org            {34.5114098,-0.115255356}}}, {{{35.4531212,0}, {31.9375,0}}}},
5991fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org
604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    {{{{421, 378}, {421, 380.209137f}, {418.761414f, 382}, {416, 382}}},
614431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org            {{{320, 378}, {421, 378.000031f}}}},
624431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org
634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    {{{{416, 383}, {418.761414f, 383}, {421, 380.761414f}, {421, 378}}},
644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org            {{{320, 378}, {421, 378.000031f}}}},
654431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org
66a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com    {{{{154,715}, {151.238571,715}, {149,712.761414}, {149,710}}},
67a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com            {{{149,675}, {149,710.001465}}}},
68a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com
69b0a0589f8ac0254ec1beba9db2fc32a2bedb31e5skia.committer@gmail.com    {{{{0,1}, {1,6}, {4,1}, {4,3}}},
70b0a0589f8ac0254ec1beba9db2fc32a2bedb31e5skia.committer@gmail.com            {{{6,1}, {1,4}}}},
717eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com
727eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com    {{{{0,1}, {2,6}, {4,1}, {5,4}}},
737eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com            {{{6,2}, {1,4}}}},
747eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com
75570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com    {{{{0,4}, {3,4}, {6,2}, {5,2}}},
76570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com            {{{4,3}, {2,6}}}},
77fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com#if 0
78fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com    {{{{258, 122}, {260.761414, 122}, { 263, 124.238579}, {263, 127}}},
79fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com            {{{259.82843, 125.17157}, {261.535522, 123.46447}}}},
80fa2aeee27af27f2934ee52a9732148f66481fb03caryclark@google.com#endif
8107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    {{{{1006.6951293945312,291}, {1023.263671875,291}, {1033.8402099609375,304.43145751953125},
8207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            {1030.318359375,321}}},
8307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            {{{979.30487060546875,561}, {1036.695068359375,291}}}},
8407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    {{{{259.30487060546875,561}, {242.73631286621094,561}, {232.15980529785156,547.56854248046875},
8507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            {235.68154907226562,531}}},
8607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            {{{286.69512939453125,291}, {229.30485534667969,561}}}},
879166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com    {{{{1, 2}, {2, 6}, {2, 0}, {1, 0}}}, {{{1, 0}, {1, 2}}}},
889166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com    {{{{0, 0}, {0, 1}, {0, 1}, {1, 1}}}, {{{0, 1}, {1, 0}}}},
899166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com};
909166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com
91ad65a3e5fb1f94699f183551b828efbcc6a133cecaryclark@google.comstatic const size_t lineCubicTests_count = SK_ARRAY_COUNT(lineCubicTests);
929166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com
932db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.orgstatic int doIntersect(SkIntersections& intersections, const SkDCubic& cubic, const SkDLine& line) {
942db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    int result;
952db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    bool flipped = false;
962db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    if (line[0].fX == line[1].fX) {
972db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        double top = line[0].fY;
982db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        double bottom = line[1].fY;
992db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        flipped = top > bottom;
1002db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        if (flipped) {
1012db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org            SkTSwap<double>(top, bottom);
1022db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        }
1032db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        result = intersections.vertical(cubic, top, bottom, line[0].fX, flipped);
1042db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    } else if (line[0].fY == line[1].fY) {
1052db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        double left = line[0].fX;
1062db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        double right = line[1].fX;
1072db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        flipped = left > right;
1082db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        if (flipped) {
1092db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org            SkTSwap<double>(left, right);
1102db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        }
1112db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        result = intersections.horizontal(cubic, left, right, line[0].fY, flipped);
1122db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    } else {
1132db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        intersections.intersect(cubic, line);
1142db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        result = intersections.used();
1152db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    }
1162db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org    return result;
1172db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org}
1182db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org
11907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.comstatic void testOne(skiatest::Reporter* reporter, int iIndex) {
12007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
1218d0a524a4847bc7e1cc63a93b78922739466c201caryclark@google.com    SkASSERT(ValidCubic(cubic));
12207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    const SkDLine& line = lineCubicTests[iIndex].line;
1238d0a524a4847bc7e1cc63a93b78922739466c201caryclark@google.com    SkASSERT(ValidLine(line));
12407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    SkReduceOrder reduce1;
12507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    SkReduceOrder reduce2;
126927b7028d44c46e9cbc18368f16ec2262d59d94dcaryclark@google.com    int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics);
12707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    int order2 = reduce2.reduce(line);
12807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    if (order1 < 4) {
12907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        SkDebugf("[%d] cubic order=%d\n", iIndex, order1);
13007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        REPORTER_ASSERT(reporter, 0);
13107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    }
13207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    if (order2 < 2) {
13307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        SkDebugf("[%d] line order=%d\n", iIndex, order2);
13407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        REPORTER_ASSERT(reporter, 0);
13507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    }
13607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    if (order1 == 4 && order2 == 2) {
13707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        SkIntersections i;
1382db7fe7d3b7ee875e1099a22f0af17520696f5d7commit-bot@chromium.org        int roots = doIntersect(i, cubic, line);
13907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        for (int pt = 0; pt < roots; ++pt) {
14007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            double tt1 = i[0][pt];
1414fdbb229649caf74e5c1b55a1823926df903af34caryclark@google.com            SkDPoint xy1 = cubic.ptAtT(tt1);
14207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            double tt2 = i[1][pt];
1434fdbb229649caf74e5c1b55a1823926df903af34caryclark@google.com            SkDPoint xy2 = line.ptAtT(tt2);
14407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            if (!xy1.approximatelyEqual(xy2)) {
14507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com                SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
14607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com                    __FUNCTION__, iIndex, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
14707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            }
14807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com            REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
14907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        }
1504431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#if ONE_OFF_DEBUG
1514431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        double cubicT = i[0][0];
1524431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDPoint prev = cubic.ptAtT(cubicT * 2 - 1);
1534431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDPoint sect = cubic.ptAtT(cubicT);
1544431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        double left[3] = { line.isLeft(prev), line.isLeft(sect), line.isLeft(cubic[3]) };
1554431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDebugf("cubic=(%1.9g, %1.9g, %1.9g)\n", left[0], left[1], left[2]);
1564431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prev.fX, prev.fY, sect.fX, sect.fY);
1574431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", sect.fX, sect.fY, cubic[3].fX, cubic[3].fY);
1584431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDPoint prevL = line.ptAtT(i[1][0] - 0.0000007);
1594431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", prevL.fX, prevL.fY, i.pt(0).fX, i.pt(0).fY);
1604431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDPoint nextL = line.ptAtT(i[1][0] + 0.0000007);
1614431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", i.pt(0).fX, i.pt(0).fY, nextL.fX, nextL.fY);
1624431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org        SkDebugf("prevD=%1.9g dist=%1.9g nextD=%1.9g\n", prev.distance(nextL),
1634431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org                sect.distance(i.pt(0)), cubic[3].distance(prevL));
1644431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org#endif
16507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    }
16607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com}
16707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com
16891fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.orgDEF_TEST(PathOpsFailCubicLineIntersection, reporter) {
16991fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    for (size_t index = 0; index < failLineCubicTests_count; ++index) {
17091fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        int iIndex = static_cast<int>(index);
17191fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        testFail(reporter, iIndex);
17291fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org        reporter->bumpTestCount();
17391fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org    }
17491fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org}
17591fc81c972c5ac4090f106d3b3fd9b26a3235ce1commit-bot@chromium.org
17678e7b4e1b928fa69f672be3c743df6d6c3ecbcedtfarina@chromium.orgDEF_TEST(PathOpsCubicLineIntersection, reporter) {
1779166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com    for (size_t index = 0; index < lineCubicTests_count; ++index) {
1789166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com        int iIndex = static_cast<int>(index);
17907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        testOne(reporter, iIndex);
18007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com        reporter->bumpTestCount();
1819166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com    }
1829166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com}
1839166dcb3a0e8784bea83d76ae01aa338c049ae05caryclark@google.com
18478e7b4e1b928fa69f672be3c743df6d6c3ecbcedtfarina@chromium.orgDEF_TEST(PathOpsCubicLineIntersectionOneOff, reporter) {
18507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    int iIndex = 0;
18607e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    testOne(reporter, iIndex);
18707e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    const SkDCubic& cubic = lineCubicTests[iIndex].cubic;
18807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    const SkDLine& line = lineCubicTests[iIndex].line;
18907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    SkIntersections i;
19007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    i.intersect(cubic, line);
19107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com    SkASSERT(i.used() == 1);
19207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com}
193