forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvas.h
More file actions
215 lines (179 loc) · 7.56 KB
/
canvas.h
File metadata and controls
215 lines (179 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_LIB_UI_PAINTING_CANVAS_H_
#define FLUTTER_LIB_UI_PAINTING_CANVAS_H_
#include "flutter/display_list/display_list_blend_mode.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "flutter/lib/ui/painting/paint.h"
#include "flutter/lib/ui/painting/path.h"
#include "flutter/lib/ui/painting/picture.h"
#include "flutter/lib/ui/painting/picture_recorder.h"
#include "flutter/lib/ui/painting/rrect.h"
#include "flutter/lib/ui/painting/vertices.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/utils/SkShadowUtils.h"
#include "third_party/tonic/typed_data/typed_list.h"
namespace flutter {
class CanvasImage;
class Canvas : public RefCountedDartWrappable<Canvas>, DisplayListOpFlags {
DEFINE_WRAPPERTYPEINFO();
FML_FRIEND_MAKE_REF_COUNTED(Canvas);
public:
static void Create(Dart_Handle wrapper,
PictureRecorder* recorder,
double left,
double top,
double right,
double bottom);
~Canvas() override;
void save();
void saveLayerWithoutBounds(Dart_Handle paint_objects,
Dart_Handle paint_data);
void saveLayer(double left,
double top,
double right,
double bottom,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void restore();
int getSaveCount();
void restoreToCount(int count);
void translate(double dx, double dy);
void scale(double sx, double sy);
void rotate(double radians);
void skew(double sx, double sy);
void transform(const tonic::Float64List& matrix4);
void getTransform(Dart_Handle matrix4_handle);
void clipRect(double left,
double top,
double right,
double bottom,
SkClipOp clipOp,
bool doAntiAlias = true);
void clipRRect(const RRect& rrect, bool doAntiAlias = true);
void clipPath(const CanvasPath* path, bool doAntiAlias = true);
void getDestinationClipBounds(Dart_Handle rect_handle);
void getLocalClipBounds(Dart_Handle rect_handle);
void drawColor(SkColor color, DlBlendMode blend_mode);
void drawLine(double x1,
double y1,
double x2,
double y2,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawPaint(Dart_Handle paint_objects, Dart_Handle paint_data);
void drawRect(double left,
double top,
double right,
double bottom,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawRRect(const RRect& rrect,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawDRRect(const RRect& outer,
const RRect& inner,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawOval(double left,
double top,
double right,
double bottom,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawCircle(double x,
double y,
double radius,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawArc(double left,
double top,
double right,
double bottom,
double startAngle,
double sweepAngle,
bool useCenter,
Dart_Handle paint_objects,
Dart_Handle paint_data);
void drawPath(const CanvasPath* path,
Dart_Handle paint_objects,
Dart_Handle paint_data);
Dart_Handle drawImage(const CanvasImage* image,
double x,
double y,
Dart_Handle paint_objects,
Dart_Handle paint_data,
int filterQualityIndex);
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);
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);
void drawPicture(Picture* picture);
// The paint argument is first for the following functions because Paint
// unwraps a number of C++ objects. Once we create a view unto a
// Float32List, we cannot re-enter the VM to unwrap objects. That means we
// either need to process the paint argument first.
void drawPoints(Dart_Handle paint_objects,
Dart_Handle paint_data,
SkCanvas::PointMode point_mode,
const tonic::Float32List& points);
void drawVertices(const Vertices* vertices,
DlBlendMode blend_mode,
Dart_Handle paint_objects,
Dart_Handle paint_data);
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);
void drawShadow(const CanvasPath* path,
SkColor color,
double elevation,
bool transparentOccluder);
SkCanvas* canvas() const { return canvas_; }
void Invalidate();
private:
explicit Canvas(SkCanvas* canvas);
// The SkCanvas is supplied by a call to SkPictureRecorder::beginRecording,
// which does not transfer ownership. For this reason, we hold a raw
// pointer and manually set to null in Clear.
SkCanvas* canvas_;
// A copy of the recorder used by the SkCanvas->DisplayList adapter for cases
// where we cannot record the SkCanvas method call through the various OnOp()
// virtual methods or where we can be more efficient by talking directly in
// the DisplayList operation lexicon. The recorder has a method for recording
// paint attributes from an SkPaint and an operation type as well as access
// to the raw DisplayListBuilder for emitting custom rendering operations.
sk_sp<DisplayListCanvasRecorder> display_list_recorder_;
DisplayListBuilder* builder() {
return display_list_recorder_->builder().get();
}
};
} // namespace flutter
#endif // FLUTTER_LIB_UI_PAINTING_CANVAS_H_