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