| 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 testSimplifyTrianglesMain(void* data) { | 10 static void testSimplifyTrianglesMain(PathOpsThreadState* data) { |
| 10 SkASSERT(data); | 11 SkASSERT(data); |
| 11 State4& state = *(State4*) data; | 12 PathOpsThreadState& state = *data; |
| 12 char pathStr[1024]; | 13 char pathStr[1024]; |
| 13 sk_bzero(pathStr, sizeof(pathStr)); | 14 sk_bzero(pathStr, sizeof(pathStr)); |
| 14 do { | 15 int ax = state.fA & 0x03; |
| 15 int ax = state.a & 0x03; | 16 int ay = state.fA >> 2; |
| 16 int ay = state.a >> 2; | 17 int bx = state.fB & 0x03; |
| 17 int bx = state.b & 0x03; | 18 int by = state.fB >> 2; |
| 18 int by = state.b >> 2; | 19 int cx = state.fC & 0x03; |
| 19 int cx = state.c & 0x03; | 20 int cy = state.fC >> 2; |
| 20 int cy = state.c >> 2; | 21 for (int d = 0; d < 15; ++d) { |
| 21 for (int d = 0; d < 15; ++d) { | 22 int dx = d & 0x03; |
| 22 int dx = d & 0x03; | 23 int dy = d >> 2; |
| 23 int dy = d >> 2; | 24 for (int e = d + 1; e < 16; ++e) { |
| 24 for (int e = d + 1; 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 = d + 1; f < 16; ++f) { |
| 27 for (int f = d + 1; f < 16; ++f) { | 28 if (e == f) { |
| 28 if (e == f) { | 29 continue; |
| 29 continue; | |
| 30 } | |
| 31 int fx = f & 0x03; | |
| 32 int fy = f >> 2; | |
| 33 if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) { | |
| 34 continue; | |
| 35 } | |
| 36 SkPath path, out; | |
| 37 path.setFillType(SkPath::kWinding_FillType); | |
| 38 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | |
| 39 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | |
| 40 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | |
| 41 path.close(); | |
| 42 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); | |
| 43 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); | |
| 44 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | |
| 45 path.close(); | |
| 46 if (1) { | |
| 47 char* str = pathStr; | |
| 48 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay
); | |
| 49 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by
); | |
| 50 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy
); | |
| 51 str += sprintf(str, " path.close();\n"); | |
| 52 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy
); | |
| 53 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey
); | |
| 54 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy
); | |
| 55 str += sprintf(str, " path.close();\n"); | |
| 56 } | |
| 57 outputProgress(state, pathStr, SkPath::kWinding_FillType); | |
| 58 testSimplify(path, false, out, state, pathStr); | |
| 59 state.testsRun++; | |
| 60 path.setFillType(SkPath::kEvenOdd_FillType); | |
| 61 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); | |
| 62 testSimplify(path, true, out, state, pathStr); | |
| 63 state.testsRun++; | |
| 64 } | 30 } |
| 31 int fx = f & 0x03; |
| 32 int fy = f >> 2; |
| 33 if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) { |
| 34 continue; |
| 35 } |
| 36 SkPath path, out; |
| 37 path.setFillType(SkPath::kWinding_FillType); |
| 38 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
| 39 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); |
| 40 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); |
| 41 path.close(); |
| 42 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
| 43 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
| 44 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
| 45 path.close(); |
| 46 char* str = pathStr; |
| 47 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); |
| 48 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by); |
| 49 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy); |
| 50 str += sprintf(str, " path.close();\n"); |
| 51 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy); |
| 52 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey); |
| 53 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); |
| 54 str += sprintf(str, " path.close();\n"); |
| 55 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillTyp
e); |
| 56 testSimplify(path, false, out, state, pathStr); |
| 57 path.setFillType(SkPath::kEvenOdd_FillType); |
| 58 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillTyp
e); |
| 59 testSimplify(path, true, out, state, pathStr); |
| 65 } | 60 } |
| 66 } | 61 } |
| 67 } while (runNextTestSet(state)); | 62 } |
| 68 THREAD_RETURN | |
| 69 } | 63 } |
| 70 | 64 |
| 71 static void TestSimplifyTrianglesThreaded(skiatest::Reporter* reporter) { | 65 static void TestSimplifyTrianglesThreaded(skiatest::Reporter* reporter) { |
| 72 int testsRun = 0; | 66 int threadCount = initializeTests("testTriangles"); |
| 73 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); | 67 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
| 74 #ifdef SK_DEBUG | |
| 75 gDebugMaxWindSum = 2; | |
| 76 gDebugMaxWindValue = 2; | |
| 77 #endif | |
| 78 const char testStr[] = "testTriangles"; | |
| 79 initializeTests(reporter, testStr, sizeof(testStr)); | |
| 80 for (int a = 0; a < 15; ++a) { | 68 for (int a = 0; a < 15; ++a) { |
| 81 int ax = a & 0x03; | 69 int ax = a & 0x03; |
| 82 int ay = a >> 2; | 70 int ay = a >> 2; |
| 83 for (int b = a + 1; b < 16; ++b) { | 71 for (int b = a + 1; b < 16; ++b) { |
| 84 int bx = b & 0x03; | 72 int bx = b & 0x03; |
| 85 int by = b >> 2; | 73 int by = b >> 2; |
| 86 for (int c = a + 1; c < 16; ++c) { | 74 for (int c = a + 1; c < 16; ++c) { |
| 87 if (b == c) { | 75 if (b == c) { |
| 88 continue; | 76 continue; |
| 89 } | 77 } |
| 90 int cx = c & 0x03; | 78 int cx = c & 0x03; |
| 91 int cy = c >> 2; | 79 int cy = c >> 2; |
| 92 if ((bx - ax) * (cy - ay) == (by - ay) * (cx - ax)) { | 80 if ((bx - ax) * (cy - ay) == (by - ay) * (cx - ax)) { |
| 93 continue; | 81 continue; |
| 94 } | 82 } |
| 95 testsRun += dispatchTest4(testSimplifyTrianglesMain, a, b, c, 0)
; | 83 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunn
able, |
| 84 (&testSimplifyTrianglesMain, a, b, c, 0, &testRunner)); |
| 96 } | 85 } |
| 97 if (!gAllowExtendedTest) goto finish; | 86 if (!reporter->allowExtendedTest()) goto finish; |
| 98 if (gShowTestProgress) SkDebugf("."); | |
| 99 } | 87 } |
| 100 if (gShowTestProgress) SkDebugf("\n%d", a); | |
| 101 } | 88 } |
| 102 finish: | 89 finish: |
| 103 testsRun += waitForCompletion(); | 90 testRunner.render(); |
| 104 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun); | |
| 105 } | 91 } |
| 106 | 92 |
| 107 #include "TestClassDef.h" | 93 #include "TestClassDef.h" |
| 108 DEFINE_TESTCLASS("SimplifyTrianglesThreaded", SimplifyTrianglesThreadedTestClass
, \ | 94 DEFINE_TESTCLASS("SimplifyTrianglesThreaded", SimplifyTrianglesThreadedTestClass
, \ |
| 109 TestSimplifyTrianglesThreaded) | 95 TestSimplifyTrianglesThreaded) |
| OLD | NEW |