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 "SkOpContour.h" | 9 #include "SkOpContour.h" |
10 #include "SkOpSegment.h" | 10 #include "SkOpSegment.h" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 399 } |
400 | 400 |
401 static bool bruteForceCheck(skiatest::Reporter* reporter, const SkDQuad& quad1, | 401 static bool bruteForceCheck(skiatest::Reporter* reporter, const SkDQuad& quad1, |
402 const SkDQuad& quad2, bool ccw) { | 402 const SkDQuad& quad2, bool ccw) { |
403 TRange lowerRange, upperRange; | 403 TRange lowerRange, upperRange; |
404 bool result = bruteMinT(reporter, quad1, quad2, &lowerRange, &upperRange); | 404 bool result = bruteMinT(reporter, quad1, quad2, &lowerRange, &upperRange); |
405 REPORTER_ASSERT(reporter, result); | 405 REPORTER_ASSERT(reporter, result); |
406 return ccw == upperRange.ccw; | 406 return ccw == upperRange.ccw; |
407 } | 407 } |
408 | 408 |
409 static void makeSegment(SkOpContour* contour, const SkDQuad& quad, SkPoint short
Quad[3], | 409 static void makeSegment(SkOpContour* contour, const SkDQuad& quad, SkPoint short
Quad[3]) { |
410 SkChunkAlloc* allocator) { | |
411 shortQuad[0] = quad[0].asSkPoint(); | 410 shortQuad[0] = quad[0].asSkPoint(); |
412 shortQuad[1] = quad[1].asSkPoint(); | 411 shortQuad[1] = quad[1].asSkPoint(); |
413 shortQuad[2] = quad[2].asSkPoint(); | 412 shortQuad[2] = quad[2].asSkPoint(); |
414 contour->addQuad(shortQuad, allocator); | 413 contour->addQuad(shortQuad); |
415 } | 414 } |
416 | 415 |
417 static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c
onst SkDQuad& quad2, | 416 static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c
onst SkDQuad& quad2, |
418 int testNo, SkChunkAlloc* allocator) { | 417 int testNo, SkChunkAlloc* allocator) { |
419 SkPoint shortQuads[2][3]; | 418 SkPoint shortQuads[2][3]; |
420 | 419 |
421 SkOpContourHead contour; | 420 SkOpContourHead contour; |
422 SkOpGlobalState state(nullptr, &contour SkDEBUGPARAMS(false) SkDEBUGPARAMS(
nullptr)); | 421 SkOpGlobalState state(&contour, allocator SkDEBUGPARAMS(false) SkDEBUGPARAM
S(nullptr)); |
423 contour.init(&state, false, false); | 422 contour.init(&state, false, false); |
424 makeSegment(&contour, quad1, shortQuads[0], allocator); | 423 makeSegment(&contour, quad1, shortQuads[0]); |
425 makeSegment(&contour, quad1, shortQuads[1], allocator); | 424 makeSegment(&contour, quad1, shortQuads[1]); |
426 SkOpSegment* seg1 = contour.first(); | 425 SkOpSegment* seg1 = contour.first(); |
427 seg1->debugAddAngle(0, 1, allocator); | 426 seg1->debugAddAngle(0, 1); |
428 SkOpSegment* seg2 = seg1->next(); | 427 SkOpSegment* seg2 = seg1->next(); |
429 seg2->debugAddAngle(0, 1, allocator); | 428 seg2->debugAddAngle(0, 1); |
430 int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(*seg1->debugLastAng
le(), | 429 int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(*seg1->debugLastAng
le(), |
431 *seg2->debugLastAngle()); | 430 *seg2->debugLastAngle()); |
432 const SkDPoint& origin = quad1[0]; | 431 const SkDPoint& origin = quad1[0]; |
433 REPORTER_ASSERT(reporter, origin == quad2[0]); | 432 REPORTER_ASSERT(reporter, origin == quad2[0]); |
434 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); |
435 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); |
436 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); |
437 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); |
438 bool oldSchoolOverlap = radianBetween(a1s, a2s, a1e) | 437 bool oldSchoolOverlap = radianBetween(a1s, a2s, a1e) |
439 || radianBetween(a1s, a2e, a1e) || radianBetween(a2s, a1s, a2e) | 438 || radianBetween(a1s, a2e, a1e) || radianBetween(a2s, a1s, a2e) |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 step /= 2; | 853 step /= 2; |
855 } | 854 } |
856 #ifdef SK_DEBUG | 855 #ifdef SK_DEBUG |
857 // DumpQ(q1, q2, 999); | 856 // DumpQ(q1, q2, 999); |
858 #endif | 857 #endif |
859 } | 858 } |
860 if (gPathOpsAngleIdeasVerbose) { | 859 if (gPathOpsAngleIdeasVerbose) { |
861 SkDebugf("maxR=%1.9g\n", maxR); | 860 SkDebugf("maxR=%1.9g\n", maxR); |
862 } | 861 } |
863 } | 862 } |
OLD | NEW |