aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-17 15:49:16 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-04-17 15:49:16 +0000
commitb3f0921fba9457ba7ea79f220d8c1ec9345bfd3a (patch)
tree88e4c5e6b5f7622e4949073f8de141c2685a503e /tests
parent319baf99636c39f41d93c8808b7be3d198aa27b4 (diff)
shape ops work in progress
Try to fix the 32 bit build by making some math decisions more robust. Rewrite the cubic intersection special case that detects if only end points are shared. Rewrite the angle sort setup that computes whether a cubic bends to the left or right. git-svn-id: http://skia.googlecode.com/svn/trunk@8726 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/PathOpsAngleTest.cpp58
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp5
-rw-r--r--tests/PathOpsOpTest.cpp30
-rw-r--r--tests/PathOpsQuadIntersectionTest.cpp4
4 files changed, 62 insertions, 35 deletions
diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp
index 650b99666b..6714ca4609 100644
--- a/tests/PathOpsAngleTest.cpp
+++ b/tests/PathOpsAngleTest.cpp
@@ -23,17 +23,17 @@ struct SortSet {
};
static const SortSet set1[] = {
- {lines[0], 2, 0.54070336, 0.388888889},
- {cubics[0], 4, 0.666669871, 0.405037112},
- {lines[0], 2, 0.54070336, 0.9140625},
- {cubics[0], 4, 0.666669871, 0.875},
+ {cubics[0], 4, 0.66666987081928919, 0.875},
+ {lines[0], 2, 0.574070336, 0.388888889},
+ {cubics[0], 4, 0.66666987081928919, 0.4050371120499307 },
+ {lines[0], 2, 0.574070336, 0.9140625},
};
static const SortSet set2[] = {
+ {cubics[0], 4, 0.666666667, 0.875},
{lines[0], 2, 0.574074074, 0.388888889},
{cubics[0], 4, 0.666666667, 0.405037112},
{lines[0], 2, 0.574074074, 0.9140625},
- {cubics[0], 4, 0.666666667, 0.875},
};
struct SortSetTests {
@@ -42,36 +42,22 @@ struct SortSetTests {
};
static const SortSetTests tests[] = {
- { set1, SK_ARRAY_COUNT(set1) },
- { set2, SK_ARRAY_COUNT(set2) }
+ { set2, SK_ARRAY_COUNT(set2) },
+ { set1, SK_ARRAY_COUNT(set1) }
};
static void setup(const SortSet* set, const size_t idx, SkPoint const ** data,
- SkPoint* reverse, SkOpSegment* seg) {
+ SkOpSegment* seg, int* ts) {
SkPoint start, end;
if (set[idx].ptCount == 2) {
- if (set[idx].tStart < set[idx].tEnd) {
- *data = set[idx].ptData;
- } else {
- reverse[0] = set[idx].ptData[1];
- reverse[1] = set[idx].ptData[0];
- *data = reverse;
- }
+ *data = set[idx].ptData;
seg->addLine(*data, false, false);
SkDLine dLine;
dLine.set(set[idx].ptData);
start = dLine.xyAtT(set[idx].tStart).asSkPoint();
end = dLine.xyAtT(set[idx].tEnd).asSkPoint();
} else if (set[idx].ptCount == 4) {
- if (set[idx].tStart < set[idx].tEnd) {
- *data = set[idx].ptData;
- } else {
- reverse[0] = set[idx].ptData[3];
- reverse[1] = set[idx].ptData[2];
- reverse[2] = set[idx].ptData[1];
- reverse[3] = set[idx].ptData[0];
- *data = reverse;
- }
+ *data = set[idx].ptData;
seg->addCubic(*data, false, false);
SkDCubic dCubic;
dCubic.set(set[idx].ptData);
@@ -82,6 +68,18 @@ static void setup(const SortSet* set, const size_t idx, SkPoint const ** data,
seg->addT(NULL, end, set[idx].tEnd);
seg->addT(NULL, set[idx].ptData[0], 0);
seg->addT(NULL, set[idx].ptData[set[idx].ptCount - 1], 1);
+ int tIndex = 0;
+ do {
+ if (seg->t(tIndex) == set[idx].tStart) {
+ ts[0] = tIndex;
+ }
+ if (seg->t(tIndex) == set[idx].tEnd) {
+ ts[1] = tIndex;
+ }
+ if (seg->t(tIndex) >= 1) {
+ break;
+ }
+ } while (++tIndex);
}
static void PathOpsAngleTest(skiatest::Reporter* reporter) {
@@ -89,19 +87,17 @@ static void PathOpsAngleTest(skiatest::Reporter* reporter) {
const SortSetTests& test = tests[index];
for (size_t idxL = 0; idxL < test.count - 1; ++idxL) {
SkOpSegment lesser, greater;
- SkPoint lesserReverse[4], greaterReverse[4];
+ int lesserTs[2], greaterTs[2];
const SkPoint* lesserData, * greaterData;
const SortSet* set = test.set;
- setup(set, idxL, &lesserData, lesserReverse, &lesser);
+ setup(set, idxL, &lesserData, &lesser, lesserTs);
size_t idxG = idxL + 1;
- setup(set, idxG, &greaterData, greaterReverse, &greater);
+ setup(set, idxG, &greaterData, &greater, greaterTs);
SkOpAngle first, second;
first.set(lesserData, (SkPath::Verb) (set[idxL].ptCount - 1), &lesser,
- 0, 1, lesser.spans());
- first.setSpans();
+ lesserTs[0], lesserTs[1], lesser.spans());
second.set(greaterData, (SkPath::Verb) (set[idxG].ptCount - 1), &greater,
- 0, 1, greater.spans());
- second.setSpans();
+ greaterTs[0], greaterTs[1], greater.spans());
bool compare = first < second;
if (!compare) {
SkDebugf("%s test[%d]: lesser[%d] > greater[%d]\n", __FUNCTION__,
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index f3db3c0909..6af76c2adb 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -163,6 +163,9 @@ static const SkDCubic testSet[] = {
const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static const SkDCubic newTestSet[] = {
+{{{3, 5}, {1, 6}, {5, 0}, {3, 1}}},
+{{{0, 5}, {1, 3}, {5, 3}, {6, 1}}},
+
{{{0, 1}, {1, 5}, {1, 0}, {1, 0}}},
{{{0, 1}, {0, 1}, {1, 0}, {5, 1}}},
@@ -283,8 +286,8 @@ static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) {
}
static void oneOffTest(skiatest::Reporter* reporter) {
+ oneOff(reporter, 14, 16);
newOneOff(reporter, 0, 1);
- oneOff(reporter, 0, 1);
}
static void oneOffTests(skiatest::Reporter* reporter) {
diff --git a/tests/PathOpsOpTest.cpp b/tests/PathOpsOpTest.cpp
index 4d7c621c3e..91a36150a0 100644
--- a/tests/PathOpsOpTest.cpp
+++ b/tests/PathOpsOpTest.cpp
@@ -1096,9 +1096,37 @@ static void rectOp1d(skiatest::Reporter* reporter) {
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
-static void (*firstTest)(skiatest::Reporter* ) = rectOp1d;
+static void cubicOp66u(skiatest::Reporter* reporter) {
+ SkPath path, pathB;
+ path.setFillType(SkPath::kWinding_FillType);
+ path.moveTo(0,1);
+ path.cubicTo(2,6, 4,2, 5,3);
+ path.close();
+ pathB.setFillType(SkPath::kWinding_FillType);
+ pathB.moveTo(2,4);
+ pathB.cubicTo(3,5, 1,0, 6,2);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kUnion_PathOp);
+}
+
+static void cubicOp67u(skiatest::Reporter* reporter) {
+ SkPath path, pathB;
+ path.moveTo(3,5);
+ path.cubicTo(1,6, 5,0, 3,1);
+ path.lineTo(3,5);
+ path.close();
+ pathB.moveTo(0,5);
+ pathB.cubicTo(1,3, 5,3, 6,1);
+ pathB.lineTo(0,5);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kUnion_PathOp);
+}
+
+static void (*firstTest)(skiatest::Reporter* ) = cubicOp1i;
static struct TestDesc tests[] = {
+ TEST(cubicOp67u),
+ TEST(cubicOp66u),
TEST(rectOp1d),
TEST(cubicOp65d),
TEST(cubicOp64d),
diff --git a/tests/PathOpsQuadIntersectionTest.cpp b/tests/PathOpsQuadIntersectionTest.cpp
index 85555631df..4276051c6c 100644
--- a/tests/PathOpsQuadIntersectionTest.cpp
+++ b/tests/PathOpsQuadIntersectionTest.cpp
@@ -252,8 +252,7 @@ static void oneOffTest1(skiatest::Reporter* reporter, size_t outer, size_t inner
}
static void QuadraticIntersection_OneOffTest(skiatest::Reporter* reporter) {
- oneOffTest1(reporter, 0, 1);
- oneOffTest1(reporter, 1, 0);
+ oneOffTest1(reporter, 43, 47);
}
static void oneOffTests(skiatest::Reporter* reporter) {
@@ -465,3 +464,4 @@ static void PathOpsQuadIntersectionTest(skiatest::Reporter* reporter) {
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionTest)
+DEFINE_TESTCLASS_SHORT(QuadraticIntersection_OneOffTest)