Flutter Engine
The Flutter Engine
Classes | Functions | Variables
GrPathUtils Namespace Reference

Classes

class  QuadUVMatrix
 

Functions

SkScalar scaleToleranceToSrc (SkScalar devTol, const SkMatrix &viewM, const SkRect &pathBounds)
 
uint32_t quadraticPointCount (const SkPoint points[], SkScalar tol)
 
uint32_t generateQuadraticPoints (const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, SkScalar tolSqd, SkPoint **points, uint32_t pointsLeft)
 
uint32_t cubicPointCount (const SkPoint points[], SkScalar tol)
 
uint32_t generateCubicPoints (const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, SkScalar tolSqd, SkPoint **points, uint32_t pointsLeft)
 
void getConicKLM (const SkPoint p[3], const SkScalar weight, SkMatrix *klm)
 
void convertCubicToQuads (const SkPoint p[4], SkScalar tolScale, skia_private::TArray< SkPoint, true > *quads)
 
void convertCubicToQuadsConstrainToTangents (const SkPoint p[4], SkScalar tolScale, SkPathFirstDirection dir, skia_private::TArray< SkPoint, true > *quads)
 

Variables

static const SkScalar kDefaultTolerance = SkDoubleToScalar(0.25)
 
static const int kMaxPointsPerCurve = 1 << 10
 

Detailed Description

Utilities for evaluating paths.

Function Documentation

◆ convertCubicToQuads()

void GrPathUtils::convertCubicToQuads ( const SkPoint  p[4],
SkScalar  tolScale,
skia_private::TArray< SkPoint, true > *  quads 
)

Definition at line 494 of file GrPathUtils.cpp.

496 {
497 if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) {
498 return;
499 }
500 if (!SkIsFinite(tolScale)) {
501 return;
502 }
503 SkPoint chopped[10];
504 int count = SkChopCubicAtInflections(p, chopped);
505
506 const SkScalar tolSqd = SkScalarSquare(tolScale);
507
508 for (int i = 0; i < count; ++i) {
509 SkPoint* cubic = chopped + 3*i;
510 convert_noninflect_cubic_to_quads(cubic, tolSqd, quads);
511 }
512}
int count
Definition: FontMgrTest.cpp:50
static bool isFinite(const SkRect &r)
Definition: MathBench.cpp:230
static bool SkIsFinite(T x, Pack... values)
int SkChopCubicAtInflections(const SkPoint src[4], SkPoint dst[10])
Definition: SkGeometry.cpp:755
static SkScalar SkScalarSquare(SkScalar x)
Definition: SkScalar.h:71
float SkScalar
Definition: extension.cpp:12
AI float cubic(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:195

◆ convertCubicToQuadsConstrainToTangents()

void GrPathUtils::convertCubicToQuadsConstrainToTangents ( const SkPoint  p[4],
SkScalar  tolScale,
SkPathFirstDirection  dir,
skia_private::TArray< SkPoint, true > *  quads 
)

Definition at line 514 of file GrPathUtils.cpp.

517 {
518 if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) {
519 return;
520 }
521 if (!SkIsFinite(tolScale)) {
522 return;
523 }
524 SkPoint chopped[10];
525 int count = SkChopCubicAtInflections(p, chopped);
526
527 const SkScalar tolSqd = SkScalarSquare(tolScale);
528
529 for (int i = 0; i < count; ++i) {
530 SkPoint* cubic = chopped + 3*i;
531 convert_noninflect_cubic_to_quads_with_constraint(cubic, tolSqd, dir, quads);
532 }
533}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145

◆ cubicPointCount()

uint32_t GrPathUtils::cubicPointCount ( const SkPoint  points[],
SkScalar  tol 
)

Definition at line 103 of file GrPathUtils.cpp.

103 {
106}
static float tolerance_to_wangs_precision(float srcTol)
Definition: GrPathUtils.cpp:25
uint32_t max_bezier_vertices(uint32_t chopCount)
Definition: GrPathUtils.cpp:35
static const int points[]
AI int cubic_log2(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:203

◆ generateCubicPoints()

uint32_t GrPathUtils::generateCubicPoints ( const SkPoint p0,
const SkPoint p1,
const SkPoint p2,
const SkPoint p3,
SkScalar  tolSqd,
SkPoint **  points,
uint32_t  pointsLeft 
)

Definition at line 108 of file GrPathUtils.cpp.

114 {
115 if (pointsLeft < 2 ||
116 (SkPointPriv::DistanceToLineSegmentBetweenSqd(p1, p0, p3) < tolSqd &&
117 SkPointPriv::DistanceToLineSegmentBetweenSqd(p2, p0, p3) < tolSqd)) {
118 (*points)[0] = p3;
119 *points += 1;
120 return 1;
121 }
122 SkPoint q[] = {
123 { SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) },
124 { SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) },
125 { SkScalarAve(p2.fX, p3.fX), SkScalarAve(p2.fY, p3.fY) }
126 };
127 SkPoint r[] = {
128 { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) },
129 { SkScalarAve(q[1].fX, q[2].fX), SkScalarAve(q[1].fY, q[2].fY) }
130 };
131 SkPoint s = { SkScalarAve(r[0].fX, r[1].fX), SkScalarAve(r[0].fY, r[1].fY) };
132 pointsLeft >>= 1;
133 uint32_t a = generateCubicPoints(p0, q[0], r[0], s, tolSqd, points, pointsLeft);
134 uint32_t b = generateCubicPoints(s, r[1], q[2], p3, tolSqd, points, pointsLeft);
135 return a + b;
136}
#define SkScalarAve(a, b)
Definition: SkScalar.h:74
static SkScalar DistanceToLineSegmentBetweenSqd(const SkPoint &pt, const SkPoint &a, const SkPoint &b)
Definition: SkPoint.cpp:126
static bool b
struct MyStruct s
struct MyStruct a[10]
uint32_t generateCubicPoints(const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, SkScalar tolSqd, SkPoint **points, uint32_t pointsLeft)
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ generateQuadraticPoints()

