| 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 #include "PathOpsThreadedCommon.h" |
| 9 | 9 |
| 10 static void testSimplifyTrianglesMain(PathOpsThreadState* data) { | 10 static void testSimplifyTrianglesMain(PathOpsThreadState* data) { |
| 11 SkASSERT(data); | 11 SkASSERT(data); |
| 12 PathOpsThreadState& state = *data; | 12 PathOpsThreadState& state = *data; |
| 13 char pathStr[1024]; | 13 char pathStr[1024]; |
| 14 sk_bzero(pathStr, sizeof(pathStr)); | 14 bool progress = state.fReporter->verbose(); // FIXME: break out into its own
parameter? |
| 15 if (progress) { |
| 16 sk_bzero(pathStr, sizeof(pathStr)); |
| 17 } |
| 15 state.fKey = "?"; | 18 state.fKey = "?"; |
| 16 int ax = state.fA & 0x03; | 19 int ax = state.fA & 0x03; |
| 17 int ay = state.fA >> 2; | 20 int ay = state.fA >> 2; |
| 18 int bx = state.fB & 0x03; | 21 int bx = state.fB & 0x03; |
| 19 int by = state.fB >> 2; | 22 int by = state.fB >> 2; |
| 20 int cx = state.fC & 0x03; | 23 int cx = state.fC & 0x03; |
| 21 int cy = state.fC >> 2; | 24 int cy = state.fC >> 2; |
| 22 for (int d = 0; d < 15; ++d) { | 25 for (int d = 0; d < 15; ++d) { |
| 23 int dx = d & 0x03; | 26 int dx = d & 0x03; |
| 24 int dy = d >> 2; | 27 int dy = d >> 2; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 SkPath path, out; | 40 SkPath path, out; |
| 38 path.setFillType(SkPath::kWinding_FillType); | 41 path.setFillType(SkPath::kWinding_FillType); |
| 39 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 42 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
| 40 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | 43 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); |
| 41 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | 44 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); |
| 42 path.close(); | 45 path.close(); |
| 43 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 46 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
| 44 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 47 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
| 45 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 48 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
| 46 path.close(); | 49 path.close(); |
| 47 char* str = pathStr; | 50 if (progress) { |
| 48 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); | 51 char* str = pathStr; |
| 49 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by); | 52 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); |
| 50 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy); | 53 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by); |
| 51 str += sprintf(str, " path.close();\n"); | 54 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy); |
| 52 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy); | 55 str += sprintf(str, " path.close();\n"); |
| 53 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey); | 56 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy); |
| 54 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); | 57 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey); |
| 55 str += sprintf(str, " path.close();\n"); | 58 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); |
| 56 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillTyp
e); | 59 str += sprintf(str, " path.close();\n"); |
| 60 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_Fil
lType); |
| 61 } |
| 57 ShowTestName(&state, d, e, f, 0); | 62 ShowTestName(&state, d, e, f, 0); |
| 58 testSimplify(path, false, out, state, pathStr); | 63 testSimplify(path, false, out, state, pathStr); |
| 59 path.setFillType(SkPath::kEvenOdd_FillType); | 64 path.setFillType(SkPath::kEvenOdd_FillType); |
| 60 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillTyp
e); | 65 if (progress) { |
| 66 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_Fil
lType); |
| 67 } |
| 61 ShowTestName(&state, d, e, f, 1); | 68 ShowTestName(&state, d, e, f, 1); |
| 62 testSimplify(path, true, out, state, pathStr); | 69 testSimplify(path, true, out, state, pathStr); |
| 63 } | 70 } |
| 64 } | 71 } |
| 65 } | 72 } |
| 66 } | 73 } |
| 67 | 74 |
| 68 static void PathOpsSimplifyTrianglesThreadedTest(skiatest::Reporter* reporter) { | 75 static void PathOpsSimplifyTrianglesThreadedTest(skiatest::Reporter* reporter) { |
| 69 int threadCount = initializeTests(reporter, "testTriangles"); | 76 int threadCount = initializeTests(reporter, "testTriangles"); |
| 70 PathOpsThreadedTestRunner testRunner(reporter, threadCount); | 77 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 88 } | 95 } |
| 89 if (!reporter->allowExtendedTest()) goto finish; | 96 if (!reporter->allowExtendedTest()) goto finish; |
| 90 } | 97 } |
| 91 } | 98 } |
| 92 finish: | 99 finish: |
| 93 testRunner.render(); | 100 testRunner.render(); |
| 94 } | 101 } |
| 95 | 102 |
| 96 #include "TestClassDef.h" | 103 #include "TestClassDef.h" |
| 97 DEFINE_TESTCLASS_SHORT(PathOpsSimplifyTrianglesThreadedTest) | 104 DEFINE_TESTCLASS_SHORT(PathOpsSimplifyTrianglesThreadedTest) |
| OLD | NEW |