Flutter Engine
 
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_LIB_UI_PAINTING_PATH_H_
6#define FLUTTER_LIB_UI_PAINTING_PATH_H_
7
12#include "third_party/skia/include/core/SkPath.h"
13#include "third_party/skia/include/core/SkPathBuilder.h"
14#include "third_party/skia/include/pathops/SkPathOps.h"
16
17namespace flutter {
18
19class CanvasPath : public RefCountedDartWrappable<CanvasPath> {
20 DEFINE_WRAPPERTYPEINFO();
22
23 public:
24 ~CanvasPath() override;
25
26 static void CreateFrom(Dart_Handle path_handle, const SkPath& src) {
27 auto path = fml::MakeRefCounted<CanvasPath>();
28 path->AssociateWithDartWrapper(path_handle);
29 path->sk_path_ = src;
30 }
31
32 static fml::RefPtr<CanvasPath> Create(Dart_Handle wrapper) {
34 auto res = fml::MakeRefCounted<CanvasPath>();
35 res->AssociateWithDartWrapper(wrapper);
36 return res;
37 }
38
39 int getFillType();
40 void setFillType(int fill_type);
41
42 void moveTo(double x, double y);
43 void relativeMoveTo(double x, double y);
44 void lineTo(double x, double y);
45 void relativeLineTo(double x, double y);
46 void quadraticBezierTo(double x1, double y1, double x2, double y2);
47 void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2);
48 void cubicTo(double x1,
49 double y1,
50 double x2,
51 double y2,
52 double x3,
53 double y3);
54 void relativeCubicTo(double x1,
55 double y1,
56 double x2,
57 double y2,
58 double x3,
59 double y3);
60 void conicTo(double x1, double y1, double x2, double y2, double w);
61 void relativeConicTo(double x1, double y1, double x2, double y2, double w);
62 void arcTo(double left,
63 double top,
64 double right,
65 double bottom,
66 double startAngle,
67 double sweepAngle,
68 bool forceMoveTo);
69 void arcToPoint(double arcEndX,
70 double arcEndY,
71 double radiusX,
72 double radiusY,
73 double xAxisRotation,
74 bool isLargeArc,
75 bool isClockwiseDirection);
76 void relativeArcToPoint(double arcEndDeltaX,
77 double arcEndDeltaY,
78 double radiusX,
79 double radiusY,
80 double xAxisRotation,
81 bool isLargeArc,
82 bool isClockwiseDirection);
83 void addRect(double left, double top, double right, double bottom);
84 void addOval(double left, double top, double right, double bottom);
85 void addArc(double left,
86 double top,
87 double right,
88 double bottom,
89 double startAngle,
90 double sweepAngle);
91 void addPolygon(const tonic::Float32List& points, bool close);
92 void addRRect(const RRect& rrect);
93 void addRSuperellipse(const RSuperellipse* rse);
94 void addPath(CanvasPath* path, double dx, double dy);
95
97 double dx,
98 double dy,
99 Dart_Handle matrix4_handle);
100
101 void extendWithPath(CanvasPath* path, double dx, double dy);
102
104 double dx,
105 double dy,
106 Dart_Handle matrix4_handle);
107
108 void close();
109 void reset();
110 bool contains(double x, double y);
111 void shift(Dart_Handle path_handle, double dx, double dy);
112
113 void transform(Dart_Handle path_handle, Dart_Handle matrix4_handle);
114
115 tonic::Float32List getBounds();
116 bool op(CanvasPath* path1, CanvasPath* path2, int operation);
117 void clone(Dart_Handle path_handle);
118
119 const DlPath& path() const;
120
121 private:
122 CanvasPath();
123
124 SkPathBuilder sk_path_;
125 mutable std::optional<const DlPath> dl_path_;
126
127 // Must be called whenever the path is created or mutated.
128 void resetVolatility();
129};
130
131} // namespace flutter
132
133#endif // FLUTTER_LIB_UI_PAINTING_PATH_H_
static void CreateFrom(Dart_Handle path_handle, const SkPath &src)
Definition path.h:26
void moveTo(double x, double y)
Definition path.cc:48
tonic::Float32List getBounds()
Definition path.cc:317
void shift(Dart_Handle path_handle, double dx, double dy)
Definition path.cc:299
static fml::RefPtr< CanvasPath > Create(Dart_Handle wrapper)
Definition path.h:32
const DlPath & path() const
Definition path.cc:346
void relativeLineTo(double x, double y)
Definition path.cc:63
void clone(Dart_Handle path_handle)
Definition path.cc:339
void addRect(double left, double top, double right, double bottom)
Definition path.cc:173
void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2)
Definition path.cc:74
void relativeArcToPoint(double arcEndDeltaX, double arcEndDeltaY, double radiusX, double radiusY, double xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
Definition path.cc:156
void conicTo(double x1, double y1, double x2, double y2, double w)
Definition path.cc:107
void addPathWithMatrix(CanvasPath *path, double dx, double dy, Dart_Handle matrix4_handle)
Definition path.cc:230
bool contains(double x, double y)
Definition path.cc:295
void addRSuperellipse(const RSuperellipse *rse)
Definition path.cc:211
void addArc(double left, double top, double right, double bottom, double startAngle, double sweepAngle)
Definition path.cc:185
void relativeConicTo(double x1, double y1, double x2, double y2, double w)
Definition path.cc:113
int getFillType()
Definition path.cc:39
void relativeMoveTo(double x, double y)
Definition path.cc:53
void lineTo(double x, double y)
Definition path.cc:58
void cubicTo(double x1, double y1, double x2, double y2, double x3, double y3)
Definition path.cc:83
void quadraticBezierTo(double x1, double y1, double x2, double y2)
Definition path.cc:68
bool op(CanvasPath *path1, CanvasPath *path2, int operation)
Definition path.cc:327
void arcToPoint(double arcEndX, double arcEndY, double radiusX, double radiusY, double xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
Definition path.cc:138
void extendWithPath(CanvasPath *path, double dx, double dy)
Definition path.cc:252
void relativeCubicTo(double x1, double y1, double x2, double y2, double x3, double y3)
Definition path.cc:95
void addPolygon(const tonic::Float32List &points, bool close)
Definition path.cc:198
void addPath(CanvasPath *path, double dx, double dy)
Definition path.cc:220
void extendWithPathAndMatrix(CanvasPath *path, double dx, double dy, Dart_Handle matrix4_handle)
Definition path.cc:263
void addRRect(const RRect &rrect)
Definition path.cc:206
~CanvasPath() override
void setFillType(int fill_type)
Definition path.cc:43
void addOval(double left, double top, double right, double bottom)
Definition path.cc:179
void arcTo(double left, double top, double right, double bottom, double startAngle, double sweepAngle, bool forceMoveTo)
Definition path.cc:123
static void ThrowIfUIOperationsProhibited()
int32_t x
double y
#define FML_FRIEND_MAKE_REF_COUNTED(T)
std::vector< Point > points