Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathOpsOpRectThreadedTest.cpp
Go to the documentation of this file.
1/*
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 */
15#include "tests/PathOpsDebug.h"
18#include "tests/Test.h"
19
20#include <atomic>
21#include <initializer_list>
22
23// four rects, of four sizes
24// for 3 smaller sizes, tall, wide
25 // top upper mid lower bottom aligned (3 bits, 5 values)
26 // same with x (3 bits, 5 values)
27// not included, square, tall, wide (2 bits)
28// cw or ccw (1 bit)
29
30static int loopNo = 6;
31static std::atomic<int> gRectsTestNo{0};
32
34{
35 SkASSERT(data);
38 SkString pathStr;
39 for (int a = 0 ; a < 6; ++a) {
40 for (int b = a + 1 ; b < 7; ++b) {
41 for (int c = 0 ; c < 6; ++c) {
42 for (int d = c + 1 ; d < 7; ++d) {
43 for (auto e : fts) {
44 for (auto f : fts) {
45 SkPath pathA, pathB;
46 pathA.setFillType((SkPathFillType) e);
51 pathA.close();
52 pathB.setFillType((SkPathFillType) f);
57 pathB.close();
58 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
59 if (state.fReporter->verbose()) {
60 pathStr.printf(
61 "static void rects%d(skiatest::Reporter* reporter,"
62 "const char* filename) {\n", loopNo);
63 pathStr.appendf(" SkPath path, pathB;");
64 pathStr.appendf(" path.setFillType(SkPathFillType::k%s);\n",
66 ? "EvenOdd" : "?UNDEFINED");
67 pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
68 " SkPathDirection::kCW);\n", state.fA, state.fA, state.fB, state.fB);
69 pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
70 " SkPathDirection::kCW);\n", state.fC, state.fC, state.fD, state.fD);
71 pathStr.appendf(" pathB.setFillType(SkPathFillType::k%s);\n",
73 ? "EvenOdd" : "?UNDEFINED");
74 pathStr.appendf(" pathB.addRect(%d, %d, %d, %d,"
75 " SkPathDirection::kCW);\n", a, a, b, b);
76 pathStr.appendf(" pathB.addRect(%d, %d, %d, %d,"
77 " SkPathDirection::kCW);\n", c, c, d, d);
78 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
80 pathStr.appendf("}\n\n");
81 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
82 }
83 SkString testName;
84 testName.printf("thread_rects%d", ++gRectsTestNo);
85 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) {
86 if (state.fReporter->verbose()) {
87 ++loopNo;
88 goto skipToNext;
89 }
90 }
92 }
93 }
94 }
95skipToNext: ;
96 }
97 }
98 }
99 }
100}
101
102DEF_TEST(PathOpsRectsThreaded, reporter) {
103 initializeTests(reporter, "testOp");
105 for (int a = 0; a < 6; ++a) { // outermost
106 for (int b = a + 1; b < 7; ++b) {
107 for (int c = 0 ; c < 6; ++c) {
108 for (int d = c + 1; d < 7; ++d) {
109 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
110 &testPathOpsRectsMain, a, b, c, d, &testRunner);
111 }
112 }
113 if (!reporter->allowExtendedTest()) goto finish;
114 }
115 }
116finish:
117 testRunner.render();
118}
119
120static std::atomic<int> gFastTestNo{0};
121
123{
124 SkASSERT(data);
125 const SkPathFillType fts[] = {
128 };
129 PathOpsThreadState& state = *data;
130 SkString pathStr;
131 int step = data->fReporter->allowExtendedTest() ? 2 : 5;
132 for (bool a : { false, true } ) {
133 for (bool b : { false, true } ) {
134 for (int c = 0; c < 6; c += step) {
135 for (int d = 0; d < 6; d += step) {
136 for (auto e : fts) {
137 for (auto f : fts) {
138 SkPath pathA, pathB;
139 pathA.setFillType(e);
140 if (a) {
143 }
144 pathA.close();
145 pathB.setFillType(f);
146 if (b) {
149 }
150 pathB.close();
151 const char* fillTypeStr[] = { "Winding", "EvenOdd", "InverseWinding", "InverseEvenOdd" };
152 for (int op = 0; op <= kXOR_SkPathOp; ++op) {
153 if (state.fReporter->verbose()) {
154 pathStr.printf(
155 "static void fast%d(skiatest::Reporter* reporter,"
156 "const char* filename) {\n", loopNo);
157 pathStr.appendf(" SkPath path, pathB;");
158 pathStr.appendf(" path.setFillType(SkPathFillType::k%s);\n", fillTypeStr[(int)e]);
159 if (a) {
160 pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
161 " SkPathDirection::kCW);\n", state.fA, state.fA, state.fB + c, state.fB);
162 }
163 pathStr.appendf(" path.setFillType(SkPathFillType::k%s);\n", fillTypeStr[(int)f]);
164 if (b) {
165 pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
166 " SkPathDirection::kCW);\n", state.fC, state.fC, state.fD + d, state.fD);
167 }
168 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
170 pathStr.appendf("}\n\n");
171 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
172 }
173 SkString testName;
174 testName.printf("fast%d", ++gFastTestNo);
175 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) {
176 if (state.fReporter->verbose()) {
177 ++loopNo;
178 goto skipToNext;
179 }
180 }
182 }
183 }
184 }
185skipToNext: ;
186 }
187 }
188 }
189 }
190}
191
192DEF_TEST(PathOpsFastThreaded, reporter) {
193 initializeTests(reporter, "testOp");
195 int step = reporter->allowExtendedTest() ? 2 : 5;
196 for (int a = 0; a < 6; a += step) { // outermost
197 for (int b = a + 1; b < 7; b += step) {
198 for (int c = 0 ; c < 6; c += step) {
199 for (int d = c + 1; d < 7; d += step) {
200 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
201 &testPathOpsFastMain, a, b, c, d, &testRunner);
202 }
203 }
204 }
205 }
206 testRunner.render();
207}
static int step(int x, SkScalar min, SkScalar max)
Definition BlurTest.cpp:215
reporter
bool testPathOp(skiatest::Reporter *reporter, const SkPath &a, const SkPath &b, const SkPathOp shapeOp, const char *testName)
void initializeTests(skiatest::Reporter *reporter, const char *test)
static int loopNo
static void testPathOpsRectsMain(PathOpsThreadState *data)
static std::atomic< int > gRectsTestNo
static void testPathOpsFastMain(PathOpsThreadState *data)
static std::atomic< int > gFastTestNo
#define SkASSERT(cond)
Definition SkAssert.h:116
SkPathOp
Definition SkPathOps.h:22
@ kXOR_SkPathOp
exclusive-or the two paths
Definition SkPathOps.h:26
SkPathFillType
Definition SkPathTypes.h:11
#define SkIntToScalar(x)
Definition SkScalar.h:57
#define DEF_TEST(name, reporter)
Definition Test.h:312
static bool gCheckForDuplicateNames
SkTDArray< PathOpsThreadedRunnable * > fRunnables
static const char * OpStr(SkPathOp)
void setFillType(SkPathFillType ft)
Definition SkPath.h:235
SkPath & close()
Definition SkPath.cpp:813
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition SkPath.cpp:854
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const char * c_str() const
Definition SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550
T * append()
Definition SkTDArray.h:191
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
struct MyStruct a[10]
AtkStateType state