Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 loopNo = 4; | |
|
scroggo
2016/10/06 14:42:00
nit: I think this should be gLoopNo, since it's a
| |
| 9 | 12 |
| 10 static void testOpCirclesMain(PathOpsThreadState* data) { | 13 static void testOpCirclesMain(PathOpsThreadState* data) { |
| 11 SkASSERT(data); | 14 SkASSERT(data); |
| 12 PathOpsThreadState& state = *data; | 15 PathOpsThreadState& state = *data; |
| 13 char pathStr[1024]; | 16 SkString pathStr; |
| 14 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? | |
| 15 if (progress) { | |
| 16 sk_bzero(pathStr, sizeof(pathStr)); | |
| 17 } | |
| 18 | |
| 19 for (int a = 0 ; a < 6; ++a) { | 17 for (int a = 0 ; a < 6; ++a) { |
| 20 for (int b = a + 1 ; b < 7; ++b) { | 18 for (int b = a + 1 ; b < 7; ++b) { |
| 21 for (int c = 0 ; c < 6; ++c) { | 19 for (int c = 0 ; c < 6; ++c) { |
| 22 for (int d = c + 1 ; d < 7; ++d) { | 20 for (int d = c + 1 ; d < 7; ++d) { |
| 23 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) { | 21 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) { |
| 24 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) { | 22 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) { |
| 25 SkPath pathA, pathB; | 23 SkPath pathA, pathB; |
| 26 if (progress) { | |
| 27 char* str = pathStr; | |
| 28 const int loopNo = 4; | |
| 29 str += sprintf(str, "static void circlesOp%d(skiatest::Reporter* rep orter," | |
| 30 " const char* filename) {\n", loopNo); | |
| 31 str += sprintf(str, " SkPath path, pathB;\n"); | |
| 32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", | |
| 33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE venOdd_FillType | |
| 34 ? "EvenOdd" : "?UNDEFINED"); | |
| 35 str += sprintf(str, " path.addCircle(%d, %d, %d, %s);\n", state.f A, state.fB, | |
| 36 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW _Direction"); | |
| 37 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n" , | |
| 38 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE venOdd_FillType | |
| 39 ? "EvenOdd" : "?UNDEFINED"); | |
| 40 str += sprintf(str, " pathB.addCircle(%d, %d, %d, %s);\n", a, b, | |
| 41 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); | |
| 42 str += sprintf(str, " testPathOp(reporter, path, pathB, kDifferen ce_SkPathOp," | |
| 43 " filename);\n"); | |
| 44 str += sprintf(str, "}\n"); | |
| 45 } | |
| 46 pathA.setFillType((SkPath::FillType) e); | 24 pathA.setFillType((SkPath::FillType) e); |
| 47 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntT oScalar(state.fC), | 25 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntT oScalar(state.fC), |
| 48 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); | 26 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
| 49 pathB.setFillType((SkPath::FillType) f); | 27 pathB.setFillType((SkPath::FillType) f); |
| 50 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), | 28 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), |
| 51 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); | 29 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
| 52 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { | 30 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
| 53 if (progress) { | 31 if (state.fReporter->verbose()) { |
| 54 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); | 32 pathStr.printf("static void circlesOp%d(skiatest::Reporter* repo rter," |
| 33 " const char* filename) {\n", loopNo); | |
| 34 pathStr.appendf(" SkPath path, pathB;\n"); | |
| 35 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", | |
| 36 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath ::kEvenOdd_FillType | |
| 37 ? "EvenOdd" : "?UNDEFINED"); | |
| 38 pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.f A, state.fB, | |
| 39 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath:: kCCW_Direction"); | |
| 40 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n" , | |
| 41 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath ::kEvenOdd_FillType | |
| 42 ? "EvenOdd" : "?UNDEFINED"); | |
| 43 pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b, | |
| 44 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction "); | |
| 45 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filen ame);\n", | |
| 46 SkPathOpsDebug::OpStr((SkPathOp) op)); | |
| 47 pathStr.appendf("}\n"); | |
| 48 outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op); | |
| 55 } | 49 } |
| 56 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles"); | 50 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circl es")) { |
| 51 if (state.fReporter->verbose()) { | |
| 52 ++loopNo; | |
| 53 goto skipToNext; | |
| 54 } | |
| 55 } | |
| 57 } | 56 } |
| 58 } | 57 } |
| 59 } | 58 } |
| 59 skipToNext: ; | |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 DEF_TEST(PathOpsOpCircleThreaded, reporter) { | 66 DEF_TEST(PathOpsOpCircleThreaded, reporter) { |
| 67 initializeTests(reporter, "circleOp"); | 67 initializeTests(reporter, "circleOp"); |
| 68 PathOpsThreadedTestRunner testRunner(reporter); | 68 PathOpsThreadedTestRunner testRunner(reporter); |
| 69 for (int a = 0; a < 6; ++a) { // outermost | 69 for (int a = 0; a < 6; ++a) { // outermost |
| 70 for (int b = a + 1; b < 7; ++b) { | 70 for (int b = a + 1; b < 7; ++b) { |
| 71 for (int c = 0 ; c < 6; ++c) { | 71 for (int c = 0 ; c < 6; ++c) { |
| 72 for (int d = 0; d < 2; ++d) { | 72 for (int d = 0; d < 2; ++d) { |
| 73 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( | 73 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( |
| 74 &testOpCirclesMain, a, b, c, d, &testRunner); | 74 &testOpCirclesMain, a, b, c, d, &testRunner); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 if (!reporter->allowExtendedTest()) goto finish; | 77 if (!reporter->allowExtendedTest()) goto finish; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 finish: | 80 finish: |
| 81 testRunner.render(); | 81 testRunner.render(); |
| 82 } | 82 } |
| OLD | NEW |