Flutter Engine
The Flutter Engine
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
8#include "flutter/display_list/dl_blend_mode.h"
9#include "flutter/display_list/dl_op_flags.h"
10#include "flutter/lib/ui/dart_wrapper.h"
11#include "flutter/lib/ui/painting/path.h"
12#include "flutter/lib/ui/painting/picture.h"
13#include "flutter/lib/ui/painting/picture_recorder.h"
14#include "flutter/lib/ui/painting/rrect.h"
15#include "flutter/lib/ui/painting/vertices.h"
17
18namespace flutter {
19class CanvasImage;
20
22 DEFINE_WRAPPERTYPEINFO();
23 FML_FRIEND_MAKE_REF_COUNTED(Canvas);
24
25 public:
26 static void Create(Dart_Handle wrapper,
27 PictureRecorder* recorder,
28 double left,
29 double top,
30 double right,
31 double bottom);
32
33 ~Canvas() override;
34
35 void save();
36 void saveLayerWithoutBounds(Dart_Handle paint_objects,
37 Dart_Handle paint_data);
38
39 void saveLayer(double left,
40 double top,
41 double right,
42 double bottom,
43 Dart_Handle paint_objects,
44 Dart_Handle paint_data);
45
46 void restore();
47 int getSaveCount();
48 void restoreToCount(int count);
49
50 void translate(double dx, double dy);
51 void scale(double sx, double sy);
52 void rotate(double radians);
53 void skew(double sx, double sy);
54 void transform(const tonic::Float64List& matrix4);
55 void getTransform(Dart_Handle matrix4_handle);
56
57 void clipRect(double left,
58 double top,
59 double right,
60 double bottom,
61 DlCanvas::ClipOp clipOp,
62 bool doAntiAlias = true);
63 void clipRRect(const RRect& rrect, bool doAntiAlias = true);
64 void clipPath(const CanvasPath* path, bool doAntiAlias = true);
65 void getDestinationClipBounds(Dart_Handle rect_handle);
66 void getLocalClipBounds(Dart_Handle rect_handle);
67
68 void drawColor(SkColor color, DlBlendMode blend_mode);
69
70 void drawLine(double x1,
71 double y1,
72 double x2,
73 double y2,
74 Dart_Handle paint_objects,
75 Dart_Handle paint_data);
76
77 void drawPaint(Dart_Handle paint_objects, Dart_Handle paint_data);
78
79 void drawRect(double left,
80 double top,
81 double right,
82 double bottom,
83 Dart_Handle paint_objects,
84 Dart_Handle paint_data);
85
86 void drawRRect(const RRect& rrect,
87 Dart_Handle paint_objects,
88 Dart_Handle paint_data);
89
90 void drawDRRect(const RRect& outer,
91 const RRect& inner,
92 Dart_Handle paint_objects,
93 Dart_Handle paint_data);
94
95 void drawOval(double left,
96 double top,
97 double right,
98 double bottom,
99 Dart_Handle paint_objects,
100 Dart_Handle paint_data);
101
102 void drawCircle(double x,
103 double y,
104 double radius,
105 Dart_Handle paint_objects,
106 Dart_Handle paint_data);
107
108 void drawArc(double left,
109 double top,
110 double right,
111 double bottom,
112 double startAngle,
113 double sweepAngle,
114 bool useCenter,
115 Dart_Handle paint_objects,
116 Dart_Handle paint_data);
117
118 void drawPath(const CanvasPath* path,
119 Dart_Handle paint_objects,
120 Dart_Handle paint_data);
121
123 double x,
124 double y,
125 Dart_Handle paint_objects,
126 Dart_Handle paint_data,
127 int filterQualityIndex);
128
130 double src_left,
131 double src_top,
132 double src_right,
133 double src_bottom,
134 double dst_left,
135 double dst_top,
136 double dst_right,
137 double dst_bottom,
138 Dart_Handle paint_objects,
139 Dart_Handle paint_data,
140 int filterQualityIndex);
141
143 double center_left,
144 double center_top,
145 double center_right,
146 double center_bottom,
147 double dst_left,
148 double dst_top,
149 double dst_right,
150 double dst_bottom,
151 Dart_Handle paint_objects,
152 Dart_Handle paint_data,
153 int bitmapSamplingIndex);
154
156
157 // The paint argument is first for the following functions because Paint
158 // unwraps a number of C++ objects. Once we create a view unto a
159 // Float32List, we cannot re-enter the VM to unwrap objects. That means we
160 // either need to process the paint argument first.
161
162 void drawPoints(Dart_Handle paint_objects,
163 Dart_Handle paint_data,
164 DlCanvas::PointMode point_mode,
165 const tonic::Float32List& points);
166
167 void drawVertices(const Vertices* vertices,
168 DlBlendMode blend_mode,
169 Dart_Handle paint_objects,
170 Dart_Handle paint_data);
171
172 Dart_Handle drawAtlas(Dart_Handle paint_objects,
173 Dart_Handle paint_data,
174 int filterQualityIndex,
176 Dart_Handle transforms_handle,
177 Dart_Handle rects_handle,
178 Dart_Handle colors_handle,
179 DlBlendMode blend_mode,
180 Dart_Handle cull_rect_handle);
181
182 void drawShadow(const CanvasPath* path,
184 double elevation,
185 bool transparentOccluder);
186
187 void Invalidate();
188
189 DisplayListBuilder* builder() { return display_list_builder_.get(); }
190
191 private:
193
194 sk_sp<DisplayListBuilder> display_list_builder_;
195};
196
197} // namespace flutter
198
199#endif // FLUTTER_LIB_UI_PAINTING_CANVAS_H_
int count
Definition: FontMgrTest.cpp:50
static const int points[]
uint32_t SkColor
Definition: SkColor.h:37
void drawLine(double x1, double y1, double x2, double y2, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:221
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:335
void drawShadow(const CanvasPath *path, SkColor color, double elevation, bool transparentOccluder)
Definition: canvas.cc:612
void rotate(double radians)
Definition: canvas.cc:122
void drawOval(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:301
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:256
void translate(double dx, double dy)
Definition: canvas.cc:110
void clipRect(double left, double top, double right, double bottom, DlCanvas::ClipOp clipOp, bool doAntiAlias=true)
Definition: canvas.cc:161
void clipRRect(const RRect &rrect, bool doAntiAlias=true)
Definition: canvas.cc:174
DisplayListBuilder * builder()
Definition: canvas.h:189
void drawColor(SkColor color, DlBlendMode blend_mode)
Definition: canvas.cc:215
void transform(const tonic::Float64List &matrix4)
Definition: canvas.cc:134
void drawRRect(const RRect &rrect, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:274
void skew(double sx, double sy)
Definition: canvas.cc:128
void clipPath(const CanvasPath *path, bool doAntiAlias=true)
Definition: canvas.cc:181
Dart_Handle drawImage(const CanvasImage *image, double x, double y, Dart_Handle paint_objects, Dart_Handle paint_data, int filterQualityIndex)
Definition: canvas.cc:379
void save()
Definition: canvas.cc:50
void restoreToCount(int count)
Definition: canvas.cc:104
~Canvas() override
Definition: canvas.cc:48
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:411
void drawVertices(const Vertices *vertices, DlBlendMode blend_mode, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:543
void restore()
Definition: canvas.cc:90
void getTransform(Dart_Handle matrix4_handle)
Definition: canvas.cc:148
void Invalidate()
Definition: canvas.cc:646
void drawCircle(double x, double y, double radius, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:319
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:454
void drawPicture(Picture *picture)
Definition: canvas.cc:498
void saveLayerWithoutBounds(Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:56
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:562
void drawDRRect(const RRect &outer, const RRect &inner, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:287
void scale(double sx, double sy)
Definition: canvas.cc:116
int getSaveCount()
Definition: canvas.cc:96
void getLocalClipBounds(Dart_Handle rect_handle)
Definition: canvas.cc:204
void drawPoints(Dart_Handle paint_objects, Dart_Handle paint_data, DlCanvas::PointMode point_mode, const tonic::Float32List &points)
Definition: canvas.cc:513
void drawPaint(Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:239
void getDestinationClipBounds(Dart_Handle rect_handle)
Definition: canvas.cc:193
void drawPath(const CanvasPath *path, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:361
void saveLayer(double left, double top, double right, double bottom, Dart_Handle paint_objects, Dart_Handle paint_data)
Definition: canvas.cc:70
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DlColor color
double y
double x
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
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
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57