uint32_t GrPathUtils::generateQuadraticPoints ( const SkPoint p0,
const SkPoint p1,
const SkPoint p2,
SkScalar  tolSqd,
SkPoint **  points,
uint32_t  pointsLeft 
)

Definition at line 78 of file GrPathUtils.cpp.

83 {
84 if (pointsLeft < 2 ||
85 (SkPointPriv::DistanceToLineSegmentBetweenSqd(p1, p0, p2)) < tolSqd) {
86 (*points)[0] = p2;
87 *points += 1;
88 return 1;
89 }
90
91 SkPoint q[] = {
92 { SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) },
93 { SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) },
94 };
95 SkPoint r = { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) };
96
97 pointsLeft >>= 1;
98 uint32_t a = generateQuadraticPoints(p0, q[0], r, tolSqd, points, pointsLeft);
99 uint32_t b = generateQuadraticPoints(r, q[1], p2, tolSqd, points, pointsLeft);
100 return a + b;
101}
uint32_t generateQuadraticPoints(const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, SkScalar tolSqd, SkPoint **points, uint32_t pointsLeft)
Definition: GrPathUtils.cpp:78

◆ getConicKLM()

void GrPathUtils::getConicKLM ( const SkPoint  p[3],
const SkScalar  weight,
SkMatrix klm 
)

Definition at line 228 of file GrPathUtils.cpp.

228 {
229 SkMatrix& klm = *out;
230 const SkScalar w2 = 2.f * weight;
231 klm[0] = p[2].fY - p[0].fY;
232 klm[1] = p[0].fX - p[2].fX;
233 klm[2] = p[2].fX * p[0].fY - p[0].fX * p[2].fY;
234
235 klm[3] = w2 * (p[1].fY - p[0].fY);
236 klm[4] = w2 * (p[0].fX - p[1].fX);
237 klm[5] = w2 * (p[1].fX * p[0].fY - p[0].fX * p[1].fY);
238
239 klm[6] = w2 * (p[2].fY - p[1].fY);
240 klm[7] = w2 * (p[1].fX - p[2].fX);
241 klm[8] = w2 * (p[2].fX * p[1].fY - p[1].fX * p[2].fY);
242
243 // scale the max absolute value of coeffs to 10
244 SkScalar scale = 0.f;
245 for (int i = 0; i < 9; ++i) {
246 scale = std::max(scale, SkScalarAbs(klm[i]));
247 }
248 SkASSERT(scale > 0.f);
249 scale = 10.f / scale;
250 for (int i = 0; i < 9; ++i) {
251 klm[i] *= scale;
252 }
253}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SkScalarAbs(x)
Definition: SkScalar.h:39
static float max(float r, float g, float b)
Definition: hsl.cpp:49
const Scalar scale

◆ quadraticPointCount()

uint32_t GrPathUtils::quadraticPointCount ( const SkPoint  points[],
SkScalar  tol 
)

Definition at line 73 of file GrPathUtils.cpp.

73 {
76}
AI int quadratic_log2(float precision, const SkPoint pts[], const VectorXform &vectorXform=VectorXform())
Definition: WangsFormula.h:164

◆ scaleToleranceToSrc()

SkScalar GrPathUtils::scaleToleranceToSrc ( SkScalar  devTol,
const SkMatrix viewM,
const SkRect pathBounds 
)

Definition at line 41 of file GrPathUtils.cpp.

43 {
44 // In order to tesselate the path we get a bound on how much the matrix can
45 // scale when mapping to screen coordinates.
46 SkScalar stretch = viewM.getMaxScale();
47
48 if (stretch < 0) {
49 // take worst case mapRadius amoung four corners.
50 // (less than perfect)
51 for (int i = 0; i < 4; ++i) {
52 SkMatrix mat;
53 mat.setTranslate((i % 2) ? pathBounds.fLeft : pathBounds.fRight,
54 (i < 2) ? pathBounds.fTop : pathBounds.fBottom);
55 mat.postConcat(viewM);
56 stretch = std::max(stretch, mat.mapRadius(SK_Scalar1));
57 }
58 }
59 SkScalar srcTol = 0;
60 if (stretch <= 0) {
61 // We have degenerate bounds or some degenerate matrix. Thus we set the tolerance to be the
62 // max of the path pathBounds width and height.
63 srcTol = std::max(pathBounds.width(), pathBounds.height());
64 } else {
65 srcTol = devTol / stretch;
66 }
67 if (srcTol < kMinCurveTol) {
68 srcTol = kMinCurveTol;
69 }
70 return srcTol;
71}
static const SkScalar kMinCurveTol
Definition: GrPathUtils.cpp:23
#define SK_Scalar1
Definition: SkScalar.h:18
SkScalar mapRadius(SkScalar radius) const
Definition: SkMatrix.cpp:1170
SkMatrix & postConcat(const SkMatrix &other)
Definition: SkMatrix.cpp:683
SkMatrix & setTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:254
SkScalar getMaxScale() const
Definition: SkMatrix.cpp:1531
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

Variable Documentation

◆ kDefaultTolerance

const SkScalar GrPathUtils::kDefaultTolerance = SkDoubleToScalar(0.25)
static

Definition at line 32 of file GrPathUtils.h.

◆ kMaxPointsPerCurve

const int GrPathUtils::kMaxPointsPerCurve = 1 << 10
static

Definition at line 35 of file GrPathUtils.h.