| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include "PathOpsExtendedTest.h" | 7 #include "PathOpsExtendedTest.h" |
| 8 #include "PathOpsThreadedCommon.h" |
| 8 | 9 |
| 9 // four rects, of four sizes | 10 // four rects, of four sizes |
| 10 // for 3 smaller sizes, tall, wide | 11 // for 3 smaller sizes, tall, wide |
| 11 // top upper mid lower bottom aligned (3 bits, 5 values) | 12 // top upper mid lower bottom aligned (3 bits, 5 values) |
| 12 // same with x (3 bits, 5 values) | 13 // same with x (3 bits, 5 values) |
| 13 // not included, square, tall, wide (2 bits) | 14 // not included, square, tall, wide (2 bits) |
| 14 // cw or ccw (1 bit) | 15 // cw or ccw (1 bit) |
| 15 | 16 |
| 16 static THREAD_TYPE testPathOpsRectsMain(void* data) | 17 static void testPathOpsRectsMain(PathOpsThreadState* data) |
| 17 { | 18 { |
| 18 SkASSERT(data); | 19 SkASSERT(data); |
| 19 State4& state = *(State4*) data; | 20 PathOpsThreadState& state = *data; |
| 20 char pathStr[1024]; // gdb: set print elements 400 | 21 char pathStr[1024]; // gdb: set print elements 400 |
| 21 sk_bzero(pathStr, sizeof(pathStr)); | 22 sk_bzero(pathStr, sizeof(pathStr)); |
| 22 do { | 23 for (int a = 0 ; a < 6; ++a) { |
| 23 for (int a = 0 ; a < 6; ++a) { | 24 for (int b = a + 1 ; b < 7; ++b) { |
| 24 for (int b = a + 1 ; b < 7; ++b) { | 25 for (int c = 0 ; c < 6; ++c) { |
| 25 for (int c = 0 ; c < 6; ++c) { | 26 for (int d = c + 1 ; d < 7; ++d) { |
| 26 for (int d = c + 1 ; d < 7; ++d) { | 27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO
dd_FillType; ++e) { |
| 27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType;
++e) { | 28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f
) { |
| 28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType;
++f) { | 29 SkPath pathA, pathB; |
| 29 SkPath pathA, pathB; | 30 char* str = pathStr; |
| 30 char* str = pathStr; | 31 pathA.setFillType((SkPath::FillType) e); |
| 31 pathA.setFillType((SkPath::FillType) e); | 32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", |
| 32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", | 33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenO
dd_FillType |
| 33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE
venOdd_FillType | 34 ? "EvenOdd" : "?UNDEFINED"); |
| 34 ? "EvenOdd" : "?UNDEFINED"); | 35 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToS
calar(state.fB), |
| 35 pathA.addRect(SkIntToScalar(state.a), SkIntToScalar(state.a), SkIntT
oScalar(state.b), | 36 SkIntToScalar(state.fB), SkPath::kCW_Direction); |
| 36 SkIntToScalar(state.b), SkPath::kCW_Direction); | 37 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 37 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 38 " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, stat
e.fB); |
| 38 " SkPath::kCW_Direction);\n", state.a, state.a, state.b, sta
te.b); | 39 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToS
calar(state.fD), |
| 39 pathA.addRect(SkIntToScalar(state.c), SkIntToScalar(state.c), SkIntT
oScalar(state.d), | 40 SkIntToScalar(state.fD), SkPath::kCW_Direction); |
| 40 SkIntToScalar(state.d), SkPath::kCW_Direction); | 41 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 41 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 42 " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, stat
e.fD); |
| 42 " SkPath::kCW_Direction);\n", state.c, state.c, state.d, sta
te.d); | 43 pathA.close(); |
| 43 pathA.close(); | 44 pathB.setFillType((SkPath::FillType) f); |
| 44 pathB.setFillType((SkPath::FillType) f); | 45 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", |
| 45 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n"
, | 46 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenO
dd_FillType |
| 46 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE
venOdd_FillType | 47 ? "EvenOdd" : "?UNDEFINED"); |
| 47 ? "EvenOdd" : "?UNDEFINED"); | 48 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), |
| 48 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), | 49 SkIntToScalar(b), SkPath::kCW_Direction); |
| 49 SkIntToScalar(b), SkPath::kCW_Direction); | 50 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 50 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," | 51 " SkPath::kCW_Direction);\n", a, a, b, b); |
| 51 " SkPath::kCW_Direction);\n", a, a, b, b); | 52 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), |
| 52 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), | 53 SkIntToScalar(d), SkPath::kCW_Direction); |
| 53 SkIntToScalar(d), SkPath::kCW_Direction); | 54 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," |
| 54 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," | 55 " SkPath::kCW_Direction);\n", c, c, d, d); |
| 55 " SkPath::kCW_Direction);\n", c, c, d, d); | 56 pathB.close(); |
| 56 pathB.close(); | 57 for (int op = 0 ; op <= kXOR_PathOp; ++op) { |
| 57 for (int op = 0 ; op <= kXOR_PathOp; ++op) { | 58 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); |
| 58 outputProgress(state, pathStr, (SkPathOp) op); | 59 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op); |
| 59 testPathOp(state.reporter, pathA, pathB, (SkPathOp) op); | 60 } |
| 60 state.testsRun++; | 61 } |
| 61 } | |
| 62 } | |
| 63 } | |
| 64 } | |
| 65 } | 62 } |
| 66 } | 63 } |
| 67 } | 64 } |
| 68 } while (runNextTestSet(state)); | 65 } |
| 69 THREAD_RETURN | 66 } |
| 70 } | 67 } |
| 71 | 68 |
| 72 static void TestPathOpsRectsThreaded(skiatest::Reporter* reporter) { | 69 static void TestPathOpsRectsThreaded(skiatest::Reporter* reporter) { |
| 73 int testsRun = 0; | 70 int threadCount = initializeTests("testOp"); |
| 74 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); | 71 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
| 75 #ifdef SK_DEBUG | |
| 76 gDebugMaxWindSum = 4; | |
| 77 gDebugMaxWindValue = 4; | |
| 78 #endif | |
| 79 const char testLineStr[] = "testOp"; | |
| 80 initializeTests(reporter, testLineStr, sizeof(testLineStr)); | |
| 81 for (int a = 0; a < 6; ++a) { // outermost | 72 for (int a = 0; a < 6; ++a) { // outermost |
| 82 for (int b = a + 1; b < 7; ++b) { | 73 for (int b = a + 1; b < 7; ++b) { |
| 83 for (int c = 0 ; c < 6; ++c) { | 74 for (int c = 0 ; c < 6; ++c) { |
| 84 for (int d = c + 1; d < 7; ++d) { | 75 for (int d = c + 1; d < 7; ++d) { |
| 85 testsRun += dispatchTest4(testPathOpsRectsMain, a, b, c, d); | 76 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded
Runnable, |
| 77 (&testPathOpsRectsMain, a, b, c, d, &testRunner)); |
| 86 } | 78 } |
| 87 if (gShowTestProgress) SkDebugf("."); | |
| 88 } | 79 } |
| 89 if (!gAllowExtendedTest) goto finish; | 80 if (!reporter->allowExtendedTest()) goto finish; |
| 90 if (gShowTestProgress) SkDebugf("%d", b); | |
| 91 } | 81 } |
| 92 if (gShowTestProgress) SkDebugf("\n%d", a); | |
| 93 } | 82 } |
| 94 finish: | 83 finish: |
| 95 testsRun += waitForCompletion(); | 84 testRunner.render(); |
| 96 if (gShowTestProgress) SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, test
sRun); | |
| 97 } | 85 } |
| 98 | 86 |
| 99 #include "TestClassDef.h" | 87 #include "TestClassDef.h" |
| 100 DEFINE_TESTCLASS("PathOpsRectsThreaded", OpRectsThreadedTestClass, \ | 88 DEFINE_TESTCLASS("PathOpsRectsThreaded", OpRectsThreadedTestClass, \ |
| 101 TestPathOpsRectsThreaded) | 89 TestPathOpsRectsThreaded) |
| 90 |
| OLD | NEW |