blob: f2c1dfc990ffee746827250ad8304d1029863430 [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];
caryclark@google.com8d0a5242013-07-16 16:11:16 +000015 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
16 if (progress) {
17 sk_bzero(pathStr, sizeof(pathStr));
18 }
caryclark@google.com66089e42013-04-10 15:55:37 +000019 int ax = state.fA & 0x03;
20 int ay = state.fA >> 2;
21 int bx = state.fB & 0x03;
22 int by = state.fB >> 2;
23 int cx = state.fC & 0x03;
24 int cy = state.fC >> 2;
25 int dx = state.fD & 0x03;
26 int dy = state.fD >> 2;
27 for (int e = 0 ; e < 16; ++e) {
28 int ex = e & 0x03;
29 int ey = e >> 2;
30 for (int f = e ; f < 16; ++f) {
31 int fx = f & 0x03;
32 int fy = f >> 2;
33 for (int g = f ; g < 16; ++g) {
34 int gx = g & 0x03;
35 int gy = g >> 2;
36 for (int h = g ; h < 16; ++h) {
37 int hx = h & 0x03;
38 int hy = h >> 2;
39 SkPath path, out;
40 path.setFillType(SkPath::kWinding_FillType);
41 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
42 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
43 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
44 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
45 path.close();
46 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
47 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
48 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
49 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
50 path.close();
caryclark@google.com8d0a5242013-07-16 16:11:16 +000051 if (progress) {
52 // gdb: set print elements 400
53 char* str = pathStr;
54 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
55 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by);
56 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy);
57 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
58 str += sprintf(str, " path.close();\n");
59 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
60 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
61 str += sprintf(str, " path.lineTo(%d, %d);\n", gx, gy);
62 str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy);
63 str += sprintf(str, " path.close();\n");
64 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
65 }
caryclark@google.com66089e42013-04-10 15:55:37 +000066 testSimplify(path, false, out, state, pathStr);
67 path.setFillType(SkPath::kEvenOdd_FillType);
caryclark@google.com8d0a5242013-07-16 16:11:16 +000068 if (progress) {
69 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
70 }
caryclark@google.com66089e42013-04-10 15:55:37 +000071 testSimplify(path, true, out, state, pathStr);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000072 }
73 }
74 }
caryclark@google.com66089e42013-04-10 15:55:37 +000075 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000076}
77
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000078DEF_TEST(PathOpsSimplifyQuadralateralsThreaded, reporter) {
mtklein406654b2014-09-03 15:34:37 -070079 initializeTests(reporter, "testQuadralaterals");
80 PathOpsThreadedTestRunner testRunner(reporter);
caryclark@google.com818b0cc2013-04-08 11:50:46 +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) {
halcanary385fe4d2015-08-26 13:07:48 -070085 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
86 &testSimplifyQuadralateralsMain, a, b, c, d, &testRunner);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000087 }
caryclark@google.com66089e42013-04-10 15:55:37 +000088 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000089 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000090 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000091 }
92finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000093 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000094}