Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
flutter::CanvasPath Class Reference

#include <path.h>

Inheritance diagram for flutter::CanvasPath:
flutter::RefCountedDartWrappable< CanvasPath > fml::RefCountedThreadSafe< CanvasPath > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ~CanvasPath () override
 
int getFillType ()
 
void setFillType (int fill_type)
 
void moveTo (double x, double y)
 
void relativeMoveTo (double x, double y)
 
void lineTo (double x, double y)
 
void relativeLineTo (double x, double y)
 
void quadraticBezierTo (double x1, double y1, double x2, double y2)
 
void relativeQuadraticBezierTo (double x1, double y1, double x2, double y2)
 
void cubicTo (double x1, double y1, double x2, double y2, double x3, double y3)
 
void relativeCubicTo (double x1, double y1, double x2, double y2, double x3, double y3)
 
void conicTo (double x1, double y1, double x2, double y2, double w)
 
void relativeConicTo (double x1, double y1, double x2, double y2, double w)
 
void arcTo (double left, double top, double right, double bottom, double startAngle, double sweepAngle, bool forceMoveTo)
 
void arcToPoint (double arcEndX, double arcEndY, double radiusX, double radiusY, double xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
 
void relativeArcToPoint (double arcEndDeltaX, double arcEndDeltaY, double radiusX, double radiusY, double xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
 
void addRect (double left, double top, double right, double bottom)
 
void addOval (double left, double top, double right, double bottom)
 
void addArc (double left, double top, double right, double bottom, double startAngle, double sweepAngle)
 
void addPolygon (const tonic::Float32List &points, bool close)
 
void addRRect (const RRect &rrect)
 
void addPath (CanvasPath *path, double dx, double dy)
 
void addPathWithMatrix (CanvasPath *path, double dx, double dy, Dart_Handle matrix4_handle)
 
void extendWithPath (CanvasPath *path, double dx, double dy)
 
void extendWithPathAndMatrix (CanvasPath *path, double dx, double dy, Dart_Handle matrix4_handle)
 
void close ()
 
void reset ()
 
bool contains (double x, double y)
 
void shift (Dart_Handle path_handle, double dx, double dy)
 
void transform (Dart_Handle path_handle, Dart_Handle matrix4_handle)
 
tonic::Float32List getBounds ()
 
bool op (CanvasPath *path1, CanvasPath *path2, int operation)
 
void clone (Dart_Handle path_handle)
 
const SkPathpath () const
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< CanvasPath >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< CanvasPath >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual void RetainDartWrappableReference () const =0
 
virtual void ReleaseDartWrappableReference () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static void CreateFrom (Dart_Handle path_handle, const SkPath &src)
 
static fml::RefPtr< CanvasPathCreate (Dart_Handle wrapper)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< CanvasPath >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 18 of file path.h.

Constructor & Destructor Documentation

◆ ~CanvasPath()

flutter::CanvasPath::~CanvasPath ( )
overridedefault

Member Function Documentation

◆ addArc()

void flutter::CanvasPath::addArc ( double  left,
double  top,
double  right,
double  bottom,
double  startAngle,
double  sweepAngle 
)

Definition at line 189 of file path.cc.

194 {
195 mutable_path().addArc(
197 SafeNarrow(bottom)),
198 SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
199 SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI));
200 resetVolatility();
201}
#define M_PI
SkPath & addArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle)
Definition: SkPath.cpp:1439
SkScalar startAngle
Definition: SkRecords.h:250
SkScalar sweepAngle
Definition: SkRecords.h:251
static float SafeNarrow(double value)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ addOval()

void flutter::CanvasPath::addOval ( double  left,
double  top,
double  right,
double  bottom 
)

Definition at line 182 of file path.cc.

