Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
PathOpsOpLoopThreadedTest.cpp File Reference
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/pathops/SkPathOps.h"
#include "include/private/base/SkTDArray.h"
#include "tests/PathOpsDebug.h"
#include "tests/PathOpsExtendedTest.h"
#include "tests/PathOpsThreadedCommon.h"
#include "tests/Test.h"
#include <atomic>

Go to the source code of this file.

Functions

static void add_point (SkString *str, SkScalar x, SkScalar y)
 
static void testOpLoopsMain (PathOpsThreadState *data)
 
 DEF_TEST (PathOpsOpLoopsThreaded, reporter)
 

Variables

static int loopNo = 17
 
static std::atomic< intgLoopsTestNo {0}
 

Function Documentation

◆ add_point()

static void add_point ( SkString str,
SkScalar  x,
SkScalar  y 
)
static

Definition at line 23 of file PathOpsOpLoopThreadedTest.cpp.

23 {
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}
#define SkScalarRoundToInt(x)
Definition SkScalar.h:37
#define SkIntToScalar(x)
Definition SkScalar.h:57
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550
double y
double x

◆ DEF_TEST()

DEF_TEST ( PathOpsOpLoopsThreaded  ,
reporter   
)

Definition at line 100 of file PathOpsOpLoopThreadedTest.cpp.

100 {
101 initializeTests(reporter, "loopOp");
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 }
114finish:
115 testRunner.render();
116}
reporter
void initializeTests(skiatest::Reporter *reporter, const char *test)
static void testOpLoopsMain(PathOpsThreadState *data)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
struct MyStruct a[10]

◆ testOpLoopsMain()

static void testOpLoopsMain ( PathOpsThreadState data)
static

Definition at line 41 of file PathOpsOpLoopThreadedTest.cpp.

41 {
42 SkASSERT(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;
61 pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD.fX, endD.fY);
62 pathA.close();
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 }
91 testName.printf("thread_loops%d", ++gLoopsTestNo);
92 testPathOp(state.fReporter, pathA, pathB, kIntersect_SkPathOp, testName.c_str());
94 }
95 }
96 }
97 }
98}
bool testPathOp(skiatest::Reporter *reporter, const SkPath &a, const SkPath &b, const SkPathOp shapeOp, const char *testName)
static void add_point(SkString *str, SkScalar x, SkScalar y)
static int loopNo
static std::atomic< int > gLoopsTestNo
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kIntersect_SkPathOp
intersect the two paths
Definition SkPathOps.h:24
static bool gCheckForDuplicateNames
SkPath & moveTo(SkScalar x, SkScalar y)
Definition SkPath.cpp:678
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
AtkStateType state
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
float fX
x-axis value
float fY
y-axis value

Variable Documentation

◆ gLoopsTestNo

std::atomic<int> gLoopsTestNo {0}
static

Definition at line 39 of file PathOpsOpLoopThreadedTest.cpp.

39{0};

◆ loopNo

int loopNo = 17
static

Definition at line 21 of file PathOpsOpLoopThreadedTest.cpp.