blob: 991d4e764c2e628898316c0aa46ae6dd9978469c [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
caryclark08bc8482015-04-24 09:08:57 -070010static int loopNo = 158;
caryclark03b03ca2015-04-23 09:13:37 -070011
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000012static void testOpCubicsMain(PathOpsThreadState* data) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +000013#if DEBUG_SHOW_TEST_NAME
14 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
15#endif
caryclark@google.com818b0cc2013-04-08 11:50:46 +000016 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000017 PathOpsThreadState& state = *data;
caryclark08bc8482015-04-24 09:08:57 -070018 char pathStr[1024];
caryclark@google.com8d0a5242013-07-16 16:11:16 +000019 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
20 if (progress) {
21 sk_bzero(pathStr, sizeof(pathStr));
22 }
caryclark@google.com66089e42013-04-10 15:55:37 +000023 for (int a = 0 ; a < 6; ++a) {
24 for (int b = a + 1 ; b < 7; ++b) {
25 for (int c = 0 ; c < 6; ++c) {
26 for (int d = c + 1 ; d < 7; ++d) {
27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
29 SkPath pathA, pathB;
caryclark@google.com66089e42013-04-10 15:55:37 +000030 pathA.setFillType((SkPath::FillType) e);
caryclark@google.com66089e42013-04-10 15:55:37 +000031 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
caryclark@google.com66089e42013-04-10 15:55:37 +000032 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b),
33 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
caryclark@google.com66089e42013-04-10 15:55:37 +000034 pathA.close();
caryclark@google.com66089e42013-04-10 15:55:37 +000035 pathB.setFillType((SkPath::FillType) f);
caryclark@google.com66089e42013-04-10 15:55:37 +000036 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
caryclark@google.com66089e42013-04-10 15:55:37 +000037 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB),
38 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
caryclark@google.com66089e42013-04-10 15:55:37 +000039 pathB.close();
caryclark54359292015-03-26 07:52:43 -070040 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
caryclark@google.com8d0a5242013-07-16 16:11:16 +000041 if (progress) {
42 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
43 }
caryclark03b03ca2015-04-23 09:13:37 -070044 if (progress) {
45 char* str = pathStr;
46 str += sprintf(str, "static void cubicOp%d(skiatest::Reporter* reporter,"
47 " const char* filename) {\n", loopNo);
48 str += sprintf(str, " SkPath path, pathB;\n");
49 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
50 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
51 ? "EvenOdd" : "?UNDEFINED");
52 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB);
53 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
54 b, a, d, c);
55 str += sprintf(str, " path.close();\n");
56 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
57 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
58 ? "EvenOdd" : "?UNDEFINED");
59 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
60 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
61 state.fB, state.fA, state.fD, state.fC);
62 str += sprintf(str, " pathB.close();\n");
63 str += sprintf(str, " testPathOp(reporter, path, pathB, %s, filename);\n",
64 SkPathOpsDebug::OpStr((SkPathOp) op));
65 str += sprintf(str, "}\n");
66 }
caryclark38a017b2015-05-13 10:13:17 -070067 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
caryclark03b03ca2015-04-23 09:13:37 -070068 if (progress) {
69 ++loopNo;
70 goto skipToNext;
71 }
72 }
caryclark@google.com66089e42013-04-10 15:55:37 +000073 }
74 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000075 }
caryclark03b03ca2015-04-23 09:13:37 -070076skipToNext: ;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000077 }
78 }
caryclark@google.com66089e42013-04-10 15:55:37 +000079 }
80 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000081}
82
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000083DEF_TEST(PathOpsOpCubicsThreaded, reporter) {
mtklein406654b2014-09-03 15:34:37 -070084 initializeTests(reporter, "cubicOp");
85 PathOpsThreadedTestRunner testRunner(reporter);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000086 for (int a = 0; a < 6; ++a) { // outermost
87 for (int b = a + 1; b < 7; ++b) {
88 for (int c = 0 ; c < 6; ++c) {
89 for (int d = c + 1; d < 7; ++d) {
halcanary385fe4d2015-08-26 13:07:48 -070090 *testRunner.fRunnables.append() =
91 new PathOpsThreadedRunnable(&testOpCubicsMain, a, b, c, d, &testRunner);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000092 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000093 }
caryclark@google.com66089e42013-04-10 15:55:37 +000094 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000095 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000096 }
97finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000098 testRunner.render();
caryclark1049f122015-04-20 08:31:59 -070099 ShowTestArray("cubicOp");
caryclark@google.com818b0cc2013-04-08 11:50:46 +0000100}