182 {
183 mutable_path().addOval(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
184 SafeNarrow(right),
185 SafeNarrow(bottom)));
186 resetVolatility();
187}
SkPath & addOval(const SkRect &oval, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1106

◆ addPath()

void flutter::CanvasPath::addPath ( CanvasPath path,
double  dx,
double  dy 
)

Definition at line 214 of file path.cc.

214 {
215 if (!path) {
216 Dart_ThrowException(ToDart("Path.addPath called with non-genuine Path."));
217 return;
218 }
219 mutable_path().addPath(path->path(), SafeNarrow(dx), SafeNarrow(dy),
221 resetVolatility();
222}
SkPath & addPath(const SkPath &src, SkScalar dx, SkScalar dy, AddPathMode mode=kAppend_AddPathMode)
Definition: SkPath.cpp:1506
@ kAppend_AddPathMode
Definition: SkPath.h:1286
const SkPath & path() const
Definition: path.h:117
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
Dart_Handle ToDart(const T &object)

◆ addPathWithMatrix()

void flutter::CanvasPath::addPathWithMatrix ( CanvasPath path,
double  dx,
double  dy,
Dart_Handle  matrix4_handle 
)

Definition at line 224 of file path.cc.

227 {
228 tonic::Float64List matrix4(matrix4_handle);
229
230 if (!path) {
231 matrix4.Release();
233 ToDart("Path.addPathWithMatrix called with non-genuine Path."));
234 return;
235 }
236
237 SkMatrix matrix = ToSkMatrix(matrix4);
238 matrix4.Release();
239 matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
240 matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
241 mutable_path().addPath(path->path(), matrix, SkPath::kAppend_AddPathMode);
242 resetVolatility();
243}
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
constexpr SkMatrix ToSkMatrix(const DlMatrix &matrix)

◆ addPolygon()

void flutter::CanvasPath::addPolygon ( const tonic::Float32List &  points,
bool  close 
)

Definition at line 203 of file path.cc.

203 {
204 mutable_path().addPoly(reinterpret_cast<const SkPoint*>(points.data()),
205 points.num_elements() / 2, close);
206 resetVolatility();
207}
static const int points[]
SkPath & addPoly(const SkPoint pts[], int count, bool close)
Definition: SkPath.cpp:890

◆ addRect()

void flutter::CanvasPath::addRect ( double  left,
double  top,
double  right,
double  bottom 
)

Definition at line 175 of file path.cc.

175 {
176 mutable_path().addRect(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
177 SafeNarrow(right),
178 SafeNarrow(bottom)));
179 resetVolatility();
180}
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864

◆ addRRect()

void flutter::CanvasPath::addRRect ( const RRect rrect)

Definition at line 209 of file path.cc.

209 {
210 mutable_path().addRRect(rrect.sk_rrect);
211 resetVolatility();
212}
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1000
SkRRect rrect
Definition: SkRecords.h:232

◆ arcTo()

void flutter::CanvasPath::arcTo ( double  left,
double  top,
double  right,
double  bottom,
double  startAngle,
double  sweepAngle,
bool  forceMoveTo 
)

Definition at line 125 of file path.cc.

131 {
132 mutable_path().arcTo(
134 SafeNarrow(bottom)),
135 SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
136 SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI), forceMoveTo);
137 resetVolatility();
138}
SkPath & arcTo(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
Definition: SkPath.cpp:1220

◆ arcToPoint()

void flutter::CanvasPath::arcToPoint ( double  arcEndX,
double  arcEndY,
double  radiusX,
double  radiusY,
double  xAxisRotation,
bool  isLargeArc,
bool  isClockwiseDirection 
)

Definition at line 140 of file path.cc.

146 {
147 const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
148 : SkPath::ArcSize::kSmall_ArcSize;
149 const auto direction =
150 isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
151
152 mutable_path().arcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
153 SafeNarrow(xAxisRotation), arcSize, direction,
154 SafeNarrow(arcEndX), SafeNarrow(arcEndY));
155 resetVolatility();
156}

◆ clone()

void flutter::CanvasPath::clone ( Dart_Handle  path_handle)

Definition at line 325 of file path.cc.

325 {
326 fml::RefPtr<CanvasPath> path = Create(path_handle);
327 // per Skia docs, this will create a fast copy
328 // data is shared until the source path or dest path are mutated
329 path->mutable_path() = this->path();
330}
static fml::RefPtr< CanvasPath > Create(Dart_Handle wrapper)
Definition: path.h:31

◆ close()

void flutter::CanvasPath::close ( )

Definition at line 277 of file path.cc.

277 {
278 mutable_path().close();
279 resetVolatility();
280}
SkPath & close()
Definition: SkPath.cpp:823

◆ conicTo()

void flutter::CanvasPath::conicTo ( double  x1,
double  y1,
double  x2,
double  y2,
double  w 
)

Definition at line 109 of file path.cc.

109 {
110 mutable_path().conicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
111 SafeNarrow(y2), SafeNarrow(w));
112 resetVolatility();
113}
SkPath & conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w)
Definition: SkPath.cpp:766
SkScalar w

◆ contains()

bool flutter::CanvasPath::contains ( double  x,
double  y 
)

Definition at line 287 of file path.cc.

287 {
288 return path().contains(SafeNarrow(x), SafeNarrow(y));
289}
bool contains(SkScalar x, SkScalar y) const
Definition: SkPath.cpp:3118
double y
double x

◆ Create()

static fml::RefPtr< CanvasPath > flutter::CanvasPath::Create ( Dart_Handle  wrapper)
inlinestatic

