Flutter Engine
The Flutter Engine
third_party
skia
tests
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
*/
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/pathops/SkPathOps.h
"
13
#include "
include/private/base/SkTDArray.h
"
14
#include "
src/pathops/SkPathOpsDebug.h
"
15
#include "
tests/PathOpsDebug.h
"
16
#include "
tests/PathOpsExtendedTest.h
"
17
#include "
tests/PathOpsThreadedCommon.h
"
18
#include "
tests/Test.h
"
19
20
#include <atomic>
21
22
static
int
loopNo
= 158;
23
static
std::atomic<int>
gCubicsTestNo
{0};
24
25
static
void
testOpCubicsMain
(
PathOpsThreadState
*
data
) {
26
SkASSERT
(
data
);
27
const
SkPathFillType
fts[] = {
SkPathFillType::kWinding
,
SkPathFillType::kEvenOdd
};
28
PathOpsThreadState
&
state
= *
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
);
38
pathA.
moveTo
(
SkIntToScalar
(
state
.fA),
SkIntToScalar
(
state
.fB));
39
pathA.
cubicTo
(
SkIntToScalar
(
state
.fC),
SkIntToScalar
(
state
.fD),
SkIntToScalar
(
b
),
40
SkIntToScalar
(
a
),
SkIntToScalar
(
d
),
SkIntToScalar
(c));
41
pathA.
close
();
42
pathB.
setFillType
((
SkPathFillType
)
f
);
43
pathB.
moveTo
(
SkIntToScalar
(
a
),
SkIntToScalar
(
b
));
44
pathB.
cubicTo
(
SkIntToScalar
(c),
SkIntToScalar
(
d
),
SkIntToScalar
(
state
.fB),
45
SkIntToScalar
(
state
.fA),
SkIntToScalar
(
state
.fD),
SkIntToScalar
(
state
.fC));
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"
,
53
e
==
SkPathFillType::kWinding
?
"Winding"
:
e
==
SkPathFillType::kEvenOdd
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"
,
60
f
==
SkPathFillType::kWinding
?
"Winding"
:
f
==
SkPathFillType::kEvenOdd
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"
,
67
SkPathOpsDebug::OpStr
((
SkPathOp
) op));
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
}
79
if
(
PathOpsDebug::gCheckForDuplicateNames
)
return
;
80
}
81
}
82
}
83
skipToNext: ;
84
}
85
}
86
}
87
}
88
}
89
90
DEF_TEST
(PathOpsOpCubicsThreaded,
reporter
) {
91
initializeTests
(
reporter
,
"cubicOp"
);
92
PathOpsThreadedTestRunner
testRunner(
reporter
);
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
}
104
finish:
105
testRunner.
render
();
106
}
reporter
reporter
Definition:
FontMgrTest.cpp:39
PathOpsDebug.h
testPathOp
bool testPathOp(skiatest::Reporter *reporter, const SkPath &a, const SkPath &b, const SkPathOp shapeOp, const char *testName)
Definition:
PathOpsExtendedTest.cpp:618
initializeTests
void initializeTests(skiatest::Reporter *reporter, const char *test)
Definition:
PathOpsExtendedTest.cpp:650
PathOpsExtendedTest.h
testOpCubicsMain
static void testOpCubicsMain(PathOpsThreadState *data)
Definition:
PathOpsOpCubicThreadedTest.cpp:25
loopNo
static int loopNo
Definition:
PathOpsOpCubicThreadedTest.cpp:22
DEF_TEST
DEF_TEST(PathOpsOpCubicsThreaded, reporter)
Definition:
PathOpsOpCubicThreadedTest.cpp:90
gCubicsTestNo
static std::atomic< int > gCubicsTestNo
Definition:
PathOpsOpCubicThreadedTest.cpp:23
PathOpsThreadedCommon.h
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkPathOpsDebug.h
SkPathOps.h
SkPathOp
SkPathOp
Definition:
SkPathOps.h:22
kXOR_SkPathOp
@ kXOR_SkPathOp
exclusive-or the two paths
Definition:
SkPathOps.h:26
SkPathTypes.h
SkPathFillType
SkPathFillType
Definition:
SkPathTypes.h:11
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
PathOpsDebug::gCheckForDuplicateNames
static bool gCheckForDuplicateNames
Definition:
PathOpsDebug.h:18
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
SkPathOpsDebug::OpStr
static const char * OpStr(SkPathOp)
Definition:
SkPathOpsDebug.cpp:543
SkPath
Definition:
SkPath.h:59
SkPath::moveTo
SkPath & moveTo(SkScalar x, SkScalar y)
Definition:
SkPath.cpp:688
SkPath::setFillType
void setFillType(SkPathFillType ft)
Definition:
SkPath.h:235
SkPath::cubicTo
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition:
SkPath.cpp:799
SkPath::close
SkPath & close()
Definition:
SkPath.cpp:823
SkString
Definition:
SkString.h:118
SkString::printf
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition:
SkString.cpp:534
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
import_conformance_tests.testName
testName
Definition:
import_conformance_tests.py:102
protoc_wrapper.e
e
Definition:
protoc_wrapper.py:226
skcms_private::f
float f
Definition:
skcms_Transform.h:121
PathOpsThreadState
Definition:
PathOpsThreadedCommon.h:27
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:43 for Flutter Engine by
1.9.4