Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
tests
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
*/
7
#include "
include/core/SkPath.h
"
8
#include "
include/core/SkPathTypes.h
"
9
#include "
include/core/SkScalar.h
"
10
#include "
include/core/SkString.h
"
11
#include "
include/core/SkTypes.h
"
12
#include "
include/private/base/SkTDArray.h
"
13
#include "
tests/PathOpsExtendedTest.h
"
14
#include "
tests/PathOpsThreadedCommon.h
"
15
#include "
tests/Test.h
"
16
17
static
void
testSimplifyDegeneratesMain
(
PathOpsThreadState
* data) {
18
SkASSERT
(data);
19
PathOpsThreadState
&
state
= *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
71
DEF_TEST
(PathOpsSimplifyDegeneratesThreaded,
reporter
) {
72
initializeTests
(
reporter
,
"testDegenerates"
);
73
PathOpsThreadedTestRunner
testRunner(
reporter
);
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
}
90
finish:
91
testRunner.
render
();
92
}
reporter
reporter
Definition
FontMgrTest.cpp:39
testSimplify
bool testSimplify(SkPath &path, bool useXor, SkPath &out, PathOpsThreadState &state, const char *pathStr)
Definition
PathOpsExtendedTest.cpp:376
initializeTests
void initializeTests(skiatest::Reporter *reporter, const char *test)
Definition
PathOpsExtendedTest.cpp:650
PathOpsExtendedTest.h
testSimplifyDegeneratesMain
static void testSimplifyDegeneratesMain(PathOpsThreadState *data)
Definition
PathOpsSimplifyDegenerateThreadedTest.cpp:17
PathOpsThreadedCommon.h
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
SkPathTypes.h
SkPathFillType::kWinding
@ kWinding
SkPathFillType::kEvenOdd
@ kEvenOdd
SkPath.h
SkScalar.h
SkIntToScalar
#define SkIntToScalar(x)
Definition
SkScalar.h:57
SkString.h
SkTDArray.h
SkTypes.h
Test.h
DEF_TEST
#define DEF_TEST(name, reporter)
Definition
Test.h:312
PathOpsThreadedRunnable
Definition
PathOpsThreadedCommon.h:55
PathOpsThreadedTestRunner
Definition
PathOpsThreadedCommon.h:42
PathOpsThreadedTestRunner::render
void render()
Definition
PathOpsThreadedCommon.cpp:19
PathOpsThreadedTestRunner::fRunnables
SkTDArray< PathOpsThreadedRunnable * > fRunnables
Definition
PathOpsThreadedCommon.h:51
SkPath
Definition
SkPath.h:59
SkString
Definition
SkString.h:118
SkString::c_str
const char * c_str() const
Definition
SkString.h:133
SkString::appendf
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition
SkString.cpp:550
SkTDArray::append
T * append()
Definition
SkTDArray.h:191
d
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition
main.cc:19
b
static bool b
Definition
ffi_native_test_module.c:74
a
struct MyStruct a[10]
state
AtkStateType state
Definition
fl_accessible_node.cc:10
ax
Definition
ax_constants.h:10
PathOpsThreadState
Definition
PathOpsThreadedCommon.h:27
Generated on Fri Apr 26 2024 06:17:55 for Flutter Engine by
1.9.8