Flutter Engine
 
Loading...
Searching...
No Matches
flutter::CanvasPath Class Reference

#include <path.h>

Inheritance diagram for flutter::CanvasPath:
flutter::RefCountedDartWrappable< CanvasPath > fml::RefCountedThreadSafe< T > 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 addRSuperellipse (const RSuperellipse *rse)
 
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 DlPathpath () 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< T >
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
 
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< T >
 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 183 of file path.cc.

188 {
189 sk_path_.addArc(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
190 SafeNarrow(right), SafeNarrow(bottom)),
191 SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
192 SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI));
193 resetVolatility();
194}
static float SafeNarrow(double value)

References flutter::SafeNarrow().

◆ addOval()

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

Definition at line 177 of file path.cc.

177 {
178 sk_path_.addOval(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
179 SafeNarrow(right), SafeNarrow(bottom)));
180 resetVolatility();
181}

References flutter::SafeNarrow().

◆ addPath()

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

Definition at line 218 of file path.cc.

218 {
219 if (!path) {
220 Dart_ThrowException(ToDart("Path.addPath called with non-genuine Path."));
221 return;
222 }
223 sk_path_.addPath(path->sk_path_, SafeNarrow(dx), SafeNarrow(dy),
224 SkPath::kAppend_AddPathMode);
225 resetVolatility();
226}
const DlPath & path() const
Definition path.cc:336
Dart_Handle ToDart(const T &object)

References path(), and flutter::SafeNarrow().

◆ addPathWithMatrix()

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

Definition at line 228 of file path.cc.

231 {
232 tonic::Float64List matrix4(matrix4_handle);
233
234 if (!path) {
235 matrix4.Release();
236 Dart_ThrowException(
237 ToDart("Path.addPathWithMatrix called with non-genuine Path."));
238 return;
239 }
240
241 SkMatrix matrix = ToSkMatrix(matrix4);
242 matrix4.Release();
243 matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
244 matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
245 sk_path_.addPath(path->sk_path_, matrix, SkPath::kAppend_AddPathMode);
246 resetVolatility();
247}
SkMatrix ToSkMatrix(const DlMatrix &matrix)

References path(), flutter::SafeNarrow(), and flutter::ToSkMatrix().

◆ addPolygon()

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

Definition at line 196 of file path.cc.

196 {
197 SkSpan<const SkPoint> ptsSpan = {
198 reinterpret_cast<const SkPoint*>(points.data()),
199 points.num_elements() / 2};
200 sk_path_.addPoly(ptsSpan, close);
201 resetVolatility();
202}
std::vector< Point > points

References close(), and points.

◆ addRect()

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

Definition at line 171 of file path.cc.

171 {
172 sk_path_.addRect(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
173 SafeNarrow(right), SafeNarrow(bottom)));
174 resetVolatility();
175}

References flutter::SafeNarrow().

◆ addRRect()

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

Definition at line 204 of file path.cc.

204 {
205 sk_path_.addRRect(ToSkRRect(rrect.rrect));
206 resetVolatility();
207}
const SkRRect ToSkRRect(const DlRoundRect &round_rect)

References flutter::RRect::rrect, and flutter::ToSkRRect().

◆ addRSuperellipse()

void flutter::CanvasPath::addRSuperellipse ( const RSuperellipse rse)

Definition at line 209 of file path.cc.

209 {
210 DlPathBuilder builder;
211 builder.AddRoundSuperellipse(DlRoundSuperellipse::MakeRectRadii(
212 rsuperellipse->bounds(), rsuperellipse->radii()));
213 sk_path_.addPath(builder.TakePath().GetSkPath(), SkPath::kAppend_AddPathMode);
214
215 resetVolatility();
216}
static RoundSuperellipse MakeRectRadii(const Rect &rect, const RoundingRadii &radii)

References flutter::DlPathBuilder::AddRoundSuperellipse(), flutter::RSuperellipse::bounds(), flutter::DlPath::GetSkPath(), impeller::RoundSuperellipse::MakeRectRadii(), flutter::RSuperellipse::radii(), and flutter::DlPathBuilder::TakePath().