Definition at line 31 of file path.h.

31 {
33 auto res = fml::MakeRefCounted<CanvasPath>();
34 res->AssociateWithDartWrapper(wrapper);
35 return res;
36 }
static void ThrowIfUIOperationsProhibited()

◆ CreateFrom()

static void flutter::CanvasPath::CreateFrom ( Dart_Handle  path_handle,
const SkPath src 
)
inlinestatic

Definition at line 25 of file path.h.

25 {
26 auto path = fml::MakeRefCounted<CanvasPath>();
27 path->AssociateWithDartWrapper(path_handle);
28 path->tracked_path_->path = src;
29 }

◆ cubicTo()

void flutter::CanvasPath::cubicTo ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)

Definition at line 87 of file path.cc.

92 {
93 mutable_path().cubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
94 SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
95 resetVolatility();
96}
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition: SkPath.cpp:799

◆ extendWithPath()

void flutter::CanvasPath::extendWithPath ( CanvasPath path,
double  dx,
double  dy 
)

Definition at line 245 of file path.cc.

245 {
246 if (!path) {
248 ToDart("Path.extendWithPath called with non-genuine Path."));
249 return;
250 }
251 mutable_path().addPath(path->path(), SafeNarrow(dx), SafeNarrow(dy),
253 resetVolatility();
254}
@ kExtend_AddPathMode
Definition: SkPath.h:1293

◆ extendWithPathAndMatrix()

void flutter::CanvasPath::extendWithPathAndMatrix ( CanvasPath path,
double  dx,
double  dy,
Dart_Handle  matrix4_handle 
)

Definition at line 256 of file path.cc.

259 {
260 tonic::Float64List matrix4(matrix4_handle);
261
262 if (!path) {
263 matrix4.Release();
265 ToDart("Path.addPathWithMatrix called with non-genuine Path."));
266 return;
267 }
268
269 SkMatrix matrix = ToSkMatrix(matrix4);
270 matrix4.Release();
271 matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
272 matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
273 mutable_path().addPath(path->path(), matrix, SkPath::kExtend_AddPathMode);
274 resetVolatility();
275}

◆ getBounds()

tonic::Float32List flutter::CanvasPath::getBounds ( )

Definition at line 308 of file path.cc.

308 {
309 tonic::Float32List rect(Dart_NewTypedData(Dart_TypedData_kFloat32, 4));
310 const SkRect& bounds = path().getBounds();
311 rect[0] = bounds.left();
312 rect[1] = bounds.top();
313 rect[2] = bounds.right();
314 rect[3] = bounds.bottom();
315 return rect;
316}
const SkRect & getBounds() const
Definition: SkPath.cpp:430
@ Dart_TypedData_kFloat32
Definition: dart_api.h:2623
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ getFillType()

int flutter::CanvasPath::getFillType ( )

Definition at line 43 of file path.cc.

43 {
44 return static_cast<int>(path().getFillType());
45}
SkPathFillType getFillType() const
Definition: SkPath.h:230

◆ lineTo()

void flutter::CanvasPath::lineTo ( double  x,
double  y 
)

Definition at line 62 of file path.cc.

62 {
63 mutable_path().lineTo(SafeNarrow(x), SafeNarrow(y));
64 resetVolatility();
65}
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728

◆ moveTo()

void flutter::CanvasPath::moveTo ( double  x,
double  y 
)

Definition at line 52 of file path.cc.

52 {
53 mutable_path().moveTo(SafeNarrow(x), SafeNarrow(y));
54 resetVolatility();
55}
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688

◆ op()

bool flutter::CanvasPath::op ( CanvasPath path1,
CanvasPath path2,
int  operation 
)

Definition at line 318 of file path.cc.

318 {
319 bool result = Op(path1->path(), path2->path(),
320 static_cast<SkPathOp>(operation), &tracked_path_->path);
321 resetVolatility();
322 return result;
323}
static SkPath path1()
static SkPath path2()
static void operation(T operation, uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint8_t s, uint32_t t)
Definition: SkMD5.cpp:144
SkPathOp
Definition: SkPathOps.h:22
GAsyncResult * result
void Op(SkPath *one, SkPath *two, SkPathOp op)
Definition: path_ops.cc:44

◆ path()

const SkPath & flutter::CanvasPath::path ( ) const
inline

Definition at line 117 of file path.h.

117{ return tracked_path_->path; }

◆ quadraticBezierTo()

void flutter::CanvasPath::quadraticBezierTo ( double  x1,
double  y1,
double  x2,
double  y2 
)

Definition at line 72 of file path.cc.

