blob: 40a02c111ed3d1b4d889a8368450435fbb95790a [file] [log] [blame]
caryclark1049f122015-04-20 08:31:59 -07001/*
2 * Copyright 2015 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"
8#include "PathOpsThreadedCommon.h"
caryclark8f186432016-10-06 11:46:25 -07009#include "SkString.h"
10
11static int loopNo = 4;
caryclark1049f122015-04-20 08:31:59 -070012
13static void testOpCirclesMain(PathOpsThreadState* data) {
14 SkASSERT(data);
15 PathOpsThreadState& state = *data;
caryclark8f186432016-10-06 11:46:25 -070016 SkString pathStr;
caryclark1049f122015-04-20 08:31:59 -070017 for (int a = 0 ; a < 6; ++a) {
18 for (int b = a + 1 ; b < 7; ++b) {
19 for (int c = 0 ; c < 6; ++c) {
20 for (int d = c + 1 ; d < 7; ++d) {
21 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
22 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
23 SkPath pathA, pathB;
caryclark1049f122015-04-20 08:31:59 -070024 pathA.setFillType((SkPath::FillType) e);
25 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
26 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
27 pathB.setFillType((SkPath::FillType) f);
28 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
29 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
30 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
caryclark8f186432016-10-06 11:46:25 -070031 if (state.fReporter->verbose()) {
32 pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter,"
33 " const char* filename) {\n", loopNo);
34 pathStr.appendf(" SkPath path, pathB;\n");
35 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
36 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
37 ? "EvenOdd" : "?UNDEFINED");
38 pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
39 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
40 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
41 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
42 ? "EvenOdd" : "?UNDEFINED");
43 pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b,
44 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
45 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
46 SkPathOpsDebug::OpStr((SkPathOp) op));
47 pathStr.appendf("}\n");
48 outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
caryclark1049f122015-04-20 08:31:59 -070049 }
caryclark8f186432016-10-06 11:46:25 -070050 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles")) {
51 if (state.fReporter->verbose()) {
52 ++loopNo;
53 goto skipToNext;
54 }
55 }
caryclark1049f122015-04-20 08:31:59 -070056 }
57 }
58 }
caryclark8f186432016-10-06 11:46:25 -070059skipToNext: ;
caryclark1049f122015-04-20 08:31:59 -070060 }
61 }
62 }
63 }
64}
65
66DEF_TEST(PathOpsOpCircleThreaded, reporter) {
67 initializeTests(reporter, "circleOp");
68 PathOpsThreadedTestRunner testRunner(reporter);
69 for (int a = 0; a < 6; ++a) { // outermost
70 for (int b = a + 1; b < 7; ++b) {
71 for (int c = 0 ; c < 6; ++c) {
72 for (int d = 0; d < 2; ++d) {
halcanary385fe4d2015-08-26 13:07:48 -070073 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
74 &testOpCirclesMain, a, b, c, d, &testRunner);
caryclark1049f122015-04-20 08:31:59 -070075 }
76 }
77 if (!reporter->allowExtendedTest()) goto finish;
78 }
79 }
80finish:
81 testRunner.render();
caryclark1049f122015-04-20 08:31:59 -070082}