aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/SimplifyAngle_Test.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-23 15:24:42 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-23 15:24:42 +0000
commitc899ad9c7fa28234d99479ab09afb6866bbd8dc3 (patch)
tree6db0ad2ad72200483a1b8af57df7a010e5229cb8 /experimental/Intersection/SimplifyAngle_Test.cpp
parentea82695325e2afc68f646fcc23fcae8b1bff6dc1 (diff)
shape ops work in progress
add xor spot tests rewrite path compare work on quadratic, angle, tooCloseToCall code git-svn-id: http://skia.googlecode.com/svn/trunk@5255 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/SimplifyAngle_Test.cpp')
-rw-r--r--experimental/Intersection/SimplifyAngle_Test.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/experimental/Intersection/SimplifyAngle_Test.cpp b/experimental/Intersection/SimplifyAngle_Test.cpp
index 739158829b..33b5fe2242 100644
--- a/experimental/Intersection/SimplifyAngle_Test.cpp
+++ b/experimental/Intersection/SimplifyAngle_Test.cpp
@@ -52,6 +52,52 @@ static const SkPoint cubics[][4] = {
static const size_t cubicCount = sizeof(cubics) / sizeof(cubics[0]);
+struct segment {
+ SkPath::Verb verb;
+ SkPoint pts[4];
+};
+
+static const segment segmentTest1[] = {
+ {SkPath::kLine_Verb, {{2, 1}, {1, 0} }},
+ {SkPath::kQuad_Verb, {{2, 1}, {1, 0}, {0, 0}}},
+ {SkPath::kQuad_Verb, {{2, 1}, {3, 2}, {2, 3}}},
+ {SkPath::kLine_Verb, {{2, 1}, {3, 2} }},
+ {SkPath::kMove_Verb }
+};
+
+static const segment* segmentTests[] = {
+ segmentTest1
+};
+
+static const size_t segmentTestCount = sizeof(segmentTests) / sizeof(segmentTests[0]);
+
+static void testSegments(bool testFlat) {
+ for (size_t testIndex = 0; testIndex < segmentTestCount; ++testIndex) {
+ const segment* segPtr = segmentTests[testIndex];
+ SimplifyAngleTest::Angle lesser, greater;
+ int index = 0;
+ do {
+ int next = index + 1;
+ if (testFlat) {
+ lesser.setFlat(segPtr[index].pts, segPtr[index].verb, 0, index, next);
+ } else {
+ lesser.set(segPtr[index].pts, segPtr[index].verb, 0, index, next);
+ }
+ if (segPtr[next].verb == SkPath::kMove_Verb) {
+ break;
+ }
+ if (testFlat) {
+ greater.setFlat(segPtr[next].pts, segPtr[next].verb, 0, index, next);
+ } else {
+ greater.set(segPtr[next].pts, segPtr[next].verb, 0, index, next);
+ }
+ bool result = lesser < greater;
+ SkASSERT(result);
+ index = next;
+ } while (true);
+ }
+}
+
static void testLines(bool testFlat) {
// create angles in a circle
SkTDArray<SimplifyAngleTest::Angle> angles;
@@ -155,6 +201,7 @@ static void testCubics(bool testFlat) {
}
static void (*tests[])(bool) = {
+ testSegments,
testLines,
testQuads,
testCubics
@@ -177,7 +224,7 @@ void SimplifyAngle_Test() {
}
bool firstTestComplete = false;
for ( ; index < testCount; ++index) {
- (*tests[index])(true);
+ (*tests[index])(false); // set to true to exercise setFlat
firstTestComplete = true;
}
}