Flutter Engine
The Flutter Engine
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
8#include "flutter/lib/ui/dart_wrapper.h"
9#include "flutter/lib/ui/painting/rrect.h"
10#include "flutter/lib/ui/ui_dart_state.h"
11#include "flutter/lib/ui/volatile_path_tracker.h"
15
16namespace flutter {
17
18class CanvasPath : public RefCountedDartWrappable<CanvasPath> {
19 DEFINE_WRAPPERTYPEINFO();
20 FML_FRIEND_MAKE_REF_COUNTED(CanvasPath);
21
22 public:
23 ~CanvasPath() override;
24
25 static void CreateFrom(Dart_Handle path_handle, const SkPath& src) {
26 auto path = fml::MakeRefCounted<CanvasPath>();
27 path->AssociateWithDartWrapper(path_handle);
28 path->tracked_path_->path = src;
29 }
30
33 auto res = fml::MakeRefCounted<CanvasPath>();
34 res->AssociateWithDartWrapper(wrapper);
35 return res;
36 }
37
38 int getFillType();
39 void setFillType(int fill_type);
40
41 void moveTo(double x, double y);
42 void relativeMoveTo(double x, double y);
43 void lineTo(double x, double y);
44 void relativeLineTo(double x, double y);
45 void quadraticBezierTo(double x1, double y1, double x2, double y2);
46 void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2);
47 void cubicTo(double x1,
48 double y1,
49 double x2,
50 double y2,
51 double x3,
52 double y3);
53 void relativeCubicTo(double x1,
54 double y1,
55 double x2,
56 double y2,
57 double x3,
58 double y3);
59 void conicTo(double x1, double y1, double x2, double y2, double w);
60 void relativeConicTo(double x1, double y1, double x2, double y2, double w);
61 void arcTo(double left,
62 double top,
63 double right,
64 double bottom,
65 double startAngle,
66 double sweepAngle,
67 bool forceMoveTo);
68 void arcToPoint(double arcEndX,
69 double arcEndY,
70 double radiusX,
71 double radiusY,
72 double xAxisRotation,
73 bool isLargeArc,
74 bool isClockwiseDirection);
75 void relativeArcToPoint(double arcEndDeltaX,
76 double arcEndDeltaY,
77 double radiusX,
78 double radiusY,
79 double xAxisRotation,
80 bool isLargeArc,
81 bool isClockwiseDirection);
82 void addRect(double left, double top, double right, double bottom);
83 void addOval(double left, double top, double right, double bottom);
84 void addArc(double left,
85 double top,
86 double right,
87 double bottom,
88 double startAngle,
89 double sweepAngle);
90 void addPolygon(const tonic::Float32List& points, bool close);
91 void addRRect(const RRect& rrect);
92 void addPath(CanvasPath* path, double dx, double dy);
93
95 double dx,
96 double dy,
97 Dart_Handle matrix4_handle);
98
99 void extendWithPath(CanvasPath* path, double dx, double dy);
100
102 double dx,
103 double dy,
104 Dart_Handle matrix4_handle);
105
106 void close();
107 void reset();
108 bool contains(double x, double y);
109 void shift(Dart_Handle path_handle, double dx, double dy);
110
111 void transform(Dart_Handle path_handle, Dart_Handle matrix4_handle);
112
113 tonic::Float32List getBounds();
115 void clone(Dart_Handle path_handle);
116
117 const SkPath& path() const { return tracked_path_->path; }
118
119 private:
120 CanvasPath();
121
122 std::shared_ptr<VolatilePathTracker> path_tracker_;
123 std::shared_ptr<VolatilePathTracker::TrackedPath> tracked_path_;
124
125 // Must be called whenever the path is created or mutated.
126 void resetVolatility();
127
128 SkPath& mutable_path() { return tracked_path_->path; }
129};
130
131} // namespace flutter
132
133#endif // FLUTTER_LIB_UI_PAINTING_PATH_H_
static const int points[]
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
Definition: SkPath.h:59
static void CreateFrom(Dart_Handle path_handle, const SkPath &src)
Definition: path.h:25
void moveTo(double x, double y)
Definition: path.cc:52
tonic::Float32List getBounds()
Definition: path.cc:308
void shift(Dart_Handle path_handle, double dx, double dy)
Definition: path.cc:291
static fml::RefPtr< CanvasPath > Create(Dart_Handle wrapper)
Definition: path.h:31
void relativeLineTo(double x, double y)
Definition: path.cc:67
void clone(Dart_Handle path_handle)
Definition: path.cc:325
void addRect(double left, double top, double right, double bottom)
Definition: path.cc:175
void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2)
Definition: path.cc:78
void relativeArcToPoint(double arcEndDeltaX, double arcEndDeltaY, double radiusX, double radiusY, double xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
Definition: path.cc:158
void conicTo(double x1, double y1, double x2, double y2, double w)
Definition: path.cc:109
void addPathWithMatrix(CanvasPath *path, double dx, double dy, Dart_Handle matrix4_handle)
Definition: path.cc:224
bool contains(double x, double y)
Definition: path.cc:287
void addArc(double left, double top, double right, double bottom, double startAngle, double sweepAngle)
Definition: path.cc:189
void relativeConicTo(double x1, double y1, double x2, double y2, double w)
Definition: path.cc:115
int getFillType()
Definition: path.cc:43
void relativeMoveTo(double x, double y)
Definition: path.cc:57
void lineTo(double x, double y)
Definition: path.cc:62
void cubicTo(double x1, double y1, double x2, double y2, double x3, double y3)
Definition: path.cc:87
void quadraticBezierTo(double x1, double y1, double x2, double y2)
Definition: path.cc:72
bool op(CanvasPath *path1, CanvasPath *path2, int operation)
Definition: path.cc:318
void arcToPoint(double arcEndX, double arcEndY, double radiusX, double radiusY, double xAxisRotation, bool isLargeArc, bool isClockwiseDirection)
Definition: path.cc:140
void extendWithPath(CanvasPath *path, double dx, double dy)
Definition: path.cc:245
void relativeCubicTo(double x1, double y1, double x2, double y2, double x3, double y3)
Definition: path.cc:98
void addPolygon(const tonic::Float32List &points, bool close)
Definition: path.cc:203
void addPath(CanvasPath *path, double dx, double dy)
Definition: path.cc:214
const SkPath & path() const
Definition: path.h:117
void extendWithPathAndMatrix(CanvasPath *path, double dx, double dy, Dart_Handle matrix4_handle)
Definition: path.cc:256
void addRRect(const RRect &rrect)
Definition: path.cc:209
~CanvasPath() override
void setFillType(int fill_type)
Definition: path.cc:47
void transform(Dart_Handle path_handle, Dart_Handle matrix4_handle)
Definition: path.cc:298
void addOval(double left, double top, double right, double bottom)
Definition: path.cc:182
void arcTo(double left, double top, double right, double bottom, double startAngle, double sweepAngle, bool forceMoveTo)
Definition: path.cc:125
static void ThrowIfUIOperationsProhibited()
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
double y
double x
SkRRect rrect
Definition: SkRecords.h:232
SkScalar startAngle
Definition: SkRecords.h:250
SkScalar sweepAngle
Definition: SkRecords.h:251
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
SkScalar w