◆ arcTo()

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

Definition at line 121 of file path.cc.

127 {
128 sk_path_.arcTo(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
129 SafeNarrow(right), SafeNarrow(bottom)),
130 SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
131 SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI),
132 forceMoveTo);
133 resetVolatility();
134}

References flutter::SafeNarrow().

◆ arcToPoint()

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

Definition at line 136 of file path.cc.

142 {
143 const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
144 : SkPath::ArcSize::kSmall_ArcSize;
145 const auto direction =
146 isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
147
148 sk_path_.arcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
149 SafeNarrow(xAxisRotation), arcSize, direction,
150 SafeNarrow(arcEndX), SafeNarrow(arcEndY));
151 resetVolatility();
152}

References flutter::SafeNarrow().

◆ clone()

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

Definition at line 329 of file path.cc.

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

References Create(), and path().

◆ close()

void flutter::CanvasPath::close ( )

Definition at line 281 of file path.cc.

281 {
282 sk_path_.close();
283 resetVolatility();
284}

Referenced by addPolygon().

◆ conicTo()

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

Definition at line 105 of file path.cc.

105 {
106 sk_path_.conicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
107 SafeNarrow(y2), SafeNarrow(w));
108 resetVolatility();
109}

References flutter::SafeNarrow().

◆ contains()

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

Definition at line 291 of file path.cc.

291 {
292 return sk_path_.contains(SafeNarrow(x), SafeNarrow(y));
293}
int32_t x
double y

References flutter::SafeNarrow(), x, and y.

◆ 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()

References flutter::UIDartState::ThrowIfUIOperationsProhibited().

Referenced by clone(), flutter::CanvasPathMeasure::getSegment(), shift(), and transform().

◆ 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->sk_path_ = src;
29 }

References path().

Referenced by flutter::CanvasPathMeasure::getSegment().

◆ cubicTo()

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

Definition at line 83 of file path.cc.

88 {
89 sk_path_.cubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
90 SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
91 resetVolatility();
92}

References flutter::SafeNarrow().

◆ extendWithPath()

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

Definition at line 249 of file path.cc.

249 {
250 if (!path) {
251 Dart_ThrowException(
252 ToDart("Path.extendWithPath called with non-genuine Path."));
253 return;
254 }
255 sk_path_.addPath(path->sk_path_, SafeNarrow(dx), SafeNarrow(dy),
256 SkPath::kExtend_AddPathMode);
257 resetVolatility();
258}

References path(), and flutter::SafeNarrow().

◆ extendWithPathAndMatrix()

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

Definition at line 260 of file path.cc.

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

References path(), flutter::SafeNarrow(), and flutter::ToSkMatrix().

◆ getBounds()

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

Definition at line 312 of file path.cc.

312 {
313 tonic::Float32List rect(Dart_NewTypedData(Dart_TypedData_kFloat32, 4));
314 const SkRect& bounds = sk_path_.getBounds();
315 rect[0] = bounds.left();
316 rect[1] = bounds.top();
317 rect[2] = bounds.right();
318 rect[3] = bounds.bottom();
319 return rect;
320}

◆ getFillType()

int flutter::CanvasPath::getFillType ( )

Definition at line 39 of file path.cc.

39 {
40 return static_cast<int>(sk_path_.getFillType());
41}

◆ lineTo()

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

Definition at line 58 of file path.cc.

58 {
59 sk_path_.lineTo(SafeNarrow(x), SafeNarrow(y));
60 resetVolatility();
61}

References flutter::SafeNarrow(), x, and y.

◆ moveTo()

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

Definition at line 48 of file path.cc.

48 {
49 sk_path_.moveTo(SafeNarrow(x), SafeNarrow(y));
50 resetVolatility();
51}

References flutter::SafeNarrow(), x, and y.

◆ op()

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

Definition at line 322 of file path.cc.

