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 #include "SkString.h" | |
10 | |
11 static int quadTest = 66; | |
scroggo
2016/10/06 14:42:00
nit: gQuadTest
| |
9 | 12 |
10 static void testSimplifyQuadsMain(PathOpsThreadState* data) | 13 static void testSimplifyQuadsMain(PathOpsThreadState* data) |
11 { | 14 { |
12 SkASSERT(data); | 15 SkASSERT(data); |
13 PathOpsThreadState& state = *data; | 16 PathOpsThreadState& state = *data; |
14 char pathStr[1024]; | 17 SkString pathStr; |
15 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? | |
16 if (progress) { | |
17 sk_bzero(pathStr, sizeof(pathStr)); | |
18 } | |
19 int ax = state.fA & 0x03; | 18 int ax = state.fA & 0x03; |
20 int ay = state.fA >> 2; | 19 int ay = state.fA >> 2; |
21 int bx = state.fB & 0x03; | 20 int bx = state.fB & 0x03; |
22 int by = state.fB >> 2; | 21 int by = state.fB >> 2; |
23 int cx = state.fC & 0x03; | 22 int cx = state.fC & 0x03; |
24 int cy = state.fC >> 2; | 23 int cy = state.fC >> 2; |
25 int dx = state.fD & 0x03; | 24 int dx = state.fD & 0x03; |
26 int dy = state.fD >> 2; | 25 int dy = state.fD >> 2; |
27 for (int e = 0 ; e < 16; ++e) { | 26 for (int e = 0 ; e < 16; ++e) { |
28 int ex = e & 0x03; | 27 int ex = e & 0x03; |
(...skipping 12 matching lines...) Expand all Loading... | |
41 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 40 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
42 path.quadTo(SkIntToScalar(bx), SkIntToScalar(by), | 41 path.quadTo(SkIntToScalar(bx), SkIntToScalar(by), |
43 SkIntToScalar(cx), SkIntToScalar(cy)); | 42 SkIntToScalar(cx), SkIntToScalar(cy)); |
44 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 43 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
45 path.close(); | 44 path.close(); |
46 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 45 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
47 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 46 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
48 path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy), | 47 path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy), |
49 SkIntToScalar(hx), SkIntToScalar(hy)); | 48 SkIntToScalar(hx), SkIntToScalar(hy)); |
50 path.close(); | 49 path.close(); |
51 if (progress) { | 50 if (state.fReporter->verbose()) { |
52 static int quadTest = 66; | 51 pathStr.printf("static void testQuads%d(skiatest::Report er* reporter," |
53 char* str = pathStr; | |
54 str += sprintf(str, "static void testQuads%d(skiatest::R eporter* reporter," | |
55 "const char* filename) {\n", quadTest); | 52 "const char* filename) {\n", quadTest); |
56 str += sprintf(str, " SkPath path;\n"); | 53 pathStr.appendf(" SkPath path;\n"); |
57 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay ); | 54 pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay); |
58 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n" , bx, by, cx, cy); | 55 pathStr.appendf(" path.quadTo(%d, %d, %d, %d);\n", bx , by, cx, cy); |
59 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy ); | 56 pathStr.appendf(" path.lineTo(%d, %d);\n", dx, dy); |
60 str += sprintf(str, " path.close();\n"); | 57 pathStr.appendf(" path.close();\n"); |
61 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey ); | 58 pathStr.appendf(" path.moveTo(%d, %d);\n", ex, ey); |
62 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy ); | 59 pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy); |
63 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n" , gx, gy, hx, hy); | 60 pathStr.appendf(" path.quadTo(%d, %d, %d, %d);\n", gx , gy, hx, hy); |
64 str += sprintf(str, " path.close();\n"); | 61 pathStr.appendf(" path.close();\n"); |
65 str += sprintf(str, " testSimplify(reporter, path, fi lename);\n"); | 62 pathStr.appendf(" testSimplify(reporter, path, filena me);\n"); |
66 str += sprintf(str, "}\n"); | 63 pathStr.appendf("}\n"); |
67 outputProgress(state.fPathStr, pathStr, SkPath::kWinding _FillType); | 64 outputProgress(state.fPathStr, pathStr.c_str(), SkPath:: kWinding_FillType); |
68 } | 65 } |
69 testSimplify(path, false, out, state, pathStr); | 66 testSimplify(path, false, out, state, pathStr.c_str()); |
70 path.setFillType(SkPath::kEvenOdd_FillType); | 67 path.setFillType(SkPath::kEvenOdd_FillType); |
71 if (progress) { | 68 if (state.fReporter->verbose()) { |
72 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd _FillType); | 69 outputProgress(state.fPathStr, pathStr.c_str(), SkPath:: kEvenOdd_FillType); |
73 } | 70 } |
74 testSimplify(path, true, out, state, pathStr); | 71 testSimplify(path, true, out, state, pathStr.c_str()); |
75 } | 72 } |
76 } | 73 } |
77 } | 74 } |
78 } | 75 } |
79 } | 76 } |
80 | 77 |
81 DEF_TEST(PathOpsSimplifyQuadsThreaded, reporter) { | 78 DEF_TEST(PathOpsSimplifyQuadsThreaded, reporter) { |
82 initializeTests(reporter, "testQuads"); | 79 initializeTests(reporter, "testQuads"); |
83 PathOpsThreadedTestRunner testRunner(reporter); | 80 PathOpsThreadedTestRunner testRunner(reporter); |
84 int a = 0; | 81 int a = 0; |
85 for (; a < 16; ++a) { | 82 for (; a < 16; ++a) { |
86 for (int b = a ; b < 16; ++b) { | 83 for (int b = a ; b < 16; ++b) { |
87 for (int c = b ; c < 16; ++c) { | 84 for (int c = b ; c < 16; ++c) { |
88 for (int d = c; d < 16; ++d) { | 85 for (int d = c; d < 16; ++d) { |
89 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( | 86 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( |
90 &testSimplifyQuadsMain, a, b, c, d, &testRunner); | 87 &testSimplifyQuadsMain, a, b, c, d, &testRunner); |
91 } | 88 } |
92 if (!reporter->allowExtendedTest()) goto finish; | 89 if (!reporter->allowExtendedTest()) goto finish; |
93 } | 90 } |
94 } | 91 } |
95 } | 92 } |
96 finish: | 93 finish: |
97 testRunner.render(); | 94 testRunner.render(); |
98 } | 95 } |
OLD | NEW |