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 | |
caryclark | 08bc848 | 2015-04-24 09:08:57 -0700 | [diff] [blame] | 11 | static int loopNo = 158; |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 12 | |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 13 | static void testOpCubicsMain(PathOpsThreadState* data) { |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 14 | #if DEBUG_SHOW_TEST_NAME |
| 15 | strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); |
| 16 | #endif |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 17 | SkASSERT(data); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 18 | PathOpsThreadState& state = *data; |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 19 | SkString pathStr; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 20 | for (int a = 0 ; a < 6; ++a) { |
| 21 | for (int b = a + 1 ; b < 7; ++b) { |
| 22 | for (int c = 0 ; c < 6; ++c) { |
| 23 | for (int d = c + 1 ; d < 7; ++d) { |
| 24 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 25 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
| 26 | SkPath pathA, pathB; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 27 | pathA.setFillType((SkPath::FillType) e); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 28 | pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 29 | pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b), |
| 30 | SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 31 | pathA.close(); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 32 | pathB.setFillType((SkPath::FillType) f); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 33 | pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 34 | pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB), |
| 35 | SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 36 | pathB.close(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 37 | for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 38 | if (state.fReporter->verbose()) { |
| 39 | pathStr.printf("static void cubicOp%d(skiatest::Reporter* reporter," |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 40 | " const char* filename) {\n", loopNo); |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 41 | pathStr.appendf(" SkPath path, pathB;\n"); |
| 42 | pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 43 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 44 | ? "EvenOdd" : "?UNDEFINED"); |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 45 | pathStr.appendf(" path.moveTo(%d,%d);\n", state.fA, state.fB); |
| 46 | pathStr.appendf(" path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD, |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 47 | b, a, d, c); |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 48 | pathStr.appendf(" path.close();\n"); |
| 49 | pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n", |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 50 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 51 | ? "EvenOdd" : "?UNDEFINED"); |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 52 | pathStr.appendf(" pathB.moveTo(%d,%d);\n", a, b); |
| 53 | pathStr.appendf(" pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d, |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 54 | state.fB, state.fA, state.fD, state.fC); |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 55 | pathStr.appendf(" pathB.close();\n"); |
| 56 | pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n", |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 57 | SkPathOpsDebug::OpStr((SkPathOp) op)); |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 58 | pathStr.appendf("}\n"); |
Mike Reed | ff80c2a | 2017-01-07 11:16:28 -0500 | [diff] [blame] | 59 | state.outputProgress(pathStr.c_str(), (SkPathOp) op); |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 60 | } |
caryclark | 38a017b | 2015-05-13 10:13:17 -0700 | [diff] [blame] | 61 | if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) { |
caryclark | 8f18643 | 2016-10-06 11:46:25 -0700 | [diff] [blame] | 62 | if (state.fReporter->verbose()) { |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 63 | ++loopNo; |
| 64 | goto skipToNext; |
| 65 | } |
| 66 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 67 | } |
| 68 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 69 | } |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 70 | skipToNext: ; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 71 | } |
| 72 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 73 | } |
| 74 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 75 | } |
| 76 | |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 77 | DEF_TEST(PathOpsOpCubicsThreaded, reporter) { |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 78 | initializeTests(reporter, "cubicOp"); |
| 79 | PathOpsThreadedTestRunner testRunner(reporter); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 80 | for (int a = 0; a < 6; ++a) { // outermost |
| 81 | for (int b = a + 1; b < 7; ++b) { |
| 82 | for (int c = 0 ; c < 6; ++c) { |
| 83 | for (int d = c + 1; d < 7; ++d) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 84 | *testRunner.fRunnables.append() = |
| 85 | new PathOpsThreadedRunnable(&testOpCubicsMain, a, b, c, d, &testRunner); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 86 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 87 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 88 | if (!reporter->allowExtendedTest()) goto finish; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 89 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 90 | } |
| 91 | finish: |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 92 | testRunner.render(); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 93 | } |