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

Side by Side Diff: tests/PathOpsQuadIntersectionTest.cpp

Issue 1029993002: Revert of pathops version two (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/PathOpsOpTest.cpp ('k') | tests/PathOpsQuadIntersectionTestData.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 "PathOpsQuadIntersectionTestData.h" 7 #include "PathOpsQuadIntersectionTestData.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 tt2, xy2.fX, xy2.fY); 46 tt2, xy2.fX, xy2.fY);
47 REPORTER_ASSERT(reporter, 0); 47 REPORTER_ASSERT(reporter, 0);
48 } 48 }
49 } 49 }
50 } 50 }
51 } 51 }
52 } 52 }
53 } 53 }
54 54
55 static const SkDQuad testSet[] = { 55 static const SkDQuad testSet[] = {
56 {{{4981.9990234375, 1590}, {4981.9990234375, 1617.7523193359375}, {4962.375, 163 7.3760986328125}}},
57 {{{4962.3759765625, 1637.3760986328125}, {4982, 1617.7523193359375}, {4982, 1590 }}},
58
59 {{{48.7416f, 7.74160004f}, {96.4831848f, -40}, {164, -40}}},
60 {{{56.9671326f, 0}, {52.7835083f, 3.69968891f}, {48.7416f, 7.74160004f}}},
61
62 {{{138, 80}, {147.15692138671875, 80}, {155.12803649902344, 82.86279296875}}},
63 {{{155.12803649902344, 82.86279296875}, {153.14971923828125, 82.152290344238281} , {151.09841918945312, 81.618133544921875}}},
64
65 {{{88, 130}, {88, 131.54483032226562}, {88.081489562988281, 133.0560302734375}}} ,
66 {{{88.081489562988281, 133.0560302734375}, {88, 131.54483032226562}, {88, 130}}} ,
67
68 {{{0.59987992,2.14448452}, {0.775417507,1.95606446}, {1.00564098,1.79310346}}},
69 {{{1.00564098,1.79310346}, {1.25936198,1.615623}, {1.35901463,1.46834028}}},
70
71 {{{3,0}, {0,1}, {3,2}}},
72 {{{2,0}, {1,1}, {2,2}}},
73
74 {{{38.656852722167969, 38.656852722167969}, {38.651023864746094, 38.662681579589 844}, {38.644744873046875, 38.668937683105469}}},
75 {{{38.656852722167969, 38.656852722167969}, {36.313709259033203, 41}, {33, 41}}} ,
76
77 {{{4914.9990234375, 1523}, {4942.75146484375, 1523}, {4962.375, 1542.62390136718 75}}},
78 {{{4962.3759765625, 1542.6239013671875}, {4942.75244140625, 1523}, {4915, 1523}} },
79
80 {{{4867.623046875, 1637.3760986328125}, {4847.9990234375, 1617.7523193359375}, { 4847.9990234375, 1590}}},
81 {{{4848, 1590}, {4848, 1617.7523193359375}, {4867.6240234375, 1637.3760986328125 }}},
82
83 {{{102.64466094970703, 165.3553466796875}, {110.79246520996094, 173.503143310546 87}, {120.81797790527344, 177.11778259277344}}},
84 {{{113.232177734375, 173.57899475097656}, {116.88026428222656, 175.6980590820312 5}, {120.81797790527344, 177.11778259277344}}},
85
86 {{{-37.3484879,10.0192947}, {-36.4966316,13.2140198}, {-38.1506348,16.0788383}}} , 56 {{{-37.3484879,10.0192947}, {-36.4966316,13.2140198}, {-38.1506348,16.0788383}}} ,
87 {{{-38.1462746,16.08918}, {-36.4904327,13.2193804}, {-37.3484879,10.0192947}}}, 57 {{{-38.1462746,16.08918}, {-36.4904327,13.2193804}, {-37.3484879,10.0192947}}},
88 58
89 {{{-37.3513985,10.0082998}, {-36.4938011,13.2090998}, {-38.1506004,16.0788002}}} , 59 {{{-37.3513985,10.0082998}, {-36.4938011,13.2090998}, {-38.1506004,16.0788002}}} ,
90 {{{-37.3508987,10.0102997}, {-36.4930992,13.2110004}, {-38.1497993,16.0809002}}} , 60 {{{-37.3508987,10.0102997}, {-36.4930992,13.2110004}, {-38.1497993,16.0809002}}} ,
91 61
92 {{{-37.3508987,10.0102997}, {-37.3510017,10.0098}, {-37.3512001,10.0093002}}}, 62 {{{-37.3508987,10.0102997}, {-37.3510017,10.0098}, {-37.3512001,10.0093002}}},
93 {{{-49.0778008,19.0097008}, {-38.2086983,6.80954981}, {-37.3508987,10.0102997}}} , 63 {{{-49.0778008,19.0097008}, {-38.2086983,6.80954981}, {-37.3508987,10.0102997}}} ,
94 64
95 {{{SkBits2Float(0xc22423b2), SkBits2Float(0x40afae2c)}, 65 {{{SkBits2Float(0xc22423b2), SkBits2Float(0x40afae2c)},
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 313
344 static void oneOffTests(skiatest::Reporter* reporter) { 314 static void oneOffTests(skiatest::Reporter* reporter) {
345 for (size_t outer = 0; outer < testSetCount - 1; ++outer) { 315 for (size_t outer = 0; outer < testSetCount - 1; ++outer) {
346 for (size_t inner = outer + 1; inner < testSetCount; ++inner) { 316 for (size_t inner = outer + 1; inner < testSetCount; ++inner) {
347 oneOffTest1(reporter, outer, inner); 317 oneOffTest1(reporter, outer, inner);
348 } 318 }
349 } 319 }
350 } 320 }
351 321
352 static const SkDQuad coincidentTestSet[] = { 322 static const SkDQuad coincidentTestSet[] = {
353 {{{4914.9990234375, 1523}, {4942.75146484375, 1523}, {4962.375, 1542.6239013 671875}}},
354 {{{4962.3759765625, 1542.6239013671875}, {4942.75244140625, 1523}, {4915, 15 23}}},
355 #if 0 323 #if 0
356 {{{97.9337615966796875,100}, {88,112.94264984130859375}, {88,130}}}, 324 {{{97.9337615966796875,100}, {88,112.94264984130859375}, {88,130}}},
357 {{{88,130}, {88,124.80951690673828125}, {88.91983795166015625,120}}}, 325 {{{88,130}, {88,124.80951690673828125}, {88.91983795166015625,120}}},
358 #endif 326 #endif
359 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287} }}, 327 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287} }},
360 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287} }}, 328 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287} }},
361 {{{8, 8}, {10, 10}, {8, -10}}}, 329 {{{8, 8}, {10, 10}, {8, -10}}},
362 {{{8, -10}, {10, 10}, {8, 8}}}, 330 {{{8, -10}, {10, 10}, {8, 8}}},
363 }; 331 };
364 332
365 static const int coincidentTestSetCount = (int) SK_ARRAY_COUNT(coincidentTestSet ); 333 static const int coincidentTestSetCount = (int) SK_ARRAY_COUNT(coincidentTestSet );
366 334
367 static void coincidentTestOne(skiatest::Reporter* reporter, int test1, int test2 ) { 335 static void coincidentTestOne(skiatest::Reporter* reporter, int test1, int test2 ) {
368 const SkDQuad& quad1 = coincidentTestSet[test1]; 336 const SkDQuad& quad1 = coincidentTestSet[test1];
369 SkASSERT(ValidQuad(quad1)); 337 SkASSERT(ValidQuad(quad1));
370 const SkDQuad& quad2 = coincidentTestSet[test2]; 338 const SkDQuad& quad2 = coincidentTestSet[test2];
371 SkASSERT(ValidQuad(quad2)); 339 SkASSERT(ValidQuad(quad2));
372 SkIntersections intersections2; 340 SkIntersections intersections2;
373 intersections2.intersect(quad1, quad2); 341 intersections2.intersect(quad1, quad2);
374 REPORTER_ASSERT(reporter, intersections2.coincidentUsed() >= 2); 342 REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2);
375 REPORTER_ASSERT(reporter, intersections2.used() >= 2); 343 REPORTER_ASSERT(reporter, intersections2.used() == 2);
376 for (int pt = 0; pt < intersections2.coincidentUsed(); pt += 2) { 344 for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) {
377 double tt1 = intersections2[0][pt]; 345 double tt1 = intersections2[0][pt];
378 double tt2 = intersections2[1][pt]; 346 double tt2 = intersections2[1][pt];
379 SkDPoint pt1 = quad1.ptAtT(tt1); 347 SkDPoint pt1 = quad1.ptAtT(tt1);
380 SkDPoint pt2 = quad2.ptAtT(tt2); 348 SkDPoint pt2 = quad2.ptAtT(tt2);
381 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); 349 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
382 } 350 }
383 } 351 }
384 352
385 static void coincidentTest(skiatest::Reporter* reporter) { 353 static void coincidentTest(skiatest::Reporter* reporter) {
386 for (int testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex += 2) { 354 for (int testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex += 2) {
(...skipping 28 matching lines...) Expand all
415 for (int index = 0; index < 3; ++index) { 383 for (int index = 0; index < 3; ++index) {
416 double t = q1.nearestT(q2[index]); 384 double t = q1.nearestT(q2[index]);
417 SkDPoint onQuad = q1.ptAtT(t); 385 SkDPoint onQuad = q1.ptAtT(t);
418 SkDebugf("%s t=%1.9g (%1.9g,%1.9g) dist=%1.9g\n", __FUNCTION__, t, onQua d.fX, onQuad.fY, 386 SkDebugf("%s t=%1.9g (%1.9g,%1.9g) dist=%1.9g\n", __FUNCTION__, t, onQua d.fX, onQuad.fY,
419 onQuad.distance(q2[index])); 387 onQuad.distance(q2[index]));
420 double left[3]; 388 double left[3];
421 left[0] = ((const SkDLine&) q1[0]).isLeft(q2[index]); 389 left[0] = ((const SkDLine&) q1[0]).isLeft(q2[index]);
422 left[1] = ((const SkDLine&) q1[1]).isLeft(q2[index]); 390 left[1] = ((const SkDLine&) q1[1]).isLeft(q2[index]);
423 SkDLine diag = {{q1[0], q1[2]}}; 391 SkDLine diag = {{q1[0], q1[2]}};
424 left[2] = diag.isLeft(q2[index]); 392 left[2] = diag.isLeft(q2[index]);
425 SkDebugf("%s left=(%d, %d, %d)\n", __FUNCTION__, floatSign(left[0]), 393 SkDebugf("%s left=(%d, %d, %d) inHull=%s\n", __FUNCTION__, floatSign(lef t[0]),
426 floatSign(left[1]), floatSign(left[2])); 394 floatSign(left[1]), floatSign(left[2]),
395 q1.pointInHull(q2[index]) ? "true" : "false");
427 } 396 }
428 SkDebugf("\n"); 397 SkDebugf("\n");
429 } 398 }
430 399
431 static void hullIntersect(const SkDQuad& q1, const SkDQuad& q2) { 400 static void hullIntersect(const SkDQuad& q1, const SkDQuad& q2) {
432 SkDebugf("%s", __FUNCTION__); 401 SkDebugf("%s", __FUNCTION__);
433 SkIntersections ts; 402 SkIntersections ts;
434 for (int i1 = 0; i1 < 3; ++i1) { 403 for (int i1 = 0; i1 < 3; ++i1) {
435 SkDLine l1 = {{q1[i1], q1[(i1 + 1) % 3]}}; 404 SkDLine l1 = {{q1[i1], q1[(i1 + 1) % 3]}};
436 for (int i2 = 0; i2 < 3; ++i2) { 405 for (int i2 = 0; i2 < 3; ++i2) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 SkDPoint p22 = quad2.ptAtT(t22); 512 SkDPoint p22 = quad2.ptAtT(t22);
544 SkDebugf("%s p2=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__, 513 SkDebugf("%s p2=(%1.9g,%1.9g)<(%1.9g,%1.9g)<(%1.9g,%1.9g)\n", __FUNCTION__,
545 p20.fX, p20.fY, p2Seed.fX, p2Seed.fY, p22.fX, p22.fY); 514 p20.fX, p20.fY, p2Seed.fX, p2Seed.fY, p22.fX, p22.fY);
546 #endif 515 #endif
547 } 516 }
548 517
549 static void QuadraticIntersection_IntersectionFinder() { 518 static void QuadraticIntersection_IntersectionFinder() {
550 intersectionFinder(0, 1); 519 intersectionFinder(0, 1);
551 } 520 }
552 521
553 DEF_TEST(PathOpsQuadIntersectionOneOff, reporter) {
554 oneOffTest1(reporter, 10, 11);
555 }
556
557 DEF_TEST(PathOpsQuadIntersectionCoincidenceOneOff, reporter) {
558 coincidentTestOne(reporter, 0, 1);
559 }
560
561 DEF_TEST(PathOpsQuadIntersection, reporter) { 522 DEF_TEST(PathOpsQuadIntersection, reporter) {
562 oneOffTests(reporter); 523 oneOffTests(reporter);
563 coincidentTest(reporter); 524 coincidentTest(reporter);
564 standardTestCases(reporter); 525 standardTestCases(reporter);
565 if (false) QuadraticIntersection_IntersectionFinder(); 526 if (false) QuadraticIntersection_IntersectionFinder();
566 if (false) QuadraticIntersection_PointFinder(); 527 if (false) QuadraticIntersection_PointFinder();
567 } 528 }
568 529
569 #include "SkCommonFlags.h" 530 DEF_TEST(PathOpsQuadIntersectionCoincidenceOneOff, reporter) {
531 coincidentTestOne(reporter, 0, 1);
532 }
570 533
571 DEF_TEST(PathOpsQuadBinaryProfile, reporter) { 534 DEF_TEST(PathOpsQuadIntersectionOneOff, reporter) {
572 if (!FLAGS_veryVerbose) { 535 oneOffTest1(reporter, 0, 1);
573 return;
574 }
575 SkIntersections intersections;
576 for (int x = 0; x < 100; ++x) {
577 int outer = 0;
578 int inner = outer + 1;
579 do {
580 const SkDQuad& quad1 = testSet[outer];
581 const SkDQuad& quad2 = testSet[inner];
582 (void) intersections.intersect(quad1, quad2);
583 REPORTER_ASSERT(reporter, intersections.used() >= 0); // make sure code isn't tossed
584 inner += 2;
585 outer += 2;
586 } while (outer < (int) testSetCount);
587 }
588 for (int x = 0; x < 100; ++x) {
589 for (size_t test = 0; test < quadraticTests_count; ++test) {
590 const SkDQuad& quad1 = quadraticTests[test][0];
591 const SkDQuad& quad2 = quadraticTests[test][1];
592 (void) intersections.intersect(quad1, quad2);
593 REPORTER_ASSERT(reporter, intersections.used() >= 0); // make sure code isn't tossed
594 }
595 }
596 } 536 }
OLDNEW
« no previous file with comments | « tests/PathOpsOpTest.cpp ('k') | tests/PathOpsQuadIntersectionTestData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698