Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: tests/PathOpsCubicIntersectionTest.cpp

Issue 131103009: update pathops to circle sort (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: disable old test that still fails on linux 32 release Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PathOpsAngleTest.cpp ('k') | tests/PathOpsCubicLineIntersectionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 {35.597065061143162, 79.872482633158796}, {75.38634169631932, 18.2448900 38969412}}}, 152 {35.597065061143162, 79.872482633158796}, {75.38634169631932, 18.2448900 38969412}}},
153 {{{61.336508189019057, 82.693132843213675}, {44.639380902349664, 54.074825790745 592}, 153 {{{61.336508189019057, 82.693132843213675}, {44.639380902349664, 54.074825790745 592},
154 {16.815615499771951, 20.049704667203923}, {41.866884958868326, 56.735503 699973002}}}, 154 {16.815615499771951, 20.049704667203923}, {41.866884958868326, 56.735503 699973002}}},
155 155
156 {{{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},
157 {18.5656052, 32.1268808}}}, 157 {18.5656052, 32.1268808}}},
158 {{{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},
159 {56.4860195, 60.529264}}}, 159 {56.4860195, 60.529264}}},
160 }; 160 };
161 161
162 const size_t testSetCount = SK_ARRAY_COUNT(testSet); 162 const int testSetCount = (int) SK_ARRAY_COUNT(testSet);
163 163
164 static const SkDCubic newTestSet[] = { 164 static const SkDCubic newTestSet[] = {
165 {{{275,532}, {277.209137,532}, {279,530.209106}, {279,528}}}, 165 {{{275,532}, {277.209137,532}, {279,530.209106}, {279,528}}},
166 {{{278,529}, {278,530.65686}, {276.65686,532}, {275,532}}}, 166 {{{278,529}, {278,530.65686}, {276.65686,532}, {275,532}}},
167 167
168 #if 0 // FIXME: asserts coincidence, not working yet 168 #if 0 // FIXME: asserts coincidence, not working yet
169 {{{195, 785}, {124.30755615234375, 785}, {67, 841.85986328125}, {67, 912}}}, 169 {{{195, 785}, {124.30755615234375, 785}, {67, 841.85986328125}, {67, 912}}},
170 {{{67, 913}, {67, 842.30755615234375}, {123.85984039306641, 785}, {194, 785}}}, 170 {{{67, 913}, {67, 842.30755615234375}, {123.85984039306641, 785}, {194, 785}}},
171 #endif 171 #endif
172 172
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 {{{1, 2}, {5, 6}, {1, 0}, {1, 0}}}, 295 {{{1, 2}, {5, 6}, {1, 0}, {1, 0}}},
296 {{{0, 1}, {0, 1}, {2, 1}, {6, 5}}}, 296 {{{0, 1}, {0, 1}, {2, 1}, {6, 5}}},
297 297
298 {{{0, 6}, {1, 2}, {1, 0}, {1, 0}}}, 298 {{{0, 6}, {1, 2}, {1, 0}, {1, 0}}},
299 {{{0, 1}, {0, 1}, {6, 0}, {2, 1}}}, 299 {{{0, 1}, {0, 1}, {6, 0}, {2, 1}}},
300 300
301 {{{0, 2}, {0, 1}, {3, 0}, {1, 0}}}, 301 {{{0, 2}, {0, 1}, {3, 0}, {1, 0}}},
302 {{{0, 3}, {0, 1}, {2, 0}, {1, 0}}}, 302 {{{0, 3}, {0, 1}, {2, 0}, {1, 0}}},
303 }; 303 };
304 304
305 const size_t newTestSetCount = SK_ARRAY_COUNT(newTestSet); 305 const int newTestSetCount = (int) SK_ARRAY_COUNT(newTestSet);
306 306
307 static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S kDCubic& cubic2, 307 static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S kDCubic& cubic2,
308 bool coin) { 308 bool coin) {
309 SkASSERT(ValidCubic(cubic1)); 309 SkASSERT(ValidCubic(cubic1));
310 SkASSERT(ValidCubic(cubic2)); 310 SkASSERT(ValidCubic(cubic2));
311 #if ONE_OFF_DEBUG 311 #if ONE_OFF_DEBUG
312 SkDebugf("computed quadratics given\n"); 312 SkDebugf("computed quadratics given\n");
313 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n" , 313 SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n" ,
314 cubic1[0].fX, cubic1[0].fY, cubic1[1].fX, cubic1[1].fY, 314 cubic1[0].fX, cubic1[0].fY, cubic1[1].fX, cubic1[1].fY,
315 cubic1[2].fX, cubic1[2].fY, cubic1[3].fX, cubic1[3].fY); 315 cubic1[2].fX, cubic1[2].fY, cubic1[3].fX, cubic1[3].fY);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 oneOff(reporter, cubic1, cubic2, false); 366 oneOff(reporter, cubic1, cubic2, false);
367 } 367 }
368 368
369 static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) { 369 static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) {
370 const SkDCubic& cubic1 = newTestSet[outer]; 370 const SkDCubic& cubic1 = newTestSet[outer];
371 const SkDCubic& cubic2 = newTestSet[inner]; 371 const SkDCubic& cubic2 = newTestSet[inner];
372 oneOff(reporter, cubic1, cubic2, false); 372 oneOff(reporter, cubic1, cubic2, false);
373 } 373 }
374 374
375 static void oneOffTests(skiatest::Reporter* reporter) { 375 static void oneOffTests(skiatest::Reporter* reporter) {
376 for (size_t outer = 0; outer < testSetCount - 1; ++outer) { 376 for (int outer = 0; outer < testSetCount - 1; ++outer) {
377 for (size_t inner = outer + 1; inner < testSetCount; ++inner) { 377 for (int inner = outer + 1; inner < testSetCount; ++inner) {
378 oneOff(reporter, outer, inner); 378 oneOff(reporter, outer, inner);
379 } 379 }
380 } 380 }
381 for (size_t outer = 0; outer < newTestSetCount - 1; ++outer) { 381 for (int outer = 0; outer < newTestSetCount - 1; ++outer) {
382 for (size_t inner = outer + 1; inner < newTestSetCount; ++inner) { 382 for (int inner = outer + 1; inner < newTestSetCount; ++inner) {
383 newOneOff(reporter, outer, inner); 383 newOneOff(reporter, outer, inner);
384 } 384 }
385 } 385 }
386 } 386 }
387 387
388 #define DEBUG_CRASH 0 388 #define DEBUG_CRASH 0
389 389
390 static void CubicIntersection_RandTest(skiatest::Reporter* reporter) { 390 static void CubicIntersection_RandTest(skiatest::Reporter* reporter) {
391 srand(0); 391 srand(0);
392 const int tests = 10000000; 392 const int tests = 10000000;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 static const SkDCubic selfSet[] = { 543 static const SkDCubic selfSet[] = {
544 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, 544 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
545 {{{3, 6}, {2, 3}, {4, 0}, {3, 2}}}, 545 {{{3, 6}, {2, 3}, {4, 0}, {3, 2}}},
546 {{{0, 2}, {2, 3}, {5, 1}, {3, 2}}}, 546 {{{0, 2}, {2, 3}, {5, 1}, {3, 2}}},
547 {{{0, 2}, {3, 5}, {5, 0}, {4, 2}}}, 547 {{{0, 2}, {3, 5}, {5, 0}, {4, 2}}},
548 {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}}, 548 {{{3.34, 8.98}, {1.95, 10.27}, {3.76, 7.65}, {4.96, 10.64}}},
549 {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}}, 549 {{{3.13, 2.74}, {1.08, 4.62}, {3.71, 0.94}, {2.01, 3.81}}},
550 {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}}, 550 {{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}},
551 {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}}, 551 {{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}},
552 }; 552 };
553 size_t selfSetCount = SK_ARRAY_COUNT(selfSet); 553
554 int selfSetCount = (int) SK_ARRAY_COUNT(selfSet);
554 555
555 static void selfOneOff(skiatest::Reporter* reporter, int index) { 556 static void selfOneOff(skiatest::Reporter* reporter, int index) {
556 const SkDCubic& cubic = selfSet[index]; 557 const SkDCubic& cubic = selfSet[index];
557 #if ONE_OFF_DEBUG 558 #if ONE_OFF_DEBUG
558 int idx2; 559 int idx2;
559 double max[3]; 560 double max[3];
560 int ts = cubic.findMaxCurvature(max); 561 int ts = cubic.findMaxCurvature(max);
561 for (idx2 = 0; idx2 < ts; ++idx2) { 562 for (idx2 = 0; idx2 < ts; ++idx2) {
562 SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2, 563 SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
563 max[idx2], cubic.ptAtT(max[idx2]).fX, cubic.ptAtT(max[idx2]).fY) ; 564 max[idx2], cubic.ptAtT(max[idx2]).fX, cubic.ptAtT(max[idx2]).fY) ;
(...skipping 17 matching lines...) Expand all
581 REPORTER_ASSERT(reporter, result == 1); 582 REPORTER_ASSERT(reporter, result == 1);
582 REPORTER_ASSERT(reporter, i.used() == 1); 583 REPORTER_ASSERT(reporter, i.used() == 1);
583 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0])); 584 REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0]));
584 SkDPoint pt1 = cubic.ptAtT(i[0][0]); 585 SkDPoint pt1 = cubic.ptAtT(i[0][0]);
585 SkDPoint pt2 = cubic.ptAtT(i[1][0]); 586 SkDPoint pt2 = cubic.ptAtT(i[1][0]);
586 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); 587 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
587 reporter->bumpTestCount(); 588 reporter->bumpTestCount();
588 } 589 }
589 590
590 static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) { 591 static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
591 size_t firstFail = 0; 592 int firstFail = 0;
592 for (size_t index = firstFail; index < selfSetCount; ++index) { 593 for (int index = firstFail; index < selfSetCount; ++index) {
593 selfOneOff(reporter, index); 594 selfOneOff(reporter, index);
594 } 595 }
595 } 596 }
596 597
597 static const SkDCubic coinSet[] = { 598 static const SkDCubic coinSet[] = {
598 {{{317, 711}, {322.52285766601562, 711}, {327, 715.4771728515625}, {327, 721 }}}, 599 {{{317, 711}, {322.52285766601562, 711}, {327, 715.4771728515625}, {327, 721 }}},
599 {{{324.07107543945312, 713.928955078125}, {324.4051513671875, 714.2630004882 8125}, 600 {{{324.07107543945312, 713.928955078125}, {324.4051513671875, 714.2630004882 8125},
600 {324.71566772460937, 714.62060546875}, {325, 714.9990234375}}}, 601 {324.71566772460937, 714.62060546875}, {325, 714.9990234375}}},
601 602
602 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, 603 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
603 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, 604 {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
604 }; 605 };
605 606
606 size_t coinSetCount = SK_ARRAY_COUNT(coinSet); 607 static int coinSetCount = (int) SK_ARRAY_COUNT(coinSet);
607 608
608 static void coinOneOff(skiatest::Reporter* reporter, int index) { 609 static void coinOneOff(skiatest::Reporter* reporter, int index) {
609 const SkDCubic& cubic1 = coinSet[index]; 610 const SkDCubic& cubic1 = coinSet[index];
610 const SkDCubic& cubic2 = coinSet[index + 1]; 611 const SkDCubic& cubic2 = coinSet[index + 1];
611 oneOff(reporter, cubic1, cubic2, true); 612 oneOff(reporter, cubic1, cubic2, true);
612 } 613 }
613 614
614 static void cubicIntersectionCoinTest(skiatest::Reporter* reporter) { 615 static void cubicIntersectionCoinTest(skiatest::Reporter* reporter) {
615 size_t firstFail = 0; 616 int firstFail = 0;
616 for (size_t index = firstFail; index < coinSetCount; index += 2) { 617 for (int index = firstFail; index < coinSetCount; index += 2) {
617 coinOneOff(reporter, index); 618 coinOneOff(reporter, index);
618 } 619 }
619 } 620 }
620 621
621 DEF_TEST(PathOpsCubicCoinOneOff, reporter) { 622 DEF_TEST(PathOpsCubicCoinOneOff, reporter) {
622 coinOneOff(reporter, 0); 623 coinOneOff(reporter, 0);
623 } 624 }
624 625
625 DEF_TEST(PathOpsCubicIntersectionOneOff, reporter) { 626 DEF_TEST(PathOpsCubicIntersectionOneOff, reporter) {
626 newOneOff(reporter, 0, 1); 627 newOneOff(reporter, 0, 1);
627 } 628 }
628 629
629 DEF_TEST(PathOpsCubicSelfOneOff, reporter) { 630 DEF_TEST(PathOpsCubicSelfOneOff, reporter) {
630 selfOneOff(reporter, 0); 631 selfOneOff(reporter, 0);
631 } 632 }
632 633
633 DEF_TEST(PathOpsCubicIntersection, reporter) { 634 DEF_TEST(PathOpsCubicIntersection, reporter) {
634 oneOffTests(reporter); 635 oneOffTests(reporter);
635 cubicIntersectionSelfTest(reporter); 636 cubicIntersectionSelfTest(reporter);
636 cubicIntersectionCoinTest(reporter); 637 cubicIntersectionCoinTest(reporter);
637 standardTestCases(reporter); 638 standardTestCases(reporter);
638 if (false) CubicIntersection_IntersectionFinder(); 639 if (false) CubicIntersection_IntersectionFinder();
639 if (false) CubicIntersection_RandTest(reporter); 640 if (false) CubicIntersection_RandTest(reporter);
640 } 641 }
OLDNEW
« no previous file with comments | « tests/PathOpsAngleTest.cpp ('k') | tests/PathOpsCubicLineIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698