EdgeWalkerQuadratic4x4_Test.cpp revision 59823f7f3ba43c7c6bc1fa8c600b093ecb4236aa
1#include "EdgeWalker_Test.h" 2#include "Intersection_Tests.h" 3#include "SkBitmap.h" 4#include "SkCanvas.h" 5#include <assert.h> 6 7 8static void* testSimplify4x4QuadraticsMain(void* data) 9{ 10 SkASSERT(data); 11 State4& state = *(State4*) data; 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 65 } 66 } 67 } 68 } 69 } while (runNextTestSet(state)); 70 return NULL; 71} 72 73void Simplify4x4QuadraticsThreaded_Test() 74{ 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; 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) { 87 testsRun += dispatchTest4(testSimplify4x4QuadraticsMain, 88 a, b, c, d); 89 } 90 if (!gRunTestsInOneThread) SkDebugf("."); 91 } 92 if (!gRunTestsInOneThread) SkDebugf("%d", b); 93 } 94 if (!gRunTestsInOneThread) SkDebugf("\n%d", a); 95 } 96 testsRun += waitForCompletion(); 97 SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); 98} 99