blob: 5afadbe88e613785d461992318d52448f603c1e0 [file] [log] [blame]
caryclark@google.com818b0cc2013-04-08 11:50:46 +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 */
7#include "PathOpsExtendedTest.h"
caryclark@google.com66089e42013-04-10 15:55:37 +00008#include "PathOpsThreadedCommon.h"
caryclark@google.com818b0cc2013-04-08 11:50:46 +00009
caryclark@google.com66089e42013-04-10 15:55:37 +000010static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000011{
12 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000013 PathOpsThreadState& state = *data;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000014 char pathStr[1024];
15 sk_bzero(pathStr, sizeof(pathStr));
caryclark@google.com66089e42013-04-10 15:55:37 +000016 int ax = state.fA & 0x03;
17 int ay = state.fA >> 2;
18 int bx = state.fB & 0x03;
19 int by = state.fB >> 2;
20 int cx = state.fC & 0x03;
21 int cy = state.fC >> 2;
22 int dx = state.fD & 0x03;
23 int dy = state.fD >> 2;
24 for (int e = 0 ; e < 16; ++e) {
25 int ex = e & 0x03;
26 int ey = e >> 2;
27 for (int f = e ; f < 16; ++f) {
28 int fx = f & 0x03;
29 int fy = f >> 2;
30 for (int g = f ; g < 16; ++g) {
31 int gx = g & 0x03;
32 int gy = g >> 2;
33 for (int h = g ; h < 16; ++h) {
34 int hx = h & 0x03;
35 int hy = h >> 2;
36 SkPath path, out;
37 path.setFillType(SkPath::kWinding_FillType);
38 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
39 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
40 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
41 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
42 path.close();
43 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
44 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
45 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
46 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
47 path.close();
48 // gdb: set print elements 400
49 char* str = pathStr;
50 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
51 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by);
52 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy);
53 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
54 str += sprintf(str, " path.close();\n");
55 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
56 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
57 str += sprintf(str, " path.lineTo(%d, %d);\n", gx, gy);
58 str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy);
59 str += sprintf(str, " path.close();\n");
60 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
61 testSimplify(path, false, out, state, pathStr);
62 path.setFillType(SkPath::kEvenOdd_FillType);
63 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
64 testSimplify(path, true, out, state, pathStr);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000065 }
66 }
67 }
caryclark@google.com66089e42013-04-10 15:55:37 +000068 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000069}
70
caryclark@google.comad65a3e2013-04-15 19:13:59 +000071static void PathOpsSimplifyQuadralateralsThreadedTest(skiatest::Reporter* reporter) {
caryclark@google.com16cfe402013-04-18 18:47:37 +000072 int threadCount = initializeTests(reporter, "testQuadralaterals");
caryclark@google.com66089e42013-04-10 15:55:37 +000073 PathOpsThreadedTestRunner testRunner(reporter, threadCount);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000074 for (int a = 0; a < 16; ++a) {
75 for (int b = a ; b < 16; ++b) {
76 for (int c = b ; c < 16; ++c) {
77 for (int d = c; d < 16; ++d) {
caryclark@google.com66089e42013-04-10 15:55:37 +000078 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
79 (&testSimplifyQuadralateralsMain, a, b, c, d, &testRunner));
caryclark@google.com818b0cc2013-04-08 11:50:46 +000080 }
caryclark@google.com66089e42013-04-10 15:55:37 +000081 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000082 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000083 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000084 }
85finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000086 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000087}
88
89#include "TestClassDef.h"
caryclark@google.comad65a3e2013-04-15 19:13:59 +000090DEFINE_TESTCLASS_SHORT(PathOpsSimplifyQuadralateralsThreadedTest)