blob: 1f5af8ec6c284fbc7100fc5aa135b77334b4dc02 [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 }
caryclark@google.com24bec792012-08-20 12:43:57 +000056 outputProgress(state, pathStr, SkPath::kWinding_FillType);
57 testSimplifyx(path, false, out, state, pathStr);
caryclark@google.com59823f72012-08-09 18:17:47 +000058 state.testsRun++;
caryclark@google.com59823f72012-08-09 18:17:47 +000059 path.setFillType(SkPath::kEvenOdd_FillType);
60 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
61 testSimplifyx(path, true, out, state, pathStr);
62 state.testsRun++;
caryclark@google.comfa0588f2012-04-26 21:01:06 +000063 }
64 }
65 }
66 }
caryclark@google.com59823f72012-08-09 18:17:47 +000067 } while (runNextTestSet(state));
caryclark@google.comfa0588f2012-04-26 21:01:06 +000068 return NULL;
69}
70
caryclark@google.com24bec792012-08-20 12:43:57 +000071void Simplify4x4QuadraticsThreaded_Test(int& testsRun)
caryclark@google.comfa0588f2012-04-26 21:01:06 +000072{
caryclark@google.com59823f72012-08-09 18:17:47 +000073 SkDebugf("%s\n", __FUNCTION__);
74#ifdef SK_DEBUG
75 gDebugMaxWindSum = 4; // FIXME: 3?
76 gDebugMaxWindValue = 4;
77#endif
78 const char testStr[] = "testQuadratic";
79 initializeTests(testStr, sizeof(testStr));
caryclark@google.com24bec792012-08-20 12:43:57 +000080 int testsStart = testsRun;
caryclark@google.comfa0588f2012-04-26 21:01:06 +000081 for (int a = 0; a < 16; ++a) {
82 for (int b = a ; b < 16; ++b) {
83 for (int c = b ; c < 16; ++c) {
84 for (int d = c; d < 16; ++d) {
caryclark@google.com59823f72012-08-09 18:17:47 +000085 testsRun += dispatchTest4(testSimplify4x4QuadraticsMain,
86 a, b, c, d);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000087 }
caryclark@google.com59823f72012-08-09 18:17:47 +000088 if (!gRunTestsInOneThread) SkDebugf(".");
caryclark@google.comfa0588f2012-04-26 21:01:06 +000089 }
caryclark@google.com59823f72012-08-09 18:17:47 +000090 if (!gRunTestsInOneThread) SkDebugf("%d", b);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000091 }
caryclark@google.com59823f72012-08-09 18:17:47 +000092 if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000093 }
caryclark@google.com59823f72012-08-09 18:17:47 +000094 testsRun += waitForCompletion();
caryclark@google.com24bec792012-08-20 12:43:57 +000095 SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000096}