blob: 61330429d4bd7198b29860ccd3e6adfebc42632a [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"
caryclark8f186432016-10-06 11:46:25 -07009#include "SkString.h"
10
11static int loopNo = 1;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000012
caryclark@google.com66089e42013-04-10 15:55:37 +000013static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000014{
15 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000016 PathOpsThreadState& state = *data;
caryclark8f186432016-10-06 11:46:25 -070017 SkString pathStr;
caryclark@google.com66089e42013-04-10 15:55:37 +000018 int ax = state.fA & 0x03;
19 int ay = state.fA >> 2;
20 int bx = state.fB & 0x03;
21 int by = state.fB >> 2;
22 int cx = state.fC & 0x03;
23 int cy = state.fC >> 2;
24 int dx = state.fD & 0x03;
25 int dy = state.fD >> 2;
26 for (int e = 0 ; e < 16; ++e) {
27 int ex = e & 0x03;
28 int ey = e >> 2;
29 for (int f = e ; f < 16; ++f) {
30 int fx = f & 0x03;
31 int fy = f >> 2;
32 for (int g = f ; g < 16; ++g) {
33 int gx = g & 0x03;
34 int gy = g >> 2;
35 for (int h = g ; h < 16; ++h) {
36 int hx = h & 0x03;
37 int hy = h >> 2;
38 SkPath path, out;
39 path.setFillType(SkPath::kWinding_FillType);
40 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
41 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
42 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
43 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
44 path.close();
45 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
46 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
47 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
48 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
49 path.close();
caryclark8f186432016-10-06 11:46:25 -070050 if (state.fReporter->verbose()) {
51 pathStr.printf("static void quadralateralSimplify%d(skiatest::Reporter*"
52 "reporter, const char* filename) {\n", loopNo);
53 pathStr.appendf(" SkPath path;\n");
54 pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay);
55 pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by);
56 pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy);
57 pathStr.appendf(" path.lineTo(%d, %d);\n", dx, dy);
58 pathStr.appendf(" path.close();\n");
59 pathStr.appendf(" path.moveTo(%d, %d);\n", ex, ey);
60 pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
61 pathStr.appendf(" path.lineTo(%d, %d);\n", gx, gy);
62 pathStr.appendf(" path.lineTo(%d, %d);\n", hx, hy);
63 pathStr.appendf(" path.close();\n");
64 pathStr.appendf(" testPathSimplify(reporter, path, filename);\n");
65 pathStr.appendf("}\n");
Mike Reedff80c2a2017-01-07 11:16:28 -050066 state.outputProgress(pathStr.c_str(), SkPath::kWinding_FillType);
caryclark@google.com8d0a5242013-07-16 16:11:16 +000067 }
caryclark8f186432016-10-06 11:46:25 -070068 testSimplify(path, false, out, state, pathStr.c_str());
caryclark@google.com66089e42013-04-10 15:55:37 +000069 path.setFillType(SkPath::kEvenOdd_FillType);
caryclark8f186432016-10-06 11:46:25 -070070 if (state.fReporter->verbose()) {
Mike Reedff80c2a2017-01-07 11:16:28 -050071 state.outputProgress(pathStr.c_str(), SkPath::kEvenOdd_FillType);
caryclark@google.com8d0a5242013-07-16 16:11:16 +000072 }
caryclark8f186432016-10-06 11:46:25 -070073 testSimplify(path, true, out, state, pathStr.c_str());
caryclark@google.com818b0cc2013-04-08 11:50:46 +000074 }
75 }
76 }
caryclark@google.com66089e42013-04-10 15:55:37 +000077 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000078}
79
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000080DEF_TEST(PathOpsSimplifyQuadralateralsThreaded, reporter) {
mtklein406654b2014-09-03 15:34:37 -070081 initializeTests(reporter, "testQuadralaterals");
82 PathOpsThreadedTestRunner testRunner(reporter);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000083 for (int a = 0; a < 16; ++a) {
84 for (int b = a ; b < 16; ++b) {
85 for (int c = b ; c < 16; ++c) {
86 for (int d = c; d < 16; ++d) {
halcanary385fe4d2015-08-26 13:07:48 -070087 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
88 &testSimplifyQuadralateralsMain, a, b, c, d, &testRunner);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000089 }
caryclark@google.com66089e42013-04-10 15:55:37 +000090 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000091 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000092 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000093 }
94finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000095 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000096}