diff options
author | 2012-05-22 17:01:14 +0000 | |
---|---|---|
committer | 2012-05-22 17:01:14 +0000 | |
commit | 1577e8f9c5bc8436cc71d3438c6d0b9f02c38338 (patch) | |
tree | f53d4e92fd8cd9ccf108d4b1e8141198e5169cec /experimental/Intersection/SimplifyFindNext_Test.cpp | |
parent | bcc8486ad421350ecd17c07c3ce76c016894abb3 (diff) |
shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@4029 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/SimplifyFindNext_Test.cpp')
-rw-r--r-- | experimental/Intersection/SimplifyFindNext_Test.cpp | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/experimental/Intersection/SimplifyFindNext_Test.cpp b/experimental/Intersection/SimplifyFindNext_Test.cpp index 6d47a93fb7..4e55038b46 100644 --- a/experimental/Intersection/SimplifyFindNext_Test.cpp +++ b/experimental/Intersection/SimplifyFindNext_Test.cpp @@ -16,13 +16,11 @@ namespace SimplifyFindNextTest { #include "Intersection_Tests.h" static const SimplifyFindNextTest::Segment* testCommon( - int start, int winding, int step, + int winding, int startIndex, int endIndex, SkTArray<SimplifyFindNextTest::Contour>& contours, SimplifyFindNextTest::EdgeBuilder& builder, const SkPath& path) { SkTDArray<SimplifyFindNextTest::Contour*> contourList; - SimplifyFindNextTest::Contour sentinel; - sentinel.reset(); - makeContourList(contours, sentinel, contourList); + makeContourList(contours, contourList); addIntersectTs(contourList[0], contourList[0], -1); if (contours.count() > 1) { SkASSERT(contours.count() == 2); @@ -31,20 +29,31 @@ static const SimplifyFindNextTest::Segment* testCommon( } fixOtherTIndex(contourList); SimplifyFindNextTest::Segment& segment = contours[0].fSegments[0]; - int spanIndex; - SimplifyFindNextTest::Segment* next = segment.findNext(start, winding, - step, spanIndex); - SkASSERT(spanIndex == 1); + SkPoint pts[2]; + double startT = segment.t(endIndex); + segment.xyAtT(startT, &pts[0]); + SimplifyFindNextTest::Segment* next = segment.findNext(winding, + startIndex, endIndex); + double endT = next->t(startIndex); + next->xyAtT(endT, &pts[1]); + SkASSERT(pts[0] == pts[1]); return next; } static void test(const SkPath& path) { SkTArray<SimplifyFindNextTest::Contour> contours; SimplifyFindNextTest::EdgeBuilder builder(path, contours); + int winding = 0; int start = 0; + int end = 1; + testCommon(winding, start, end, contours, builder, path); +} + +static void test(const SkPath& path, int start, int end) { + SkTArray<SimplifyFindNextTest::Contour> contours; + SimplifyFindNextTest::EdgeBuilder builder(path, contours); int winding = 0; - int step = 1; - testCommon(start, winding, step, contours, builder, path); + testCommon(winding, start, end, contours, builder, path); } static void testLine1() { @@ -56,8 +65,60 @@ static void testLine1() { test(path); } +static void addInnerCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(4,1); + path.lineTo(2,1); + path.close(); +} + +static void addInnerCCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(2,1); + path.lineTo(4,1); + path.close(); +} + +static void addOuterCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(6,2); + path.lineTo(0,2); + path.close(); +} + +static void addOuterCCWTriangle(SkPath& path) { + path.moveTo(3,0); + path.lineTo(0,2); + path.lineTo(6,2); + path.close(); +} + +static void testLine2() { + SkPath path; + addInnerCWTriangle(path); + addOuterCWTriangle(path); + test(path, 0, 3); +} + +static void testLine3() { + SkPath path; + addInnerCWTriangle(path); + addOuterCWTriangle(path); + test(path, 3, 0); +} + +static void testLine4() { + SkPath path; + addInnerCWTriangle(path); + addOuterCWTriangle(path); + test(path, 3, 2); +} + static void (*tests[])() = { testLine1, + testLine2, + testLine3, + testLine4, }; static const size_t testCount = sizeof(tests) / sizeof(tests[0]); |