Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathOpsOpCubicThreadedTest.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
22static int loopNo = 158;
23static std::atomic<int> gCubicsTestNo{0};
24
26 SkASSERT(data);
29 SkString pathStr;
30 for (int a = 0 ; a < 6; ++a) {
31 for (int b = a + 1 ; b < 7; ++b) {
32 for (int c = 0 ; c < 6; ++c) {
33 for (int d = c + 1 ; d < 7; ++d) {
34 for (auto e : fts) {
35 for (auto f : fts) {
36 SkPath pathA, pathB;
37 pathA.setFillType((SkPathFillType) e);
41 pathA.close();
42 pathB.setFillType((SkPathFillType) f);
46 pathB.close();
47 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
48 if (state.fReporter->verbose()) {
49 pathStr.printf("static void cubicOp%d(skiatest::Reporter* reporter,"
50 " const char* filename) {\n", loopNo);
51 pathStr.appendf(" SkPath path, pathB;\n");
52 pathStr.appendf(" path.setFillType(SkPathFillType::k%s);\n",
54 ? "EvenOdd" : "?UNDEFINED");
55 pathStr.appendf(" path.moveTo(%d,%d);\n", state.fA, state.fB);
56 pathStr.appendf(" path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
57 b, a, d, c);
58 pathStr.appendf(" path.close();\n");
59 pathStr.appendf(" pathB.setFillType(SkPathFillType::k%s);\n",
61 ? "EvenOdd" : "?UNDEFINED");
62 pathStr.appendf(" pathB.moveTo(%d,%d);\n", a, b);
63 pathStr.appendf(" pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
64 state.fB, state.fA, state.fD, state.fC);
65 pathStr.appendf(" pathB.close();\n");
66 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
68 pathStr.appendf("}\n");
69 state.outputProgress(pathStr.c_str(), (SkPathOp) op);
70 }
71 SkString testName;
72 testName.printf("thread_cubics%d", ++gCubicsTestNo);
73 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) {
74 if (state.fReporter->verbose()) {
75 ++loopNo;
76 goto skipToNext;
77 }
78 }
80 }
81 }
82 }
83skipToNext: ;
84 }
85 }
86 }
87 }
88}
89
90DEF_TEST(PathOpsOpCubicsThreaded, reporter) {
91 initializeTests(reporter, "cubicOp");
93 for (int a = 0; a < 6; ++a) { // outermost
94 for (int b = a + 1; b < 7; ++b) {
95 for (int c = 0 ; c < 6; ++c) {
96 for (int d = c + 1; d < 7; ++d) {
97 *testRunner.fRunnables.append() =
98 new PathOpsThreadedRunnable(&testOpCubicsMain, a, b, c, d, &testRunner);
99 }
100 }
101 if (!reporter->allowExtendedTest()) goto finish;
102 }
103 }
104finish:
105 testRunner.render();
106}
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 void testOpCubicsMain(PathOpsThreadState *data)
static int loopNo
static std::atomic< int > gCubicsTestNo
#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)
SkPath & moveTo(SkScalar x, SkScalar y)
Definition SkPath.cpp:678
void setFillType(SkPathFillType ft)
Definition SkPath.h:235
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition SkPath.cpp:789
SkPath & close()
Definition SkPath.cpp:813
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