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
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< CanvasPath >
virtual void RetainDartWrappableReference () 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,
  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 21 of file path.h.

Constructor & Destructor Documentation

◆ ~CanvasPath()

flutter::CanvasPath::~CanvasPath ( )
overridedefault

Referenced by RegisterNatives().

Member Function Documentation

◆ addArc()

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

Definition at line 226 of file path.cc.

231  {
232  mutable_path().addArc(SkRect::MakeLTRB(left, top, right, bottom),
233  startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI);
234  resetVolatility();
235 }

◆ addOval()

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

Definition at line 221 of file path.cc.

221  {
222  mutable_path().addOval(SkRect::MakeLTRB(left, top, right, bottom));
223  resetVolatility();
224 }

◆ addPath()

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

Definition at line 248 of file path.cc.

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

248  {
249  if (!path) {
250  Dart_ThrowException(ToDart("Path.addPath called with non-genuine Path."));
251  return;
252  }
253  mutable_path().addPath(path->path(), dx, dy, SkPath::kAppend_AddPathMode);
254  resetVolatility();
255 }
const SkPath & path() const
Definition: path.h:112
Dart_Handle ToDart(const T &object)

◆ addPathWithMatrix()

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

Definition at line 257 of file path.cc.

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

260  {
261  if (!path) {
262  Dart_ThrowException(
263  ToDart("Path.addPathWithMatrix called with non-genuine Path."));
264  return;
265  }
266 
267  SkMatrix matrix = ToSkMatrix(matrix4);
268  matrix.setTranslateX(matrix.getTranslateX() + dx);
269  matrix.setTranslateY(matrix.getTranslateY() + dy);
270  mutable_path().addPath(path->path(), matrix, SkPath::kAppend_AddPathMode);
271  matrix4.Release();
272  resetVolatility();
273 }
const SkPath & path() const
Definition: path.h:112
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 237 of file path.cc.

References close().

237  {
238  mutable_path().addPoly(reinterpret_cast<const SkPoint*>(points.data()),
239  points.num_elements() / 2, close);
240  resetVolatility();
241 }

◆ addRect()

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

Definition at line 216 of file path.cc.

216  {
217  mutable_path().addRect(SkRect::MakeLTRB(left, top, right, bottom));
218  resetVolatility();
219 }

◆ addRRect()

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

Definition at line 243 of file path.cc.

References flutter::RRect::sk_rrect.

243  {
244  mutable_path().addRRect(rrect.sk_rrect);
245  resetVolatility();
246 }

◆ arcTo()

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

Definition at line 170 of file path.cc.

176  {
177  mutable_path().arcTo(SkRect::MakeLTRB(left, top, right, bottom),
178  startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI,
179  forceMoveTo);
180  resetVolatility();
181 }

◆ arcToPoint()

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

Definition at line 183 of file path.cc.

189  {
190  const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
191  : SkPath::ArcSize::kSmall_ArcSize;
192  const auto direction =
193  isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
194 
195  mutable_path().arcTo(radiusX, radiusY, xAxisRotation, arcSize, direction,
196  arcEndX, arcEndY);
197  resetVolatility();
198 }

◆ clone()

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

Definition at line 348 of file path.cc.

References Create(), and path().

348  {
350  // per Skia docs, this will create a fast copy
351  // data is shared until the source path or dest path are mutated
352  path->mutable_path() = this->path();
353 }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:31
const SkPath & path() const
Definition: path.h:112

◆ close()

void flutter::CanvasPath::close ( )

Definition at line 303 of file path.cc.

Referenced by addPolygon().

303  {
304  mutable_path().close();
305  resetVolatility();
306 }

◆ conicTo()

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

Definition at line 156 of file path.cc.

156  {
157  mutable_path().conicTo(x1, y1, x2, y2, w);
158  resetVolatility();
159 }

◆ contains()

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

Definition at line 313 of file path.cc.

References path().

313  {
314  return path().contains(x, y);
315 }
const SkPath & path() const
Definition: path.h:112

◆ Create()

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

Definition at line 31 of file path.h.

References flutter::path.

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

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

◆ CreateFrom()

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

Definition at line 37 of file path.h.

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

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

38  {
40  path->tracked_path_->path = src;
41  return path;
42  }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:31
const SkPath & path() const
Definition: path.h:112

◆ CreateNew()

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

Definition at line 27 of file path.h.

Referenced by flutter::Path_constructor().

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

◆ cubicTo()

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

Definition at line 136 of file path.cc.

141  {
142  mutable_path().cubicTo(x1, y1, x2, y2, x3, y3);
143  resetVolatility();
144 }

◆ extendWithPath()

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

Definition at line 275 of file path.cc.

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

275  {
276  if (!path) {
277  Dart_ThrowException(
278  ToDart("Path.extendWithPath called with non-genuine Path."));
279  return;
280  }
281  mutable_path().addPath(path->path(), dx, dy, SkPath::kExtend_AddPathMode);
282  resetVolatility();
283 }
const SkPath & path() const
Definition: path.h:112
Dart_Handle ToDart(const T &object)

◆ extendWithPathAndMatrix()

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

Definition at line 285 of file path.cc.

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

