Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkPathMeasure.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkPathMeasure_DEFINED
9#define SkPathMeasure_DEFINED
10
16
17class SkMatrix;
18class SkPath;
19
21public:
23 /** Initialize the pathmeasure with the specified path. The parts of the path that are needed
24 * are copied, so the client is free to modify/delete the path after this call.
25 *
26 * resScale controls the precision of the measure. values > 1 increase the
27 * precision (and possibly slow down the computation).
28 */
29 SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
31
34
35 /** Reset the pathmeasure with the specified path. The parts of the path that are needed
36 * are copied, so the client is free to modify/delete the path after this call..
37 */
38 void setPath(const SkPath*, bool forceClosed);
39
40 /** Return the total length of the current contour, or 0 if no path
41 is associated (e.g. resetPath(null))
42 */
43 SkScalar getLength();
44
45 /** Pins distance to 0 <= distance <= getLength(), and then computes
46 the corresponding position and tangent.
47 Returns false if there is no path, or a zero-length path was specified, in which case
48 position and tangent are unchanged.
49 */
50 [[nodiscard]] bool getPosTan(SkScalar distance, SkPoint* position, SkVector* tangent);
51
53 kGetPosition_MatrixFlag = 0x01,
54 kGetTangent_MatrixFlag = 0x02,
55 kGetPosAndTan_MatrixFlag = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
56 };
57
58 /** Pins distance to 0 <= distance <= getLength(), and then computes
59 the corresponding matrix (by calling getPosTan).
60 Returns false if there is no path, or a zero-length path was specified, in which case
61 matrix is unchanged.
62 */
63 [[nodiscard]] bool getMatrix(SkScalar distance, SkMatrix* matrix,
64 MatrixFlags flags = kGetPosAndTan_MatrixFlag);
65
66 /** Given a start and stop distance, return in dst the intervening segment(s).
67 If the segment is zero-length, return false, else return true.
68 startD and stopD are pinned to legal values (0..getLength()). If startD > stopD
69 then return false (and leave dst untouched).
70 Begin the segment with a moveTo if startWithMoveTo is true
71 */
72 bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo);
73
74 /** Return true if the current contour is closed()
75 */
76 bool isClosed();
77
78 /** Move to the next contour in the path. Return true if one exists, or false if
79 we're done with the path.
80 */
81 bool nextContour();
82
83#ifdef SK_DEBUG
84 void dump();
85#endif
86
87 const SkContourMeasure* currentMeasure() const { return fContour.get(); }
88
89private:
92};
93
94#endif
std::unique_ptr< SkLatticeIter > fIter
#define SK_API
Definition SkAPI.h:35
static void dump(const float m[20], SkYUVColorSpace cs, bool rgb2yuv)
SkPathMeasure & operator=(SkPathMeasure &&)=default
SkPathMeasure(SkPathMeasure &&)=default
const SkContourMeasure * currentMeasure() const
float SkScalar
Definition extension.cpp:12
FlutterSemanticsFlag flags