caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Cary Clark | 4533f3d | 2018-08-08 09:48:09 -0400 | [diff] [blame] | 7 | #include "PathOpsDebug.h" |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 8 | #include "PathOpsExtendedTest.h" |
| 9 | #include "PathOpsThreadedCommon.h" |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 10 | #include "SkString.h" |
Hal Canary | 8a00144 | 2018-09-19 11:31:27 -0400 | [diff] [blame] | 11 | |
Cary Clark | 8af4c40 | 2018-08-08 23:22:37 -0400 | [diff] [blame] | 12 | #include <atomic> |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 13 | |
| 14 | static int loopNo = 4; |
Cary Clark | 8af4c40 | 2018-08-08 23:22:37 -0400 | [diff] [blame] | 15 | static std::atomic<int> gCirclesTestNo{0}; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 16 | |
| 17 | static void testOpCirclesMain(PathOpsThreadState* data) { |
| 18 | SkASSERT(data); |
| 19 | PathOpsThreadState& state = *data; |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 20 | SkString pathStr; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 21 | for (int a = 0 ; a < 6; ++a) { |
| 22 | for (int b = a + 1 ; b < 7; ++b) { |
| 23 | for (int c = 0 ; c < 6; ++c) { |
| 24 | for (int d = c + 1 ; d < 7; ++d) { |
| 25 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 26 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
| 27 | SkPath pathA, pathB; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 28 | pathA.setFillType((SkPath::FillType) e); |
| 29 | pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC), |
| 30 | state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
| 31 | pathB.setFillType((SkPath::FillType) f); |
| 32 | pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), |
| 33 | d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
| 34 | for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 35 | if (state.fReporter->verbose()) { |
| 36 | pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter," |
| 37 | " const char* filename) {\n", loopNo); |
| 38 | pathStr.appendf(" SkPath path, pathB;\n"); |
| 39 | pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", |
| 40 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 41 | ? "EvenOdd" : "?UNDEFINED"); |
| 42 | pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB, |
| 43 | state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); |
| 44 | pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n", |
| 45 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 46 | ? "EvenOdd" : "?UNDEFINED"); |
| 47 | pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b, |
| 48 | c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); |
| 49 | pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n", |
| 50 | SkPathOpsDebug::OpStr((SkPathOp) op)); |
| 51 | pathStr.appendf("}\n"); |
Mike Reed | ff80c2a | 2017-01-07 11:16:28 -0500 | [diff] [blame] | 52 | state.outputProgress(pathStr.c_str(), (SkPathOp) op); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 53 | } |
Cary Clark | 4533f3d | 2018-08-08 09:48:09 -0400 | [diff] [blame] | 54 | SkString testName; |
| 55 | testName.printf("thread_circles%d", ++gCirclesTestNo); |
| 56 | if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) { |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 57 | if (state.fReporter->verbose()) { |
| 58 | ++loopNo; |
| 59 | goto skipToNext; |
| 60 | } |
| 61 | } |
Cary Clark | 4533f3d | 2018-08-08 09:48:09 -0400 | [diff] [blame] | 62 | if (PathOpsDebug::gCheckForDuplicateNames) return; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | } |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 66 | skipToNext: ; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | DEF_TEST(PathOpsOpCircleThreaded, reporter) { |
| 74 | initializeTests(reporter, "circleOp"); |
| 75 | PathOpsThreadedTestRunner testRunner(reporter); |
| 76 | for (int a = 0; a < 6; ++a) { // outermost |
| 77 | for (int b = a + 1; b < 7; ++b) { |
| 78 | for (int c = 0 ; c < 6; ++c) { |
| 79 | for (int d = 0; d < 2; ++d) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 80 | *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( |
| 81 | &testOpCirclesMain, a, b, c, d, &testRunner); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | if (!reporter->allowExtendedTest()) goto finish; |
| 85 | } |
| 86 | } |
| 87 | finish: |
| 88 | testRunner.render(); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 89 | } |