blob: a55f6ab9a4d9e043c826977f4b50f84e56841c23 [file] [log] [blame]
caryclark@google.com9e49fb62012-08-27 14:11:33 +00001/*
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.comfa0588f2012-04-26 21:01:06 +00007#include "EdgeWalker_Test.h"
8#include "Intersection_Tests.h"
9#include "SkBitmap.h"
10#include "SkCanvas.h"
caryclark@google.comfa0588f2012-04-26 21:01:06 +000011
12
13static void* testSimplify4x4QuadraticsMain(void* data)
14{
caryclark@google.comfa0588f2012-04-26 21:01:06 +000015 SkASSERT(data);
16 State4& state = *(State4*) data;
caryclark@google.com59823f72012-08-09 18:17:47 +000017 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.com24bec792012-08-20 12:43:57 +000061 outputProgress(state, pathStr, SkPath::kWinding_FillType);
62 testSimplifyx(path, false, out, state, pathStr);
caryclark@google.com59823f72012-08-09 18:17:47 +000063 state.testsRun++;
caryclark@google.com59823f72012-08-09 18:17:47 +000064 path.setFillType(SkPath::kEvenOdd_FillType);
65 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
66 testSimplifyx(path, true, out, state, pathStr);
67 state.testsRun++;
caryclark@google.comfa0588f2012-04-26 21:01:06 +000068 }
69 }
70 }
71 }
caryclark@google.com59823f72012-08-09 18:17:47 +000072 } while (runNextTestSet(state));
caryclark@google.comfa0588f2012-04-26 21:01:06 +000073 return NULL;
74}
75
caryclark@google.com24bec792012-08-20 12:43:57 +000076void Simplify4x4QuadraticsThreaded_Test(int& testsRun)
caryclark@google.comfa0588f2012-04-26 21:01:06 +000077{
caryclark@google.com59823f72012-08-09 18:17:47 +000078 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.com24bec792012-08-20 12:43:57 +000085 int testsStart = testsRun;
caryclark@google.com8f9f4682013-01-03 21:18:16 +000086 int a = 0;
87#define SKIP_A 0
88#if SKIP_A
89 a = 2;
90#endif
91 for (; a < 16; ++a) {
caryclark@google.comfa0588f2012-04-26 21:01:06 +000092 for (int b = a ; b < 16; ++b) {
93 for (int c = b ; c < 16; ++c) {
rmistry@google.comd6176b02012-08-23 18:14:13 +000094 for (int d = c; d < 16; ++d) {
caryclark@google.com59823f72012-08-09 18:17:47 +000095 testsRun += dispatchTest4(testSimplify4x4QuadraticsMain,
96 a, b, c, d);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000097 }
caryclark@google.com59823f72012-08-09 18:17:47 +000098 if (!gRunTestsInOneThread) SkDebugf(".");
caryclark@google.comfa0588f2012-04-26 21:01:06 +000099 }
caryclark@google.com59823f72012-08-09 18:17:47 +0000100 if (!gRunTestsInOneThread) SkDebugf("%d", b);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000101 }
caryclark@google.com59823f72012-08-09 18:17:47 +0000102 if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000103 }
caryclark@google.com59823f72012-08-09 18:17:47 +0000104 testsRun += waitForCompletion();
caryclark@google.com24bec792012-08-20 12:43:57 +0000105 SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000106}