Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
PathOpsQuadLineIntersectionThreadedTest.cpp File Reference
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/base/SkTemplates.h"
#include "src/pathops/SkIntersections.h"
#include "src/pathops/SkPathOpsLine.h"
#include "src/pathops/SkPathOpsPoint.h"
#include "src/pathops/SkPathOpsQuad.h"
#include "src/pathops/SkReduceOrder.h"
#include "tests/PathOpsExtendedTest.h"
#include "tests/PathOpsTestCommon.h"
#include "tests/PathOpsThreadedCommon.h"
#include "tests/Test.h"
#include <utility>

Go to the source code of this file.

Functions

static int doIntersect (SkIntersections &intersections, const SkDQuad &quad, const SkDLine &line, bool &flipped)
 
static void testLineIntersect (skiatest::Reporter *reporter, const SkDQuad &quad, const SkDLine &line, const double x, const double y)
 
static void testQuadLineIntersectMain (PathOpsThreadState *data)
 
 DEF_TEST (PathOpsQuadLineIntersectionThreaded, reporter)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( PathOpsQuadLineIntersectionThreaded  ,
reporter   
)

Definition at line 124 of file PathOpsQuadLineIntersectionThreadedTest.cpp.

124 {
125 initializeTests(reporter, "testQuadLineIntersect");
127 for (int a = 0; a < 16; ++a) {
128 for (int b = 0 ; b < 16; ++b) {
129 for (int c = 0 ; c < 16; ++c) {
130 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
131 &testQuadLineIntersectMain, a, b, c, 0, &testRunner);
132 }
133 if (!reporter->allowExtendedTest()) goto finish;
134 }
135 }
136finish:
137 testRunner.render();
138}
reporter
void initializeTests(skiatest::Reporter *reporter, const char *test)
static void testQuadLineIntersectMain(PathOpsThreadState *data)
static bool b
struct MyStruct a[10]

◆ doIntersect()

static int doIntersect ( SkIntersections intersections,
const SkDQuad quad,
const SkDLine line,
bool &  flipped 
)
static

Definition at line 23 of file PathOpsQuadLineIntersectionThreadedTest.cpp.

24 {
25 int result;
26 flipped = false;
27 if (line[0].fX == line[1].fX) {
28 double top = line[0].fY;
29 double bottom = line[1].fY;
30 flipped = top > bottom;
31 if (flipped) {
32 using std::swap;
33 swap(top, bottom);
34 }
35 result = intersections.vertical(quad, top, bottom, line[0].fX, flipped);
36 } else if (line[0].fY == line[1].fY) {
37 double left = line[0].fX;
38 double right = line[1].fX;
39 flipped = left > right;
40 if (flipped) {
41 using std::swap;
42 swap(left, right);
43 }
44 result = intersections.horizontal(quad, left, right, line[0].fY, flipped);
45 } else {
46 intersections.intersect(quad, line);
47 result = intersections.used();
48 }
49 return result;
50}
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition SkRefCnt.h:341
int intersect(const SkDLine &, const SkDLine &)
int vertical(const SkDLine &, double top, double bottom, double x, bool flipped)
int horizontal(const SkDLine &, double left, double right, double y, bool flipped)
GAsyncResult * result

◆ testLineIntersect()

static void testLineIntersect ( skiatest::Reporter reporter,
const SkDQuad quad,
const SkDLine line,
const double  x,
const double  y 
)
static

Definition at line 52 of file PathOpsQuadLineIntersectionThreadedTest.cpp.

53 {
54 SkString pathStr;
55 pathStr.appendf(" path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0].fY);
56 pathStr.appendf(" path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1].fX,
57 quad[1].fY, quad[2].fX, quad[2].fY);
58 pathStr.appendf(" path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0].fY);
59 pathStr.appendf(" path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1].fY);
60
61 SkIntersections intersections;
62 bool flipped = false;
63 int result = doIntersect(intersections, quad, line, flipped);
64 bool found = false;
65 for (int index = 0; index < result; ++index) {
66 double quadT = intersections[0][index];
67 SkDPoint quadXY = quad.ptAtT(quadT);
68 double lineT = intersections[1][index];
69 SkDPoint lineXY = line.ptAtT(lineT);
70 if (quadXY.approximatelyEqual(lineXY)) {
71 found = true;
72 }
73 }
75}
static int doIntersect(SkIntersections &intersections, const SkDQuad &quad, const SkDLine &line, bool &flipped)
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550
bool approximatelyEqual(const SkDPoint &a) const
SkDPoint ptAtT(double t) const

◆ testQuadLineIntersectMain()

static void testQuadLineIntersectMain ( PathOpsThreadState data)
static

Definition at line 82 of file PathOpsQuadLineIntersectionThreadedTest.cpp.

83{
85 REPORTER_ASSERT(state.fReporter, data);
86 int ax = state.fA & 0x03;
87 int ay = state.fA >> 2;
88 int bx = state.fB & 0x03;
89 int by = state.fB >> 2;
90 int cx = state.fC & 0x03;
91 int cy = state.fC >> 2;
92 QuadPts q = {{{(double) ax, (double) ay}, {(double) bx, (double) by},
93 {(double) cx, (double) cy}}};
94 SkDQuad quad;
95 quad.debugSet(q.fPts);
96 SkReduceOrder reducer;
97 int order = reducer.reduce(quad);
98 if (order < 3) {
99 return;
100 }
101 for (int tIndex = 0; tIndex <= 4; ++tIndex) {
102 SkDPoint xy = quad.ptAtT(tIndex / 4.0);
103 for (int h = -2; h <= 2; ++h) {
104 for (int v = -2; v <= 2; ++v) {
105 if (h == v && SkTAbs(h) != 1) {
106 continue;
107 }
108 double x = xy.fX;
109 double y = xy.fY;
110 SkDLine line = {{{x - h, y - v}, {x, y}}};
111 testLineIntersect(state.fReporter, quad, line, x, y);
112 state.fReporter->bumpTestCount();
113 SkDLine line2 = {{{x, y}, {x + h, y + v}}};
114 testLineIntersect(state.fReporter, quad, line2, x, y);
115 state.fReporter->bumpTestCount();
116 SkDLine line3 = {{{x - h, y - v}, {x + h, y + v}}};
117 testLineIntersect(state.fReporter, quad, line3, x, y);
118 state.fReporter->bumpTestCount();
119 }
120 }
121 }
122}
static void testLineIntersect(skiatest::Reporter *reporter, const SkDQuad &quad, const SkDLine &line, const double x, const double y)
static T SkTAbs(T value)
Definition SkTemplates.h:43
AtkStateType state
double y
double x
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
SkScalar h
SkDPoint fPts[kPointCount]
void debugSet(const SkDPoint *pts)
int reduce(const SkDCubic &cubic, Quadratics)