Flutter Engine
The Flutter Engine
display_list_testing.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_TESTING_DISPLAY_LIST_TESTING_H_
6#define FLUTTER_TESTING_DISPLAY_LIST_TESTING_H_
7
8#include <ostream>
9
10#include "flutter/display_list/display_list.h"
11#include "flutter/display_list/dl_op_receiver.h"
12
13namespace flutter {
14namespace testing {
15
17bool inline DisplayListsEQ_Verbose(const DisplayList& a, const DisplayList& b) {
18 return DisplayListsEQ_Verbose(&a, &b);
19}
22 return DisplayListsEQ_Verbose(a.get(), b.get());
23}
25bool inline DisplayListsNE_Verbose(const DisplayList& a, const DisplayList& b) {
26 return DisplayListsNE_Verbose(&a, &b);
27}
30 return DisplayListsNE_Verbose(a.get(), b.get());
31}
32
33} // namespace testing
34} // namespace flutter
35
36namespace std {
37
38extern std::ostream& operator<<(std::ostream& os,
39 const flutter::DisplayList& display_list);
40extern std::ostream& operator<<(std::ostream& os,
41 const flutter::DlPaint& paint);
42extern std::ostream& operator<<(std::ostream& os,
44extern std::ostream& operator<<(std::ostream& os,
46extern std::ostream& operator<<(std::ostream& os,
48extern std::ostream& operator<<(std::ostream& os,
50extern std::ostream& operator<<(std::ostream& os,
51 const flutter::DlStrokeCap& cap);
52extern std::ostream& operator<<(std::ostream& os,
54extern std::ostream& operator<<(std::ostream& os,
55 const flutter::DlDrawStyle& style);
56extern std::ostream& operator<<(std::ostream& os,
57 const flutter::DlBlurStyle& style);
58extern std::ostream& operator<<(std::ostream& os,
60extern std::ostream& operator<<(std::ostream& os,
61 const flutter::DlColor& color);
62extern std::ostream& operator<<(std::ostream& os,
64extern std::ostream& operator<<(std::ostream& os,
66extern std::ostream& operator<<(std::ostream& os,
68extern std::ostream& operator<<(std::ostream& os,
69 const flutter::DlImage* image);
70extern std::ostream& operator<<(std::ostream& os,
72
73} // namespace std
74
75namespace flutter {
76namespace testing {
77
79 public:
80 explicit DisplayListStreamDispatcher(std::ostream& os,
81 int cur_indent = 2,
82 int indent = 2)
83 : os_(os), cur_indent_(cur_indent), indent_(indent) {}
84
85 void setAntiAlias(bool aa) override;
86 void setDrawStyle(DlDrawStyle style) override;
87 void setColor(DlColor color) override;
88 void setStrokeWidth(SkScalar width) override;
89 void setStrokeMiter(SkScalar limit) override;
90 void setStrokeCap(DlStrokeCap cap) override;
91 void setStrokeJoin(DlStrokeJoin join) override;
92 void setColorSource(const DlColorSource* source) override;
93 void setColorFilter(const DlColorFilter* filter) override;
94 void setInvertColors(bool invert) override;
95 void setBlendMode(DlBlendMode mode) override;
96 void setMaskFilter(const DlMaskFilter* filter) override;
97 void setImageFilter(const DlImageFilter* filter) override;
98
99 void save() override;
100 void saveLayer(const SkRect& bounds,
102 const DlImageFilter* backdrop) override;
103 void restore() override;
104
105 void translate(SkScalar tx, SkScalar ty) override;
106 void scale(SkScalar sx, SkScalar sy) override;
107 void rotate(SkScalar degrees) override;
108 void skew(SkScalar sx, SkScalar sy) override;
109 // clang-format off
110 void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt,
111 SkScalar myx, SkScalar myy, SkScalar myt) override;
113 SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
114 SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
115 SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
116 SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) override;
117 // clang-format on
118 void transformReset() override;
119
120 void clipRect(const SkRect& rect, ClipOp clip_op, bool is_aa) override;
121 void clipRRect(const SkRRect& rrect, ClipOp clip_op, bool is_aa) override;
122 void clipPath(const SkPath& path, ClipOp clip_op, bool is_aa) override;
123
124 void drawColor(DlColor color, DlBlendMode mode) override;
125 void drawPaint() override;
126 void drawLine(const SkPoint& p0, const SkPoint& p1) override;
127 void drawDashedLine(const DlPoint& p0,
128 const DlPoint& p1,
129 DlScalar on_length,
130 DlScalar off_length) override;
131 void drawRect(const SkRect& rect) override;
132 void drawOval(const SkRect& bounds) override;
133 void drawCircle(const SkPoint& center, SkScalar radius) override;
134 void drawRRect(const SkRRect& rrect) override;
135 void drawDRRect(const SkRRect& outer, const SkRRect& inner) override;
136 void drawPath(const SkPath& path) override;
137 void drawArc(const SkRect& oval_bounds,
138 SkScalar start_degrees,
139 SkScalar sweep_degrees,
140 bool use_center) override;
142 uint32_t count,
143 const SkPoint points[]) override;
144 void drawVertices(const DlVertices* vertices, DlBlendMode mode) override;
145 void drawImage(const sk_sp<DlImage> image,
146 const SkPoint point,
148 bool render_with_attributes) override;
150 const SkRect& src,
151 const SkRect& dst,
153 bool render_with_attributes,
154 SrcRectConstraint constraint) override;
156 const SkIRect& center,
157 const SkRect& dst,
158 DlFilterMode filter,
159 bool render_with_attributes) override;
160 void drawAtlas(const sk_sp<DlImage> atlas,
161 const SkRSXform xform[],
162 const SkRect tex[],
163 const DlColor colors[],
164 int count,
167 const SkRect* cull_rect,
168 bool render_with_attributes) override;
169 void drawDisplayList(const sk_sp<DisplayList> display_list,
170 SkScalar opacity) override;
171 void drawTextBlob(const sk_sp<SkTextBlob> blob,
172 SkScalar x,
173 SkScalar y) override;
174 void drawTextFrame(const std::shared_ptr<impeller::TextFrame>& text_frame,
175 SkScalar x,
176 SkScalar y) override;
177 void drawShadow(const SkPath& path,
178 const DlColor color,
179 const SkScalar elevation,
180 bool transparent_occluder,
181 SkScalar dpr) override;
182
183 private:
184 std::ostream& os_;
185 int cur_indent_;
186 int indent_;
187
188 void indent() { indent(indent_); }
189 void outdent() { outdent(indent_); }
190 void indent(int spaces) { cur_indent_ += spaces; }
191 void outdent(int spaces) { cur_indent_ -= spaces; }
192
193 template <class T>
194 std::ostream& out_array(std::string name, int count, const T array[]);
195
196 std::ostream& startl();
197
198 void out(const DlColorFilter& filter);
199 void out(const DlColorFilter* filter);
200 void out(const DlImageFilter& filter);
201 void out(const DlImageFilter* filter);
202};
203
204} // namespace testing
205} // namespace flutter
206
207#endif // FLUTTER_TESTING_DISPLAY_LIST_TESTING_H_
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
Definition: SkPath.h:59
Represents an image whose allocation is (usually) resident on device memory.
Definition: dl_image.h:30
Internal API for rendering recorded display lists to backends.
DlCanvas::SrcRectConstraint SrcRectConstraint
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
void drawOval(const SkRect &bounds) override
void setImageFilter(const DlImageFilter *filter) override
void drawVertices(const DlVertices *vertices, DlBlendMode mode) override
DisplayListStreamDispatcher(std::ostream &os, int cur_indent=2, int indent=2)
void drawDRRect(const SkRRect &outer, const SkRRect &inner) override
void clipRect(const SkRect &rect, ClipOp clip_op, bool is_aa) override
void drawShadow(const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y) override
void drawImageNine(const sk_sp< DlImage > image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, bool render_with_attributes) override
void setMaskFilter(const DlMaskFilter *filter) override
void drawImageRect(const sk_sp< DlImage > image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint) override
void drawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length) override
void translate(SkScalar tx, SkScalar ty) override
void saveLayer(const SkRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop) override
void setStrokeJoin(DlStrokeJoin join) override
void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt) override
void setColorFilter(const DlColorFilter *filter) override
void drawArc(const SkRect &oval_bounds, SkScalar start_degrees, SkScalar sweep_degrees, bool use_center) override
void drawCircle(const SkPoint &center, SkScalar radius) override
void drawImage(const sk_sp< DlImage > image, const SkPoint point, DlImageSampling sampling, bool render_with_attributes) override
void drawAtlas(const sk_sp< DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes) override
void drawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity) override
void clipRRect(const SkRRect &rrect, ClipOp clip_op, bool is_aa) override
void drawLine(const SkPoint &p0, const SkPoint &p1) override
void drawPoints(PointMode mode, uint32_t count, const SkPoint points[]) override
void drawColor(DlColor color, DlBlendMode mode) override
void skew(SkScalar sx, SkScalar sy) override
void drawRRect(const SkRRect &rrect) override
void setColorSource(const DlColorSource *source) override
void scale(SkScalar sx, SkScalar sy) 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 drawTextBlob(const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y) override
void clipPath(const SkPath &path, ClipOp clip_op, bool is_aa) override
const Paint & paint
Definition: color_source.cc:38
DlColor color
SkBitmap source
Definition: examples.cpp:28
float SkScalar
Definition: extension.cpp:12
static bool b
struct MyStruct a[10]
gboolean invert
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
bool DisplayListsNE_Verbose(const DisplayList *a, const DisplayList *b)
bool DisplayListsEQ_Verbose(const DisplayList *a, const DisplayList *b)
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
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
Definition: dl_vertices.h:20
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
dst
Definition: cp.py:12
Definition: ref_ptr.h:256
std::ostream & operator<<(std::ostream &out, const impeller::Color &c)
Definition: color.h:961
flutter::DisplayList DisplayList
#define T
Definition: precompiler.cc:65
int32_t width
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741
Definition: SkRect.h:32