OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
10 #include "SkPathOpsTriangle.h" | 10 #include "SkPathOpsTriangle.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 shortQuad[2] = quad[2].asSkPoint(); | 419 shortQuad[2] = quad[2].asSkPoint(); |
420 PathOpsSegmentTester::ConstructQuad(result, shortQuad); | 420 PathOpsSegmentTester::ConstructQuad(result, shortQuad); |
421 } | 421 } |
422 | 422 |
423 static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c
onst SkDQuad& quad2, | 423 static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c
onst SkDQuad& quad2, |
424 int testNo) { | 424 int testNo) { |
425 SkPoint shortQuads[2][3]; | 425 SkPoint shortQuads[2][3]; |
426 SkOpSegment seg[2]; | 426 SkOpSegment seg[2]; |
427 makeSegment(quad1, shortQuads[0], &seg[0]); | 427 makeSegment(quad1, shortQuads[0], &seg[0]); |
428 makeSegment(quad2, shortQuads[1], &seg[1]); | 428 makeSegment(quad2, shortQuads[1], &seg[1]); |
429 int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(seg[0].angle(0), se
g[1].angle(0)); | 429 int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(*seg[0].debugLastAn
gle(), |
| 430 *seg[1].debugLastAngle()); |
430 const SkDPoint& origin = quad1[0]; | 431 const SkDPoint& origin = quad1[0]; |
431 REPORTER_ASSERT(reporter, origin == quad2[0]); | 432 REPORTER_ASSERT(reporter, origin == quad2[0]); |
432 double a1s = atan2(origin.fY - quad1[1].fY, quad1[1].fX - origin.fX); | 433 double a1s = atan2(origin.fY - quad1[1].fY, quad1[1].fX - origin.fX); |
433 double a1e = atan2(origin.fY - quad1[2].fY, quad1[2].fX - origin.fX); | 434 double a1e = atan2(origin.fY - quad1[2].fY, quad1[2].fX - origin.fX); |
434 double a2s = atan2(origin.fY - quad2[1].fY, quad2[1].fX - origin.fX); | 435 double a2s = atan2(origin.fY - quad2[1].fY, quad2[1].fX - origin.fX); |
435 double a2e = atan2(origin.fY - quad2[2].fY, quad2[2].fX - origin.fX); | 436 double a2e = atan2(origin.fY - quad2[2].fY, quad2[2].fX - origin.fX); |
436 bool oldSchoolOverlap = radianBetween(a1s, a2s, a1e) | 437 bool oldSchoolOverlap = radianBetween(a1s, a2s, a1e) |
437 || radianBetween(a1s, a2e, a1e) || radianBetween(a2s, a1s, a2e) | 438 || radianBetween(a1s, a2e, a1e) || radianBetween(a2s, a1s, a2e) |
438 || radianBetween(a2s, a1e, a2e); | 439 || radianBetween(a2s, a1e, a2e); |
439 int overlap = quadHullsOverlap(reporter, quad1, quad2); | 440 int overlap = quadHullsOverlap(reporter, quad1, quad2); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 SkASSERT(SkScalarSignAsInt(SkDoubleToScalar(midXray)) | 538 SkASSERT(SkScalarSignAsInt(SkDoubleToScalar(midXray)) |
538 == SkScalarSignAsInt(SkDoubleToScalar(vDir[sIndex]))); | 539 == SkScalarSignAsInt(SkDoubleToScalar(vDir[sIndex]))); |
539 firstInside = (rayDist > endDist) ^ (sIndex == 0) ^ (vDir[sIndex] < 0); | 540 firstInside = (rayDist > endDist) ^ (sIndex == 0) ^ (vDir[sIndex] < 0); |
540 } else if (overlap >= 0) { | 541 } else if (overlap >= 0) { |
541 return; // answer has already been determined | 542 return; // answer has already been determined |
542 } else { | 543 } else { |
543 firstInside = checkParallel(reporter, quad1, quad2); | 544 firstInside = checkParallel(reporter, quad1, quad2); |
544 } | 545 } |
545 if (overlap < 0) { | 546 if (overlap < 0) { |
546 SkDEBUGCODE(int realEnds =) | 547 SkDEBUGCODE(int realEnds =) |
547 PathOpsAngleTester::EndsIntersect(seg[0].angle(0), seg[1].angle(
0)); | 548 PathOpsAngleTester::EndsIntersect(*seg[0].debugLastAngle(), |
| 549 *seg[1].debugLastAngle()); |
548 SkASSERT(realEnds == (firstInside ? 1 : 0)); | 550 SkASSERT(realEnds == (firstInside ? 1 : 0)); |
549 } | 551 } |
550 bruteForce(reporter, quad1, quad2, firstInside); | 552 bruteForce(reporter, quad1, quad2, firstInside); |
551 } | 553 } |
552 | 554 |
553 DEF_TEST(PathOpsAngleOverlapHullsOne, reporter) { | 555 DEF_TEST(PathOpsAngleOverlapHullsOne, reporter) { |
554 // gPathOpsAngleIdeasVerbose = true; | 556 // gPathOpsAngleIdeasVerbose = true; |
555 const SkDQuad quads[] = { | 557 const SkDQuad quads[] = { |
556 {{{939.4808349609375, 914.355224609375}, {-357.7921142578125, 590.842529296875},
{736.8936767578125, -350.717529296875}}}, | 558 {{{939.4808349609375, 914.355224609375}, {-357.7921142578125, 590.842529296875},
{736.8936767578125, -350.717529296875}}}, |
557 {{{939.4808349609375, 914.355224609375}, {-182.85418701171875, 634.4552001953125
}, {-509.62615966796875, 576.1182861328125}}} | 559 {{{939.4808349609375, 914.355224609375}, {-182.85418701171875, 634.4552001953125
}, {-509.62615966796875, 576.1182861328125}}} |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 step /= 2; | 851 step /= 2; |
850 } | 852 } |
851 #ifdef SK_DEBUG | 853 #ifdef SK_DEBUG |
852 // DumpQ(q1, q2, 999); | 854 // DumpQ(q1, q2, 999); |
853 #endif | 855 #endif |
854 } | 856 } |
855 if (gPathOpsAngleIdeasVerbose) { | 857 if (gPathOpsAngleIdeasVerbose) { |
856 SkDebugf("maxR=%1.9g\n", maxR); | 858 SkDebugf("maxR=%1.9g\n", maxR); |
857 } | 859 } |
858 } | 860 } |
OLD | NEW |