| 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 "SkIntersections.h" | 9 #include "SkIntersections.h" |
| 10 #include "SkPathOpsRect.h" | 10 #include "SkPathOpsRect.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 {{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945}, | 157 {{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945}, |
| 158 {18.5656052, 32.1268808}}}, | 158 {18.5656052, 32.1268808}}}, |
| 159 {{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981}, | 159 {{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981}, |
| 160 {56.4860195, 60.529264}}}, | 160 {56.4860195, 60.529264}}}, |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 const size_t testSetCount = SK_ARRAY_COUNT(testSet); | 163 const size_t testSetCount = SK_ARRAY_COUNT(testSet); |
| 164 | 164 |
| 165 static const SkDCubic newTestSet[] = { | 165 static const SkDCubic newTestSet[] = { |
| 166 {{{1.0516976506771041, 2.9684399028541346 }, |
| 167 {1.0604363140895228, 2.9633503074444141 }, |
| 168 {1.0692548215065762, 2.9580354426587459 }, |
| 169 {1.0781560339512140, 2.9525043684031349 }}}, |
| 170 |
| 171 {{{1.0523038101345104, 2.9523755204833737 }, |
| 172 {1.0607035288264237, 2.9580853881628375 }, |
| 173 {1.0690530472271964, 2.9633896794787749 }, |
| 174 {1.0773566568712512, 2.9682969775000219 }}}, |
| 175 |
| 176 {{{1.0386522625066592, 2.9759024812329078 }, |
| 177 {1.0559713690392631, 2.9661782500838885 }, |
| 178 {1.0736041309019990, 2.9555348259177858 }, |
| 179 {1.0915734362784633, 2.9440446879826569 }}}, |
| 180 |
| 181 {{{1.0396670794879301, 2.9435062123457261 }, |
| 182 {1.0565690546812769, 2.9557413250983462 }, |
| 183 {1.0732616463413533, 2.9663369676594282 }, |
| 184 {1.0897791867435489, 2.9753618045797472 }}}, |
| 185 |
| 186 {{{0.8685656183311091, 3.0409266475785208 }, |
| 187 {0.99189542936395292, 3.0212163698184424 }, |
| 188 {1.1302108367493320, 2.9265646471747306 }, |
| 189 {1.2952305904872474, 2.7940808546473788 }}}, |
| 190 |
| 191 {{{0.85437872843682727, 2.7536036928549055 }, |
| 192 {1.0045584590592620, 2.9493041024831705 }, |
| 193 {1.1336998329885613, 3.0248027987251747 }, |
| 194 {1.2593809752247314, 3.0152560315809107 }}}, |
| 195 |
| 196 {{{0, 1}, {1, 6}, {1, 0}, {6, 2}}}, |
| 197 {{{0, 1}, {2, 6}, {1, 0}, {6, 1}}}, |
| 198 |
| 166 {{{134,11414}, {131.990234375,11414}, {130.32666015625,11415.482421875}, {130.04
275512695312,11417.4130859375}}}, | 199 {{{134,11414}, {131.990234375,11414}, {130.32666015625,11415.482421875}, {130.04
275512695312,11417.4130859375}}}, |
| 167 {{{132,11419}, {130.89543151855469,11419}, {130,11418.1044921875}, {130,11417}}}
, | 200 {{{132,11419}, {130.89543151855469,11419}, {130,11418.1044921875}, {130,11417}}}
, |
| 168 | 201 |
| 169 {{{132,11419}, {130.89543151855469,11419}, {130,11418.1044921875}, {130,11417}}}
, | 202 {{{132,11419}, {130.89543151855469,11419}, {130,11418.1044921875}, {130,11417}}}
, |
| 170 {{{130.04275512695312,11417.4130859375}, {130.23312377929687,11418.3193359375},
{131.03707885742187,11419}, {132,11419}}}, | 203 {{{130.04275512695312,11417.4130859375}, {130.23312377929687,11418.3193359375},
{131.03707885742187,11419}, {132,11419}}}, |
| 171 | 204 |
| 172 {{{0, 1}, {2, 3}, {5, 1}, {4, 3}}}, | 205 {{{0, 1}, {2, 3}, {5, 1}, {4, 3}}}, |
| 173 {{{1, 5}, {3, 4}, {1, 0}, {3, 2}}}, | 206 {{{1, 5}, {3, 4}, {1, 0}, {3, 2}}}, |
| 174 | 207 |
| 175 {{{3, 5}, {1, 6}, {5, 0}, {3, 1}}}, | 208 {{{3, 5}, {1, 6}, {5, 0}, {3, 1}}}, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 const SkDCubic& cubic2 = testSet[inner]; | 323 const SkDCubic& cubic2 = testSet[inner]; |
| 291 oneOff(reporter, cubic1, cubic2); | 324 oneOff(reporter, cubic1, cubic2); |
| 292 } | 325 } |
| 293 | 326 |
| 294 static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) { | 327 static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) { |
| 295 const SkDCubic& cubic1 = newTestSet[outer]; | 328 const SkDCubic& cubic1 = newTestSet[outer]; |
| 296 const SkDCubic& cubic2 = newTestSet[inner]; | 329 const SkDCubic& cubic2 = newTestSet[inner]; |
| 297 oneOff(reporter, cubic1, cubic2); | 330 oneOff(reporter, cubic1, cubic2); |
| 298 } | 331 } |
| 299 | 332 |
| 300 static void oneOffTest(skiatest::Reporter* reporter) { | |
| 301 newOneOff(reporter, 0, 1); | |
| 302 oneOff(reporter, 14, 16); | |
| 303 } | |
| 304 | |
| 305 static void oneOffTests(skiatest::Reporter* reporter) { | 333 static void oneOffTests(skiatest::Reporter* reporter) { |
| 306 for (size_t outer = 0; outer < testSetCount - 1; ++outer) { | 334 for (size_t outer = 0; outer < testSetCount - 1; ++outer) { |
| 307 for (size_t inner = outer + 1; inner < testSetCount; ++inner) { | 335 for (size_t inner = outer + 1; inner < testSetCount; ++inner) { |
| 308 oneOff(reporter, outer, inner); | 336 oneOff(reporter, outer, inner); |
| 309 } | 337 } |
| 310 } | 338 } |
| 311 for (size_t outer = 0; outer < newTestSetCount - 1; ++outer) { | 339 for (size_t outer = 0; outer < newTestSetCount - 1; ++outer) { |
| 312 for (size_t inner = outer + 1; inner < newTestSetCount; ++inner) { | 340 for (size_t inner = outer + 1; inner < newTestSetCount; ++inner) { |
| 313 oneOff(reporter, outer, inner); | 341 oneOff(reporter, outer, inner); |
| 314 } | 342 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 int result = i.intersect(cubic); | 536 int result = i.intersect(cubic); |
| 509 REPORTER_ASSERT(reporter, result == 1); | 537 REPORTER_ASSERT(reporter, result == 1); |
| 510 REPORTER_ASSERT(reporter, i.used() == 1); | 538 REPORTER_ASSERT(reporter, i.used() == 1); |
| 511 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0])); | 539 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0])); |
| 512 SkDPoint pt1 = cubic.xyAtT(i[0][0]); | 540 SkDPoint pt1 = cubic.xyAtT(i[0][0]); |
| 513 SkDPoint pt2 = cubic.xyAtT(i[1][0]); | 541 SkDPoint pt2 = cubic.xyAtT(i[1][0]); |
| 514 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); | 542 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); |
| 515 } | 543 } |
| 516 } | 544 } |
| 517 | 545 |
| 546 static void PathOpsCubicIntersectionOneOffTest(skiatest::Reporter* reporter) { |
| 547 newOneOff(reporter, 6, 7); |
| 548 } |
| 549 |
| 518 static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) { | 550 static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) { |
| 519 oneOffTest(reporter); | |
| 520 oneOffTests(reporter); | 551 oneOffTests(reporter); |
| 521 cubicIntersectionSelfTest(reporter); | 552 cubicIntersectionSelfTest(reporter); |
| 522 standardTestCases(reporter); | 553 standardTestCases(reporter); |
| 523 if (false) CubicIntersection_IntersectionFinder(); | 554 if (false) CubicIntersection_IntersectionFinder(); |
| 524 if (false) CubicIntersection_RandTest(reporter); | 555 if (false) CubicIntersection_RandTest(reporter); |
| 525 } | 556 } |
| 526 | 557 |
| 527 #include "TestClassDef.h" | 558 #include "TestClassDef.h" |
| 528 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest) | 559 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest) |
| 560 |
| 561 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest) |
| OLD | NEW |