caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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" |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 8 | #include "PathOpsThreadedCommon.h" |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 9 | #include "SkString.h" |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 10 | |
| 11 | // four rects, of four sizes |
| 12 | // for 3 smaller sizes, tall, wide |
| 13 | // top upper mid lower bottom aligned (3 bits, 5 values) |
| 14 | // same with x (3 bits, 5 values) |
| 15 | // not included, square, tall, wide (2 bits) |
| 16 | // cw or ccw (1 bit) |
| 17 | |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 18 | static int loopNo = 6; |
| 19 | |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 20 | static void testPathOpsRectsMain(PathOpsThreadState* data) |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 21 | { |
| 22 | SkASSERT(data); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 23 | PathOpsThreadState& state = *data; |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 24 | SkString pathStr; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 25 | for (int a = 0 ; a < 6; ++a) { |
| 26 | for (int b = a + 1 ; b < 7; ++b) { |
| 27 | for (int c = 0 ; c < 6; ++c) { |
| 28 | for (int d = c + 1 ; d < 7; ++d) { |
| 29 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 30 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
| 31 | SkPath pathA, pathB; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 32 | pathA.setFillType((SkPath::FillType) e); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 33 | pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB), |
| 34 | SkIntToScalar(state.fB), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 35 | pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD), |
| 36 | SkIntToScalar(state.fD), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 37 | pathA.close(); |
| 38 | pathB.setFillType((SkPath::FillType) f); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 39 | pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), |
| 40 | SkIntToScalar(b), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 41 | pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), |
| 42 | SkIntToScalar(d), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 43 | pathB.close(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 44 | for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 45 | if (state.fReporter->verbose()) { |
| 46 | pathStr.printf( |
| 47 | "static void rects%d(skiatest::Reporter* reporter," |
| 48 | "const char* filename) {\n", loopNo); |
| 49 | pathStr.appendf(" SkPath path, pathB;"); |
| 50 | pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", |
| 51 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 52 | ? "EvenOdd" : "?UNDEFINED"); |
| 53 | pathStr.appendf(" path.addRect(%d, %d, %d, %d," |
| 54 | " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB); |
| 55 | pathStr.appendf(" path.addRect(%d, %d, %d, %d," |
| 56 | " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD); |
| 57 | pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n", |
| 58 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 59 | ? "EvenOdd" : "?UNDEFINED"); |
| 60 | pathStr.appendf(" pathB.addRect(%d, %d, %d, %d," |
| 61 | " SkPath::kCW_Direction);\n", a, a, b, b); |
| 62 | pathStr.appendf(" pathB.addRect(%d, %d, %d, %d," |
| 63 | " SkPath::kCW_Direction);\n", c, c, d, d); |
| 64 | pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n", |
| 65 | SkPathOpsDebug::OpStr((SkPathOp) op)); |
| 66 | pathStr.appendf("}\n\n"); |
Mike Reed | ff80c2a | 2017-01-07 11:16:28 -0500 | [diff] [blame] | 67 | state.outputProgress(pathStr.c_str(), (SkPathOp) op); |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 68 | } |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 69 | if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects")) { |
| 70 | if (state.fReporter->verbose()) { |
| 71 | ++loopNo; |
| 72 | goto skipToNext; |
| 73 | } |
| 74 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 75 | } |
| 76 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 77 | } |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 78 | skipToNext: ; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 79 | } |
| 80 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 81 | } |
| 82 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 83 | } |
| 84 | |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 85 | DEF_TEST(PathOpsRectsThreaded, reporter) { |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 86 | initializeTests(reporter, "testOp"); |
| 87 | PathOpsThreadedTestRunner testRunner(reporter); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 88 | for (int a = 0; a < 6; ++a) { // outermost |
| 89 | for (int b = a + 1; b < 7; ++b) { |
| 90 | for (int c = 0 ; c < 6; ++c) { |
| 91 | for (int d = c + 1; d < 7; ++d) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 92 | *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( |
| 93 | &testPathOpsRectsMain, a, b, c, d, &testRunner); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 94 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 95 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 96 | if (!reporter->allowExtendedTest()) goto finish; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 97 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 98 | } |
| 99 | finish: |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 100 | testRunner.render(); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 101 | } |