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@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 10 | static void testOpCubicsMain(PathOpsThreadState* data) |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 11 | { |
caryclark@google.com | fa2aeee | 2013-07-15 13:29:13 +0000 | [diff] [blame] | 12 | #if DEBUG_SHOW_TEST_NAME |
| 13 | strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); |
| 14 | #endif |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 15 | SkASSERT(data); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 16 | PathOpsThreadState& state = *data; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 17 | char pathStr[1024]; // gdb: set print elements 400 |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 18 | bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? |
| 19 | if (progress) { |
| 20 | sk_bzero(pathStr, sizeof(pathStr)); |
| 21 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 22 | for (int a = 0 ; a < 6; ++a) { |
| 23 | for (int b = a + 1 ; b < 7; ++b) { |
| 24 | for (int c = 0 ; c < 6; ++c) { |
| 25 | for (int d = c + 1 ; d < 7; ++d) { |
| 26 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 27 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
| 28 | SkPath pathA, pathB; |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 29 | if (progress) { |
| 30 | char* str = pathStr; |
| 31 | str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", |
| 32 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 33 | ? "EvenOdd" : "?UNDEFINED"); |
| 34 | str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB); |
| 35 | str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD, |
| 36 | b, a, d, c); |
| 37 | str += sprintf(str, " path.close();\n"); |
| 38 | str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", |
| 39 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 40 | ? "EvenOdd" : "?UNDEFINED"); |
| 41 | str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b); |
| 42 | str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d, |
| 43 | state.fB, state.fA, state.fD, state.fC); |
| 44 | str += sprintf(str, " pathB.close();\n"); |
| 45 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 46 | pathA.setFillType((SkPath::FillType) e); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 47 | pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 48 | pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b), |
| 49 | SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 50 | pathA.close(); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 51 | pathB.setFillType((SkPath::FillType) f); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 52 | pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 53 | pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB), |
| 54 | SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC)); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 55 | pathB.close(); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 56 | for (int op = 0 ; op <= kXOR_PathOp; ++op) { |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 57 | if (progress) { |
| 58 | outputProgress(state.fPathStr, pathStr, (SkPathOp) op); |
| 59 | } |
| 60 | testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 61 | } |
| 62 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 66 | } |
| 67 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 68 | } |
| 69 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 70 | static void PathOpsOpCubicsThreadedTest(skiatest::Reporter* reporter) |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 71 | { |
caryclark@google.com | 16cfe40 | 2013-04-18 18:47:37 +0000 | [diff] [blame] | 72 | int threadCount = initializeTests(reporter, "cubicOp"); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 73 | PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 74 | for (int a = 0; a < 6; ++a) { // outermost |
| 75 | for (int b = a + 1; b < 7; ++b) { |
| 76 | for (int c = 0 ; c < 6; ++c) { |
| 77 | for (int d = c + 1; d < 7; ++d) { |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 78 | *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, |
| 79 | (&testOpCubicsMain, a, b, c, d, &testRunner)); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 80 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 81 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 82 | if (!reporter->allowExtendedTest()) goto finish; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 83 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 84 | } |
| 85 | finish: |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 86 | testRunner.render(); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | #include "TestClassDef.h" |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 90 | DEFINE_TESTCLASS_SHORT(PathOpsOpCubicsThreadedTest) |