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