| 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 "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
| 8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
| 9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 {{{{0, 0}, {1, 0}}}, {{{3, 0}, {2, 0}}}}, | 43 {{{{0, 0}, {1, 0}}}, {{{3, 0}, {2, 0}}}}, |
| 44 {{{{0, 0}, {0, 0}}}, {{{1, 0}, {2, 0}}}}, | 44 {{{{0, 0}, {0, 0}}}, {{{1, 0}, {2, 0}}}}, |
| 45 {{{{0, 1}, {0, 1}}}, {{{0, 3}, {0, 2}}}}, | 45 {{{{0, 1}, {0, 1}}}, {{{0, 3}, {0, 2}}}}, |
| 46 {{{{0, 0}, {1, 0}}}, {{{2, 0}, {3, 0}}}}, | 46 {{{{0, 0}, {1, 0}}}, {{{2, 0}, {3, 0}}}}, |
| 47 {{{{1, 1}, {2, 2}}}, {{{4, 4}, {3, 3}}}}, | 47 {{{{1, 1}, {2, 2}}}, {{{4, 4}, {3, 3}}}}, |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect); | 50 static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect); |
| 51 | 51 |
| 52 static const SkDLine coincidentTests[][2] = { | 52 static const SkDLine coincidentTests[][2] = { |
| 53 {{{{0,482.5}, {-4.4408921e-016,682.5}}}, | 53 {{{ { 10105, 2510 }, { 10123, 2509.98999f } }}, |
| 54 {{{10105, 2509.98999f}, { 10123, 2510 } }}}, |
| 55 |
| 56 {{ { { 0, 482.5 }, { -4.4408921e-016, 682.5 } } }, |
| 54 {{{0,683}, {0,482}}}}, | 57 {{{0,683}, {0,482}}}}, |
| 55 | 58 |
| 56 {{{{1.77635684e-015,312}, {-1.24344979e-014,348}}}, | 59 {{{{1.77635684e-015,312}, {-1.24344979e-014,348}}}, |
| 57 {{{0,348}, {0,312}}}}, | 60 {{{0,348}, {0,312}}}}, |
| 58 | 61 |
| 59 {{{{979.304871, 561}, {1036.69507, 291}}}, | 62 {{{{979.304871, 561}, {1036.69507, 291}}}, |
| 60 {{{985.681519, 531}, {982.159790, 547.568542}}}}, | 63 {{{985.681519, 531}, {982.159790, 547.568542}}}}, |
| 61 | 64 |
| 62 {{{{232.159805, 547.568542}, {235.681549, 531}}}, | 65 {{{{232.159805, 547.568542}, {235.681549, 531}}}, |
| 63 {{{286.695129,291}, {229.304855,561}}}}, | 66 {{{286.695129,291}, {229.304855,561}}}}, |
| 64 | 67 |
| 65 {{{{186.3661956787109375f, 134.7042236328125f}, {187.8782806396484375f, 133.
7258148193359375f}}}, | 68 {{{{186.3661956787109375f, 134.7042236328125f}, {187.8782806396484375f, 133.
7258148193359375f}}}, |
| 66 {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 1
33.7258148193359375f}}}}, | 69 {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 1
33.7258148193359375f}}}}, |
| 67 | 70 |
| 68 {{{{235.681549, 531.000000}, {280.318420, 321.000000}}}, | 71 {{{{235.681549, 531.000000}, {280.318420, 321.000000}}}, |
| 69 {{{286.695129, 291.000000}, {229.304855, 561.000000}}}}, | 72 {{{286.695129, 291.000000}, {229.304855, 561.000000}}}}, |
| 70 }; | 73 }; |
| 71 | 74 |
| 72 static const size_t coincidentTests_count = SK_ARRAY_COUNT(coincidentTests); | 75 static const size_t coincidentTests_count = SK_ARRAY_COUNT(coincidentTests); |
| 73 | 76 |
| 74 static void check_results(skiatest::Reporter* reporter, const SkDLine& line1, co
nst SkDLine& line2, | 77 static void check_results(skiatest::Reporter* reporter, const SkDLine& line1, co
nst SkDLine& line2, |
| 75 const SkIntersections& ts) { | 78 const SkIntersections& ts) { |
| 76 for (int i = 0; i < ts.used(); ++i) { | 79 for (int i = 0; i < ts.used(); ++i) { |
| 77 SkDPoint result1 = line1.ptAtT(ts[0][i]); | 80 SkDPoint result1 = line1.ptAtT(ts[0][i]); |
| 78 SkDPoint result2 = line2.ptAtT(ts[1][i]); | 81 SkDPoint result2 = line2.ptAtT(ts[1][i]); |
| 79 if (!result1.approximatelyEqual(result2)) { | 82 if (!result1.approximatelyEqual(result2) && !ts.nearlySame(i)) { |
| 80 REPORTER_ASSERT(reporter, ts.used() != 1); | 83 REPORTER_ASSERT(reporter, ts.used() != 1); |
| 81 result2 = line2.ptAtT(ts[1][i ^ 1]); | 84 result2 = line2.ptAtT(ts[1][i ^ 1]); |
| 85 if (!result1.approximatelyEqual(result2)) { |
| 86 SkDebugf("."); |
| 87 } |
| 82 REPORTER_ASSERT(reporter, result1.approximatelyEqual(result2)); | 88 REPORTER_ASSERT(reporter, result1.approximatelyEqual(result2)); |
| 83 REPORTER_ASSERT(reporter, result1.approximatelyEqual(ts.pt(i).asSkPo
int())); | 89 REPORTER_ASSERT(reporter, result1.approximatelyEqual(ts.pt(i).asSkPo
int())); |
| 84 } | 90 } |
| 85 } | 91 } |
| 86 } | 92 } |
| 87 | 93 |
| 88 static void testOne(skiatest::Reporter* reporter, const SkDLine& line1, const Sk
DLine& line2) { | 94 static void testOne(skiatest::Reporter* reporter, const SkDLine& line1, const Sk
DLine& line2) { |
| 89 SkASSERT(ValidLine(line1)); | 95 SkASSERT(ValidLine(line1)); |
| 90 SkASSERT(ValidLine(line2)); | 96 SkASSERT(ValidLine(line2)); |
| 91 SkIntersections i; | 97 SkIntersections i; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 testOne(reporter, tests[1][0], tests[1][1]); | 214 testOne(reporter, tests[1][0], tests[1][1]); |
| 209 } | 215 } |
| 210 | 216 |
| 211 DEF_TEST(PathOpsLineIntersectionOneCoincident, reporter) { | 217 DEF_TEST(PathOpsLineIntersectionOneCoincident, reporter) { |
| 212 int index = 0; | 218 int index = 0; |
| 213 SkASSERT(index < (int) coincidentTests_count); | 219 SkASSERT(index < (int) coincidentTests_count); |
| 214 const SkDLine& line1 = coincidentTests[index][0]; | 220 const SkDLine& line1 = coincidentTests[index][0]; |
| 215 const SkDLine& line2 = coincidentTests[index][1]; | 221 const SkDLine& line2 = coincidentTests[index][1]; |
| 216 testOneCoincident(reporter, line1, line2); | 222 testOneCoincident(reporter, line1, line2); |
| 217 } | 223 } |
| OLD | NEW |