blob: f1f7df1840241eb6a1c7f0ce79f20b79f01fed17 [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 */
Cary Clark4533f3d2018-08-08 09:48:09 -04007#include "PathOpsDebug.h"
caryclark1049f122015-04-20 08:31:59 -07008#include "PathOpsExtendedTest.h"
9#include "PathOpsThreadedCommon.h"
caryclark8f186432016-10-06 11:46:25 -070010#include "SkString.h"
Cary Clark8af4c402018-08-08 23:22:37 -040011#include <atomic>
caryclark8f186432016-10-06 11:46:25 -070012
13static int loopNo = 4;
Cary Clark8af4c402018-08-08 23:22:37 -040014static std::atomic<int> gCirclesTestNo{0};
caryclark1049f122015-04-20 08:31:59 -070015
16static void testOpCirclesMain(PathOpsThreadState* data) {
17 SkASSERT(data);
18 PathOpsThreadState& state = *data;
caryclark8f186432016-10-06 11:46:25 -070019 SkString pathStr;
caryclark1049f122015-04-20 08:31:59 -070020 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;
caryclark1049f122015-04-20 08:31:59 -070027 pathA.setFillType((SkPath::FillType) e);
28 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
29 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
30 pathB.setFillType((SkPath::FillType) f);
31 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
32 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
33 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
caryclark8f186432016-10-06 11:46:25 -070034 if (state.fReporter->verbose()) {
35 pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter,"
36 " const char* filename) {\n", loopNo);
37 pathStr.appendf(" SkPath path, pathB;\n");
38 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
39 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
40 ? "EvenOdd" : "?UNDEFINED");
41 pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
42 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
43 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
44 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
45 ? "EvenOdd" : "?UNDEFINED");
46 pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b,
47 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
48 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
49 SkPathOpsDebug::OpStr((SkPathOp) op));
50 pathStr.appendf("}\n");
Mike Reedff80c2a2017-01-07 11:16:28 -050051 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
caryclark1049f122015-04-20 08:31:59 -070052 }
Cary Clark4533f3d2018-08-08 09:48:09 -040053 SkString testName;
54 testName.printf("thread_circles%d", ++gCirclesTestNo);
55 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) {
caryclark8f186432016-10-06 11:46:25 -070056 if (state.fReporter->verbose()) {
57 ++loopNo;
58 goto skipToNext;
59 }
60 }
Cary Clark4533f3d2018-08-08 09:48:09 -040061 if (PathOpsDebug::gCheckForDuplicateNames) return;
caryclark1049f122015-04-20 08:31:59 -070062 }
63 }
64 }
caryclark8f186432016-10-06 11:46:25 -070065skipToNext: ;
caryclark1049f122015-04-20 08:31:59 -070066 }
67 }
68 }
69 }
70}
71
72DEF_TEST(PathOpsOpCircleThreaded, reporter) {
73 initializeTests(reporter, "circleOp");
74 PathOpsThreadedTestRunner testRunner(reporter);
75 for (int a = 0; a < 6; ++a) { // outermost
76 for (int b = a + 1; b < 7; ++b) {
77 for (int c = 0 ; c < 6; ++c) {
78 for (int d = 0; d < 2; ++d) {
halcanary385fe4d2015-08-26 13:07:48 -070079 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
80 &testOpCirclesMain, a, b, c, d, &testRunner);
caryclark1049f122015-04-20 08:31:59 -070081 }
82 }
83 if (!reporter->allowExtendedTest()) goto finish;
84 }
85 }
86finish:
87 testRunner.render();
caryclark1049f122015-04-20 08:31:59 -070088}