blob: 751ccc5f1baedfa01089b494b1fad988fa2bf2ee [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
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000010static void testOpCubicsMain(PathOpsThreadState* data) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +000011#if DEBUG_SHOW_TEST_NAME
12 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
13#endif
caryclark@google.com818b0cc2013-04-08 11:50:46 +000014 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000015 PathOpsThreadState& state = *data;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000016 char pathStr[1024]; // gdb: set print elements 400
caryclark@google.com8d0a5242013-07-16 16:11:16 +000017 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
18 if (progress) {
19 sk_bzero(pathStr, sizeof(pathStr));
20 }
caryclark@google.com66089e42013-04-10 15:55:37 +000021 for (int a = 0 ; a < 6; ++a) {
22 for (int b = a + 1 ; b < 7; ++b) {
23 for (int c = 0 ; c < 6; ++c) {
24 for (int d = c + 1 ; d < 7; ++d) {
25 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
26 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
27 SkPath pathA, pathB;
caryclark@google.com8d0a5242013-07-16 16:11:16 +000028 if (progress) {
29 char* str = pathStr;
30 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
31 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
32 ? "EvenOdd" : "?UNDEFINED");
33 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB);
34 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
35 b, a, d, c);
36 str += sprintf(str, " path.close();\n");
37 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
38 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
39 ? "EvenOdd" : "?UNDEFINED");
40 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
41 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
42 state.fB, state.fA, state.fD, state.fC);
43 str += sprintf(str, " pathB.close();\n");
44 }
caryclark@google.com66089e42013-04-10 15:55:37 +000045 pathA.setFillType((SkPath::FillType) e);
caryclark@google.com66089e42013-04-10 15:55:37 +000046 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
caryclark@google.com66089e42013-04-10 15:55:37 +000047 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToScalar(b),
48 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
caryclark@google.com66089e42013-04-10 15:55:37 +000049 pathA.close();
caryclark@google.com66089e42013-04-10 15:55:37 +000050 pathB.setFillType((SkPath::FillType) f);
caryclark@google.com66089e42013-04-10 15:55:37 +000051 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
caryclark@google.com66089e42013-04-10 15:55:37 +000052 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB),
53 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
caryclark@google.com66089e42013-04-10 15:55:37 +000054 pathB.close();
caryclark@google.com66089e42013-04-10 15:55:37 +000055 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
caryclark@google.com8d0a5242013-07-16 16:11:16 +000056 if (progress) {
57 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
58 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000059 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics");
caryclark@google.com66089e42013-04-10 15:55:37 +000060 }
61 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000062 }
63 }
64 }
caryclark@google.com66089e42013-04-10 15:55:37 +000065 }
66 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000067}
68
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000069DEF_TEST(PathOpsOpCubicsThreaded, reporter) {
mtklein406654b2014-09-03 15:34:37 -070070 initializeTests(reporter, "cubicOp");
71 PathOpsThreadedTestRunner testRunner(reporter);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000072 for (int a = 0; a < 6; ++a) { // outermost
73 for (int b = a + 1; b < 7; ++b) {
74 for (int c = 0 ; c < 6; ++c) {
75 for (int d = c + 1; d < 7; ++d) {
caryclark@google.com66089e42013-04-10 15:55:37 +000076 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
77 (&testOpCubicsMain, a, b, c, d, &testRunner));
caryclark@google.com818b0cc2013-04-08 11:50:46 +000078 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000079 }
caryclark@google.com66089e42013-04-10 15:55:37 +000080 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000081 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000082 }
83finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000084 testRunner.render();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000085 ShowTestArray();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000086}