Flutter Engine
 
Loading...
Searching...
No Matches
canvas.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_CANVAS_H_
6#define FLUTTER_LIB_UI_PAINTING_CANVAS_H_
7
18
19namespace flutter {
20class CanvasImage;
21
25
26 public:
27 static void Create(Dart_Handle wrapper,
28 PictureRecorder* recorder,
29 double left,
30 double top,
31 double right,
32 double bottom);
33
34 ~Canvas() override;
35
36 void save();
37 void saveLayerWithoutBounds(Dart_Handle paint_objects,
38 Dart_Handle paint_data);
39
40 void saveLayer(double left,
41 double top,
42 double right,
43 double bottom,
44 Dart_Handle paint_objects,
45 Dart_Handle paint_data);
46
47 void restore();
48 int getSaveCount();
49 void restoreToCount(int count);
50
51 void translate(double dx, double dy);
52 void scale(double sx, double sy);
53 void rotate(double radians);
54 void skew(double sx, double sy);
55 void transform(const tonic::Float64List& matrix4);
56 void getTransform(Dart_Handle matrix4_handle);
57
58 void clipRect(double left,
59 double top,
60 double right,
61 double bottom,
62 DlClipOp clipOp,
63 bool doAntiAlias = true);
64 void clipRRect(const RRect& rrect, bool doAntiAlias = true);
65 void clipRSuperellipse(const RSuperellipse* rse, bool doAntiAlias = true);
66 void clipPath(const CanvasPath* path, bool doAntiAlias = true);
67 void getDestinationClipBounds(Dart_Handle rect_handle);
68 void getLocalClipBounds(Dart_Handle rect_handle);
69
70 void drawColor(uint32_t color, DlBlendMode blend_mode);
71
72 void drawLine(double x1,
73 double y1,
74 double x2,
75 double y2,
76 Dart_Handle paint_objects,
77 Dart_Handle paint_data);
78
79 void drawPaint(Dart_Handle paint_objects, Dart_Handle paint_data);
80
81 void drawRect(double left,
82 double top,
83 double right,
84 double bottom,
85 Dart_Handle paint_objects,
86 Dart_Handle paint_data);
87
88 void drawRRect(const RRect& rrect,
89 Dart_Handle paint_objects,
90 Dart_Handle paint_data);
91
92 void drawDRRect(const RRect& outer,
93 const RRect& inner,
94 Dart_Handle paint_objects,
95 Dart_Handle paint_data);
96
97 void drawRSuperellipse(const RSuperellipse* rse,
98 Dart_Handle paint_objects,
99 Dart_Handle paint_data);
100
101 void drawOval(double left,
102 double top,
103 double right,
104 double bottom,
105 Dart_Handle paint_objects,
106 Dart_Handle paint_data);
107
108 void drawCircle(double x,
109 double y,
110 double radius,
111 Dart_Handle paint_objects,
112 Dart_Handle paint_data);
113
114 void drawArc(double left,
115 double top,
116 double right,
117 double bottom,
118 double startAngle,
119 double sweepAngle,
120 bool useCenter,
121 Dart_Handle paint_objects,
122 Dart_Handle paint_data);
123
124 void drawPath(const CanvasPath* path,
125 Dart_Handle paint_objects,
126 Dart_Handle paint_data);
127
128 Dart_Handle drawImage(const CanvasImage* image,
129 double x,
130 double y,
131 Dart_Handle paint_objects,
132 Dart_Handle paint_data,
133 int filterQualityIndex);
134
135 Dart_Handle drawImageRect(const CanvasImage* image,
136 double src_left,
137 double src_top,
138 double src_right,
139 double src_bottom,
140 double dst_left,
141 double dst_top,
142 double dst_right,
143 double dst_bottom,
144 Dart_Handle paint_objects,
145 Dart_Handle paint_data,
146 int filterQualityIndex);
147
148 Dart_Handle drawImageNine(const CanvasImage* image,
149 double center_left,
150 double center_top,
151 double center_right,
152 double center_bottom,
153 double dst_left,
154 double dst_top,
155 double dst_right,
156 double dst_bottom,
157 Dart_Handle paint_objects,
158 Dart_Handle paint_data,
159 int bitmapSamplingIndex);
160
161 void drawPicture(Picture* picture);
162
163 // The paint argument is first for the following functions because Paint
164 // unwraps a number of C++ objects. Once we create a view unto a
165 // Float32List, we cannot re-enter the VM to unwrap objects. That means we
166 // either need to process the paint argument first.
167
168 void drawPoints(Dart_Handle paint_objects,
169 Dart_Handle paint_data,
170 DlPointMode point_mode,
171 const tonic::Float32List& points);
172
173 void drawVertices(const Vertices* vertices,
174 DlBlendMode blend_mode,
175 Dart_Handle paint_objects,
176 Dart_Handle paint_data);
177
178 Dart_Handle drawAtlas(Dart_Handle paint_objects,
179 Dart_Handle paint_data,
180 int filterQualityIndex,
181 CanvasImage* atlas,
182 Dart_Handle transforms_handle,
183 Dart_Handle rects_handle,
184 Dart_Handle colors_handle,
185 DlBlendMode blend_mode,
186 Dart_Handle cull_rect_handle);
187
188 void drawShadow(const CanvasPath* path,
189 uint32_t color,
190 double elevation,
191 bool transparentOccluder);
192
193 void Invalidate();
194
195 DisplayListBuilder* builder() { return display_list_builder_.get(); }
196
197 private:
198 explicit Canvas(sk_sp<DisplayListBuilder> builder);
199
200 sk_sp<DisplayListBuilder> display_list_builder_;
201};
202
203} // namespace flutter
204
205#endif // FLUTTER_LIB_UI_PAINTING_CANVAS_H_
void drawLine(double x1, double y1, double x2, double y2, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:226
void drawArc(double left, double top, double right, double bottom, double startAngle, double sweepAngle, bool useCenter, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:352
void clipRSuperellipse(const RSuperellipse *rse, bool doAntiAlias=true)
Definition canvas.cc:180
void drawShadow(const CanvasPath *path, uint32_t color, double elevation, bool transparentOccluder)
Definition canvas.cc:635
void rotate(double radians)
Definition canvas.cc:124
void drawOval(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:318
static void Create(Dart_Handle wrapper, PictureRecorder *recorder, double left, double top, double right, double bottom)
Definition canvas.cc:23
void drawRect(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:260
void translate(double dx, double dy)
Definition canvas.cc:112
void drawColor(uint32_t color, DlBlendMode blend_mode)
Definition canvas.cc:220
void clipRRect(const RRect &rrect, bool doAntiAlias=true)
Definition canvas.cc:174
DisplayListBuilder * builder()
Definition canvas.h:195
void drawRRect(const RRect &rrect, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:278
void skew(double sx, double sy)
Definition canvas.cc:130
void clipPath(const CanvasPath *path, bool doAntiAlias=true)
Definition canvas.cc:187
Dart_Handle drawImage(const CanvasImage *image, double x, double y, Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex)
Definition canvas.cc:396
void save()
Definition canvas.cc:50
void restoreToCount(int count)
Definition canvas.cc:106
~Canvas() override
void drawRSuperellipse(const RSuperellipse *rse, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:305
Dart_Handle drawImageRect(const CanvasImage *image, double src_left, double src_top, double src_right, double src_bottom, double dst_left, double dst_top, double dst_right, double dst_bottom, Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex)
Definition canvas.cc:429
void drawPoints(Dart_Handle paint_objects, Dart_Handle paint_data, DlPointMode point_mode, const tonic::Float32List &points)
Definition canvas.cc:530
void drawVertices(const Vertices *vertices, DlBlendMode blend_mode, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:560
void restore()
Definition canvas.cc:92
void getTransform(Dart_Handle matrix4_handle)
Definition canvas.cc:150
void Invalidate()
Definition canvas.cc:662
void drawCircle(double x, double y, double radius, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:336
Dart_Handle drawImageNine(const CanvasImage *image, double center_left, double center_top, double center_right, double center_bottom, double dst_left, double dst_top, double dst_right, double dst_bottom, Dart_Handle paint_objects, Dart_Handle paint_data, int bitmapSamplingIndex)
Definition canvas.cc:472
void drawPicture(Picture *picture)
Definition canvas.cc:515
void saveLayerWithoutBounds(Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:56
void clipRect(double left, double top, double right, double bottom, DlClipOp clipOp, bool doAntiAlias=true)
Definition canvas.cc:161
Dart_Handle drawAtlas(Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex, CanvasImage *atlas, Dart_Handle transforms_handle, Dart_Handle rects_handle, Dart_Handle colors_handle, DlBlendMode blend_mode, Dart_Handle cull_rect_handle)
Definition canvas.cc:579
void drawDRRect(const RRect &outer, const RRect &inner, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:291
void scale(double sx, double sy)
Definition canvas.cc:118
int getSaveCount()
Definition canvas.cc:98
void getLocalClipBounds(Dart_Handle rect_handle)
Definition canvas.cc:209
void drawPaint(Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:243
void getDestinationClipBounds(Dart_Handle rect_handle)
Definition canvas.cc:198
void drawPath(const CanvasPath *path, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:378
void saveLayer(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition canvas.cc:71
#define DEFINE_WRAPPERTYPEINFO()
int32_t x
FlutterVulkanImage * image
double y
DlPointMode
Definition dl_types.h:15
BlendMode
Definition color.h:58
#define FML_FRIEND_MAKE_REF_COUNTED(T)
std::vector< Point > points