Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathOpsSimplifyDegenerateThreadedTest.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/Test.h"
16
18 SkASSERT(data);
20 int ax = state.fA & 0x03;
21 int ay = state.fA >> 2;
22 int bx = state.fB & 0x03;
23 int by = state.fB >> 2;
24 int cx = state.fC & 0x03;
25 int cy = state.fC >> 2;
26 for (int d = 0; d < 16; ++d) {
27 int dx = d & 0x03;
28 int dy = d >> 2;
29 for (int e = d ; e < 16; ++e) {
30 int ex = e & 0x03;
31 int ey = e >> 2;
32 for (int f = d ; f < 16; ++f) {
33 int fx = f & 0x03;
34 int fy = f >> 2;
35 if (state.fD && (ex - dx) * (fy - dy)
36 != (ey - dy) * (fx - dx)) {
37 continue;
38 }
39 SkString pathStr;
40 SkPath path, out;
41 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
42 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by));
43 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy));
44 path.close();
45 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy));
46 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey));
47 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
48 path.close();
49 if (state.fReporter->verbose()) {
50 pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay);
51 pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by);
52 pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy);
53 pathStr.appendf(" path.close();\n");
54 pathStr.appendf(" path.moveTo(%d, %d);\n", dx, dy);
55 pathStr.appendf(" path.lineTo(%d, %d);\n", ex, ey);
56 pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
57 pathStr.appendf(" path.close();\n");
58 state.outputProgress(pathStr.c_str(), SkPathFillType::kWinding);
59 }
60 testSimplify(path, false, out, state, pathStr.c_str());
61 path.setFillType(SkPathFillType::kEvenOdd);
62 if (state.fReporter->verbose()) {
63 state.outputProgress(pathStr.c_str(), SkPathFillType::kEvenOdd);
64 }
65 testSimplify(path, true, out, state, pathStr.c_str());
66 }
67 }
68 }
69}
70
71DEF_TEST(PathOpsSimplifyDegeneratesThreaded, reporter) {
72 initializeTests(reporter, "testDegenerates");
74 for (int a = 0; a < 16; ++a) {
75 int ax = a & 0x03;
76 int ay = a >> 2;
77 for (int b = a ; b < 16; ++b) {
78 int bx = b & 0x03;
79 int by = b >> 2;
80 for (int c = a ; c < 16; ++c) {
81 int cx = c & 0x03;
82 int cy = c >> 2;
83 bool abcIsATriangle = (bx - ax) * (cy - ay) != (by - ay) * (cx - ax);
84 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
85 &testSimplifyDegeneratesMain, a, b, c, abcIsATriangle, &testRunner);
86 }
87 if (!reporter->allowExtendedTest()) goto finish;
88 }
89 }
90finish:
91 testRunner.render();
92}
reporter
bool testSimplify(SkPath &path, bool useXor, SkPath &out, PathOpsThreadState &state, const char *pathStr)
void initializeTests(skiatest::Reporter *reporter, const char *test)
static void testSimplifyDegeneratesMain(PathOpsThreadState *data)
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkIntToScalar(x)
Definition SkScalar.h:57
#define DEF_TEST(name, reporter)
Definition Test.h:312
SkTDArray< PathOpsThreadedRunnable * > fRunnables
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