| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include "PathOpsExtendedTest.h" | 7 #include "PathOpsExtendedTest.h" |
| 8 #include "PathOpsThreadedCommon.h" |
| 8 | 9 |
| 9 static THREAD_TYPE testSimplifyQuadralateralsMain(void* data) | 10 static void testSimplifyQuadralateralsMain(PathOpsThreadState* data) |
| 10 { | 11 { |
| 11 SkASSERT(data); | 12 SkASSERT(data); |
| 12 State4& state = *(State4*) data; | 13 PathOpsThreadState& state = *data; |
| 13 char pathStr[1024]; | 14 char pathStr[1024]; |
| 14 sk_bzero(pathStr, sizeof(pathStr)); | 15 sk_bzero(pathStr, sizeof(pathStr)); |
| 15 do { | 16 int ax = state.fA & 0x03; |
| 16 int ax = state.a & 0x03; | 17 int ay = state.fA >> 2; |
| 17 int ay = state.a >> 2; | 18 int bx = state.fB & 0x03; |
| 18 int bx = state.b & 0x03; | 19 int by = state.fB >> 2; |
| 19 int by = state.b >> 2; | 20 int cx = state.fC & 0x03; |
| 20 int cx = state.c & 0x03; | 21 int cy = state.fC >> 2; |
| 21 int cy = state.c >> 2; | 22 int dx = state.fD & 0x03; |
| 22 int dx = state.d & 0x03; | 23 int dy = state.fD >> 2; |
| 23 int dy = state.d >> 2; | 24 for (int e = 0 ; e < 16; ++e) { |
| 24 for (int e = 0 ; e < 16; ++e) { | 25 int ex = e & 0x03; |
| 25 int ex = e & 0x03; | 26 int ey = e >> 2; |
| 26 int ey = e >> 2; | 27 for (int f = e ; f < 16; ++f) { |
| 27 for (int f = e ; f < 16; ++f) { | 28 int fx = f & 0x03; |
| 28 int fx = f & 0x03; | 29 int fy = f >> 2; |
| 29 int fy = f >> 2; | 30 for (int g = f ; g < 16; ++g) { |
| 30 for (int g = f ; g < 16; ++g) { | 31 int gx = g & 0x03; |
| 31 int gx = g & 0x03; | 32 int gy = g >> 2; |
| 32 int gy = g >> 2; | 33 for (int h = g ; h < 16; ++h) { |
| 33 for (int h = g ; h < 16; ++h) { | 34 int hx = h & 0x03; |
| 34 int hx = h & 0x03; | 35 int hy = h >> 2; |
| 35 int hy = h >> 2; | 36 SkPath path, out; |
| 36 SkPath path, out; | 37 path.setFillType(SkPath::kWinding_FillType); |
| 37 path.setFillType(SkPath::kWinding_FillType); | 38 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
| 38 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 39 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); |
| 39 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | 40 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); |
| 40 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | 41 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
| 41 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 42 path.close(); |
| 42 path.close(); | 43 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
| 43 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 44 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
| 44 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 45 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy)); |
| 45 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy)); | 46 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy)); |
| 46 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy)); | 47 path.close(); |
| 47 path.close(); | 48 // gdb: set print elements 400 |
| 48 if (1) { // gdb: set print elements 400 | 49 char* str = pathStr; |
| 49 char* str = pathStr; | 50 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); |
| 50 str += sprintf(str, " path.moveTo(%d, %d);\n", ax
, ay); | 51 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by); |
| 51 str += sprintf(str, " path.lineTo(%d, %d);\n", bx
, by); | 52 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy); |
| 52 str += sprintf(str, " path.lineTo(%d, %d);\n", cx
, cy); | 53 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy); |
| 53 str += sprintf(str, " path.lineTo(%d, %d);\n", dx
, dy); | 54 str += sprintf(str, " path.close();\n"); |
| 54 str += sprintf(str, " path.close();\n"); | 55 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey); |
| 55 str += sprintf(str, " path.moveTo(%d, %d);\n", ex
, ey); | 56 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); |
| 56 str += sprintf(str, " path.lineTo(%d, %d);\n", fx
, fy); | 57 str += sprintf(str, " path.lineTo(%d, %d);\n", gx, gy); |
| 57 str += sprintf(str, " path.lineTo(%d, %d);\n", gx
, gy); | 58 str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy); |
| 58 str += sprintf(str, " path.lineTo(%d, %d);\n", hx
, hy); | 59 str += sprintf(str, " path.close();\n"); |
| 59 str += sprintf(str, " path.close();\n"); | 60 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_Fil
lType); |
| 60 } | 61 testSimplify(path, false, out, state, pathStr); |
| 61 outputProgress(state, pathStr, SkPath::kWinding_FillType
); | 62 path.setFillType(SkPath::kEvenOdd_FillType); |
| 62 testSimplify(path, false, out, state, pathStr); | 63 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_Fil
lType); |
| 63 state.testsRun++; | 64 testSimplify(path, true, out, state, pathStr); |
| 64 path.setFillType(SkPath::kEvenOdd_FillType); | |
| 65 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType
); | |
| 66 testSimplify(path, true, out, state, pathStr); | |
| 67 state.testsRun++; | |
| 68 } | |
| 69 } | 65 } |
| 70 } | 66 } |
| 71 } | 67 } |
| 72 } while (runNextTestSet(state)); | 68 } |
| 73 THREAD_RETURN | |
| 74 } | 69 } |
| 75 | 70 |
| 76 static void TestSimplifyQuadralateralsThreaded(skiatest::Reporter* reporter) | 71 static void TestSimplifyQuadralateralsThreaded(skiatest::Reporter* reporter) |
| 77 { | 72 { |
| 78 int testsRun = 0; | 73 int threadCount = initializeTests("testQuadralaterals"); |
| 79 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); | 74 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
| 80 #ifdef SK_DEBUG | |
| 81 gDebugMaxWindSum = 4; // FIXME: 3? | |
| 82 gDebugMaxWindValue = 4; | |
| 83 #endif | |
| 84 const char testStr[] = "testQuadralaterals"; | |
| 85 initializeTests(reporter, testStr, sizeof(testStr)); | |
| 86 for (int a = 0; a < 16; ++a) { | 75 for (int a = 0; a < 16; ++a) { |
| 87 for (int b = a ; b < 16; ++b) { | 76 for (int b = a ; b < 16; ++b) { |
| 88 for (int c = b ; c < 16; ++c) { | 77 for (int c = b ; c < 16; ++c) { |
| 89 for (int d = c; d < 16; ++d) { | 78 for (int d = c; d < 16; ++d) { |
| 90 testsRun += dispatchTest4(testSimplifyQuadralateralsMain, a,
b, c, d); | 79 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded
Runnable, |
| 80 (&testSimplifyQuadralateralsMain, a, b, c, d, &testR
unner)); |
| 91 } | 81 } |
| 92 if (!gAllowExtendedTest) goto finish; | 82 if (!reporter->allowExtendedTest()) goto finish; |
| 93 if (gShowTestProgress) SkDebugf("."); | |
| 94 } | 83 } |
| 95 if (gShowTestProgress) SkDebugf("%d", b); | |
| 96 } | 84 } |
| 97 if (gShowTestProgress) SkDebugf("\n%d", a); | |
| 98 } | 85 } |
| 99 finish: | 86 finish: |
| 100 testsRun += waitForCompletion(); | 87 testRunner.render(); |
| 101 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun); | |
| 102 } | 88 } |
| 103 | 89 |
| 104 #include "TestClassDef.h" | 90 #include "TestClassDef.h" |
| 105 DEFINE_TESTCLASS("SimplifyQuadralateralsThreaded", SimplifyQuadralateralsThreade
dTestClass, \ | 91 DEFINE_TESTCLASS("SimplifyQuadralateralsThreaded", SimplifyQuadralateralsThreade
dTestClass, \ |
| 106 TestSimplifyQuadralateralsThreaded) | 92 TestSimplifyQuadralateralsThreaded) |
| OLD | NEW |