blob: 3a0a8f5b974ae75ca096a369caa610a863732688 [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"
11#include <assert.h>
12
13
14static void* testSimplify4x4QuadraticsMain(void* data)
15{
caryclark@google.comfa0588f2012-04-26 21:01:06 +000016 SkASSERT(data);
17 State4& state = *(State4*) data;
caryclark@google.com59823f72012-08-09 18:17:47 +000018 char pathStr[1024];
19 bzero(pathStr, sizeof(pathStr));
20 do {
21 int ax = state.a & 0x03;
22 int ay = state.a >> 2;
23 int bx = state.b & 0x03;
24 int by = state.b >> 2;
25 int cx = state.c & 0x03;
26 int cy = state.c >> 2;
27 int dx = state.d & 0x03;
28 int dy = state.d >> 2;
29 for (int e = 0 ; e < 16; ++e) {
30 int ex = e & 0x03;
31 int ey = e >> 2;
32 for (int f = e ; f < 16; ++f) {
33 int fx = f & 0x03;
34 int fy = f >> 2;
35 for (int g = f ; g < 16; ++g) {
36 int gx = g & 0x03;
37 int gy = g >> 2;
38 for (int h = g ; h < 16; ++h) {
39 int hx = h & 0x03;
40 int hy = h >> 2;
41 SkPath path, out;
42 path.setFillType(SkPath::kWinding_FillType);
43 path.moveTo(ax, ay);
44 path.quadTo(bx, by, cx, cy);
45 path.lineTo(dx, dy);
46 path.close();
47 path.moveTo(ex, ey);
48 path.lineTo(fx, fy);
49 path.quadTo(gx, gy, hx, hy);
50 path.close();
51 if (1) { // gdb: set print elements 400
52 char* str = pathStr;
53 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
54 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy);
55 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
56 str += sprintf(str, " path.close();\n");
57 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
58 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
59 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy);
60 str += sprintf(str, " path.close();\n");
61 }
caryclark@google.com24bec792012-08-20 12:43:57 +000062 outputProgress(state, pathStr, SkPath::kWinding_FillType);
63 testSimplifyx(path, false, out, state, pathStr);
caryclark@google.com59823f72012-08-09 18:17:47 +000064 state.testsRun++;
caryclark@google.com59823f72012-08-09 18:17:47 +000065 path.setFillType(SkPath::kEvenOdd_FillType);
66 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
67 testSimplifyx(path, true, out, state, pathStr);
68 state.testsRun++;
caryclark@google.comfa0588f2012-04-26 21:01:06 +000069 }
70 }
71 }
72 }
caryclark@google.com59823f72012-08-09 18:17:47 +000073 } while (runNextTestSet(state));
caryclark@google.comfa0588f2012-04-26 21:01:06 +000074 return NULL;
75}
76
caryclark@google.com24bec792012-08-20 12:43:57 +000077void Simplify4x4QuadraticsThreaded_Test(int& testsRun)
caryclark@google.comfa0588f2012-04-26 21:01:06 +000078{
caryclark@google.com59823f72012-08-09 18:17:47 +000079 SkDebugf("%s\n", __FUNCTION__);
80#ifdef SK_DEBUG
81 gDebugMaxWindSum = 4; // FIXME: 3?
82 gDebugMaxWindValue = 4;
83#endif
84 const char testStr[] = "testQuadratic";
85 initializeTests(testStr, sizeof(testStr));
caryclark@google.com24bec792012-08-20 12:43:57 +000086 int testsStart = testsRun;
caryclark@google.com8f9f4682013-01-03 21:18:16 +000087 int a = 0;
88#define SKIP_A 0
89#if SKIP_A
90 a = 2;
91#endif
92 for (; a < 16; ++a) {
caryclark@google.comfa0588f2012-04-26 21:01:06 +000093 for (int b = a ; b < 16; ++b) {
94 for (int c = b ; c < 16; ++c) {
rmistry@google.comd6176b02012-08-23 18:14:13 +000095 for (int d = c; d < 16; ++d) {
caryclark@google.com59823f72012-08-09 18:17:47 +000096 testsRun += dispatchTest4(testSimplify4x4QuadraticsMain,
97 a, b, c, d);
caryclark@google.comfa0588f2012-04-26 21:01:06 +000098 }
caryclark@google.com59823f72012-08-09 18:17:47 +000099 if (!gRunTestsInOneThread) SkDebugf(".");
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000100 }
caryclark@google.com59823f72012-08-09 18:17:47 +0000101 if (!gRunTestsInOneThread) SkDebugf("%d", b);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000102 }
caryclark@google.com59823f72012-08-09 18:17:47 +0000103 if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000104 }
caryclark@google.com59823f72012-08-09 18:17:47 +0000105 testsRun += waitForCompletion();
caryclark@google.com24bec792012-08-20 12:43:57 +0000106 SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
caryclark@google.comfa0588f2012-04-26 21:01:06 +0000107}