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 | |
| 10 | // four rects, of four sizes |
| 11 | // for 3 smaller sizes, tall, wide |
| 12 | // top upper mid lower bottom aligned (3 bits, 5 values) |
| 13 | // same with x (3 bits, 5 values) |
| 14 | // not included, square, tall, wide (2 bits) |
| 15 | // cw or ccw (1 bit) |
| 16 | |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 17 | static void testPathOpsRectsMain(PathOpsThreadState* data) |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 18 | { |
| 19 | SkASSERT(data); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 20 | PathOpsThreadState& state = *data; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 21 | char pathStr[1024]; // gdb: set print elements 400 |
| 22 | sk_bzero(pathStr, sizeof(pathStr)); |
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; |
| 30 | char* str = pathStr; |
| 31 | pathA.setFillType((SkPath::FillType) e); |
| 32 | str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", |
| 33 | e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType |
| 34 | ? "EvenOdd" : "?UNDEFINED"); |
| 35 | pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB), |
| 36 | SkIntToScalar(state.fB), SkPath::kCW_Direction); |
| 37 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 38 | " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB); |
| 39 | pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD), |
| 40 | SkIntToScalar(state.fD), SkPath::kCW_Direction); |
| 41 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 42 | " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD); |
| 43 | pathA.close(); |
| 44 | pathB.setFillType((SkPath::FillType) f); |
| 45 | str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", |
| 46 | f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType |
| 47 | ? "EvenOdd" : "?UNDEFINED"); |
| 48 | pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), |
| 49 | SkIntToScalar(b), SkPath::kCW_Direction); |
| 50 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 51 | " SkPath::kCW_Direction);\n", a, a, b, b); |
| 52 | pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), |
| 53 | SkIntToScalar(d), SkPath::kCW_Direction); |
| 54 | str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 55 | " SkPath::kCW_Direction);\n", c, c, d, d); |
| 56 | pathB.close(); |
| 57 | for (int op = 0 ; op <= kXOR_PathOp; ++op) { |
| 58 | outputProgress(state.fPathStr, pathStr, (SkPathOp) op); |
| 59 | testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op); |
| 60 | } |
| 61 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 65 | } |
| 66 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 67 | } |
| 68 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 69 | static void PathOpsRectsThreadedTest(skiatest::Reporter* reporter) { |
caryclark@google.com | 16cfe40 | 2013-04-18 18:47:37 +0000 | [diff] [blame] | 70 | int threadCount = initializeTests(reporter, "testOp"); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 71 | PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 72 | for (int a = 0; a < 6; ++a) { // outermost |
| 73 | for (int b = a + 1; b < 7; ++b) { |
| 74 | for (int c = 0 ; c < 6; ++c) { |
| 75 | for (int d = c + 1; d < 7; ++d) { |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 76 | *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, |
| 77 | (&testPathOpsRectsMain, a, b, c, d, &testRunner)); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 78 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 79 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 80 | if (!reporter->allowExtendedTest()) goto finish; |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 81 | } |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 82 | } |
| 83 | finish: |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 84 | testRunner.render(); |
caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | #include "TestClassDef.h" |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 88 | DEFINE_TESTCLASS_SHORT(PathOpsRectsThreadedTest) |