288  {
289  if (!path) {
290  Dart_ThrowException(
291  ToDart("Path.addPathWithMatrix called with non-genuine Path."));
292  return;
293  }
294 
295  SkMatrix matrix = ToSkMatrix(matrix4);
296  matrix.setTranslateX(matrix.getTranslateX() + dx);
297  matrix.setTranslateY(matrix.getTranslateY() + dy);
298  mutable_path().addPath(path->path(), matrix, SkPath::kExtend_AddPathMode);
299  matrix4.Release();
300  resetVolatility();
301 }
const SkPath & path() const
Definition: path.h:112
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 358 of file path.cc.

References path().

358  {
359  return sizeof(CanvasPath) + path().approximateBytesUsed();
360 }
const SkPath & path() const
Definition: path.h:112

◆ getBounds()

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

Definition at line 332 of file path.cc.

References path().

332  {
333  tonic::Float32List rect(Dart_NewTypedData(Dart_TypedData_kFloat32, 4));
334  const SkRect& bounds = path().getBounds();
335  rect[0] = bounds.left();
336  rect[1] = bounds.top();
337  rect[2] = bounds.right();
338  rect[3] = bounds.bottom();
339  return rect;
340 }
const SkPath & path() const
Definition: path.h:112

◆ getFillType()

int flutter::CanvasPath::getFillType ( )

Definition at line 94 of file path.cc.

References path().

94  {
95  return static_cast<int>(path().getFillType());
96 }
const SkPath & path() const
Definition: path.h:112

◆ lineTo()

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

Definition at line 113 of file path.cc.

113  {
114  mutable_path().lineTo(x, y);
115  resetVolatility();
116 }

◆ moveTo()

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

Definition at line 103 of file path.cc.

103  {
104  mutable_path().moveTo(x, y);
105  resetVolatility();
106 }

◆ op()

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

Definition at line 342 of file path.cc.

References path().

342  {
343  return Op(path1->path(), path2->path(), static_cast<SkPathOp>(operation),
344  &tracked_path_->path);
345  resetVolatility();
346 }

◆ path()

◆ quadraticBezierTo()

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

Definition at line 123 of file path.cc.

123  {
124  mutable_path().quadTo(x1, y1, x2, y2);
125  resetVolatility();
126 }

◆ RegisterNatives()

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

Definition at line 65 of file path.cc.

References flutter::UIDartState::Current(), DART_REGISTER_NATIVE, FML_DCHECK, FOR_EACH_BINDING, flutter::Path_constructor(), and ~CanvasPath().

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 200 of file path.cc.

206  {
207  const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
208  : SkPath::ArcSize::kSmall_ArcSize;
209  const auto direction =
210  isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
211  mutable_path().rArcTo(radiusX, radiusY, xAxisRotation, arcSize, direction,
212  arcEndDeltaX, arcEndDeltaY);
213  resetVolatility();
214 }

◆ relativeConicTo()

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

Definition at line 161 of file path.cc.

165  {
166  mutable_path().rConicTo(x1, y1, x2, y2, w);
167  resetVolatility();
168 }

◆ relativeCubicTo()

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

Definition at line 146 of file path.cc.

151  {
152  mutable_path().rCubicTo(x1, y1, x2, y2, x3, y3);
153  resetVolatility();
154 }

◆ relativeLineTo()

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

Definition at line 118 of file path.cc.

118  {
119  mutable_path().rLineTo(x, y);
120  resetVolatility();
121 }

◆ relativeMoveTo()

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

Definition at line 108 of file path.cc.

108  {
109  mutable_path().rMoveTo(x, y);
110  resetVolatility();
111 }

◆ relativeQuadraticBezierTo()

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

Definition at line 128 of file path.cc.

131  {
132  mutable_path().rQuadTo(x1, y1, x2, y2);
133  resetVolatility();
134 }

◆ ReleaseDartWrappableReference()

void flutter::CanvasPath::ReleaseDartWrappableReference ( ) const
overridevirtual

Reimplemented from flutter::RefCountedDartWrappable< CanvasPath >.

Definition at line 88 of file path.cc.

References FML_DCHECK, and flutter::RefCountedDartWrappable< T >::ReleaseDartWrappableReference().

Referenced by flutter::testing::TEST_F().

88  {
89  FML_DCHECK(path_tracker_);
90  path_tracker_->Erase(tracked_path_);
92 }
virtual void ReleaseDartWrappableReference() const override
Definition: dart_wrapper.h:21
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ reset()

void flutter::CanvasPath::reset ( )

Definition at line 308 of file path.cc.

308  {
309  mutable_path().reset();
310  resetVolatility();
311 }

◆ setFillType()

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

Definition at line 98 of file path.cc.

98  {
99  mutable_path().setFillType(static_cast<SkPathFillType>(fill_type));
100  resetVolatility();
101 }

◆ shift()

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

Definition at line 317 of file path.cc.

References Create(), and path().

317  {
319  auto& other_mutable_path = path->mutable_path();
320  mutable_path().offset(dx, dy, &other_mutable_path);
321  resetVolatility();
322 }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:31
const SkPath & path() const
Definition: path.h:112

◆ transform()

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

Definition at line 324 of file path.cc.

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

325  {
327  auto& other_mutable_path = path->mutable_path();
328  mutable_path().transform(ToSkMatrix(matrix4), &other_mutable_path);
329  matrix4.Release();
330 }
static fml::RefPtr< CanvasPath > Create(Dart_Handle path_handle)
Definition: path.h:31
const SkPath & path() const
Definition: path.h:112
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

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