Flutter Engine
The Flutter Engine
Functions
skpathutils Namespace Reference

Functions

SK_API bool FillPathWithPaint (const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
 
SK_API bool FillPathWithPaint (const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, const SkMatrix &ctm)
 
SK_API bool FillPathWithPaint (const SkPath &src, const SkPaint &paint, SkPath *dst)
 

Function Documentation

◆ FillPathWithPaint() [1/3]

bool skpathutils::FillPathWithPaint ( const SkPath src,
const SkPaint paint,
SkPath dst 
)

Definition at line 19 of file SkPathUtils.cpp.

19 {
20 return skpathutils::FillPathWithPaint(src, paint, dst, nullptr, 1);
21}
const Paint & paint
Definition: color_source.cc:38
dst
Definition: cp.py:12
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23

◆ FillPathWithPaint() [2/3]

bool skpathutils::FillPathWithPaint ( const SkPath src,
const SkPaint paint,
SkPath dst,
const SkRect cullRect,
const SkMatrix ctm 
)

Definition at line 29 of file SkPathUtils.cpp.

30 {
31 if (!src.isFinite()) {
32 dst->reset();
33 return false;
34 }
35
37 SkStrokeRec rec(paint, resScale);
38
39#if defined(SK_BUILD_FOR_FUZZER)
40 // Prevent lines with small widths from timing out.
41 if (rec.getStyle() == SkStrokeRec::Style::kStroke_Style && rec.getWidth() < 0.001) {
42 return false;
43 }
44#endif
45
46 const SkPath* srcPtr = &src;
47 SkPath tmpPath;
48
49 SkPathEffect* pe = paint.getPathEffect();
50 if (pe && pe->filterPath(&tmpPath, src, &rec, cullRect, ctm)) {
51 srcPtr = &tmpPath;
52 }
53
54 if (!rec.applyToPath(dst, *srcPtr)) {
55 if (srcPtr == &tmpPath) {
56 // If path's were copy-on-write, this trick would not be needed.
57 // As it is, we want to save making a deep-copy from tmpPath -> dst
58 // since we know we're just going to delete tmpPath when we return,
59 // so the swap saves that copy.
60 dst->swap(tmpPath);
61 } else {
62 *dst = *srcPtr;
63 }
64 }
65
66 if (!dst->isFinite()) {
67 dst->reset();
68 return false;
69 }
70 return !rec.isHairlineStyle();
71}
static SkScalar ComputeResScaleForStroking(const SkMatrix &matrix)
Definition: SkMatrix.cpp:1877
bool filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR) const
Definition: SkPath.h:59
float SkScalar
Definition: extension.cpp:12

◆ FillPathWithPaint() [3/3]

bool skpathutils::FillPathWithPaint ( const SkPath src,
const SkPaint paint,
SkPath dst,
const SkRect cullRect,
SkScalar  resScale = 1 
)

Returns the filled equivalent of the stroked path.

Parameters
srcSkPath read to create a filled version
paintSkPaint, from which attributes such as stroke cap, width, miter, and join, as well as pathEffect will be used.
dstresulting SkPath; may be the same as src, but may not be nullptr
cullRectoptional limit passed to SkPathEffect
resScaleif > 1, increase precision, else if (0 < resScale < 1) reduce precision to favor speed and size
Returns
true if the dst path was updated, false if it was not (e.g. if the path represents hairline and cannot be filled).

Definition at line 23 of file SkPathUtils.cpp.

24 {
26 SkMatrix::Scale(resScale, resScale));
27}
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75