Flutter Engine
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 (float x, float y)
 
void relativeMoveTo (float x, float y)
 
void lineTo (float x, float y)
 
void relativeLineTo (float x, float y)
 
void quadraticBezierTo (float x1, float y1, float x2, float y2)
 
void relativeQuadraticBezierTo (float x1, float y1, float x2, float y2)
 
void cubicTo (float x1, float y1, float x2, float y2, float x3, float y3)
 
void relativeCubicTo (float x1, float y1, float x2, float y2, float x3, float y3)
 
void conicTo (float x1, float y1, float x2, float y2, float w)
 
void relativeConicTo (float x1, float y1, float x2, float y2, float w)
 
void arcTo (float left, float top, float right, float bottom, float startAngle, float sweepAngle, bool forceMoveTo)
 
void arcToPoint (float arcEndX, float arcEndY, float radiusX, float radiusY, float xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
 
void relativeArcToPoint (float arcEndDeltaX, float arcEndDeltaY, float radiusX, float radiusY, float xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
 
void addRect (float left, float top, float right, float bottom)
 
void addOval (float left, float top, float right, float bottom)
 
void addArc (float left, float top, float right, float bottom, float startAngle, float 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, tonic::Float64List &matrix4)
 
void extendWithPath (CanvasPath *path, double dx, double dy)
 
void extendWithPathAndMatrix (CanvasPath *path, double dx, double dy, tonic::Float64List &matrix4)
 
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, tonic::Float64List &matrix4)
 
tonic::Float32List getBounds ()
 
bool op (CanvasPath *path1, CanvasPath *path2, int operation)
 
void clone (Dart_Handle path_handle)
 
const SkPath & path () const
 
size_t GetAllocationSize () const override
 
- 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
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static fml::RefPtr< CanvasPathCreateNew (Dart_Handle path_handle)
 
static fml::RefPtr< CanvasPathCreate (Dart_Handle path_handle)
 
static fml::RefPtr< CanvasPathCreateFrom (Dart_Handle path_handle, const SkPath &src)
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kWrapperInfoIndex,
  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 20 of file path.h.

Constructor & Destructor Documentation

◆ ~CanvasPath()

flutter::CanvasPath::~CanvasPath ( )
override

Definition at line 72 of file path.cc.

72 {}

Member Function Documentation

◆ addArc()

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

Definition at line 190 of file path.cc.

195  {
196  path_.addArc(SkRect::MakeLTRB(left, top, right, bottom),
197  startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI);
198 }

◆ addOval()

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

Definition at line 186 of file path.cc.

186  {
187  path_.addOval(SkRect::MakeLTRB(left, top, right, bottom));
188 }

◆ addPath()

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

Definition at line 209 of file path.cc.

References path(), and tonic::ToDart().

209  {
210  if (!path) {
211  Dart_ThrowException(ToDart("Path.addPath called with non-genuine Path."));
212  return;
213  }
214  path_.addPath(path->path(), dx, dy, SkPath::kAppend_AddPathMode);
215 }
const SkPath & path() const
Definition: path.h:111
Dart_Handle ToDart(const T &object)

◆ addPathWithMatrix()

void flutter::CanvasPath::addPathWithMatrix ( CanvasPath path,
double  dx,
double  dy,
tonic::Float64List &  matrix4 
)

Definition at line 217 of file path.cc.

References path(), tonic::ToDart(), and flutter::ToSkMatrix().

220  {
221  if (!path) {
222  Dart_ThrowException(
223  ToDart("Path.addPathWithMatrix called with non-genuine Path."));
224  return;
225  }
226 
227  SkMatrix matrix = ToSkMatrix(matrix4);
228  matrix.setTranslateX(matrix.getTranslateX() + dx);
229  matrix.setTranslateY(matrix.getTranslateY() + dy);
230  path_.addPath(path->path(), matrix, SkPath::kAppend_AddPathMode);
231  matrix4.Release();
232 }
const SkPath & path() const
Definition: path.h:111
Dart_Handle ToDart(const T &object)
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

◆ addPolygon()

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

Definition at line 200 of file path.cc.

References close().

200  {
201  path_.addPoly(reinterpret_cast<const SkPoint*>(points.data()),
202  points.num_elements() / 2, close);
203 }

◆ addRect()

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

Definition at line 182 of file path.cc.

182  {
183  path_.addRect(SkRect::MakeLTRB(left, top, right, bottom));
184 }

◆ addRRect()

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

Definition at line 205 of file path.cc.

References flutter::RRect::sk_rrect.

205  {
206  path_.addRRect(rrect.sk_rrect);
207 }

◆ arcTo()

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

Definition at line 139 of file path.cc.

145  {
146  path_.arcTo(SkRect::MakeLTRB(left, top, right, bottom),
147  startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI,
148  forceMoveTo);
149 }

◆ arcToPoint()

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

Definition at line 151 of file path.cc.

157  {
158  const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
159  : SkPath::ArcSize::kSmall_ArcSize;
160  const auto direction =
161  isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
162 
163  path_.arcTo(radiusX, radiusY, xAxisRotation, arcSize, direction, arcEndX,
164  arcEndY);
165 }

◆ clone()

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

Definition at line 299 of file path.cc.

References Create(), and path().

299  {
301  // per Skia docs, this will create a fast copy
302  // data is shared until the source path or dest path are mutated
303  path->path_ = path_;
304 }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:30
const SkPath & path() const
Definition: path.h:111

◆ close()

void flutter::CanvasPath::close ( )

Definition at line 260 of file path.cc.

Referenced by addPolygon().

260  {
261  path_.close();
262 }

◆ conicTo()

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

Definition at line 127 of file path.cc.

127  {
128  path_.conicTo(x1, y1, x2, y2, w);
129 }

◆ contains()

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

Definition at line 268 of file path.cc.

268  {
269  return path_.contains(x, y);
270 }

◆ Create()

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

Definition at line 30 of file path.h.

References flutter::path.

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

30  {
31  auto path = fml::MakeRefCounted<CanvasPath>();
32  path->AssociateWithDartWrapper(path_handle);
33  return path;
34  }
const SkPath & path() const
Definition: path.h:111

◆ CreateFrom()

static fml::RefPtr<CanvasPath> flutter::CanvasPath::CreateFrom ( Dart_Handle  path_handle,
const SkPath &  src 
)
inlinestatic

Definition at line 36 of file path.h.

References flutter::path, and flutter::transform.

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

37  {
39  path->path_ = src;
40  return path;
41  }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:30
const SkPath & path() const
Definition: path.h:111

◆ CreateNew()

static fml::RefPtr<CanvasPath> flutter::CanvasPath::CreateNew ( Dart_Handle  path_handle)
inlinestatic

Definition at line 26 of file path.h.

Referenced by flutter::Path_constructor().

26  {
27  return fml::MakeRefCounted<CanvasPath>();
28  }

◆ cubicTo()

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

Definition at line 109 of file path.cc.

114  {
115  path_.cubicTo(x1, y1, x2, y2, x3, y3);
116 }

◆ extendWithPath()

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

Definition at line 234 of file path.cc.

References path(), and tonic::ToDart().

234  {
235  if (!path) {
236  Dart_ThrowException(
237  ToDart("Path.extendWithPath called with non-genuine Path."));
238  return;
239  }
240  path_.addPath(path->path(), dx, dy, SkPath::kExtend_AddPathMode);
241 }
const SkPath & path() const
Definition: path.h:111
Dart_Handle ToDart(const T &object)

◆ extendWithPathAndMatrix()

void flutter::CanvasPath::extendWithPathAndMatrix ( CanvasPath path,
double  dx,
double  dy,
tonic::Float64List &  matrix4 
)

Definition at line 243 of file path.cc.

References path(), tonic::ToDart(), and flutter::ToSkMatrix().

246  {
247  if (!path) {
248  Dart_ThrowException(
249  ToDart("Path.addPathWithMatrix called with non-genuine Path."));
250  return;
251  }
252 
253  SkMatrix matrix = ToSkMatrix(matrix4);
254  matrix.setTranslateX(matrix.getTranslateX() + dx);
255  matrix.setTranslateY(matrix.getTranslateY() + dy);
256  path_.addPath(path->path(), matrix, SkPath::kExtend_AddPathMode);
257  matrix4.Release();
258 }
const SkPath & path() const
Definition: path.h:111
Dart_Handle ToDart(const T &object)
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

◆ GetAllocationSize()

size_t flutter::CanvasPath::GetAllocationSize ( ) const
overridevirtual

Reimplemented from tonic::DartWrappable.

Definition at line 309 of file path.cc.

309  {
310  return sizeof(CanvasPath) + path_.approximateBytesUsed();
311 }

◆ getBounds()

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

Definition at line 284 of file path.cc.

Referenced by flutter::PhysicalShapeLayer::DrawShadow().

284  {
285  tonic::Float32List rect(Dart_NewTypedData(Dart_TypedData_kFloat32, 4));
286  const SkRect& bounds = path_.getBounds();
287  rect[0] = bounds.left();
288  rect[1] = bounds.top();
289  rect[2] = bounds.right();
290  rect[3] = bounds.bottom();
291  return rect;
292 }

◆ getFillType()

int flutter::CanvasPath::getFillType ( )

Definition at line 74 of file path.cc.

74  {
75  return static_cast<int>(path_.getFillType());
76 }

◆ lineTo()

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

Definition at line 90 of file path.cc.

90  {
91  path_.lineTo(x, y);
92 }

◆ moveTo()

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

Definition at line 82 of file path.cc.

82  {
83  path_.moveTo(x, y);
84 }

◆ op()

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

Definition at line 294 of file path.cc.

References path().

294  {
295  return Op(path1->path(), path2->path(), static_cast<SkPathOp>(operation),
296  &path_);
297 }

◆ path()

◆ quadraticBezierTo()

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

Definition at line 98 of file path.cc.

98  {
99  path_.quadTo(x1, y1, x2, y2);
100 }

◆ RegisterNatives()

void flutter::CanvasPath::RegisterNatives ( tonic::DartLibraryNatives natives)
static

Definition at line 65 of file path.cc.

References DART_REGISTER_NATIVE, FOR_EACH_BINDING, and flutter::Path_constructor().

Referenced by flutter::DartUI::InitForGlobal().

65  {
66  natives->Register({{"Path_constructor", Path_constructor, 1, true},
68 }
static void Path_constructor(Dart_NativeArguments args)
Definition: path.cc:22
#define FOR_EACH_BINDING(V)
Definition: path.cc:29
void Register(std::initializer_list< Entry > entries)
#define DART_REGISTER_NATIVE(CLASS, METHOD)

◆ relativeArcToPoint()

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

Definition at line 167 of file path.cc.

173  {
174  const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
175  : SkPath::ArcSize::kSmall_ArcSize;
176  const auto direction =
177  isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
178  path_.rArcTo(radiusX, radiusY, xAxisRotation, arcSize, direction,
179  arcEndDeltaX, arcEndDeltaY);
180 }

◆ relativeConicTo()

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

Definition at line 131 of file path.cc.

135  {
136  path_.rConicTo(x1, y1, x2, y2, w);
137 }

◆ relativeCubicTo()

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

Definition at line 118 of file path.cc.

123  {
124  path_.rCubicTo(x1, y1, x2, y2, x3, y3);
125 }

◆ relativeLineTo()

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

Definition at line 94 of file path.cc.

94  {
95  path_.rLineTo(x, y);
96 }

◆ relativeMoveTo()

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

Definition at line 86 of file path.cc.

86  {
87  path_.rMoveTo(x, y);
88 }

◆ relativeQuadraticBezierTo()

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

Definition at line 102 of file path.cc.

105  {
106  path_.rQuadTo(x1, y1, x2, y2);
107 }

◆ reset()

void flutter::CanvasPath::reset ( )

Definition at line 264 of file path.cc.

264  {
265  path_.reset();
266 }

◆ setFillType()

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

Definition at line 78 of file path.cc.

78  {
79  path_.setFillType(static_cast<SkPathFillType>(fill_type));
80 }

◆ shift()

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

Definition at line 272 of file path.cc.

References Create(), and path().

272  {
274  path_.offset(dx, dy, &path->path_);
275 }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:30
const SkPath & path() const
Definition: path.h:111

◆ transform()

void flutter::CanvasPath::transform ( Dart_Handle  path_handle,
tonic::Float64List &  matrix4 
)

Definition at line 277 of file path.cc.

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

278  {
280  path_.transform(ToSkMatrix(matrix4), &path->path_);
281  matrix4.Release();
282 }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:30
const SkPath & path() const
Definition: path.h:111
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

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