Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SpecialLineRec Class Reference

Public Member Functions

bool init (const SkPath &src, SkPath *dst, SkStrokeRec *rec, int intervalCount, SkScalar intervalLength)
 
void addSegment (SkScalar d0, SkScalar d1, SkPath *path) const
 

Detailed Description

Definition at line 235 of file SkDashPath.cpp.

Member Function Documentation

◆ addSegment()

void SpecialLineRec::addSegment ( SkScalar  d0,
SkScalar  d1,
SkPath path 
) const
inline

Definition at line 280 of file SkDashPath.cpp.

280 {
281 SkASSERT(d0 <= fPathLength);
282 // clamp the segment to our length
283 if (d1 > fPathLength) {
284 d1 = fPathLength;
285 }
286
287 SkScalar x0 = fPts[0].fX + fTangent.fX * d0;
288 SkScalar x1 = fPts[0].fX + fTangent.fX * d1;
289 SkScalar y0 = fPts[0].fY + fTangent.fY * d0;
290 SkScalar y1 = fPts[0].fY + fTangent.fY * d1;
291
292 SkPoint pts[4];
293 pts[0].set(x0 + fNormal.fX, y0 + fNormal.fY); // moveTo
294 pts[1].set(x1 + fNormal.fX, y1 + fNormal.fY); // lineTo
295 pts[2].set(x1 - fNormal.fX, y1 - fNormal.fY); // lineTo
296 pts[3].set(x0 - fNormal.fX, y0 - fNormal.fY); // lineTo
297
298 path->addPoly(pts, std::size(pts), false);
299 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
float SkScalar
Definition: extension.cpp:12
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
Definition: switches.h:57
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
float fX
x-axis value
Definition: SkPoint_impl.h:164
void set(float x, float y)
Definition: SkPoint_impl.h:200
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ init()

bool SpecialLineRec::init ( const SkPath src,
SkPath dst,
SkStrokeRec rec,
int  intervalCount,
SkScalar  intervalLength 
)
inline

Definition at line 237 of file SkDashPath.cpp.

238 {
239 if (rec->isHairlineStyle() || !src.isLine(fPts)) {
240 return false;
241 }
242
243 // can relax this in the future, if we handle square and round caps
244 if (SkPaint::kButt_Cap != rec->getCap()) {
245 return false;
246 }
247
248 SkScalar pathLength = SkPoint::Distance(fPts[0], fPts[1]);
249
250 fTangent = fPts[1] - fPts[0];
251 if (fTangent.isZero()) {
252 return false;
253 }
254
255 fPathLength = pathLength;
256 fTangent.scale(sk_ieee_float_divide(1.0f, pathLength));
257 if (!SkIsFinite(fTangent.fX, fTangent.fY)) {
258 return false;
259 }
260 SkPointPriv::RotateCCW(fTangent, &fNormal);
261 fNormal.scale(SkScalarHalf(rec->getWidth()));
262
263 // now estimate how many quads will be added to the path
264 // resulting segments = pathLen * intervalCount / intervalLen
265 // resulting points = 4 * segments
266
267 SkScalar ptCount = pathLength * intervalCount / (float)intervalLength;
268 ptCount = std::min(ptCount, SkDashPath::kMaxDashCount);
269 if (SkIsNaN(ptCount)) {
270 return false;
271 }
272 int n = SkScalarCeilToInt(ptCount) << 2;
273 dst->incReserve(n);
274
275 // we will take care of the stroking
276 rec->setFillStyle();
277 return true;
278 }
static constexpr bool SkIsNaN(T x)
static bool SkIsFinite(T x, Pack... values)
static constexpr float sk_ieee_float_divide(float numer, float denom)
#define SkScalarHalf(a)
Definition: SkScalar.h:75
#define SkScalarCeilToInt(x)
Definition: SkScalar.h:36
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
static void RotateCCW(const SkPoint &src, SkPoint *dst)
Definition: SkPointPriv.h:72
void setFillStyle()
Definition: SkStrokeRec.cpp:81
bool isHairlineStyle() const
Definition: SkStrokeRec.h:47
SkScalar getWidth() const
Definition: SkStrokeRec.h:42
SkPaint::Cap getCap() const
Definition: SkStrokeRec.h:44
static float min(float r, float g, float b)
Definition: hsl.cpp:48
const SkScalar kMaxDashCount
dst
Definition: cp.py:12
bool isZero() const
Definition: SkPoint_impl.h:193
static float Distance(const SkPoint &a, const SkPoint &b)
Definition: SkPoint_impl.h:508
void scale(float scale, SkPoint *dst) const
Definition: SkPoint.cpp:17

The documentation for this class was generated from the following file: