blob: cb99acdcdf37b1acaa4960e489352dd140f9edc9 [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 */
Mike Kleinc0bd9f92019-04-23 12:05:21 -05007#include "include/core/SkString.h"
8#include "tests/PathOpsDebug.h"
9#include "tests/PathOpsExtendedTest.h"
10#include "tests/PathOpsThreadedCommon.h"
Hal Canary8a001442018-09-19 11:31:27 -040011
Cary Clark8af4c402018-08-08 23:22:37 -040012#include <atomic>
caryclark8f186432016-10-06 11:46:25 -070013
14static int loopNo = 4;
Cary Clark8af4c402018-08-08 23:22:37 -040015static std::atomic<int> gCirclesTestNo{0};
caryclark1049f122015-04-20 08:31:59 -070016
17static void testOpCirclesMain(PathOpsThreadState* data) {
18 SkASSERT(data);
19 PathOpsThreadState& state = *data;
caryclark8f186432016-10-06 11:46:25 -070020 SkString pathStr;
caryclark1049f122015-04-20 08:31:59 -070021 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;
caryclark1049f122015-04-20 08:31:59 -070028 pathA.setFillType((SkPath::FillType) e);
29 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
30 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
31 pathB.setFillType((SkPath::FillType) f);
32 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
33 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
34 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
caryclark8f186432016-10-06 11:46:25 -070035 if (state.fReporter->verbose()) {
36 pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter,"
37 " const char* filename) {\n", loopNo);
38 pathStr.appendf(" SkPath path, pathB;\n");
39 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
40 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
41 ? "EvenOdd" : "?UNDEFINED");
42 pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
43 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
44 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
45 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
46 ? "EvenOdd" : "?UNDEFINED");
47 pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b,
48 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
49 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
50 SkPathOpsDebug::OpStr((SkPathOp) op));
51 pathStr.appendf("}\n");
Mike Reedff80c2a2017-01-07 11:16:28 -050052 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
caryclark1049f122015-04-20 08:31:59 -070053 }
Cary Clark4533f3d2018-08-08 09:48:09 -040054 SkString testName;
55 testName.printf("thread_circles%d", ++gCirclesTestNo);
56 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) {
caryclark8f186432016-10-06 11:46:25 -070057 if (state.fReporter->verbose()) {
58 ++loopNo;
59 goto skipToNext;
60 }
61 }
Cary Clark4533f3d2018-08-08 09:48:09 -040062 if (PathOpsDebug::gCheckForDuplicateNames) return;
caryclark1049f122015-04-20 08:31:59 -070063 }
64 }
65 }
caryclark8f186432016-10-06 11:46:25 -070066skipToNext: ;
caryclark1049f122015-04-20 08:31:59 -070067 }
68 }
69 }
70 }
71}
72
73DEF_TEST(PathOpsOpCircleThreaded, reporter) {
74 initializeTests(reporter, "circleOp");
75 PathOpsThreadedTestRunner testRunner(reporter);
76 for (int a = 0; a < 6; ++a) { // outermost
77 for (int b = a + 1; b < 7; ++b) {
78 for (int c = 0 ; c < 6; ++c) {
79 for (int d = 0; d < 2; ++d) {
halcanary385fe4d2015-08-26 13:07:48 -070080 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
81 &testOpCirclesMain, a, b, c, d, &testRunner);
caryclark1049f122015-04-20 08:31:59 -070082 }
83 }
84 if (!reporter->allowExtendedTest()) goto finish;
85 }
86 }
87finish:
88 testRunner.render();
caryclark1049f122015-04-20 08:31:59 -070089}