Flutter Engine
The Flutter Engine
dl_dispatcher.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_IMPELLER_DISPLAY_LIST_DL_DISPATCHER_H_
6#define FLUTTER_IMPELLER_DISPLAY_LIST_DL_DISPATCHER_H_
7
8#include "flutter/display_list/dl_op_receiver.h"
9#include "flutter/display_list/geometry/dl_geometry_types.h"
10#include "flutter/display_list/utils/dl_receiver_utils.h"
11#include "fml/logging.h"
14#include "impeller/aiks/paint.h"
17
18namespace impeller {
19
22
24 public:
26
27 // |flutter::DlOpReceiver|
28 bool PrefersImpellerPaths() const override { return true; }
29
30 // |flutter::DlOpReceiver|
31 void setAntiAlias(bool aa) override;
32
33 // |flutter::DlOpReceiver|
34 void setDrawStyle(flutter::DlDrawStyle style) override;
35
36 // |flutter::DlOpReceiver|
37 void setColor(flutter::DlColor color) override;
38
39 // |flutter::DlOpReceiver|
40 void setStrokeWidth(SkScalar width) override;
41
42 // |flutter::DlOpReceiver|
43 void setStrokeMiter(SkScalar limit) override;
44
45 // |flutter::DlOpReceiver|
46 void setStrokeCap(flutter::DlStrokeCap cap) override;
47
48 // |flutter::DlOpReceiver|
50
51 // |flutter::DlOpReceiver|
52 void setColorSource(const flutter::DlColorSource* source) override;
53
54 // |flutter::DlOpReceiver|
55 void setColorFilter(const flutter::DlColorFilter* filter) override;
56
57 // |flutter::DlOpReceiver|
58 void setInvertColors(bool invert) override;
59
60 // |flutter::DlOpReceiver|
62
63 // |flutter::DlOpReceiver|
64 void setMaskFilter(const flutter::DlMaskFilter* filter) override;
65
66 // |flutter::DlOpReceiver|
67 void setImageFilter(const flutter::DlImageFilter* filter) override;
68
69 // |flutter::DlOpReceiver|
70 void save(uint32_t total_content_depth) override;
71
72 // |flutter::DlOpReceiver|
73 void saveLayer(const SkRect& bounds,
75 uint32_t total_content_depth,
76 flutter::DlBlendMode max_content_mode,
77 const flutter::DlImageFilter* backdrop) override;
78
79 // |flutter::DlOpReceiver|
80 void restore() override;
81
82 // |flutter::DlOpReceiver|
83 void translate(SkScalar tx, SkScalar ty) override;
84
85 // |flutter::DlOpReceiver|
86 void scale(SkScalar sx, SkScalar sy) override;
87
88 // |flutter::DlOpReceiver|
89 void rotate(SkScalar degrees) override;
90
91 // |flutter::DlOpReceiver|
92 void skew(SkScalar sx, SkScalar sy) override;
93
94 // |flutter::DlOpReceiver|
96 SkScalar mxy,
97 SkScalar mxt,
98 SkScalar myx,
99 SkScalar myy,
100 SkScalar myt) override;
101
102 // |flutter::DlOpReceiver|
104 SkScalar mxy,
105 SkScalar mxz,
106 SkScalar mxt,
107 SkScalar myx,
108 SkScalar myy,
109 SkScalar myz,
110 SkScalar myt,
111 SkScalar mzx,
112 SkScalar mzy,
113 SkScalar mzz,
114 SkScalar mzt,
115 SkScalar mwx,
116 SkScalar mwy,
117 SkScalar mwz,
118 SkScalar mwt) override;
119
120 // |flutter::DlOpReceiver|
121 void transformReset() override;
122
123 // |flutter::DlOpReceiver|
124 void clipRect(const SkRect& rect, ClipOp clip_op, bool is_aa) override;
125
126 // |flutter::DlOpReceiver|
127 void clipRRect(const SkRRect& rrect, ClipOp clip_op, bool is_aa) override;
128
129 // |flutter::DlOpReceiver|
130 void clipPath(const SkPath& path, ClipOp clip_op, bool is_aa) override;
131
132 // |flutter::DlOpReceiver|
133 void clipPath(const CacheablePath& cache,
134 ClipOp clip_op,
135 bool is_aa) override;
136
137 // |flutter::DlOpReceiver|
139
140 // |flutter::DlOpReceiver|
141 void drawPaint() override;
142
143 // |flutter::DlOpReceiver|
144 void drawLine(const SkPoint& p0, const SkPoint& p1) override;
145
146 // |flutter::DlOpReceiver|
147 void drawDashedLine(const DlPoint& p0,
148 const DlPoint& p1,
149 DlScalar on_length,
150 DlScalar off_length) override;
151
152 // |flutter::DlOpReceiver|
153 void drawRect(const SkRect& rect) override;
154
155 // |flutter::DlOpReceiver|
156 void drawOval(const SkRect& bounds) override;
157
158 // |flutter::DlOpReceiver|
159 void drawCircle(const SkPoint& center, SkScalar radius) override;
160
161 // |flutter::DlOpReceiver|
162 void drawRRect(const SkRRect& rrect) override;
163
164 // |flutter::DlOpReceiver|
165 void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
166
167 // |flutter::DlOpReceiver|
168 void drawPath(const SkPath& path) override;
169
170 // |flutter::DlOpReceiver|
171 void drawPath(const CacheablePath& cache) override;
172
173 // |flutter::DlOpReceiver|
174 void drawArc(const SkRect& oval_bounds,
175 SkScalar start_degrees,
176 SkScalar sweep_degrees,
177 bool use_center) override;
178
179 // |flutter::DlOpReceiver|
181 uint32_t count,
182 const SkPoint points[]) override;
183
184 // |flutter::DlOpReceiver|
185 void drawVertices(const flutter::DlVertices* vertices,
186 flutter::DlBlendMode dl_mode) override;
187
188 // |flutter::DlOpReceiver|
190 const SkPoint point,
192 bool render_with_attributes) override;
193
194 // |flutter::DlOpReceiver|
196 const SkRect& src,
197 const SkRect& dst,
199 bool render_with_attributes,
200 SrcRectConstraint constraint) override;
201
202 // |flutter::DlOpReceiver|
204 const SkIRect& center,
205 const SkRect& dst,
207 bool render_with_attributes) override;
208
209 // |flutter::DlOpReceiver|
211 const SkRSXform xform[],
212 const SkRect tex[],
213 const flutter::DlColor colors[],
214 int count,
217 const SkRect* cull_rect,
218 bool render_with_attributes) override;
219
220 // |flutter::DlOpReceiver|
221 void drawDisplayList(const sk_sp<flutter::DisplayList> display_list,
222 SkScalar opacity) override;
223
224 // |flutter::DlOpReceiver|
225 void drawTextBlob(const sk_sp<SkTextBlob> blob,
226 SkScalar x,
227 SkScalar y) override;
228
229 // |flutter::DlOpReceiver|
230 void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
231 SkScalar x,
232 SkScalar y) override;
233
234 // |flutter::DlOpReceiver|
235 void drawShadow(const SkPath& path,
237 const SkScalar elevation,
238 bool transparent_occluder,
239 SkScalar dpr) override;
240
241 // |flutter::DlOpReceiver|
242 void drawShadow(const CacheablePath& cache,
244 const SkScalar elevation,
245 bool transparent_occluder,
246 SkScalar dpr) override;
247
248 virtual Canvas& GetCanvas() = 0;
249
250 private:
251 Paint paint_;
252 Matrix initial_matrix_;
253
254 static const Path& GetOrCachePath(const CacheablePath& cache);
255
256 static void SimplifyOrDrawPath(Canvas& canvas,
257 const CacheablePath& cache,
258 const Paint& paint);
259};
260
262 public:
264
265 explicit DlDispatcher(IRect cull_rect);
266
267 explicit DlDispatcher(Rect cull_rect);
268
269 ~DlDispatcher() = default;
270
271 // |flutter::DlOpReceiver|
272 void save() override {
273 // This dispatcher is used from test cases that might not supply
274 // a content_depth parameter. Since this dispatcher doesn't use
275 // the value, we just pass through a 0.
277 }
279
280 // |flutter::DlOpReceiver|
283 const flutter::DlImageFilter* backdrop) override {
284 // This dispatcher is used from test cases that might not supply
285 // a content_depth parameter. Since this dispatcher doesn't use
286 // the value, we just pass through a 0.
289 }
291
292 private:
293 Canvas canvas_;
294
295 Canvas& GetCanvas() override;
296};
297
299 public:
301 RenderTarget& render_target,
302 bool has_root_backdrop_filter,
303 flutter::DlBlendMode max_root_blend_mode,
304 IRect cull_rect);
305
307
308 // |flutter::DlOpReceiver|
309 void save() override {
310 // This dispatcher should never be used with the save() variant
311 // that does not include the content_depth parameter.
313 }
315
316 // |flutter::DlOpReceiver|
319 const flutter::DlImageFilter* backdrop) override {
320 // This dispatcher should never be used with the saveLayer() variant
321 // that does not include the content_depth parameter.
323 }
325
326 void FinishRecording() { canvas_.EndReplay(); }
327
328 private:
329 ExperimentalCanvas canvas_;
330
331 Canvas& GetCanvas() override;
332};
333
334/// Performs a first pass over the display list to collect all text frames.
338 public:
340 const Matrix& initial_matrix);
341 void save() override;
342
343 void saveLayer(const SkRect& bounds,
345 const flutter::DlImageFilter* backdrop) override;
346
347 void restore() override;
348
349 void translate(SkScalar tx, SkScalar ty) override;
350
351 void scale(SkScalar sx, SkScalar sy) override;
352
353 void rotate(SkScalar degrees) override;
354
355 void skew(SkScalar sx, SkScalar sy) override;
356
357 // clang-format off
358 // 2x3 2D affine subset of a 4x4 transform in row major order
359 void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt,
360 SkScalar myx, SkScalar myy, SkScalar myt) override;
361
362 // full 4x4 transform in row major order
364 SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
365 SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
366 SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
367 SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override;
368
369 void transformReset() override;
370
371 void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
372 SkScalar x,
373 SkScalar y) override;
374
375 void drawDisplayList(const sk_sp<flutter::DisplayList> display_list,
376 SkScalar opacity) override;
377
378 // |flutter::DlOpReceiver|
379 void setDrawStyle(flutter::DlDrawStyle style) override;
380
381 // |flutter::DlOpReceiver|
382 void setColor(flutter::DlColor color) override;
383
384 // |flutter::DlOpReceiver|
385 void setStrokeWidth(SkScalar width) override;
386
387 // |flutter::DlOpReceiver|
388 void setStrokeMiter(SkScalar limit) override;
389
390 // |flutter::DlOpReceiver|
391 void setStrokeCap(flutter::DlStrokeCap cap) override;
392
393 // |flutter::DlOpReceiver|
395
396 private:
397 const ContentContext& renderer_;
398 Matrix matrix_;
399 std::vector<Matrix> stack_;
400 Paint paint_;
401};
402
403} // namespace impeller
404
405#endif // FLUTTER_IMPELLER_DISPLAY_LIST_DL_DISPATCHER_H_
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
Definition: SkPath.h:59
Internal API for rendering recorded display lists to backends.
virtual void save()=0
DlCanvas::SrcRectConstraint SrcRectConstraint
DlCanvas::ClipOp ClipOp
DlCanvas::PointMode PointMode
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
void transformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override
void drawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length) override
void setImageFilter(const flutter::DlImageFilter *filter) override
void drawVertices(const flutter::DlVertices *vertices, flutter::DlBlendMode dl_mode) override
void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y) override
void setStrokeCap(flutter::DlStrokeCap cap) override
void drawPath(const SkPath &path) override
void setAntiAlias(bool aa) override
void drawPoints(PointMode mode, uint32_t count, const SkPoint points[]) override
void drawLine(const SkPoint &p0, const SkPoint &p1) override
bool PrefersImpellerPaths() const override
Definition: dl_dispatcher.h:28
void clipRect(const SkRect &rect, ClipOp clip_op, bool is_aa) override
void drawOval(const SkRect &bounds) override
void drawCircle(const SkPoint &center, SkScalar radius) override
void setStrokeJoin(flutter::DlStrokeJoin join) override
void setStrokeWidth(SkScalar width) override
void setColorFilter(const flutter::DlColorFilter *filter) override
void translate(SkScalar tx, SkScalar ty) override
void setDrawStyle(flutter::DlDrawStyle style) override
void clipRRect(const SkRRect &rrect, ClipOp clip_op, bool is_aa) override
void drawShadow(const SkPath &path, const flutter::DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
void setStrokeMiter(SkScalar limit) override
void scale(SkScalar sx, SkScalar sy) override
void skew(SkScalar sx, SkScalar sy) override
void clipPath(const SkPath &path, ClipOp clip_op, bool is_aa) override
void setInvertColors(bool invert) override
void drawImage(const sk_sp< flutter::DlImage > image, const SkPoint point, flutter::DlImageSampling sampling, bool render_with_attributes) override
void drawImageNine(const sk_sp< flutter::DlImage > image, const SkIRect &center, const SkRect &dst, flutter::DlFilterMode filter, bool render_with_attributes) override
void drawAtlas(const sk_sp< flutter::DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const flutter::DlColor colors[], int count, flutter::DlBlendMode mode, flutter::DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes) override
void drawDRRect(const SkRRect &outer, const SkRRect &inner) override
void drawRect(const SkRect &rect) override
void drawDisplayList(const sk_sp< flutter::DisplayList > display_list, SkScalar opacity) override
void setColor(flutter::DlColor color) override
void drawImageRect(const sk_sp< flutter::DlImage > image, const SkRect &src, const SkRect &dst, flutter::DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint) override
void setMaskFilter(const flutter::DlMaskFilter *filter) override
virtual Canvas & GetCanvas()=0
void setColorSource(const flutter::DlColorSource *source) override
void transformReset() override
void setBlendMode(flutter::DlBlendMode mode) override
void drawArc(const SkRect &oval_bounds, SkScalar start_degrees, SkScalar sweep_degrees, bool use_center) override
void drawColor(flutter::DlColor color, flutter::DlBlendMode mode) override
void drawTextBlob(const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y) override
void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt) override
void saveLayer(const SkRect &bounds, const flutter::SaveLayerOptions &options, uint32_t total_content_depth, flutter::DlBlendMode max_content_mode, const flutter::DlImageFilter *backdrop) override
void rotate(SkScalar degrees) override
void drawRRect(const SkRRect &rrect) override
void saveLayer(const SkRect &bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter *backdrop) override
DlDispatcher()
Subclasses.
void save() override
void saveLayer(const SkRect &bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter *backdrop) override
ExperimentalDlDispatcher(ContentContext &renderer, RenderTarget &render_target, bool has_root_backdrop_filter, flutter::DlBlendMode max_root_blend_mode, IRect cull_rect)
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition: path.h:52
Performs a first pass over the display list to collect all text frames.
void drawDisplayList(const sk_sp< flutter::DisplayList > display_list, SkScalar opacity) override
void rotate(SkScalar degrees) override
TextFrameDispatcher(const ContentContext &renderer, const Matrix &initial_matrix)
void setStrokeJoin(flutter::DlStrokeJoin join) override
void setStrokeWidth(SkScalar width) override
void skew(SkScalar sx, SkScalar sy) override
void setStrokeMiter(SkScalar limit) override
void saveLayer(const SkRect &bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter *backdrop) override
void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt) override
void transformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override
void scale(SkScalar sx, SkScalar sy) override
void translate(SkScalar tx, SkScalar ty) override
void setColor(flutter::DlColor color) override
void setStrokeCap(flutter::DlStrokeCap cap) override
void setDrawStyle(flutter::DlDrawStyle style) override
void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y) override
const Paint & paint
Definition: color_source.cc:38
DlColor color
SkBitmap source
Definition: examples.cpp:28
float SkScalar
Definition: extension.cpp:12
gboolean invert
#define FML_UNREACHABLE()
Definition: logging.h:109
double y
double x
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< const SkImageFilter > backdrop
Definition: SkRecords.h:191
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
impeller::Scalar DlScalar
DlStrokeJoin
Definition: dl_paint.h:37
DlStrokeCap
Definition: dl_paint.h:28
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
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
DlDrawStyle
Definition: dl_paint.h:19
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
impeller::Point DlPoint
@ kLastMode
last valid value
dst
Definition: cp.py:12
flutter::DlScalar DlScalar
Definition: dl_dispatcher.h:20
int32_t width
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741
Definition: SkRect.h:32
A 4x4 matrix using column-major storage.
Definition: matrix.h:37