blob: 0bb8c19934666d402e47f3628538321cc6cbe060 [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"
caryclark@google.com818b0cc2013-04-08 11:50:46 +000010
caryclark08bc8482015-04-24 09:08:57 -070011static int loopNo = 158;
caryclark03b03ca2015-04-23 09:13:37 -070012
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000013static void testOpCubicsMain(PathOpsThreadState* data) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +000014#if DEBUG_SHOW_TEST_NAME
15 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
16#endif
caryclark@google.com818b0cc2013-04-08 11:50:46 +000017 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000018 PathOpsThreadState& state = *data;
caryclark8f186432016-10-06 11:46:25 -070019 SkString pathStr;
caryclark@google.com66089e42013-04-10 15:55:37 +000020 for (int a = 0 ; a < 6; ++a) {
21 for (int b = a + 1 ; b < 7; ++b) {
22 for (int c = 0 ; c < 6; ++c) {
23 for (int d = c + 1 ; d < 7; ++d) {
24 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
25 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
26 SkPath pathA, pathB;
caryclark@google.com66089e42013-04-10 15:55:37 +000027 pathA.setFillType((SkPath::FillType) e);
caryclark@google.com66089e42013-04-10 15:55:37 +000028 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
caryclark@google.com66089e42013-04-10 15:55:37 +000029 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b),
30 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
caryclark@google.com66089e42013-04-10 15:55:37 +000031 pathA.close();
caryclark@google.com66089e42013-04-10 15:55:37 +000032 pathB.setFillType((SkPath::FillType) f);
caryclark@google.com66089e42013-04-10 15:55:37 +000033 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
caryclark@google.com66089e42013-04-10 15:55:37 +000034 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB),
35 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
caryclark@google.com66089e42013-04-10 15:55:37 +000036 pathB.close();
caryclark54359292015-03-26 07:52:43 -070037 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
caryclark8f186432016-10-06 11:46:25 -070038 if (state.fReporter->verbose()) {
39 pathStr.printf("static void cubicOp%d(skiatest::Reporter* reporter,"
caryclark03b03ca2015-04-23 09:13:37 -070040 " const char* filename) {\n", loopNo);
caryclark8f186432016-10-06 11:46:25 -070041 pathStr.appendf(" SkPath path, pathB;\n");
42 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
caryclark03b03ca2015-04-23 09:13:37 -070043 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
44 ? "EvenOdd" : "?UNDEFINED");
caryclark8f186432016-10-06 11:46:25 -070045 pathStr.appendf(" path.moveTo(%d,%d);\n", state.fA, state.fB);
46 pathStr.appendf(" path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
caryclark03b03ca2015-04-23 09:13:37 -070047 b, a, d, c);
caryclark8f186432016-10-06 11:46:25 -070048 pathStr.appendf(" path.close();\n");
49 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
caryclark03b03ca2015-04-23 09:13:37 -070050 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
51 ? "EvenOdd" : "?UNDEFINED");
caryclark8f186432016-10-06 11:46:25 -070052 pathStr.appendf(" pathB.moveTo(%d,%d);\n", a, b);
53 pathStr.appendf(" pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
caryclark03b03ca2015-04-23 09:13:37 -070054 state.fB, state.fA, state.fD, state.fC);
caryclark8f186432016-10-06 11:46:25 -070055 pathStr.appendf(" pathB.close();\n");
56 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
caryclark03b03ca2015-04-23 09:13:37 -070057 SkPathOpsDebug::OpStr((SkPathOp) op));
caryclark8f186432016-10-06 11:46:25 -070058 pathStr.appendf("}\n");
Mike Reedff80c2a2017-01-07 11:16:28 -050059 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
caryclark03b03ca2015-04-23 09:13:37 -070060 }
caryclark38a017b2015-05-13 10:13:17 -070061 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
caryclark8f186432016-10-06 11:46:25 -070062 if (state.fReporter->verbose()) {
caryclark03b03ca2015-04-23 09:13:37 -070063 ++loopNo;
64 goto skipToNext;
65 }
66 }
caryclark@google.com66089e42013-04-10 15:55:37 +000067 }
68 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000069 }
caryclark03b03ca2015-04-23 09:13:37 -070070skipToNext: ;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000071 }
72 }
caryclark@google.com66089e42013-04-10 15:55:37 +000073 }
74 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000075}
76
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000077DEF_TEST(PathOpsOpCubicsThreaded, reporter) {
mtklein406654b2014-09-03 15:34:37 -070078 initializeTests(reporter, "cubicOp");
79 PathOpsThreadedTestRunner testRunner(reporter);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000080 for (int a = 0; a < 6; ++a) { // outermost
81 for (int b = a + 1; b < 7; ++b) {
82 for (int c = 0 ; c < 6; ++c) {
83 for (int d = c + 1; d < 7; ++d) {
halcanary385fe4d2015-08-26 13:07:48 -070084 *testRunner.fRunnables.append() =
85 new PathOpsThreadedRunnable(&testOpCubicsMain, a, b, c, d, &testRunner);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000086 }
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 }
91finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000092 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000093}