| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2012 Google Inc. | 2  * Copyright 2012 Google Inc. | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 #include "PathOpsCubicIntersectionTestData.h" | 7 #include "PathOpsCubicIntersectionTestData.h" | 
| 8 #include "PathOpsTestCommon.h" | 8 #include "PathOpsTestCommon.h" | 
| 9 #include "SkGeometry.h" | 9 #include "SkGeometry.h" | 
| 10 #include "SkIntersections.h" | 10 #include "SkIntersections.h" | 
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 676 } | 676 } | 
| 677 | 677 | 
| 678 DEF_TEST(PathOpsCubicIntersection, reporter) { | 678 DEF_TEST(PathOpsCubicIntersection, reporter) { | 
| 679     oneOffTests(reporter); | 679     oneOffTests(reporter); | 
| 680     cubicIntersectionSelfTest(reporter); | 680     cubicIntersectionSelfTest(reporter); | 
| 681     cubicIntersectionCoinTest(reporter); | 681     cubicIntersectionCoinTest(reporter); | 
| 682     standardTestCases(reporter); | 682     standardTestCases(reporter); | 
| 683     if (false) CubicIntersection_IntersectionFinder(); | 683     if (false) CubicIntersection_IntersectionFinder(); | 
| 684     if (false) CubicIntersection_RandTest(reporter); | 684     if (false) CubicIntersection_RandTest(reporter); | 
| 685 } | 685 } | 
|  | 686 | 
|  | 687 static void binaryTest(const SkDCubic& cubic1, const SkDCubic& cubic2, | 
|  | 688         skiatest::Reporter* reporter) { | 
|  | 689     SkASSERT(ValidCubic(cubic1)); | 
|  | 690     SkASSERT(ValidCubic(cubic2)); | 
|  | 691     SkIntersections intersections; | 
|  | 692     SkReduceOrder reduce1, reduce2; | 
|  | 693     int order1 = reduce1.reduce(cubic1, SkReduceOrder::kNo_Quadratics); | 
|  | 694     int order2 = reduce2.reduce(cubic2, SkReduceOrder::kNo_Quadratics); | 
|  | 695     if (order1 == 4 && order2 == 4) { | 
|  | 696         intersections.intersect(cubic1, cubic2); | 
|  | 697     } else { | 
|  | 698         intersections.reset(); | 
|  | 699     } | 
|  | 700     SkIntersections intersections2; | 
|  | 701     (void) intersections2.intersect(cubic1, cubic2); | 
|  | 702     REPORTER_ASSERT(reporter, intersections.used() <= intersections2.used() | 
|  | 703             || intersections[0][0] + 0.01 > intersections[0][1]); | 
|  | 704     for (int index = 0; index < intersections2.used(); ++index) { | 
|  | 705 //            SkASSERT(intersections.pt(index).approximatelyEqual(intersections2
     .pt(index))); | 
|  | 706         double tt1 = intersections2[0][index]; | 
|  | 707         SkDPoint xy1 = cubic1.ptAtT(tt1); | 
|  | 708         double tt2 = intersections2[1][index]; | 
|  | 709         SkDPoint xy2 = cubic2.ptAtT(tt2); | 
|  | 710         REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); | 
|  | 711     } | 
|  | 712 } | 
|  | 713 | 
|  | 714 DEF_TEST(PathOpsCubicBinaryTest, reporter) { | 
|  | 715     int outer = 0; | 
|  | 716     int inner = outer + 1; | 
|  | 717     do { | 
|  | 718         const SkDCubic& cubic1 = testSet[outer]; | 
|  | 719         const SkDCubic& cubic2 = testSet[inner]; | 
|  | 720         binaryTest(cubic1, cubic2, reporter); | 
|  | 721         inner += 2; | 
|  | 722         outer += 2; | 
|  | 723     } while (outer < (int) testSetCount); | 
|  | 724 } | 
|  | 725 | 
|  | 726 DEF_TEST(PathOpsCubicBinaryNew, reporter) { | 
|  | 727     int outer = 62; | 
|  | 728     int inner = outer + 1; | 
|  | 729     do { | 
|  | 730         const SkDCubic& cubic1 = newTestSet[outer]; | 
|  | 731         const SkDCubic& cubic2 = newTestSet[inner]; | 
|  | 732         binaryTest(cubic1, cubic2, reporter); | 
|  | 733         inner += 2; | 
|  | 734         outer += 2; | 
|  | 735     } while (outer < (int) newTestSetCount); | 
|  | 736 } | 
|  | 737 | 
|  | 738 DEF_TEST(PathOpsCubicBinaryStd, reporter) { | 
|  | 739     const int firstTest = 0; | 
|  | 740     for (size_t index = firstTest; index < tests_count; ++index) { | 
|  | 741         const SkDCubic& cubic1 = tests[index][0]; | 
|  | 742         const SkDCubic& cubic2 = tests[index][1]; | 
|  | 743         binaryTest(cubic1, cubic2, reporter); | 
|  | 744     } | 
|  | 745 } | 
|  | 746 | 
|  | 747 DEF_TEST(PathOpsCubicBinaryCoin, reporter) { | 
|  | 748     int firstFail = 0; | 
|  | 749     for (int index = firstFail; index < coinSetCount; index += 2) { | 
|  | 750         const SkDCubic& cubic1 = coinSet[index]; | 
|  | 751         const SkDCubic& cubic2 = coinSet[index + 1]; | 
|  | 752         binaryTest(cubic1, cubic2, reporter); | 
|  | 753     } | 
|  | 754 } | 
| OLD | NEW | 
|---|