72 {
73 mutable_path().quadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
74 SafeNarrow(y2));
75 resetVolatility();
76}
SkPath & quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
Definition: SkPath.cpp:746

◆ relativeArcToPoint()

void flutter::CanvasPath::relativeArcToPoint ( double  arcEndDeltaX,
double  arcEndDeltaY,
double  radiusX,
double  radiusY,
double  xAxisRotation,
bool  isLargeArc,
bool  isClockwiseDirection 
)

Definition at line 158 of file path.cc.

164 {
165 const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
166 : SkPath::ArcSize::kSmall_ArcSize;
167 const auto direction =
168 isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
169 mutable_path().rArcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
170 SafeNarrow(xAxisRotation), arcSize, direction,
171 SafeNarrow(arcEndDeltaX), SafeNarrow(arcEndDeltaY));
172 resetVolatility();
173}
SkPath & rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, SkPathDirection sweep, SkScalar dx, SkScalar dy)
Definition: SkPath.cpp:1431

◆ relativeConicTo()

void flutter::CanvasPath::relativeConicTo ( double  x1,
double  y1,
double  x2,
double  y2,
double  w 
)

Definition at line 115 of file path.cc.

119 {
120 mutable_path().rConicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
121 SafeNarrow(y2), SafeNarrow(w));
122 resetVolatility();
123}
SkPath & rConicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar w)
Definition: SkPath.cpp:791

◆ relativeCubicTo()

void flutter::CanvasPath::relativeCubicTo ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)

Definition at line 98 of file path.cc.

103 {
104 mutable_path().rCubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
105 SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
106 resetVolatility();
107}
SkPath & rCubicTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2, SkScalar dx3, SkScalar dy3)
Definition: SkPath.cpp:814

◆ relativeLineTo()

void flutter::CanvasPath::relativeLineTo ( double  x,
double  y 
)

Definition at line 67 of file path.cc.

67 {
68 mutable_path().rLineTo(SafeNarrow(x), SafeNarrow(y));
69 resetVolatility();
70}
SkPath & rLineTo(SkScalar dx, SkScalar dy)
Definition: SkPath.cpp:739

◆ relativeMoveTo()

void flutter::CanvasPath::relativeMoveTo ( double  x,
double  y 
)

Definition at line 57 of file path.cc.

57 {
58 mutable_path().rMoveTo(SafeNarrow(x), SafeNarrow(y));
59 resetVolatility();
60}
SkPath & rMoveTo(SkScalar dx, SkScalar dy)
Definition: SkPath.cpp:701

◆ relativeQuadraticBezierTo()

void flutter::CanvasPath::relativeQuadraticBezierTo ( double  x1,
double  y1,
double  x2,
double  y2 
)

Definition at line 78 of file path.cc.

81 {
82 mutable_path().rQuadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
83 SafeNarrow(y2));
84 resetVolatility();
85}
SkPath & rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2)
Definition: SkPath.cpp:759

◆ reset()

void flutter::CanvasPath::reset ( )

Definition at line 282 of file path.cc.

282 {
283 mutable_path().reset();
284 resetVolatility();
285}
SkPath & reset()
Definition: SkPath.cpp:370

◆ setFillType()

void flutter::CanvasPath::setFillType ( int  fill_type)

Definition at line 47 of file path.cc.

47 {
48 mutable_path().setFillType(static_cast<SkPathFillType>(fill_type));
49 resetVolatility();
50}
SkPathFillType
Definition: SkPathTypes.h:11
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235

◆ shift()

void flutter::CanvasPath::shift ( Dart_Handle  path_handle,
double  dx,
double  dy 
)

Definition at line 291 of file path.cc.

291 {
292 fml::RefPtr<CanvasPath> path = Create(path_handle);
293 auto& other_mutable_path = path->mutable_path();
294 mutable_path().offset(SafeNarrow(dx), SafeNarrow(dy), &other_mutable_path);
295 resetVolatility();
296}
void offset(SkScalar dx, SkScalar dy, SkPath *dst) const
Definition: SkPath.cpp:1691

◆ transform()

void flutter::CanvasPath::transform ( Dart_Handle  path_handle,
Dart_Handle  matrix4_handle 
)

Definition at line 298 of file path.cc.

299 {
300 tonic::Float64List matrix4(matrix4_handle);
301 auto sk_matrix = ToSkMatrix(matrix4);
302 matrix4.Release();
303 fml::RefPtr<CanvasPath> path = Create(path_handle);
304 auto& other_mutable_path = path->mutable_path();
305 mutable_path().transform(sk_matrix, &other_mutable_path);
306}
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkPath.cpp:1711
SkMatrix sk_matrix

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