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" | |
10 #include "SkIntersections.h" | 9 #include "SkIntersections.h" |
11 #include "SkPathOpsRect.h" | 10 #include "SkPathOpsRect.h" |
12 #include "SkReduceOrder.h" | 11 #include "SkReduceOrder.h" |
13 #include "Test.h" | 12 #include "Test.h" |
14 | 13 |
15 const int firstCubicIntersectionTest = 9; | 14 const int firstCubicIntersectionTest = 9; |
16 | 15 |
17 static void standardTestCases(skiatest::Reporter* reporter) { | 16 static void standardTestCases(skiatest::Reporter* reporter) { |
18 for (size_t index = firstCubicIntersectionTest; index < tests_count; ++index
) { | 17 for (size_t index = firstCubicIntersectionTest; index < tests_count; ++index
) { |
19 int iIndex = static_cast<int>(index); | 18 int iIndex = static_cast<int>(index); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 155 |
157 {{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945}, | 156 {{{18.1312339, 31.6473732}, {95.5711034, 63.5350219}, {92.3283165, 62.0158945}, |
158 {18.5656052, 32.1268808}}}, | 157 {18.5656052, 32.1268808}}}, |
159 {{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981}, | 158 {{{97.402018, 35.7169972}, {33.1127443, 25.8935163}, {1.13970027, 54.9424981}, |
160 {56.4860195, 60.529264}}}, | 159 {56.4860195, 60.529264}}}, |
161 }; | 160 }; |
162 | 161 |
163 const int testSetCount = (int) SK_ARRAY_COUNT(testSet); | 162 const int testSetCount = (int) SK_ARRAY_COUNT(testSet); |
164 | 163 |
165 static const SkDCubic newTestSet[] = { | 164 static const SkDCubic newTestSet[] = { |
166 {{{980.026001,1481.276}, {980.026001,1481.276}, {980.02594,1481.27576}, {980.025
879,1481.27527}}}, | |
167 {{{980.025879,1481.27527}, {980.025452,1481.27222}, {980.023743,1481.26038}, {98
0.02179,1481.24072}}}, | |
168 | |
169 {{{1.80943513,3.07782435}, {1.66686702,2.16806936}, {1.68301272,0}, {3,0}}}, | |
170 {{{0,1}, {0,3}, {3,2}, {5,2}}}, | |
171 | |
172 {{{3.4386673,2.66977954}, {4.06668949,2.17046738}, {4.78887367,1.59629118}, {6,2
}}}, | |
173 {{{1.71985495,3.49467373}, {2.11620402,2.7201426}, {2.91897964,1.15138781}, {6,3
}}}, | |
174 | |
175 {{{0,1}, {0.392703831,1.78540766}, {0.219947904,2.05676103}, {0.218561709,2.0563
0541}}}, | |
176 {{{0.218561709,2.05630541}, {0.216418028,2.05560064}, {0.624105453,1.40486407},
{4.16666651,1.00000012}}}, | |
177 | |
178 {{{0, 1}, {3, 5}, {2, 1}, {3, 1}}}, | |
179 {{{1.01366711f, 2.21379328f}, {1.09074128f, 2.23241305f}, {1.60246587f, 0.451849
401f}, {5, 3}}}, | |
180 | |
181 {{{0, 1}, {0.541499972f, 3.16599989f}, {1.08299994f, 2.69299984f}, {2.10083938f,
1.80391729f}}}, | |
182 {{{0.806384504f, 2.85426903f}, {1.52740121f, 1.99355423f}, {2.81689167f, 0.45422
2918f}, {5, 1}}}, | |
183 | |
184 {{{0, 1}, {1.90192389f, 2.90192389f}, {2.59807634f, 2.79422879f}, {3.1076951f, 2
.71539044f}}}, | |
185 {{{2, 3}, {2.36602545f, 3.36602545f}, {2.330127f, 3.06217766f}, {2.28460979f, 2.
67691422f}}}, | |
186 | |
187 {{{0, 1}, {1.90192389f, 2.90192389f}, {2.59807634f, 2.79422879f}, {3.1076951f, 2
.71539044f}}}, | |
188 {{{2.28460979f, 2.67691422f}, {2.20577145f, 2.00961876f}, {2.09807634f, 1.098076
22f}, {4, 3}}}, | |
189 | |
190 {{{0, 1}, {0.8211091160774231, 2.0948121547698975}, {0.91805583238601685, 2.5154
04224395752}, {0.91621249914169312, 2.5146586894989014}}}, | |
191 {{{0.91621249914169312, 2.5146586894989014}, {0.91132104396820068, 2.51268076896
66748}, {0.21079301834106445, -0.45617169141769409}, {10.5, -1.6666665077209473}
}}, | |
192 | |
193 {{{42.6237564,68.9841232}, {32.449646,81.963089}, {14.7713947,103.565269}, {12.6
310005,105.247002}}}, | |
194 {{{37.2640038,95.3540039}, {37.2640038,95.3540039}, {11.3710003,83.7339935}, {-2
5.0779991,124.912003}}}, | |
195 | |
196 {{{0,1}, {4,5}, {6,0}, {1,0}}}, | |
197 {{{0,6}, {0,1}, {1,0}, {5,4}}}, | |
198 | |
199 {{{0,1}, {4,6}, {5,1}, {6,2}}}, | |
200 {{{1,5}, {2,6}, {1,0}, {6,4}}}, | |
201 | |
202 {{{322, 896.04803466796875}, {314.09201049804687, 833.4376220703125}, {260.24713
134765625, 785}, {195, 785}}}, | |
203 {{{195, 785}, {265.14016723632812, 785}, {322, 842.30755615234375}, {322, 913}}}
, | |
204 | |
205 {{{1, 4}, {4, 5}, {3, 2}, {6, 3}}}, | |
206 {{{2, 3}, {3, 6}, {4, 1}, {5, 4}}}, | |
207 | |
208 {{{67, 913}, {67, 917.388916015625}, {67.224380493164063, 921.72576904296875}, {
67.662384033203125, 926}}}, | |
209 {{{194, 1041}, {123.85984039306641, 1041}, {67, 983.69244384765625}, {67, 913}}}
, | |
210 | |
211 {{{1,4}, {1,5}, {6,0}, {5,1}}}, | |
212 {{{0,6}, {1,5}, {4,1}, {5,1}}}, | |
213 | |
214 {{{0,1}, {4,5}, {6,0}, {1,0}}}, | |
215 {{{0,6}, {0,1}, {1,0}, {5,4}}}, | |
216 | |
217 {{{0,1}, {4,6}, {2,0}, {2,0}}}, | |
218 {{{0,2}, {0,2}, {1,0}, {6,4}}}, | |
219 | |
220 {{{980.9000244140625, 1474.3280029296875}, {980.9000244140625, 1474.328002929687
5}, {978.89300537109375, 1471.95703125}, {981.791015625, 1469.487060546875}}}, | 165 {{{980.9000244140625, 1474.3280029296875}, {980.9000244140625, 1474.328002929687
5}, {978.89300537109375, 1471.95703125}, {981.791015625, 1469.487060546875}}}, |
221 {{{981.791015625, 1469.487060546875}, {981.791015625, 1469.4859619140625}, {983.
3580322265625, 1472.72900390625}, {980.9000244140625, 1474.3280029296875}}}, | 166 {{{981.791015625, 1469.487060546875}, {981.791015625, 1469.4859619140625}, {983.
3580322265625, 1472.72900390625}, {980.9000244140625, 1474.3280029296875}}}, |
222 | 167 |
223 {{{275,532}, {277.209137,532}, {279,530.209106}, {279,528}}}, | 168 {{{275,532}, {277.209137,532}, {279,530.209106}, {279,528}}}, |
224 {{{278,529}, {278,530.65686}, {276.65686,532}, {275,532}}}, | 169 {{{278,529}, {278,530.65686}, {276.65686,532}, {275,532}}}, |
225 | 170 |
226 #if 0 // FIXME: asserts coincidence, not working yet | 171 #if 0 // FIXME: asserts coincidence, not working yet |
227 {{{195, 785}, {124.30755615234375, 785}, {67, 841.85986328125}, {67, 912}}}, | 172 {{{195, 785}, {124.30755615234375, 785}, {67, 841.85986328125}, {67, 912}}}, |
228 {{{67, 913}, {67, 842.30755615234375}, {123.85984039306641, 785}, {194, 785}}}, | 173 {{{67, 913}, {67, 842.30755615234375}, {123.85984039306641, 785}, {194, 785}}}, |
229 #endif | 174 #endif |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 {{{0, 1}, {0, 1}, {2, 1}, {6, 5}}}, | 299 {{{0, 1}, {0, 1}, {2, 1}, {6, 5}}}, |
355 | 300 |
356 {{{0, 6}, {1, 2}, {1, 0}, {1, 0}}}, | 301 {{{0, 6}, {1, 2}, {1, 0}, {1, 0}}}, |
357 {{{0, 1}, {0, 1}, {6, 0}, {2, 1}}}, | 302 {{{0, 1}, {0, 1}, {6, 0}, {2, 1}}}, |
358 | 303 |
359 {{{0, 2}, {0, 1}, {3, 0}, {1, 0}}}, | 304 {{{0, 2}, {0, 1}, {3, 0}, {1, 0}}}, |
360 {{{0, 3}, {0, 1}, {2, 0}, {1, 0}}}, | 305 {{{0, 3}, {0, 1}, {2, 0}, {1, 0}}}, |
361 }; | 306 }; |
362 | 307 |
363 const int newTestSetCount = (int) SK_ARRAY_COUNT(newTestSet); | 308 const int newTestSetCount = (int) SK_ARRAY_COUNT(newTestSet); |
| 309 |
364 static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
kDCubic& cubic2, | 310 static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
kDCubic& cubic2, |
365 bool coin) { | 311 bool coin) { |
366 SkASSERT(ValidCubic(cubic1)); | 312 SkASSERT(ValidCubic(cubic1)); |
367 SkASSERT(ValidCubic(cubic2)); | 313 SkASSERT(ValidCubic(cubic2)); |
368 #if ONE_OFF_DEBUG | 314 #if ONE_OFF_DEBUG |
369 SkDebugf("computed quadratics given\n"); | 315 SkDebugf("computed quadratics given\n"); |
370 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n"
, | 316 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n"
, |
371 cubic1[0].fX, cubic1[0].fY, cubic1[1].fX, cubic1[1].fY, | 317 cubic1[0].fX, cubic1[0].fY, cubic1[1].fX, cubic1[1].fY, |
372 cubic1[2].fX, cubic1[2].fY, cubic1[3].fX, cubic1[3].fY); | 318 cubic1[2].fX, cubic1[2].fY, cubic1[3].fX, cubic1[3].fY); |
373 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n"
, | 319 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n"
, |
374 cubic2[0].fX, cubic2[0].fY, cubic2[1].fX, cubic2[1].fY, | 320 cubic2[0].fX, cubic2[0].fY, cubic2[1].fX, cubic2[1].fY, |
375 cubic2[2].fX, cubic2[2].fY, cubic2[3].fX, cubic2[3].fY); | 321 cubic2[2].fX, cubic2[2].fY, cubic2[3].fX, cubic2[3].fY); |
376 #endif | 322 #endif |
377 #if DEBUG_T_SECT_DUMP > 1 | 323 SkTArray<SkDQuad, true> quads1; |
378 gDumpTSectNum = 0; | 324 CubicToQuads(cubic1, cubic1.calcPrecision(), quads1); |
| 325 #if ONE_OFF_DEBUG |
| 326 SkDebugf("computed quadratics set 1\n"); |
| 327 for (int index = 0; index < quads1.count(); ++index) { |
| 328 const SkDQuad& q = quads1[index]; |
| 329 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX,
q[0].fY, |
| 330 q[1].fX, q[1].fY, q[2].fX, q[2].fY); |
| 331 } |
| 332 #endif |
| 333 SkTArray<SkDQuad, true> quads2; |
| 334 CubicToQuads(cubic2, cubic2.calcPrecision(), quads2); |
| 335 #if ONE_OFF_DEBUG |
| 336 SkDebugf("computed quadratics set 2\n"); |
| 337 for (int index = 0; index < quads2.count(); ++index) { |
| 338 const SkDQuad& q = quads2[index]; |
| 339 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX,
q[0].fY, |
| 340 q[1].fX, q[1].fY, q[2].fX, q[2].fY); |
| 341 } |
379 #endif | 342 #endif |
380 SkIntersections intersections; | 343 SkIntersections intersections; |
381 intersections.intersect(cubic1, cubic2); | 344 intersections.intersect(cubic1, cubic2); |
382 #if DEBUG_T_SECT_DUMP == 3 | |
383 SkDebugf("</div>\n\n"); | |
384 SkDebugf("<script type=\"text/javascript\">\n\n"); | |
385 SkDebugf("var testDivs = [\n"); | |
386 for (int index = 1; index <= gDumpTSectNum; ++index) { | |
387 SkDebugf("sect%d,\n", index); | |
388 } | |
389 #endif | |
390 if (coin && intersections.used() != 2) { | |
391 SkDebugf(""); | |
392 } | |
393 REPORTER_ASSERT(reporter, !coin || intersections.used() == 2); | 345 REPORTER_ASSERT(reporter, !coin || intersections.used() == 2); |
394 double tt1, tt2; | 346 double tt1, tt2; |
395 SkDPoint xy1, xy2; | 347 SkDPoint xy1, xy2; |
396 for (int pt3 = 0; pt3 < intersections.used(); ++pt3) { | 348 for (int pt3 = 0; pt3 < intersections.used(); ++pt3) { |
397 tt1 = intersections[0][pt3]; | 349 tt1 = intersections[0][pt3]; |
398 xy1 = cubic1.ptAtT(tt1); | 350 xy1 = cubic1.ptAtT(tt1); |
399 tt2 = intersections[1][pt3]; | 351 tt2 = intersections[1][pt3]; |
400 xy2 = cubic2.ptAtT(tt2); | 352 xy2 = cubic2.ptAtT(tt2); |
401 const SkDPoint& iPt = intersections.pt(pt3); | 353 const SkDPoint& iPt = intersections.pt(pt3); |
402 #if ONE_OFF_DEBUG | 354 #if ONE_OFF_DEBUG |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}}, | 551 {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}}, |
600 {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}}, | 552 {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}}, |
601 {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}}, | 553 {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}}, |
602 {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}}, | 554 {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}}, |
603 }; | 555 }; |
604 | 556 |
605 int selfSetCount = (int) SK_ARRAY_COUNT(selfSet); | 557 int selfSetCount = (int) SK_ARRAY_COUNT(selfSet); |
606 | 558 |
607 static void selfOneOff(skiatest::Reporter* reporter, int index) { | 559 static void selfOneOff(skiatest::Reporter* reporter, int index) { |
608 const SkDCubic& cubic = selfSet[index]; | 560 const SkDCubic& cubic = selfSet[index]; |
609 SkPoint c[4]; | 561 #if ONE_OFF_DEBUG |
610 for (int i = 0; i < 4; ++i) { | 562 int idx2; |
611 c[i] = cubic[i].asSkPoint(); | 563 double max[3]; |
| 564 int ts = cubic.findMaxCurvature(max); |
| 565 for (idx2 = 0; idx2 < ts; ++idx2) { |
| 566 SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2, |
| 567 max[idx2], cubic.ptAtT(max[idx2]).fX, cubic.ptAtT(max[idx2]).fY)
; |
612 } | 568 } |
613 SkScalar loopT; | 569 SkTArray<double, true> ts1; |
614 SkScalar d[3]; | 570 SkTArray<SkDQuad, true> quads1; |
615 SkCubicType cubicType = SkClassifyCubic(c, d); | 571 cubic.toQuadraticTs(cubic.calcPrecision(), &ts1); |
616 if (SkDCubic::ComplexBreak(c, &loopT) && cubicType == SkCubicType::kLoop_SkC
ubicType) { | 572 for (idx2 = 0; idx2 < ts1.count(); ++idx2) { |
617 SkIntersections i; | 573 SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]); |
618 SkPoint twoCubics[7]; | |
619 SkChopCubicAt(c, twoCubics, loopT); | |
620 SkDCubic chopped[2]; | |
621 chopped[0].set(&twoCubics[0]); | |
622 chopped[1].set(&twoCubics[3]); | |
623 int result = i.intersect(chopped[0], chopped[1]); | |
624 REPORTER_ASSERT(reporter, result == 2); | |
625 REPORTER_ASSERT(reporter, i.used() == 2); | |
626 for (int index = 0; index < result; ++index) { | |
627 SkDPoint pt1 = chopped[0].ptAtT(i[0][index]); | |
628 SkDPoint pt2 = chopped[1].ptAtT(i[1][index]); | |
629 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); | |
630 reporter->bumpTestCount(); | |
631 } | |
632 } | 574 } |
| 575 CubicToQuads(cubic, cubic.calcPrecision(), quads1); |
| 576 for (idx2 = 0; idx2 < quads1.count(); ++idx2) { |
| 577 const SkDQuad& q = quads1[idx2]; |
| 578 SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n", |
| 579 q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY); |
| 580 } |
| 581 SkDebugf("\n"); |
| 582 #endif |
| 583 SkIntersections i; |
| 584 int result = i.intersect(cubic); |
| 585 REPORTER_ASSERT(reporter, result == 1); |
| 586 REPORTER_ASSERT(reporter, i.used() == 1); |
| 587 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0])); |
| 588 SkDPoint pt1 = cubic.ptAtT(i[0][0]); |
| 589 SkDPoint pt2 = cubic.ptAtT(i[1][0]); |
| 590 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); |
| 591 reporter->bumpTestCount(); |
633 } | 592 } |
634 | 593 |
635 static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) { | 594 static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) { |
636 int firstFail = 0; | 595 int firstFail = 0; |
637 for (int index = firstFail; index < selfSetCount; ++index) { | 596 for (int index = firstFail; index < selfSetCount; ++index) { |
638 selfOneOff(reporter, index); | 597 selfOneOff(reporter, index); |
639 } | 598 } |
640 } | 599 } |
641 | 600 |
642 static const SkDCubic coinSet[] = { | 601 static const SkDCubic coinSet[] = { |
643 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, | |
644 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, | |
645 | |
646 {{{317, 711}, {322.52285766601562, 711}, {327, 715.4771728515625}, {327, 721
}}}, | 602 {{{317, 711}, {322.52285766601562, 711}, {327, 715.4771728515625}, {327, 721
}}}, |
647 {{{324.07107543945312, 713.928955078125}, {324.4051513671875, 714.2630004882
8125}, | 603 {{{324.07107543945312, 713.928955078125}, {324.4051513671875, 714.2630004882
8125}, |
648 {324.71566772460937, 714.62060546875}, {325, 714.9990234375}}}, | 604 {324.71566772460937, 714.62060546875}, {325, 714.9990234375}}}, |
| 605 |
| 606 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, |
| 607 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, |
649 }; | 608 }; |
650 | 609 |
651 static int coinSetCount = (int) SK_ARRAY_COUNT(coinSet); | 610 static int coinSetCount = (int) SK_ARRAY_COUNT(coinSet); |
652 | 611 |
653 static void coinOneOff(skiatest::Reporter* reporter, int index) { | 612 static void coinOneOff(skiatest::Reporter* reporter, int index) { |
654 const SkDCubic& cubic1 = coinSet[index]; | 613 const SkDCubic& cubic1 = coinSet[index]; |
655 const SkDCubic& cubic2 = coinSet[index + 1]; | 614 const SkDCubic& cubic2 = coinSet[index + 1]; |
656 oneOff(reporter, cubic1, cubic2, true); | 615 oneOff(reporter, cubic1, cubic2, true); |
657 } | 616 } |
658 | 617 |
(...skipping 17 matching lines...) Expand all Loading... |
676 } | 635 } |
677 | 636 |
678 DEF_TEST(PathOpsCubicIntersection, reporter) { | 637 DEF_TEST(PathOpsCubicIntersection, reporter) { |
679 oneOffTests(reporter); | 638 oneOffTests(reporter); |
680 cubicIntersectionSelfTest(reporter); | 639 cubicIntersectionSelfTest(reporter); |
681 cubicIntersectionCoinTest(reporter); | 640 cubicIntersectionCoinTest(reporter); |
682 standardTestCases(reporter); | 641 standardTestCases(reporter); |
683 if (false) CubicIntersection_IntersectionFinder(); | 642 if (false) CubicIntersection_IntersectionFinder(); |
684 if (false) CubicIntersection_RandTest(reporter); | 643 if (false) CubicIntersection_RandTest(reporter); |
685 } | 644 } |
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 |