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