Flutter Engine
The Flutter Engine
third_party
skia
tests
PathOpsOpLoopThreadedTest.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2014 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/SkPoint.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 "
tests/PathOpsDebug.h
"
15
#include "
tests/PathOpsExtendedTest.h
"
16
#include "
tests/PathOpsThreadedCommon.h
"
17
#include "
tests/Test.h
"
18
19
#include <atomic>
20
21
static
int
loopNo
= 17;
22
23
static
void
add_point
(
SkString
* str,
SkScalar
x
,
SkScalar
y
) {
24
int
asInt =
SkScalarRoundToInt
(
x
);
25
if
(
SkIntToScalar
(asInt) ==
x
) {
26
str->
appendf
(
"%d"
, asInt);
27
}
else
{
28
str->
appendf
(
"%1.9gf"
,
x
);
29
}
30
str->
appendf
(
","
);
31
asInt =
SkScalarRoundToInt
(
y
);
32
if
(
SkIntToScalar
(asInt) ==
y
) {
33
str->
appendf
(
"%d"
, asInt);
34
}
else
{
35
str->
appendf
(
"%1.9gf"
,
y
);
36
}
37
}
38
39
static
std::atomic<int>
gLoopsTestNo
{0};
40
41
static
void
testOpLoopsMain
(
PathOpsThreadState
*
data
) {
42
SkASSERT
(
data
);
43
PathOpsThreadState
&
state
= *
data
;
44
SkString
pathStr;
45
for
(
int
a
= 0 ;
a
< 6; ++
a
) {
46
for
(
int
b
=
a
+ 1 ;
b
< 7; ++
b
) {
47
for
(
int
c = 0 ; c < 6; ++c) {
48
for
(
int
d
= c + 1 ;
d
< 7; ++
d
) {
49
// define 4 points that form two lines that often cross; one line is (a, b) (c, d)
50
SkVector
v = {
SkIntToScalar
(
a
- c),
SkIntToScalar
(
b
-
d
)};
51
SkPoint
midA = {
SkIntToScalar
(
a
*
state
.fA + c * (6 -
state
.fA)) / 6,
52
SkIntToScalar
(
b
*
state
.fA +
d
* (6 -
state
.fA)) / 6 };
53
SkPoint
midB = {
SkIntToScalar
(
a
*
state
.fB + c * (6 -
state
.fB)) / 6,
54
SkIntToScalar
(
b
*
state
.fB +
d
* (6 -
state
.fB)) / 6 };
55
SkPoint
endC = { midA.
fX
+ v.
fY
*
state
.fC / 3,
56
midA.
fY
+ v.
fX
*
state
.fC / 3 };
57
SkPoint
endD = { midB.
fX
- v.
fY
*
state
.fD / 3,
58
midB.
fY
+ v.
fX
*
state
.fD / 3 };
59
SkPath
pathA, pathB;
60
pathA.
moveTo
(
SkIntToScalar
(
a
),
SkIntToScalar
(
b
));
61
pathA.
cubicTo
(
SkIntToScalar
(c),
SkIntToScalar
(
d
), endC.
fX
, endC.
fY
, endD.
fX
, endD.
fY
);
62
pathA.
close
();
63
pathB.
moveTo
(
SkIntToScalar
(c),
SkIntToScalar
(
d
));
64
pathB.
cubicTo
(endC.
fX
, endC.
fY
, endD.
fX
, endD.
fY
,
SkIntToScalar
(
a
),
SkIntToScalar
(
b
));
65
pathB.
close
();
66
// SkDebugf("%s\n", pathStr);
67
if
(
state
.fReporter->verbose()) {
68
pathStr.
printf
(
"static void loop%d(skiatest::Reporter* reporter,"
69
" const char* filename) {\n"
,
loopNo
);
70
pathStr.
appendf
(
" SkPath path, pathB;\n"
);
71
pathStr.
appendf
(
" path.moveTo(%d,%d);\n"
,
a
,
b
);
72
pathStr.
appendf
(
" path.cubicTo(%d,%d, "
, c,
d
);
73
add_point
(&pathStr, endC.
fX
, endC.
fY
);
74
pathStr.
appendf
(
", "
);
75
add_point
(&pathStr, endD.
fX
, endD.
fY
);
76
pathStr.
appendf
(
");\n"
);
77
pathStr.
appendf
(
" path.close();\n"
);
78
pathStr.
appendf
(
" pathB.moveTo(%d,%d);\n"
, c,
d
);
79
pathStr.
appendf
(
" pathB.cubicTo("
);
80
add_point
(&pathStr, endC.
fX
, endC.
fY
);
81
pathStr.
appendf
(
", "
);
82
add_point
(&pathStr, endD.
fX
, endD.
fY
);
83
pathStr.
appendf
(
", %d,%d);\n"
,
a
,
b
);
84
pathStr.
appendf
(
" pathB.close();\n"
);
85
pathStr.
appendf
(
" testPathOp(reporter, path, pathB, kIntersect_SkPathOp,"
86
" filename);\n"
);
87
pathStr.
appendf
(
"}\n"
);
88
state
.outputProgress(pathStr.
c_str
(),
kIntersect_SkPathOp
);
89
}
90
SkString
testName
;
91
testName
.printf(
"thread_loops%d"
, ++
gLoopsTestNo
);
92
testPathOp
(
state
.fReporter, pathA, pathB,
kIntersect_SkPathOp
,
testName
.c_str());
93
if
(
PathOpsDebug::gCheckForDuplicateNames
)
return
;
94
}
95
}
96
}
97
}
98
}
99
100
DEF_TEST
(PathOpsOpLoopsThreaded,
reporter
) {
101
initializeTests
(
reporter
,
"loopOp"
);
102
PathOpsThreadedTestRunner
testRunner(
reporter
);
103
for
(
int
a
= 0;
a
< 6; ++
a
) {
// outermost
104
for
(
int
b
=
a
+ 1;
b
< 7; ++
b
) {
105
for
(
int
c = 0 ; c < 6; ++c) {
106
for
(
int
d
= c + 1;
d
< 7; ++
d
) {
107
*testRunner.
fRunnables
.
append
() =
108
new
PathOpsThreadedRunnable
(&
testOpLoopsMain
,
a
,
b
, c,
d
, &testRunner);
109
}
110
}
111
if
(!
reporter
->allowExtendedTest())
goto
finish;
112
}
113
}
114
finish:
115
testRunner.
render
();
116
}
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
DEF_TEST
DEF_TEST(PathOpsOpLoopsThreaded, reporter)
Definition:
PathOpsOpLoopThreadedTest.cpp:100
add_point
static void add_point(SkString *str, SkScalar x, SkScalar y)
Definition:
PathOpsOpLoopThreadedTest.cpp:23
loopNo
static int loopNo
Definition:
PathOpsOpLoopThreadedTest.cpp:21
testOpLoopsMain
static void testOpLoopsMain(PathOpsThreadState *data)
Definition:
PathOpsOpLoopThreadedTest.cpp:41
gLoopsTestNo
static std::atomic< int > gLoopsTestNo
Definition:
PathOpsOpLoopThreadedTest.cpp:39
PathOpsThreadedCommon.h
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkPathOps.h
kIntersect_SkPathOp
@ kIntersect_SkPathOp
intersect the two paths
Definition:
SkPathOps.h:24
SkPath.h
SkPoint.h
SkScalar.h
SkScalarRoundToInt
#define SkScalarRoundToInt(x)
Definition:
SkScalar.h:37
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
SkPath
Definition:
SkPath.h:59
SkPath::moveTo
SkPath & moveTo(SkScalar x, SkScalar y)
Definition:
SkPath.cpp:688
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
SkScalar
float SkScalar
Definition:
extension.cpp:12
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
y
double y
Definition:
mouse-input-test.cc:83
x
double x
Definition:
mouse-input-test.cc:82
import_conformance_tests.testName
testName
Definition:
import_conformance_tests.py:102
PathOpsThreadState
Definition:
PathOpsThreadedCommon.h:27
SkPoint
Definition:
SkPoint_impl.h:163
SkPoint::fX
float fX
x-axis value
Definition:
SkPoint_impl.h:164
SkPoint::fY
float fY
y-axis value
Definition:
SkPoint_impl.h:165
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