caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 1 | #include "EdgeWalker_Test.h" |
| 2 | #include "Intersection_Tests.h" |
| 3 | #include "SkBitmap.h" |
| 4 | #include "SkCanvas.h" |
| 5 | #include <assert.h> |
| 6 | |
| 7 | |
| 8 | static void* testSimplify4x4QuadraticsMain(void* data) |
| 9 | { |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 10 | SkASSERT(data); |
| 11 | State4& state = *(State4*) data; |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 12 | char pathStr[1024]; |
| 13 | bzero(pathStr, sizeof(pathStr)); |
| 14 | do { |
| 15 | int ax = state.a & 0x03; |
| 16 | int ay = state.a >> 2; |
| 17 | int bx = state.b & 0x03; |
| 18 | int by = state.b >> 2; |
| 19 | int cx = state.c & 0x03; |
| 20 | int cy = state.c >> 2; |
| 21 | int dx = state.d & 0x03; |
| 22 | int dy = state.d >> 2; |
| 23 | for (int e = 0 ; e < 16; ++e) { |
| 24 | int ex = e & 0x03; |
| 25 | int ey = e >> 2; |
| 26 | for (int f = e ; f < 16; ++f) { |
| 27 | int fx = f & 0x03; |
| 28 | int fy = f >> 2; |
| 29 | for (int g = f ; g < 16; ++g) { |
| 30 | int gx = g & 0x03; |
| 31 | int gy = g >> 2; |
| 32 | for (int h = g ; h < 16; ++h) { |
| 33 | int hx = h & 0x03; |
| 34 | int hy = h >> 2; |
| 35 | SkPath path, out; |
| 36 | path.setFillType(SkPath::kWinding_FillType); |
| 37 | path.moveTo(ax, ay); |
| 38 | path.quadTo(bx, by, cx, cy); |
| 39 | path.lineTo(dx, dy); |
| 40 | path.close(); |
| 41 | path.moveTo(ex, ey); |
| 42 | path.lineTo(fx, fy); |
| 43 | path.quadTo(gx, gy, hx, hy); |
| 44 | path.close(); |
| 45 | if (1) { // gdb: set print elements 400 |
| 46 | char* str = pathStr; |
| 47 | str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); |
| 48 | str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy); |
| 49 | str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy); |
| 50 | str += sprintf(str, " path.close();\n"); |
| 51 | str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey); |
| 52 | str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); |
| 53 | str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy); |
| 54 | str += sprintf(str, " path.close();\n"); |
| 55 | } |
| 56 | outputProgress(state, pathStr); |
| 57 | testSimplifyx(path, out, state, pathStr); |
| 58 | state.testsRun++; |
| 59 | #if 0 // FIXME: enable once we have support for even/odd |
| 60 | path.setFillType(SkPath::kEvenOdd_FillType); |
| 61 | outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); |
| 62 | testSimplifyx(path, true, out, state, pathStr); |
| 63 | state.testsRun++; |
| 64 | #endif |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 69 | } while (runNextTestSet(state)); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 70 | return NULL; |
| 71 | } |
| 72 | |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 73 | void Simplify4x4QuadraticsThreaded_Test() |
| 74 | { |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 75 | SkDebugf("%s\n", __FUNCTION__); |
| 76 | #ifdef SK_DEBUG |
| 77 | gDebugMaxWindSum = 4; // FIXME: 3? |
| 78 | gDebugMaxWindValue = 4; |
| 79 | #endif |
| 80 | const char testStr[] = "testQuadratic"; |
| 81 | initializeTests(testStr, sizeof(testStr)); |
| 82 | int testsRun = 0; |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 83 | for (int a = 0; a < 16; ++a) { |
| 84 | for (int b = a ; b < 16; ++b) { |
| 85 | for (int c = b ; c < 16; ++c) { |
| 86 | for (int d = c; d < 16; ++d) { |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 87 | testsRun += dispatchTest4(testSimplify4x4QuadraticsMain, |
| 88 | a, b, c, d); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 89 | } |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 90 | if (!gRunTestsInOneThread) SkDebugf("."); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 91 | } |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 92 | if (!gRunTestsInOneThread) SkDebugf("%d", b); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 93 | } |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 94 | if (!gRunTestsInOneThread) SkDebugf("\n%d", a); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 95 | } |
caryclark@google.com | 59823f7 | 2012-08-09 18:17:47 +0000 | [diff] [blame^] | 96 | testsRun += waitForCompletion(); |
| 97 | SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); |
caryclark@google.com | fa0588f | 2012-04-26 21:01:06 +0000 | [diff] [blame] | 98 | } |