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