diff options
author | caryclark <caryclark@google.com> | 2015-03-24 07:28:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-24 07:28:17 -0700 |
commit | ccec0f958ffc71a9986d236bc2eb335cb2111119 (patch) | |
tree | f864209e3594293256ac391715d50222ff22d96b /tests/PathOpsAngleIdeas.cpp | |
parent | 62a320c8d444cd04e4f2952c269ea4cbd58dee64 (diff) |
pathops version two
R=reed@google.com
marked 'no commit' to attempt to get trybots to run
TBR=reed@google.com
Review URL: https://codereview.chromium.org/1002693002
Diffstat (limited to 'tests/PathOpsAngleIdeas.cpp')
-rwxr-xr-x | tests/PathOpsAngleIdeas.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/tests/PathOpsAngleIdeas.cpp b/tests/PathOpsAngleIdeas.cpp index 901cab2bb5..1a2bce77f2 100755 --- a/tests/PathOpsAngleIdeas.cpp +++ b/tests/PathOpsAngleIdeas.cpp @@ -6,8 +6,8 @@ */ #include "PathOpsTestCommon.h" #include "SkIntersections.h" +#include "SkOpContour.h" #include "SkOpSegment.h" -#include "SkPathOpsTriangle.h" #include "SkRandom.h" #include "SkTArray.h" #include "SkTSort.h" @@ -18,12 +18,12 @@ static bool gPathOpsAngleIdeasEnableBruteCheck = false; class PathOpsAngleTester { public: - static int ConvexHullOverlaps(const SkOpAngle& lh, const SkOpAngle& rh) { - return lh.convexHullOverlaps(rh); + static int ConvexHullOverlaps(SkOpAngle& lh, SkOpAngle& rh) { + return lh.convexHullOverlaps(&rh); } - static int EndsIntersect(const SkOpAngle& lh, const SkOpAngle& rh) { - return lh.endsIntersect(rh); + static int EndsIntersect(SkOpAngle& lh, SkOpAngle& rh) { + return lh.endsIntersect(&rh); } }; @@ -406,28 +406,29 @@ static bool bruteForceCheck(skiatest::Reporter* reporter, const SkDQuad& quad1, return ccw == upperRange.ccw; } -class PathOpsSegmentTester { -public: - static void ConstructQuad(SkOpSegment* segment, SkPoint shortQuad[3]) { - segment->debugConstructQuad(shortQuad); - } -}; - -static void makeSegment(const SkDQuad& quad, SkPoint shortQuad[3], SkOpSegment* result) { +static void makeSegment(SkOpContour* contour, const SkDQuad& quad, SkPoint shortQuad[3], + SkChunkAlloc* allocator) { shortQuad[0] = quad[0].asSkPoint(); shortQuad[1] = quad[1].asSkPoint(); shortQuad[2] = quad[2].asSkPoint(); - PathOpsSegmentTester::ConstructQuad(result, shortQuad); + contour->addQuad(shortQuad, allocator); } static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, const SkDQuad& quad2, - int testNo) { + int testNo, SkChunkAlloc* allocator) { SkPoint shortQuads[2][3]; - SkOpSegment seg[2]; - makeSegment(quad1, shortQuads[0], &seg[0]); - makeSegment(quad2, shortQuads[1], &seg[1]); - int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(*seg[0].debugLastAngle(), - *seg[1].debugLastAngle()); + + SkOpContour contour; + SkOpGlobalState state(NULL PATH_OPS_DEBUG_PARAMS(&contour)); + contour.init(&state, false, false); + makeSegment(&contour, quad1, shortQuads[0], allocator); + makeSegment(&contour, quad1, shortQuads[1], allocator); + SkOpSegment* seg1 = contour.first(); + seg1->debugAddAngle(0, 1, allocator); + SkOpSegment* seg2 = seg1->next(); + seg2->debugAddAngle(0, 1, allocator); + int realOverlap = PathOpsAngleTester::ConvexHullOverlaps(*seg1->debugLastAngle(), + *seg2->debugLastAngle()); const SkDPoint& origin = quad1[0]; REPORTER_ASSERT(reporter, origin == quad2[0]); double a1s = atan2(origin.fY - quad1[1].fY, quad1[1].fX - origin.fX); @@ -545,25 +546,27 @@ static void testQuadAngles(skiatest::Reporter* reporter, const SkDQuad& quad1, c } if (overlap < 0) { SkDEBUGCODE(int realEnds =) - PathOpsAngleTester::EndsIntersect(*seg[0].debugLastAngle(), - *seg[1].debugLastAngle()); + PathOpsAngleTester::EndsIntersect(*seg1->debugLastAngle(), + *seg2->debugLastAngle()); SkASSERT(realEnds == (firstInside ? 1 : 0)); } bruteForce(reporter, quad1, quad2, firstInside); } DEF_TEST(PathOpsAngleOverlapHullsOne, reporter) { + SkChunkAlloc allocator(4096); // gPathOpsAngleIdeasVerbose = true; const SkDQuad quads[] = { {{{939.4808349609375, 914.355224609375}, {-357.7921142578125, 590.842529296875}, {736.8936767578125, -350.717529296875}}}, {{{939.4808349609375, 914.355224609375}, {-182.85418701171875, 634.4552001953125}, {-509.62615966796875, 576.1182861328125}}} }; for (int index = 0; index < (int) SK_ARRAY_COUNT(quads); index += 2) { - testQuadAngles(reporter, quads[index], quads[index + 1], 0); + testQuadAngles(reporter, quads[index], quads[index + 1], 0, &allocator); } } DEF_TEST(PathOpsAngleOverlapHulls, reporter) { + SkChunkAlloc allocator(4096); if (!gPathOpsAngleIdeasVerbose) { // takes a while to run -- so exclude it by default return; } @@ -587,7 +590,7 @@ DEF_TEST(PathOpsAngleOverlapHulls, reporter) { if (i.used() > 1) { continue; } - testQuadAngles(reporter, quad1, quad2, index); + testQuadAngles(reporter, quad1, quad2, index, &allocator); } } |