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" |
tfarina@chromium.org | 78e7b4e | 2014-01-02 21:45:03 +0000 | [diff] [blame] | 9 | #include "TestClassDef.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@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 18 | static void testPathOpsRectsMain(PathOpsThreadState* data) |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 19 | { |
| 20 | SkASSERT(data); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 21 | PathOpsThreadState& state = *data; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 22 | char pathStr[1024]; // gdb: set print elements 400 |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 23 | bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? |
| 24 | if (progress) { |
| 25 | sk_bzero(pathStr, sizeof(pathStr)); |
| 26 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 27 | for (int a = 0 ; a < 6; ++a) { |
| 28 | for (int b = a + 1 ; b < 7; ++b) { |
| 29 | for (int c = 0 ; c < 6; ++c) { |
| 30 | for (int d = c + 1 ; d < 7; ++d) { |
| 31 | for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { |
| 32 | for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 33 | if (progress) { |
| 34 | char* str = pathStr; |
| 35 | str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", |
| 36 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 37 | ? "EvenOdd" : "?UNDEFINED"); |
| 38 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 39 | " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB); |
| 40 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 41 | " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD); |
| 42 | str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", |
| 43 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 44 | ? "EvenOdd" : "?UNDEFINED"); |
| 45 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 46 | " SkPath::kCW_Direction);\n", a, a, b, b); |
| 47 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 48 | " SkPath::kCW_Direction);\n", c, c, d, d); |
| 49 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 50 | SkPath pathA, pathB; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 51 | pathA.setFillType((SkPath::FillType) e); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 52 | pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB), |
| 53 | SkIntToScalar(state.fB), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 54 | pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD), |
| 55 | SkIntToScalar(state.fD), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 56 | pathA.close(); |
| 57 | pathB.setFillType((SkPath::FillType) f); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 58 | pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), |
| 59 | SkIntToScalar(b), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 60 | pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), |
| 61 | SkIntToScalar(d), SkPath::kCW_Direction); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 62 | pathB.close(); |
| 63 | for (int op = 0 ; op <= kXOR_PathOp; ++op) { |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 64 | if (progress) { |
| 65 | outputProgress(state.fPathStr, pathStr, (SkPathOp) op); |
| 66 | } |
| 67 | testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 70 | } |
| 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(PathOpsRectsThreaded, reporter) { |
caryclark@google.com | 16cfe40 | 2013-04-18 18:47:37 +0000 | [diff] [blame] | 78 | int threadCount = initializeTests(reporter, "testOp"); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 79 | PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
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) { |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 84 | *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, |
| 85 | (&testPathOpsRectsMain, 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 | } |