EdgeWalkerQuadratic4x4_Test.cpp revision fa0588ff672564af1c235a63589573829035a60b
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 char pathStr[1024]; 11 bzero(pathStr, sizeof(pathStr)); 12 SkASSERT(data); 13 State4& state = *(State4*) data; 14 int ax = state.a & 0x03; 15 int ay = state.a >> 2; 16 int bx = state.b & 0x03; 17 int by = state.b >> 2; 18 int cx = state.c & 0x03; 19 int cy = state.c >> 2; 20 int dx = state.d & 0x03; 21 int dy = state.d >> 2; 22 for (int e = 0 ; e < 16; ++e) { 23 int ex = e & 0x03; 24 int ey = e >> 2; 25 for (int f = e ; f < 16; ++f) { 26 int fx = f & 0x03; 27 int fy = f >> 2; 28 for (int g = f ; g < 16; ++g) { 29 int gx = g & 0x03; 30 int gy = g >> 2; 31 for (int h = g ; h < 16; ++h) { 32 int hx = h & 0x03; 33 int hy = h >> 2; 34 SkPath path, out; 35 path.setFillType(SkPath::kWinding_FillType); 36 path.moveTo(ax, ay); 37 path.quadTo(bx, by, cx, cy); 38 path.lineTo(dx, dy); 39 path.close(); 40 path.moveTo(ex, ey); 41 path.lineTo(fx, fy); 42 path.quadTo(gx, gy, hx, hy); 43 path.close(); 44 if (1) { // gdb: set print elements 400 45 char* str = pathStr; 46 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); 47 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy); 48 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy); 49 str += sprintf(str, " path.close();\n"); 50 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey); 51 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); 52 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy); 53 str += sprintf(str, " path.close();"); 54 } 55 if (!testSimplify(path, true, out, state.bitmap, state.canvas)) { 56 SkDebugf("*/\n{ SkPath::kWinding_FillType, %d, %d, %d, %d," 57 " %d, %d, %d, %d },\n/*\n", state.a, state.b, state.c, state.d, 58 e, f, g, h); 59 } 60 path.setFillType(SkPath::kEvenOdd_FillType); 61 if (!testSimplify(path, true, out, state.bitmap, state.canvas)) { 62 SkDebugf("*/\n{ SkPath::kEvenOdd_FillType, %d, %d, %d, %d," 63 " %d, %d, %d, %d },\n/*\n", state.a, state.b, state.c, state.d, 64 e, f, g, h); 65 } 66 } 67 } 68 } 69 } 70 return NULL; 71} 72 73const int maxThreads = gRunTestsInOneThread ? 1 : 24; 74 75void Simplify4x4QuadraticsThreaded_Test() 76{ 77 State4 threadState[maxThreads]; 78 int threadIndex = 0; 79 for (int a = 0; a < 16; ++a) { 80 for (int b = a ; b < 16; ++b) { 81 for (int c = b ; c < 16; ++c) { 82 for (int d = c; d < 16; ++d) { 83 State4* statePtr = &threadState[threadIndex]; 84 statePtr->a = a; 85 statePtr->b = b; 86 statePtr->c = c; 87 statePtr->d = d; 88 if (maxThreads > 1) { 89 createThread(statePtr, testSimplify4x4QuadraticsMain); 90 if (++threadIndex >= maxThreads) { 91 waitForCompletion(threadState, threadIndex); 92 } 93 } else { 94 testSimplify4x4QuadraticsMain(statePtr); 95 } 96 } 97 } 98 } 99 } 100 waitForCompletion(threadState, threadIndex); 101} 102