Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
trace_serializer.cc
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
6#include "flutter/fml/logging.h"
7
8namespace impeller {
9
10namespace {
11
12class ImageFilterTraceVisitor : public ImageFilterVisitor {
13 public:
14 explicit ImageFilterTraceVisitor(std::ostream& os) : os_(os) {}
15 void Visit(const BlurImageFilter& filter) override {
16 os_ << "BlurImageFilter";
17 }
18 void Visit(const LocalMatrixImageFilter& filter) override {
19 os_ << "LocalMatrixImageFilter";
20 }
21 void Visit(const DilateImageFilter& filter) override {
22 os_ << "DilateImageFilter";
23 }
24 void Visit(const ErodeImageFilter& filter) override {
25 os_ << "ErodeImageFilter";
26 }
27 void Visit(const MatrixImageFilter& filter) override {
28 os_ << "{MatrixImageFilter matrix: " << filter.GetMatrix() << "}";
29 }
30 void Visit(const ComposeImageFilter& filter) override {
31 os_ << "ComposeImageFilter";
32 }
33 void Visit(const ColorImageFilter& filter) override {
34 os_ << "ColorImageFilter";
35 }
36
37 private:
38 std::ostream& os_;
39};
40
41std::ostream& operator<<(std::ostream& os,
42 const std::shared_ptr<ImageFilter>& image_filter) {
43 if (image_filter) {
44 os << "[";
45 ImageFilterTraceVisitor visitor(os);
46 image_filter->Visit(visitor);
47 os << "]";
48 } else {
49 os << "[None]";
50 }
51 return os;
52}
53
54std::ostream& operator<<(std::ostream& os, const ColorSource& color_source) {
55 os << "{ type: ";
56 switch (color_source.GetType()) {
58 os << "kColor";
59 break;
61 os << "kImage";
62 break;
64 os << "kLinearGradient";
65 break;
67 os << "kRadialGradient";
68 break;
70 os << "kConicalGradient";
71 break;
73 os << "kSweepGradient";
74 break;
76 os << "kRuntimeEffect";
77 break;
79 os << "kScene";
80 break;
81 }
82 os << " }";
83 return os;
84}
85
86std::ostream& operator<<(std::ostream& os, const Paint& paint) {
87 os << "{" << std::endl;
88 os << " color: [" << paint.color << "]" << std::endl;
89 os << " color_source:" << "[" << paint.color_source << "]" << std::endl;
90 os << " dither: [" << paint.dither << "]" << std::endl;
91 os << " stroke_width: [" << paint.stroke_width << "]" << std::endl;
92 os << " stroke_cap: " << "[Paint::Cap]" << std::endl;
93 os << " stroke_join: " << "[Paint::Join]" << std::endl;
94 os << " stroke_miter: [" << paint.stroke_miter << "]" << std::endl;
95 os << " style:" << "[Paint::Style]" << std::endl;
96 os << " blend_mode: [" << BlendModeToString(paint.blend_mode) << "]"
97 << std::endl;
98 os << " invert_colors: [" << paint.invert_colors << "]" << std::endl;
99 os << " image_filter: " << paint.image_filter << std::endl;
100 os << " color_filter: " << paint.color_filter << std::endl;
101 os << " mask_blur_descriptor: " << "[std::optional<MaskBlurDescriptor>]"
102 << std::endl;
103 os << "}";
104 return os;
105}
106} // namespace
107
108#define FLT_CANVAS_RECORDER_OP_TO_STRING(name) \
109 case CanvasRecorderOp::name: \
110 return #name
111
112namespace {
113std::string_view CanvasRecorderOpToString(CanvasRecorderOp op) {
114 switch (op) {
146 }
147}
148} // namespace
149
151
153 if (op == CanvasRecorderOp::kNew) {
154 FML_LOG(ERROR) << "######################################################";
155 } else {
156 FML_LOG(ERROR) << CanvasRecorderOpToString(op) << ":" << buffer_.str();
157 buffer_.str("");
158 buffer_.clear();
159 }
160}
161
163 buffer_ << "[" << paint << "] ";
164}
165
166void TraceSerializer::Write(const std::optional<Rect> optional_rect) {
167 if (optional_rect.has_value()) {
168 buffer_ << "[" << optional_rect.value() << "] ";
169 } else {
170 buffer_ << "[None] ";
171 }
172}
173
174void TraceSerializer::Write(const std::shared_ptr<ImageFilter>& image_filter) {
175 buffer_ << image_filter << " ";
176}
177
178void TraceSerializer::Write(size_t size) {
179 buffer_ << "[" << size << "] ";
180}
181
182void TraceSerializer::Write(const Matrix& matrix) {
183 buffer_ << "[" << matrix << "] ";
184}
185
187 buffer_ << "[" << vec3 << "] ";
188}
189
191 buffer_ << "[" << vec2 << "] ";
192}
193
194void TraceSerializer::Write(const Radians& radians) {
195 buffer_ << "[" << radians.radians << "] ";
196}
197
198void TraceSerializer::Write(const Path& path) {
199 buffer_ << "[Path] ";
200}
201
202void TraceSerializer::Write(const std::vector<Point>& points) {
203 buffer_ << "[std::vector<Point>] ";
204}
205
206void TraceSerializer::Write(const PointStyle& point_style) {
207 buffer_ << "[PointStyle] ";
208}
209
210void TraceSerializer::Write(const std::shared_ptr<Image>& image) {
211 buffer_ << "[std::shared_ptr<Image>] ";
212}
213
215 buffer_ << "[SamplerDescriptor] ";
216}
217
219 switch (clip_op) {
221 buffer_ << "[kDifference] ";
222 break;
224 buffer_ << "[kIntersect] ";
225 break;
226 }
227}
228
229void TraceSerializer::Write(const Picture& clip_op) {
230 buffer_ << "[Picture] ";
231}
232
233void TraceSerializer::Write(const std::shared_ptr<TextFrame>& text_frame) {
234 buffer_ << "[std::shared_ptr<TextFrame>] ";
235}
236
237void TraceSerializer::Write(const std::shared_ptr<VerticesGeometry>& vertices) {
238 buffer_ << "[std::shared_ptr<VerticesGeometry>] ";
239}
240
241void TraceSerializer::Write(const BlendMode& blend_mode) {
242 buffer_ << "[" << BlendModeToString(blend_mode) << "] ";
243}
244
245void TraceSerializer::Write(const std::vector<Matrix>& matrices) {
246 buffer_ << "[std::vector<Matrix>] ";
247}
248
249void TraceSerializer::Write(const std::vector<Rect>& matrices) {
250 buffer_ << "[std::vector<Rect>] ";
251}
252
253void TraceSerializer::Write(const std::vector<Color>& matrices) {
254 buffer_ << "[std::vector<Color>] ";
255}
256
257void TraceSerializer::Write(const SourceRectConstraint& src_rect_constraint) {
258 buffer_ << "[SourceRectConstraint] ";
259}
260
262 buffer_ << "[SaveLayerBoundsPromise]";
263}
264
265} // namespace impeller
static const int points[]
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition path.h:51
void Write(CanvasRecorderOp op)
const Paint & paint
std::ostream & operator<<(std::ostream &out, const FlutterPoint &point)
sk_sp< SkImage > image
Definition examples.cpp:29
#define FML_LOG(severity)
Definition logging.h:82
SourceRectConstraint
Controls the behavior of the source rectangle given to DrawImageRect.
Definition canvas.h:51
PointStyle
Definition canvas.h:42
const char * BlendModeToString(BlendMode blend_mode)
Definition color.cc:47
BlendMode
Definition color.h:59
ContentBoundsPromise
Definition entity_pass.h:28
A 4x4 matrix using column-major storage.
Definition matrix.h:37
bool dither
Definition paint.h:57
ColorSource color_source
Definition paint.h:56
Scalar stroke_miter
Definition paint.h:62
bool invert_colors
Definition paint.h:65
std::shared_ptr< ImageFilter > image_filter
Definition paint.h:67
Color color
Definition paint.h:55
BlendMode blend_mode
Definition paint.h:64
std::shared_ptr< ColorFilter > color_filter
Definition paint.h:68
Scalar stroke_width
Definition paint.h:59
Scalar radians
Definition scalar.h:39
#define ERROR(message)
#define FLT_CANVAS_RECORDER_OP_TO_STRING(name)