path ops work in progress
fix bugs in tests on 32 bit release
Most changes revolve around pinning computed t values
very close to zero and one.
git-svn-id: http://skia.googlecode.com/svn/trunk@8745 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index ec8afb0..9b27fce 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -44,7 +44,7 @@
static bool gPathStrAssert = true;
#if FORCE_RELEASE
-static bool gRunTestsInOneThread = false;
+static bool gRunTestsInOneThread = true;
#else
static bool gRunTestsInOneThread = true;
#endif
@@ -167,6 +167,35 @@
showPath(scaled, str);
}
+#if DEBUG_SHOW_TEST_NAME
+static char hexorator(int x) {
+ if (x < 10) {
+ return x + '0';
+ }
+ x -= 10;
+ SkASSERT(x < 26);
+ return x + 'A';
+}
+#endif
+
+void ShowTestName(PathOpsThreadState* state, int a, int b, int c, int d) {
+#if DEBUG_SHOW_TEST_NAME
+ state->fSerialNo[0] = hexorator(state->fA);
+ state->fSerialNo[1] = hexorator(state->fB);
+ state->fSerialNo[2] = hexorator(state->fC);
+ state->fSerialNo[3] = hexorator(state->fD);
+ state->fSerialNo[4] = hexorator(a);
+ state->fSerialNo[5] = hexorator(b);
+ state->fSerialNo[6] = hexorator(c);
+ state->fSerialNo[7] = hexorator(d);
+ state->fSerialNo[8] = '\0';
+ SkDebugf("%s\n", state->fSerialNo);
+ if (strcmp(state->fSerialNo, state->fKey) == 0) {
+ SkDebugf("%s\n", state->fPathStr);
+ }
+#endif
+}
+
const int bitWidth = 64;
const int bitHeight = 64;
@@ -434,6 +463,9 @@
}
bool testSimplify(skiatest::Reporter* reporter, const SkPath& path) {
+#if FORCE_RELEASE == 0
+ showPathData(path);
+#endif
SkPath out;
Simplify(path, &out);
SkBitmap bitmap;
diff --git a/tests/PathOpsExtendedTest.h b/tests/PathOpsExtendedTest.h
index 5267409..ece1c86 100644
--- a/tests/PathOpsExtendedTest.h
+++ b/tests/PathOpsExtendedTest.h
@@ -42,5 +42,6 @@
void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
void (*firstTest)(skiatest::Reporter* ),
void (*stopTest)(skiatest::Reporter* ), bool reverse);
+void ShowTestName(PathOpsThreadState* data, int a, int b, int c, int d);
#endif
diff --git a/tests/PathOpsLineIntersectionTest.cpp b/tests/PathOpsLineIntersectionTest.cpp
index d0b5731..675ce9d 100644
--- a/tests/PathOpsLineIntersectionTest.cpp
+++ b/tests/PathOpsLineIntersectionTest.cpp
@@ -10,6 +10,7 @@
// FIXME: add tests for intersecting, non-intersecting, degenerate, coincident
static const SkDLine tests[][2] = {
+ {{{{5, 0}, {0, 5}}}, {{{5, 4}, {1, 4}}}},
{{{{0, 0}, {1, 0}}}, {{{1, 0}, {0, 0}}}},
{{{{0, 0}, {0, 0}}}, {{{0, 0}, {1, 0}}}},
{{{{0, 1}, {0, 1}}}, {{{0, 0}, {0, 2}}}},
diff --git a/tests/PathOpsOpTest.cpp b/tests/PathOpsOpTest.cpp
index 91a3615..3c8765f 100644
--- a/tests/PathOpsOpTest.cpp
+++ b/tests/PathOpsOpTest.cpp
@@ -1122,9 +1122,33 @@
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
-static void (*firstTest)(skiatest::Reporter* ) = cubicOp1i;
+static void cubicOp68u(skiatest::Reporter* reporter) {
+ SkPath path, pathB;
+ path.moveTo(0,5);
+ path.cubicTo(4,5, 4,1, 5,0);
+ path.close();
+ pathB.moveTo(1,4);
+ pathB.cubicTo(0,5, 5,0, 5,4);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kUnion_PathOp);
+}
+
+static void cubicOp69d(skiatest::Reporter* reporter) {
+ SkPath path, pathB;
+ path.moveTo(1,3);
+ path.cubicTo(0,1, 3,1, 2,0);
+ path.close();
+ pathB.moveTo(1,3);
+ pathB.cubicTo(0,2, 3,1, 1,0);
+ pathB.close();
+ testPathOp(reporter, path, pathB, kDifference_PathOp);
+}
+
+static void (*firstTest)(skiatest::Reporter* ) = 0;
static struct TestDesc tests[] = {
+ TEST(cubicOp69d),
+ TEST(cubicOp68u),
TEST(cubicOp67u),
TEST(cubicOp66u),
TEST(rectOp1d),
diff --git a/tests/PathOpsSimplifyTest.cpp b/tests/PathOpsSimplifyTest.cpp
index e9133ef..356f172 100644
--- a/tests/PathOpsSimplifyTest.cpp
+++ b/tests/PathOpsSimplifyTest.cpp
@@ -3626,9 +3626,37 @@
testSimplify(reporter, path);
}
+static void testTriangles1(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.moveTo(0, 0);
+ path.lineTo(1, 0);
+ path.lineTo(3, 3);
+ path.close();
+ path.moveTo(0, 0);
+ path.lineTo(1, 2);
+ path.lineTo(1, 1);
+ path.close();
+ testSimplify(reporter, path);
+}
+
+static void testTriangles2(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.moveTo(0, 0);
+ path.lineTo(1, 0);
+ path.lineTo(3, 3);
+ path.close();
+ path.moveTo(1, 1);
+ path.lineTo(2, 3);
+ path.lineTo(1, 2);
+ path.close();
+ testSimplify(reporter, path);
+}
+
static void (*firstTest)(skiatest::Reporter* ) = 0;
static TestDesc tests[] = {
+ TEST(testTriangles2),
+ TEST(testTriangles1),
TEST(testQuadratic97),
TEST(testQuadratic96),
TEST(testQuadratic95),
diff --git a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
index 4030a67..42aad38 100755
--- a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
+++ b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
@@ -12,6 +12,7 @@
PathOpsThreadState& state = *data;
char pathStr[1024];
sk_bzero(pathStr, sizeof(pathStr));
+ state.fKey = "?";
int ax = state.fA & 0x03;
int ay = state.fA >> 2;
int bx = state.fB & 0x03;
@@ -53,9 +54,11 @@
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
str += sprintf(str, " path.close();\n");
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
+ ShowTestName(&state, d, e, f, 0);
testSimplify(path, false, out, state, pathStr);
path.setFillType(SkPath::kEvenOdd_FillType);
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
+ ShowTestName(&state, d, e, f, 1);
testSimplify(path, true, out, state, pathStr);
}
}
diff --git a/tests/PathOpsThreadedCommon.h b/tests/PathOpsThreadedCommon.h
index 410194f..d1f6ff0 100644
--- a/tests/PathOpsThreadedCommon.h
+++ b/tests/PathOpsThreadedCommon.h
@@ -26,6 +26,8 @@
unsigned char fC;
unsigned char fD;
char* fPathStr;
+ const char* fKey;
+ char fSerialNo[9];
skiatest::Reporter* fReporter;
SkBitmap* fBitmap;
};