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" |
| 8 | |
| 9 | static THREAD_TYPE testSimplifyQuadsMain(void* data) |
| 10 | { |
| 11 | SkASSERT(data); |
| 12 | State4& state = *(State4*) data; |
| 13 | char pathStr[1024]; |
| 14 | sk_bzero(pathStr, sizeof(pathStr)); |
| 15 | do { |
| 16 | int ax = state.a & 0x03; |
| 17 | int ay = state.a >> 2; |
| 18 | int bx = state.b & 0x03; |
| 19 | int by = state.b >> 2; |
| 20 | int cx = state.c & 0x03; |
| 21 | int cy = state.c >> 2; |
| 22 | int dx = state.d & 0x03; |
| 23 | int dy = state.d >> 2; |
| 24 | for (int e = 0 ; e < 16; ++e) { |
| 25 | int ex = e & 0x03; |
| 26 | int ey = e >> 2; |
| 27 | for (int f = e ; f < 16; ++f) { |
| 28 | int fx = f & 0x03; |
| 29 | int fy = f >> 2; |
| 30 | for (int g = f ; g < 16; ++g) { |
| 31 | int gx = g & 0x03; |
| 32 | int gy = g >> 2; |
| 33 | for (int h = g ; h < 16; ++h) { |
| 34 | int hx = h & 0x03; |
| 35 | int hy = h >> 2; |
| 36 | SkPath path, out; |
| 37 | path.setFillType(SkPath::kWinding_FillType); |
| 38 | path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |
| 39 | path.quadTo(SkIntToScalar(bx), SkIntToScalar(by), |
| 40 | SkIntToScalar(cx), SkIntToScalar(cy)); |
| 41 | path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); |
| 42 | path.close(); |
| 43 | path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); |
| 44 | path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |
| 45 | path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy), |
| 46 | SkIntToScalar(hx), SkIntToScalar(hy)); |
| 47 | path.close(); |
| 48 | // gdb: set print elements 400 |
| 49 | char* str = pathStr; |
| 50 | str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); |
| 51 | str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy); |
| 52 | str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy); |
| 53 | str += sprintf(str, " path.close();\n"); |
| 54 | str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey); |
| 55 | str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); |
| 56 | str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy); |
| 57 | str += sprintf(str, " path.close();\n"); |
| 58 | outputProgress(state, pathStr, SkPath::kWinding_FillType); |
| 59 | testSimplify(path, false, out, state, pathStr); |
| 60 | state.testsRun++; |
| 61 | path.setFillType(SkPath::kEvenOdd_FillType); |
| 62 | outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); |
| 63 | testSimplify(path, true, out, state, pathStr); |
| 64 | state.testsRun++; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } while (runNextTestSet(state)); |
| 70 | THREAD_RETURN |
| 71 | } |
| 72 | |
| 73 | static void TestSimplifyQuadsThreaded(skiatest::Reporter* reporter) |
| 74 | { |
| 75 | int testsRun = 0; |
| 76 | if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); |
| 77 | #ifdef SK_DEBUG |
| 78 | gDebugMaxWindSum = 4; // FIXME: 3? |
| 79 | gDebugMaxWindValue = 4; |
| 80 | #endif |
| 81 | const char testStr[] = "testQuads"; |
| 82 | initializeTests(reporter, testStr, sizeof(testStr)); |
| 83 | int a = 0; |
| 84 | for (; a < 16; ++a) { |
| 85 | for (int b = a ; b < 16; ++b) { |
| 86 | for (int c = b ; c < 16; ++c) { |
| 87 | for (int d = c; d < 16; ++d) { |
| 88 | testsRun += dispatchTest4(testSimplifyQuadsMain, a, b, c, d); |
| 89 | } |
| 90 | if (!gAllowExtendedTest) goto finish; |
| 91 | if (gShowTestProgress) SkDebugf("."); |
| 92 | } |
| 93 | if (gShowTestProgress) SkDebugf("%d", b); |
| 94 | } |
| 95 | if (gShowTestProgress) SkDebugf("\n%d", a); |
| 96 | } |
| 97 | finish: |
| 98 | testsRun += waitForCompletion(); |
| 99 | if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun); |
| 100 | } |
| 101 | |
| 102 | #include "TestClassDef.h" |
| 103 | DEFINE_TESTCLASS("PathOpsSimplifyQuadsThreaded", SimplifyQuadsThreadedTestClass, \ |
| 104 | TestSimplifyQuadsThreaded) |