From 24bec79d6f3d71ff97b50db72461a3892bd4f6b5 Mon Sep 17 00:00:00 2001 From: "caryclark@google.com" Date: Mon, 20 Aug 2012 12:43:57 +0000 Subject: [PATCH] shape ops work in progress major milestone: 35.8M tests pass (all rect/triangle/quadralateral) git-svn-id: http://skia.googlecode.com/svn/trunk@5166 2bbb7eff-a529-9590-31e7-b0007b416f81 --- .../EdgeWalkerPolygon4x4_Test.cpp | 36 +- .../EdgeWalkerQuadratic4x4_Test.cpp | 12 +- experimental/Intersection/EdgeWalker_Test.h | 6 +- .../Intersection/EdgeWalker_TestUtility.cpp | 77 +-- .../Intersection/Intersection_Tests.cpp | 14 +- .../Intersection/Intersection_Tests.h | 11 +- .../Intersection/LineCubicIntersection.cpp | 4 +- .../LineQuadraticIntersection.cpp | 51 +- .../LineQuadraticIntersection_Test.cpp | 118 +++++ experimental/Intersection/Simplify.cpp | 454 ++++++++++++------ .../Intersection/SimplifyFindNext_Test.cpp | 8 +- .../Intersection/SimplifyNew_Test.cpp | 239 ++++++++- .../Intersection/SimplifyRect4x4_Test.cpp | 13 +- experimental/Intersection/op.htm | 195 ++++++++ 14 files changed, 991 insertions(+), 247 deletions(-) diff --git a/experimental/Intersection/EdgeWalkerPolygon4x4_Test.cpp b/experimental/Intersection/EdgeWalkerPolygon4x4_Test.cpp index e795cd0410..befac71c7c 100755 --- a/experimental/Intersection/EdgeWalkerPolygon4x4_Test.cpp +++ b/experimental/Intersection/EdgeWalkerPolygon4x4_Test.cpp @@ -53,15 +53,13 @@ static void* testSimplify4x4QuadralateralsMain(void* data) str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy); str += sprintf(str, " path.close();\n"); } - outputProgress(state, pathStr); - testSimplifyx(path, out, state, pathStr); + outputProgress(state, pathStr, SkPath::kWinding_FillType); + testSimplifyx(path, false, out, state, pathStr); state.testsRun++; - #if 0 // FIXME: enable once we have support for even/odd path.setFillType(SkPath::kEvenOdd_FillType); outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); testSimplifyx(path, true, out, state, pathStr); state.testsRun++; - #endif } } } @@ -70,7 +68,7 @@ static void* testSimplify4x4QuadralateralsMain(void* data) return NULL; } -void Simplify4x4QuadralateralsThreaded_Test() +void Simplify4x4QuadralateralsThreaded_Test(int& testsRun) { SkDebugf("%s\n", __FUNCTION__); #ifdef SK_DEBUG @@ -79,7 +77,7 @@ void Simplify4x4QuadralateralsThreaded_Test() #endif const char testStr[] = "testQuadralateral"; initializeTests(testStr, sizeof(testStr)); - int testsRun = 0; + int testsStart = testsRun; for (int a = 0; a < 16; ++a) { for (int b = a ; b < 16; ++b) { for (int c = b ; c < 16; ++c) { @@ -94,7 +92,7 @@ void Simplify4x4QuadralateralsThreaded_Test() if (!gRunTestsInOneThread) SkDebugf("\n%d", a); } testsRun += waitForCompletion(); - SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); + SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); } @@ -146,15 +144,13 @@ static void* testSimplify4x4NondegeneratesMain(void* data) { str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); str += sprintf(str, " path.close();\n"); } - outputProgress(state, pathStr); - testSimplifyx(path, out, state, pathStr); + outputProgress(state, pathStr, SkPath::kWinding_FillType); + testSimplifyx(path, false, out, state, pathStr); state.testsRun++; - #if 0 // FIXME: enable once we have support for even/odd path.setFillType(SkPath::kEvenOdd_FillType); outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); testSimplifyx(path, true, out, state, pathStr); state.testsRun++; - #endif } } } @@ -162,7 +158,7 @@ static void* testSimplify4x4NondegeneratesMain(void* data) { return NULL; } -void SimplifyNondegenerate4x4TrianglesThreaded_Test() { +void SimplifyNondegenerate4x4TrianglesThreaded_Test(int& testsRun) { SkDebugf("%s\n", __FUNCTION__); #ifdef SK_DEBUG gDebugMaxWindSum = 2; @@ -170,7 +166,7 @@ void SimplifyNondegenerate4x4TrianglesThreaded_Test() { #endif const char testStr[] = "testNondegenerate"; initializeTests(testStr, sizeof(testStr)); - int testsRun = 0; + int testsStart = testsRun; for (int a = 0; a < 15; ++a) { int ax = a & 0x03; int ay = a >> 2; @@ -194,7 +190,7 @@ void SimplifyNondegenerate4x4TrianglesThreaded_Test() { if (!gRunTestsInOneThread) SkDebugf("\n%d", a); } testsRun += waitForCompletion(); - SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); + SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); } static void* testSimplify4x4DegeneratesMain(void* data) { @@ -243,15 +239,13 @@ static void* testSimplify4x4DegeneratesMain(void* data) { str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); str += sprintf(str, " path.close();\n"); } - outputProgress(state, pathStr); - testSimplifyx(path, out, state, pathStr); + outputProgress(state, pathStr, SkPath::kWinding_FillType); + testSimplifyx(path, false, out, state, pathStr); state.testsRun++; - #if 0 // FIXME: enable once we have support for even/odd path.setFillType(SkPath::kEvenOdd_FillType); outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); testSimplifyx(path, true, out, state, pathStr); state.testsRun++; - #endif } } } @@ -259,7 +253,7 @@ static void* testSimplify4x4DegeneratesMain(void* data) { return NULL; } -void SimplifyDegenerate4x4TrianglesThreaded_Test() { +void SimplifyDegenerate4x4TrianglesThreaded_Test(int& testsRun) { SkDebugf("%s\n", __FUNCTION__); #ifdef SK_DEBUG gDebugMaxWindSum = 2; @@ -267,7 +261,7 @@ void SimplifyDegenerate4x4TrianglesThreaded_Test() { #endif const char testStr[] = "testDegenerate"; initializeTests(testStr, sizeof(testStr)); - int testsRun = 0; + int testsStart = testsRun; for (int a = 0; a < 16; ++a) { int ax = a & 0x03; int ay = a >> 2; @@ -286,6 +280,6 @@ void SimplifyDegenerate4x4TrianglesThreaded_Test() { if (!gRunTestsInOneThread) SkDebugf("\n%d", a); } testsRun += waitForCompletion(); - SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); + SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); } diff --git a/experimental/Intersection/EdgeWalkerQuadratic4x4_Test.cpp b/experimental/Intersection/EdgeWalkerQuadratic4x4_Test.cpp index f7142495d9..1f5af8ec6c 100644 --- a/experimental/Intersection/EdgeWalkerQuadratic4x4_Test.cpp +++ b/experimental/Intersection/EdgeWalkerQuadratic4x4_Test.cpp @@ -53,15 +53,13 @@ static void* testSimplify4x4QuadraticsMain(void* data) str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy); str += sprintf(str, " path.close();\n"); } - outputProgress(state, pathStr); - testSimplifyx(path, out, state, pathStr); + outputProgress(state, pathStr, SkPath::kWinding_FillType); + testSimplifyx(path, false, out, state, pathStr); state.testsRun++; - #if 0 // FIXME: enable once we have support for even/odd path.setFillType(SkPath::kEvenOdd_FillType); outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); testSimplifyx(path, true, out, state, pathStr); state.testsRun++; - #endif } } } @@ -70,7 +68,7 @@ static void* testSimplify4x4QuadraticsMain(void* data) return NULL; } -void Simplify4x4QuadraticsThreaded_Test() +void Simplify4x4QuadraticsThreaded_Test(int& testsRun) { SkDebugf("%s\n", __FUNCTION__); #ifdef SK_DEBUG @@ -79,7 +77,7 @@ void Simplify4x4QuadraticsThreaded_Test() #endif const char testStr[] = "testQuadratic"; initializeTests(testStr, sizeof(testStr)); - int testsRun = 0; + int testsStart = testsRun; for (int a = 0; a < 16; ++a) { for (int b = a ; b < 16; ++b) { for (int c = b ; c < 16; ++c) { @@ -94,5 +92,5 @@ void Simplify4x4QuadraticsThreaded_Test() if (!gRunTestsInOneThread) SkDebugf("\n%d", a); } testsRun += waitForCompletion(); - SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); + SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); } diff --git a/experimental/Intersection/EdgeWalker_Test.h b/experimental/Intersection/EdgeWalker_Test.h index 229a94dae0..c86cefd9d1 100644 --- a/experimental/Intersection/EdgeWalker_Test.h +++ b/experimental/Intersection/EdgeWalker_Test.h @@ -16,7 +16,7 @@ extern bool drawAsciiPaths(const SkPath& one, const SkPath& two, extern void showPath(const SkPath& path, const char* str = NULL); extern bool testSimplify(const SkPath& path, bool fill, SkPath& out, SkBitmap& bitmap, SkCanvas* canvas = 0); -extern bool testSimplifyx(const SkPath& path, SkPath& out, +extern bool testSimplifyx(SkPath& path, bool useXor, SkPath& out, State4& state, const char* pathStr); extern bool testSimplifyx(const SkPath& path); @@ -44,7 +44,7 @@ struct State4 { void createThread(State4* statePtr, void* (*test)(void* )); int dispatchTest4(void* (*testFun)(void* ), int a, int b, int c, int d); void initializeTests(const char* testName, size_t testNameSize); -void outputProgress(const State4& state, const char* pathStr); -void outputToStream(const State4& state, const char* pathStr, SkWStream& outFile); +void outputProgress(const State4& state, const char* pathStr, SkPath::FillType ); +void outputToStream(const State4& state, const char* pathStr, SkPath::FillType, SkWStream& outFile); bool runNextTestSet(State4& state); int waitForCompletion(); diff --git a/experimental/Intersection/EdgeWalker_TestUtility.cpp b/experimental/Intersection/EdgeWalker_TestUtility.cpp index 7baa17b055..0fb37b0840 100644 --- a/experimental/Intersection/EdgeWalker_TestUtility.cpp +++ b/experimental/Intersection/EdgeWalker_TestUtility.cpp @@ -22,11 +22,9 @@ static const char marker[] = "