blob: f7142495d921381cd3279c2f51ec229447b618a8 [file] [log] [blame]
caryclark@google.comfa0588f2012-04-26 21:01:06 +00001#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{
caryclark@google.comfa0588f2012-04-26 21:01:06 +000010 SkASSERT(data);
11 State4& state = *(State4*) data;
caryclark@google.com59823f72012-08-09 18:17:47 +000012 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.comfa0588f2012-04-26 21:01:06 +000065 }
66 }
67 }
68 }
caryclark@google.com59823f72012-08-09 18:17:47 +000069 } while (runNextTestSet(state));
caryclark@google.comfa0588f2012-04-26 21:01:06 +000070 return NULL;
71}
72
caryclark@google.comfa0588f2012-04-26 21:01:06 +000073void Simplify4x4QuadraticsThreaded_Test()
74{
caryclark@google.com59823f72012-08-09 18:17:47 +000075 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.comfa0588f2012-04-26 21:01:06 +000083 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.com59823f72012-08-09 18:17:47 +000087 testsRun += dispatchTest4(testSimplify4x4QuadraticsMain,
88 a, b, c, d);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000089 }
caryclark@google.com59823f72012-08-09 18:17:47 +000090 if (!gRunTestsInOneThread) SkDebugf(".");
caryclark@google.comfa0588f2012-04-26 21:01:06 +000091 }
caryclark@google.com59823f72012-08-09 18:17:47 +000092 if (!gRunTestsInOneThread) SkDebugf("%d", b);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000093 }
caryclark@google.com59823f72012-08-09 18:17:47 +000094 if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000095 }
caryclark@google.com59823f72012-08-09 18:17:47 +000096 testsRun += waitForCompletion();
97 SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000098}