322 {
323 bool result = Op(path1->sk_path_, path2->sk_path_,
324 static_cast<SkPathOp>(operation), &sk_path_);
325 resetVolatility();
326 return result;
327}
void Op(SkPath *one, SkPath *two, SkPathOp op)
Definition path_ops.cc:44

References flutter::Op().

◆ path()

const DlPath & flutter::CanvasPath::path ( ) const

Definition at line 336 of file path.cc.

336 {
337 if (!dl_path_.has_value()) {
338 dl_path_.emplace(sk_path_);
339 }
340 return dl_path_.value();
341}

Referenced by addPath(), addPathWithMatrix(), clone(), CreateFrom(), extendWithPath(), extendWithPathAndMatrix(), shift(), and transform().

◆ quadraticBezierTo()

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

Definition at line 68 of file path.cc.

68 {
69 sk_path_.quadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
70 SafeNarrow(y2));
71 resetVolatility();
72}

References flutter::SafeNarrow().

◆ relativeArcToPoint()

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

Definition at line 154 of file path.cc.

160 {
161 const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
162 : SkPath::ArcSize::kSmall_ArcSize;
163 const auto direction =
164 isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
165 sk_path_.rArcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
166 SafeNarrow(xAxisRotation), arcSize, direction,
167 SafeNarrow(arcEndDeltaX), SafeNarrow(arcEndDeltaY));
168 resetVolatility();
169}

References flutter::SafeNarrow().

◆ relativeConicTo()

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

Definition at line 111 of file path.cc.

115 {
116 sk_path_.rConicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
117 SafeNarrow(y2), SafeNarrow(w));
118 resetVolatility();
119}

References flutter::SafeNarrow().

◆ relativeCubicTo()

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

Definition at line 94 of file path.cc.

99 {
100 sk_path_.rCubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
101 SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
102 resetVolatility();
103}

References flutter::SafeNarrow().

◆ relativeLineTo()

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

Definition at line 63 of file path.cc.

63 {
64 sk_path_.rLineTo(SafeNarrow(x), SafeNarrow(y));
65 resetVolatility();
66}

References flutter::SafeNarrow(), x, and y.

◆ relativeMoveTo()

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

Definition at line 53 of file path.cc.

53 {
54 sk_path_.rMoveTo(SafeNarrow(x), SafeNarrow(y));
55 resetVolatility();
56}

References flutter::SafeNarrow(), x, and y.

◆ relativeQuadraticBezierTo()

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

Definition at line 74 of file path.cc.

77 {
78 sk_path_.rQuadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
79 SafeNarrow(y2));
80 resetVolatility();
81}

References flutter::SafeNarrow().

◆ reset()

void flutter::CanvasPath::reset ( )

Definition at line 286 of file path.cc.

286 {
287 sk_path_.reset();
288 resetVolatility();
289}

Referenced by impeller::compiler::CompilerSkSL::compile().

◆ setFillType()

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

Definition at line 43 of file path.cc.

43 {
44 sk_path_.setFillType(static_cast<SkPathFillType>(fill_type));
45 resetVolatility();
46}

◆ shift()

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

Definition at line 295 of file path.cc.

295 {
296 fml::RefPtr<CanvasPath> path = Create(path_handle);
297 auto& other_mutable_path = path->sk_path_;
298 sk_path_.offset(SafeNarrow(dx), SafeNarrow(dy), &other_mutable_path);
299 resetVolatility();
300}

References Create(), path(), and flutter::SafeNarrow().

◆ transform()

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

Definition at line 302 of file path.cc.

303 {
304 tonic::Float64List matrix4(matrix4_handle);
305 auto sk_matrix = ToSkMatrix(matrix4);
306 matrix4.Release();
307 fml::RefPtr<CanvasPath> path = Create(path_handle);
308 auto& other_mutable_path = path->sk_path_;
309 sk_path_.transform(sk_matrix, &other_mutable_path);
310}
SkMatrix sk_matrix

References Create(), path(), sk_matrix, and flutter::ToSkMatrix().


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