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 | */ |
| 7 | #include "PathOpsExtendedTest.h" |
| 8 | #include "PathOpsThreadedCommon.h" |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 9 | #include "SkString.h" |
| 10 | |
| 11 | static int loopNo = 4; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 12 | |
| 13 | static void testOpCirclesMain(PathOpsThreadState* data) { |
| 14 | SkASSERT(data); |
| 15 | PathOpsThreadState& state = *data; |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 16 | SkString pathStr; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 17 | for (int a = 0 ; a < 6; ++a) { |
| 18 | for (int b = a + 1 ; b < 7; ++b) { |
| 19 | for (int c = 0 ; c < 6; ++c) { |
| 20 | for (int d = c + 1 ; d < 7; ++d) { |
| 21 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 22 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
| 23 | SkPath pathA, pathB; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 24 | pathA.setFillType((SkPath::FillType) e); |
| 25 | pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC), |
| 26 | state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
| 27 | pathB.setFillType((SkPath::FillType) f); |
| 28 | pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), |
| 29 | d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); |
| 30 | for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 31 | if (state.fReporter->verbose()) { |
| 32 | pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter," |
| 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.fA, 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, filename);\n", |
| 46 | SkPathOpsDebug::OpStr((SkPathOp) op)); |
| 47 | pathStr.appendf("}\n"); |
Mike Reed | ff80c2a | 2017-01-07 11:16:28 -0500 | [diff] [blame] | 48 | state.outputProgress(pathStr.c_str(), (SkPathOp) op); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 49 | } |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 50 | if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles")) { |
| 51 | if (state.fReporter->verbose()) { |
| 52 | ++loopNo; |
| 53 | goto skipToNext; |
| 54 | } |
| 55 | } |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 56 | } |
| 57 | } |
| 58 | } |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 59 | skipToNext: ; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | DEF_TEST(PathOpsOpCircleThreaded, reporter) { |
| 67 | initializeTests(reporter, "circleOp"); |
| 68 | PathOpsThreadedTestRunner testRunner(reporter); |
| 69 | for (int a = 0; a < 6; ++a) { // outermost |
| 70 | for (int b = a + 1; b < 7; ++b) { |
| 71 | for (int c = 0 ; c < 6; ++c) { |
| 72 | for (int d = 0; d < 2; ++d) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 73 | *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( |
| 74 | &testOpCirclesMain, a, b, c, d, &testRunner); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | if (!reporter->allowExtendedTest()) goto finish; |
| 78 | } |
| 79 | } |
| 80 | finish: |
| 81 | testRunner.render(); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 82 | } |