Flutter Engine
 
Loading...
Searching...
No Matches
display_list_testing.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
7#include <cstdint>
8#include <iomanip>
9
16
17namespace flutter::testing {
18
19// clang-format off
21 if (a->Equals(b)) {
22 return true;
23 }
24 FML_LOG(ERROR) << std::endl
25 << std::endl
26 << *a << std::endl
27 << "not identical to ..." << std::endl
28 << std::endl
29 << *b;
30 return false;
31}
32
34 if (a->Equals(b)) {
35 FML_LOG(ERROR) << std::endl
36 << "DisplayLists are both the same:" << std::endl
37 << *a;
38 return false;
39 }
40 return true;
41}
42
43} // namespace flutter::testing
44
45namespace std {
46
66
68
69std::ostream& operator<<(std::ostream& os,
70 const DisplayList& display_list) {
71 DisplayListStreamDispatcher dispatcher(os);
72 os << std::boolalpha;
73 os << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
74 os << "DisplayList {" << std::endl;
75 display_list.Dispatch(dispatcher);
76 os << "}" << std::endl;
77 return os;
78}
79
80std::ostream& operator<<(std::ostream& os, const DlPaint& paint) {
81 os << "DlPaint("
82 << "isaa: " << paint.isAntiAlias() << ", "
83 << paint.getColor() << ", "
84 << paint.getBlendMode() << ", "
85 << paint.getDrawStyle();
86 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
87 os << ", width: " << paint.getStrokeWidth()
88 << ", miter: " << paint.getStrokeMiter()
89 << ", " << paint.getStrokeCap()
90 << ", " << paint.getStrokeJoin();
91 }
92 if (paint.getColorSource()) {
93 os << ", " << paint.getColorSource();
94 }
95 if (paint.getColorFilter()) {
96 os << ", " << paint.getColorFilter();
97 }
98 if (paint.getImageFilter()) {
99 os << ", " << paint.getImageFilter();
100 }
101 if (paint.getMaskFilter()) {
102 os << ", " << paint.getMaskFilter();
103 }
104 if (paint.isInvertColors()) {
105 os << ", invertColors: " << paint.isInvertColors();
106 }
107 return os << ")";
108}
109
110#define DLT_OSTREAM_CASE(enum_name, value_name) \
111 case enum_name::k##value_name: return os << #enum_name "::k" #value_name
112
113extern std::ostream& operator<<(std::ostream& os,
115 switch (type) {
116#define DLT_OP_TYPE_CASE(V) DLT_OSTREAM_CASE(DisplayListOpType, V);
118 DLT_OP_TYPE_CASE(InvalidOp)
119
120#undef DLT_OP_TYPE_CASE
121 }
122 // Not a valid enum, should never happen, but in case we encounter bad data.
123 return os << "DisplayListOpType::???";
124}
125
126extern std::ostream& operator<<(
127 std::ostream& os, const flutter::DisplayListOpCategory& category) {
128 switch (category) {
137 DLT_OSTREAM_CASE(DisplayListOpCategory, InvalidCategory);
138 }
139 // Not a valid enum, should never happen, but in case we encounter bad data.
140 return os << "DisplayListOpCategory::???";
141}
142
143extern std::ostream& operator<<(
144 std::ostream& os, const flutter::DlPathFillType& type) {
145 switch (type) {
148 }
149}
150
151#undef DLT_OSTREAM_CASE
152
153std::ostream& operator<<(std::ostream& os, const SaveLayerOptions& options) {
154 return os << "SaveLayerOptions("
155 << "renders_with_attributes: " << options.renders_with_attributes()
156 << ", "
157 << "can_distribute_opacity: " << options.can_distribute_opacity()
158 << ", "
159 << "contains_backdrop: " << options.contains_backdrop_filter()
160 << ", "
161 << "is_unbounded: " << options.content_is_unbounded()
162 << ")";
163}
164
165static std::ostream& operator<<(std::ostream& os, const SkRect& rect) {
166 return os << "SkRect("
167 << "left: " << rect.fLeft << ", "
168 << "top: " << rect.fTop << ", "
169 << "right: " << rect.fRight << ", "
170 << "bottom: " << rect.fBottom
171 << ")";
172}
173
174extern std::ostream& operator<<(std::ostream& os, const DlPath& path) {
175 return os << "DlPath("
176 << "bounds: " << path.GetBounds()
177 // should iterate over verbs and coordinates...
178 << ")";
179}
180
181extern std::ostream& operator<<(std::ostream& os, const flutter::testing::DlVerbosePath& path) {
182 DisplayListStreamDispatcher dispatcher(os, 0);
183 dispatcher.out(path);
184 return os;
185}
186
187std::ostream& operator<<(std::ostream& os, const flutter::DlClipOp& op) {
188 switch (op) {
189 case flutter::DlClipOp::kDifference: return os << "DlClipOp::kDifference";
190 case flutter::DlClipOp::kIntersect: return os << "DlClipOp::kIntersect";
191 }
192}
193
194std::ostream& operator<<(std::ostream& os, const flutter::DlSrcRectConstraint& constraint) {
195 switch (constraint) {
197 return os << "SrcRectConstraint::kFast";
199 return os << "SrcRectConstraint::kStrict";
200 }
201}
202
203std::ostream& operator<<(std::ostream& os, const DlStrokeCap& cap) {
204 switch (cap) {
205 case DlStrokeCap::kButt: return os << "Cap::kButt";
206 case DlStrokeCap::kRound: return os << "Cap::kRound";
207 case DlStrokeCap::kSquare: return os << "Cap::kSquare";
208 }
209}
210
211std::ostream& operator<<(std::ostream& os, const DlStrokeJoin& join) {
212 switch (join) {
213 case DlStrokeJoin::kMiter: return os << "Join::kMiter";
214 case DlStrokeJoin::kRound: return os << "Join::kRound";
215 case DlStrokeJoin::kBevel: return os << "Join::kBevel";
216 }
217}
218
219std::ostream& operator<<(std::ostream& os, const DlDrawStyle& style) {
220 switch (style) {
221 case DlDrawStyle::kFill: return os << "Style::kFill";
222 case DlDrawStyle::kStroke: return os << "Style::kStroke";
223 case DlDrawStyle::kStrokeAndFill: return os << "Style::kStrokeAnFill";
224 }
225}
226
227std::ostream& operator<<(std::ostream& os, const DlBlurStyle& style) {
228 switch (style) {
229 case DlBlurStyle::kNormal: return os << "BlurStyle::kNormal";
230 case DlBlurStyle::kSolid: return os << "BlurStyle::kSolid";
231 case DlBlurStyle::kOuter: return os << "BlurStyle::kOuter";
232 case DlBlurStyle::kInner: return os << "BlurStyle::kInner";
233 }
234}
235
236std::ostream& operator<<(std::ostream& os, const flutter::DlPointMode& mode) {
237 switch (mode) {
238 case flutter::DlPointMode::kPoints: return os << "PointMode::kPoints";
239 case flutter::DlPointMode::kLines: return os << "PointMode::kLines";
240 case flutter::DlPointMode::kPolygon: return os << "PointMode::kPolygon";
241 }
242}
243
244std::ostream& operator<<(std::ostream& os, const DlFilterMode& mode) {
245 switch (mode) {
246 case DlFilterMode::kNearest: return os << "FilterMode::kNearest";
247 case DlFilterMode::kLinear: return os << "FilterMode::kLinear";
248
249 default: return os << "FilterMode::????";
250 }
251}
252
253std::ostream& operator<<(std::ostream& os, const DlColor& color) {
254 const char* color_space;
255 switch(color.getColorSpace()) {
257 color_space = "srgb";
258 break;
260 color_space = "srgb_xr";
261 break;
263 color_space = "p3";
264 break;
265 }
266 return os << "DlColor(" << //
267 color.getAlphaF() << ", " << //
268 color.getRedF() << ", " << //
269 color.getGreenF() << ", " << //
270 color.getBlueF() << ", " << //
271 color_space << ")";
272}
273
274std::ostream& operator<<(std::ostream& os, DlImageSampling sampling) {
275 switch (sampling) {
276 case DlImageSampling::kNearestNeighbor: {
277 return os << "NearestSampling";
278 }
279 case DlImageSampling::kLinear: {
280 return os << "LinearSampling";
281 }
282 case DlImageSampling::kMipmapLinear: {
283 return os << "MipmapSampling";
284 }
285 case DlImageSampling::kCubic: {
286 return os << "CubicSampling";
287 }
288 }
289}
290
291static std::ostream& operator<<(std::ostream& os, const flutter::DlText* text) {
292 auto blob = text->GetTextBlob();
293 if (blob != nullptr) {
294 return os << "&SkTextBlob(ID: " << blob->uniqueID() << ", " << blob->bounds() << ")";
295 }
296 auto frame = text->GetTextFrame();
297 if (frame != nullptr) {
298 auto bounds = frame->GetBounds();
299 return os << "&TextFrame("
300 << bounds.GetLeft() << ", " << bounds.GetTop() << " => "
301 << bounds.GetRight() << ", " << bounds.GetBottom() << ")";
302 }
303 return os << "no text";
304}
305
306std::ostream& operator<<(std::ostream& os, const DlVertexMode& mode) {
307 switch (mode) {
308 case DlVertexMode::kTriangles: return os << "VertexMode::kTriangles";
309 case DlVertexMode::kTriangleStrip: return os << "VertexMode::kTriangleStrip";
310 case DlVertexMode::kTriangleFan: return os << "VertexMode::kTriangleFan";
311
312 default: return os << "VertexMode::????";
313 }
314}
315
316std::ostream& operator<<(std::ostream& os, const DlTileMode& mode) {
317 switch (mode) {
318 case DlTileMode::kClamp: return os << "TileMode::kClamp";
319 case DlTileMode::kRepeat: return os << "TileMode::kRepeat";
320 case DlTileMode::kMirror: return os << "TileMode::kMirror";
321 case DlTileMode::kDecal: return os << "TileMode::kDecal";
322
323 default: return os << "TileMode::????";
324 }
325}
326
327std::ostream& operator<<(std::ostream& os, const DlImage* image) {
328 if (image == nullptr) {
329 return os << "null image";
330 }
331 os << "&DlImage(" << image->width() << " x " << image->height() << ", ";
332 if (image->skia_image()) {
333 os << "skia(" << image->skia_image().get() << "), ";
334 }
335 if (image->impeller_texture()) {
336 os << "impeller(" << image->impeller_texture().get() << "), ";
337 }
338 return os << "isTextureBacked: " << image->isTextureBacked() << ")";
339}
340
341std::ostream& operator<<(std::ostream& os,
342 const flutter::DlImageFilter& filter) {
343 DisplayListStreamDispatcher(os, 0).out(filter);
344 return os;
345}
346
347std::ostream& operator<<(std::ostream& os,
348 const flutter::DlColorFilter& filter) {
349 DisplayListStreamDispatcher(os, 0).out(filter);
350 return os;
351}
352
353} // namespace std
354
355namespace flutter::testing {
356
357std::ostream& DisplayListStreamDispatcher::startl() {
358 for (int i = 0; i < cur_indent_; i++) {
359 os_ << " ";
360 }
361 return os_;
362}
363
364template <class T>
365std::ostream& DisplayListStreamDispatcher::out_array(std::string name, // NOLINT(performance-unnecessary-value-param)
366 int count,
367 const T array[]) {
368 if (array == nullptr || count < 0) {
369 return os_ << "no " << name;
370 }
371 os_ << name << "[" << count << "] = [" << std::endl;
372 indent();
373 indent();
374 for (int i = 0; i < count; i++) {
375 startl() << array[i] << "," << std::endl;
376 }
377 outdent();
378 startl() << "]";
379 outdent();
380 return os_;
381}
382
384 startl() << "setAntiAlias(" << aa << ");" << std::endl;
385}
387 startl() << "setStyle(" << style << ");" << std::endl;
388}
390 startl() << "setColor(" << color << ");" << std::endl;
391}
393 startl() << "setStrokeWidth(" << width << ");" << std::endl;
394}
396 startl() << "setStrokeMiter(" << limit << ");" << std::endl;
397}
399 startl() << "setStrokeCap(" << cap << ");" << std::endl;
400}
402 startl() << "setStrokeJoin(" << join << ");" << std::endl;
403}
405 if (source == nullptr) {
406 startl() << "setColorSource(no ColorSource);" << std::endl;
407 return;
408 }
409 startl() << "setColorSource(";
410 switch (source->type()) {
412 const DlImageColorSource* image_src = source->asImage();
413 FML_DCHECK(image_src);
414 os_ << "DlImageColorSource(image: " << image_src->image()
415 << ", hMode: " << image_src->horizontal_tile_mode()
416 << ", vMode: " << image_src->vertical_tile_mode()
417 << ", " << image_src->sampling()
418 << ", " << image_src->matrix_ptr()
419 << ")";
420 break;
421 }
423 const DlLinearGradientColorSource* linear_src = source->asLinearGradient();
424 FML_DCHECK(linear_src);
425 os_ << "DlLinearGradientSource("
426 << "start: " << linear_src->start_point()
427 << ", end: " << linear_src->end_point() << ", ";
428 out_array("colors", linear_src->stop_count(), linear_src->colors()) << ", ";
429 out_array("stops", linear_src->stop_count(), linear_src->stops()) << ", "
430 << linear_src->tile_mode() << ", " << linear_src->matrix_ptr() << ")";
431 break;
432 }
434 const DlRadialGradientColorSource* radial_src = source->asRadialGradient();
435 FML_DCHECK(radial_src);
436 os_ << "DlRadialGradientSource("
437 << "center: " << radial_src->center()
438 << ", radius: " << radial_src->radius() << ", ";
439 out_array("colors", radial_src->stop_count(), radial_src->colors()) << ", ";
440 out_array("stops", radial_src->stop_count(), radial_src->stops()) << ", "
441 << radial_src->tile_mode() << ", " << radial_src->matrix_ptr() << ")";
442 break;
443 }
445 const DlConicalGradientColorSource* conical_src = source->asConicalGradient();
446 FML_DCHECK(conical_src);
447 os_ << "DlConicalGradientColorSource("
448 << "start center: " << conical_src->start_center()
449 << ", start radius: " << conical_src->start_radius()
450 << ", end center: " << conical_src->end_center()
451 << ", end radius: " << conical_src->end_radius() << ", ";
452 out_array("colors", conical_src->stop_count(), conical_src->colors()) << ", ";
453 out_array("stops", conical_src->stop_count(), conical_src->stops()) << ", "
454 << conical_src->tile_mode() << ", " << conical_src->matrix_ptr() << ")";
455 break;
456 }
458 const DlSweepGradientColorSource* sweep_src = source->asSweepGradient();
459 FML_DCHECK(sweep_src);
460 os_ << "DlSweepGradientColorSource("
461 << "center: " << sweep_src->center()
462 << ", start: " << sweep_src->start() << ", "
463 << ", end: " << sweep_src->end() << ", ";
464 out_array("colors", sweep_src->stop_count(), sweep_src->colors()) << ", ";
465 out_array("stops", sweep_src->stop_count(), sweep_src->stops()) << ", "
466 << sweep_src->tile_mode() << ", " << sweep_src->matrix_ptr() << ")";
467 break;
468 }
469 default:
470 os_ << "?DlUnknownColorSource?()";
471 break;
472 }
473 os_ << ");" << std::endl;
474}
476 switch (filter.type()) {
478 const DlBlendColorFilter* blend = filter.asBlend();
479 FML_DCHECK(blend);
480 os_ << "DlBlendColorFilter(" << blend->color() << ", "
481 << static_cast<int>(blend->mode()) << ")";
482 break;
483 }
485 const DlMatrixColorFilter* matrix = filter.asMatrix();
486 FML_DCHECK(matrix);
487 float values[20];
488 matrix->get_matrix(values);
489 os_ << "DlMatrixColorFilter(matrix[20] = [" << std::endl;
490 indent();
491 for (int i = 0; i < 20; i += 5) {
492 startl() << values[i] << ", "
493 << values[i+1] << ", "
494 << values[i+2] << ", "
495 << values[i+3] << ", "
496 << values[i+4] << ","
497 << std::endl;
498 }
499 outdent();
500 startl() << "]";
501 break;
502 }
504 os_ << "DlSrgbToLinearGammaColorFilter()";
505 break;
506 }
508 os_ << "DlLinearToSrgbGammaColorFilter()";
509 break;
510 }
511 default:
512 os_ << "?DlUnknownColorFilter?()";
513 break;
514 }
515}
517 if (filter == nullptr) {
518 os_ << "no ColorFilter";
519 } else {
520 os_ << "&";
521 out(*filter);
522 }
523}
525 startl() << "setColorFilter(";
526 out(filter);
527 os_ << ");" << std::endl;
528}
530 startl() << "setInvertColors(" << invert << ");" << std::endl;
531}
533 startl() << "setBlendMode(" << mode << ");" << std::endl;
534}
536 if (filter == nullptr) {
537 startl() << "setMaskFilter(no MaskFilter);" << std::endl;
538 return;
539 }
540 startl() << "setMaskFilter(";
541 switch (filter->type()) {
543 const DlBlurMaskFilter* blur = filter->asBlur();
544 FML_DCHECK(blur);
545 os_ << "DlMaskFilter(" << blur->style() << ", " << blur->sigma() << ")";
546 break;
547 }
548 default:
549 os_ << "?DlUnknownMaskFilter?()";
550 break;
551 }
552 os_ << ");" << std::endl;
553}
555 switch (filter.type()) {
557 const DlBlurImageFilter* blur = filter.asBlur();
558 FML_DCHECK(blur);
559 os_ << "DlBlurImageFilter(" << blur->sigma_x() << ", "
560 << blur->sigma_y() << ", "
561 << blur->tile_mode() << ")";
562 break;
563 }
565 const DlDilateImageFilter* dilate = filter.asDilate();
566 FML_DCHECK(dilate);
567 os_ << "DlDilateImageFilter(" << dilate->radius_x() << ", " << dilate->radius_y() << ")";
568 break;
569 }
571 const DlErodeImageFilter* erode = filter.asErode();
572 FML_DCHECK(erode);
573 os_ << "DlErodeImageFilter(" << erode->radius_x() << ", " << erode->radius_y() << ")";
574 break;
575 }
577 const DlMatrixImageFilter* matrix = filter.asMatrix();
578 FML_DCHECK(matrix);
579 os_ << "DlMatrixImageFilter(" << matrix->matrix() << ", " << matrix->sampling() << ")";
580 break;
581 }
583 const DlComposeImageFilter* compose = filter.asCompose();
584 FML_DCHECK(compose);
585 os_ << "DlComposeImageFilter(" << std::endl;
586 indent();
587 startl() << "outer: ";
588 indent(7);
589 out(compose->outer().get());
590 os_ << "," << std::endl;
591 outdent(7);
592 startl() << "inner: ";
593 indent(7);
594 out(compose->inner().get());
595 os_ << std::endl;
596 outdent(7);
597 outdent();
598 startl() << ")";
599 break;
600 }
602 const DlColorFilterImageFilter* color_filter = filter.asColorFilter();
603 FML_DCHECK(color_filter);
604 os_ << "DlColorFilterImageFilter(";
605 out(*color_filter->color_filter());
606 os_ << ")";
607 break;
608 }
610 const DlLocalMatrixImageFilter* local_matrix = filter.asLocalMatrix();
611 FML_DCHECK(local_matrix);
612 os_ << "DlLocalMatrixImageFilter(" << local_matrix->matrix();
613 os_ << "," << std::endl;
614 indent(25);
615 startl() << "filter: ";
616 out(local_matrix->image_filter().get());
617 os_ << std::endl;
618 outdent(25);
619 startl() << ")";
620 break;
621 }
623 [[maybe_unused]] const DlRuntimeEffectImageFilter* runtime_effect = filter.asRuntimeEffectFilter();
624 FML_DCHECK(runtime_effect);
625 os_ << "DlRuntimeEffectImageFilter(";
626 os_ << runtime_effect->samplers().size() << " samplers, ";
627 os_ << runtime_effect->uniform_data()->size() << " uniform bytes)";
628 break;
629 }
630 }
631}
633 if (filter == nullptr) {
634 os_ << "no ImageFilter";
635 } else {
636 os_ << "&";
637 indent(1);
638 out(*filter);
639 outdent(1);
640 }
641}
642DisplayListStreamDispatcher::DlPathStreamer::~DlPathStreamer() {
643 if (done_with_info_) {
644 dispatcher_.outdent(2);
645 dispatcher_.startl() << "}" << std::endl;
646 }
647}
648void DisplayListStreamDispatcher::DlPathStreamer::MoveTo(const DlPoint& p2,
649 bool will_be_closed) {
650 if (!done_with_info_) {
651 done_with_info_ = true;
652 dispatcher_.startl() << "{" << std::endl;
653 dispatcher_.indent(2);
654 }
655 dispatcher_.startl() << "MoveTo(" << p2 << ", " << will_be_closed << "),"
656 << std::endl;
657}
658void DisplayListStreamDispatcher::DlPathStreamer::LineTo(const DlPoint& p2) {
659 FML_DCHECK(done_with_info_);
660 dispatcher_.startl() << "LineTo(" << p2 << ")," << std::endl;
661}
662void DisplayListStreamDispatcher::DlPathStreamer::QuadTo(const DlPoint& cp,
663 const DlPoint& p2) {
664 FML_DCHECK(done_with_info_);
665 dispatcher_.startl() << "QuadTo(" << cp << ", " << p2 << ")," << std::endl;
666}
667bool DisplayListStreamDispatcher::DlPathStreamer::ConicTo(const DlPoint& cp,
668 const DlPoint& p2,
669 DlScalar weight) {
670 FML_DCHECK(done_with_info_);
671 dispatcher_.startl() << "ConicTo(" << cp << ", " << p2 << ", " << weight
672 << ")," << std::endl;
673 return true;
674}
675void DisplayListStreamDispatcher::DlPathStreamer::CubicTo(const DlPoint& cp1,
676 const DlPoint& cp2,
677 const DlPoint& p2) {
678 FML_DCHECK(done_with_info_);
679 dispatcher_.startl() << "CubicTo(" << cp1 << ", " << cp2 << ", " << p2 << ", "
680 << p2 << ")," << std::endl;
681}
682void DisplayListStreamDispatcher::DlPathStreamer::Close() {
683 FML_DCHECK(done_with_info_);
684 dispatcher_.startl() << "Close()," << std::endl;
685}
687 os_ << "DlPath(" << path.path.GetFillType() << ", ";
688 if (path.path.IsConvex()) {
689 os_ << "(convex), ";
690 }
691 os_ << path.path.GetBounds() << "," << std::endl;
692 indent(2);
693 {
694 DlPathStreamer streamer(*this);
695 path.path.Dispatch(streamer);
696 }
697 outdent(2);
698 os_ << ")";
699}
701 startl() << "setImageFilter(";
702 indent(15);
703 out(filter);
704 outdent(15);
705 os_ << ");" << std::endl;
706}
708 startl() << "save();" << std::endl;
709 startl() << "{" << std::endl;
710 indent();
711}
713 const SaveLayerOptions options,
714 const DlImageFilter* backdrop,
715 std::optional<int64_t> backdrop_id) {
716 startl() << "saveLayer(" << bounds << ", " << options;
717 if (backdrop) {
718 os_ << "," << std::endl;
719 indent(10);
720 if (backdrop_id.has_value()) {
721 startl() << "backdrop: " << backdrop_id.value() << ", ";
722 } else {
723 startl() << "backdrop: (no id), ";
724 }
725 out(backdrop);
726 outdent(10);
727 } else {
728 os_ << ", no backdrop";
729 }
730 os_ << ");" << std::endl;
731 startl() << "{" << std::endl;
732 indent();
733}
735 outdent();
736 startl() << "}" << std::endl;
737 startl() << "restore();" << std::endl;
738}
739
741 startl() << "translate(" << tx << ", " << ty << ");" << std::endl;
742}
744 startl() << "scale(" << sx << ", " << sy << ");" << std::endl;
745}
747 startl() << "rotate(" << degrees << ");" << std::endl;
748}
750 startl() << "skew(" << sx << ", " << sy << ");" << std::endl;
751}
753 DlScalar mxx, DlScalar mxy, DlScalar mxt,
754 DlScalar myx, DlScalar myy, DlScalar myt) {
755 startl() << "transform2DAffine(" << std::endl;
756 indent();
757 {
758 startl()
759 << "[" << mxx << ", " << mxy << ", " << mxt << "], "
760 << std::endl;
761 startl()
762 << "[" << myx << ", " << myy << ", " << myt << "], "
763 << std::endl;
764 }
765 outdent();
766 startl() << ");" << std::endl;
767}
769 DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt,
770 DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt,
771 DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt,
772 DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) {
773 startl() << "transformFullPerspective(" << std::endl;
774 indent();
775 {
776 startl()
777 << "[" << mxx << ", " << mxy << ", " << mxz << ", " << mxt << "], "
778 << std::endl;
779 startl()
780 << "[" << myx << ", " << myy << ", " << myz << ", " << myt << "], "
781 << std::endl;
782 startl()
783 << "[" << mzx << ", " << mzy << ", " << mzz << ", " << mzt << "], "
784 << std::endl;
785 startl()
786 << "[" << mwx << ", " << mwy << ", " << mwz << ", " << mwt << "]"
787 << std::endl;
788 }
789 outdent();
790 startl() << ");" << std::endl;
791}
793 startl() << "transformReset();" << std::endl;
794}
795
797 bool is_aa) {
798 startl() << "clipRect("
799 << rect << ", "
800 << clip_op << ", "
801 << "isaa: " << is_aa
802 << ");" << std::endl;
803}
805 bool is_aa) {
806 startl() << "clipOval("
807 << bounds << ", "
808 << clip_op << ", "
809 << "isaa: " << is_aa
810 << ");" << std::endl;
811}
813 DlClipOp clip_op,
814 bool is_aa) {
815 startl() << "clipRRect("
816 << rrect << ", "
817 << clip_op << ", "
818 << "isaa: " << is_aa
819 << ");" << std::endl;
820}
822 DlClipOp clip_op,
823 bool is_aa) {
824 startl() << "clipRoundSuperellipse("
825 << rse << ", "
826 << clip_op << ", "
827 << "isaa: " << is_aa
828 << ");" << std::endl;
829}
831 bool is_aa) {
832 startl() << "clipPath("
833 << path << ", "
834 << clip_op << ", "
835 << "isaa: " << is_aa
836 << ");" << std::endl;
837}
838
840 startl() << "drawColor("
841 << color << ", "
842 << mode
843 << ");" << std::endl;
844}
846 startl() << "drawPaint();" << std::endl;
847}
849 const DlPoint& p1) {
850 startl() << "drawLine(" << p0 << ", " << p1 << ");" << std::endl;
851}
853 const DlPoint& p1,
854 DlScalar on_length,
855 DlScalar off_length) {
856 startl() << "drawDashedLine("
857 << p0 << ", "
858 << p1 << ", "
859 << on_length << ", "
860 << off_length
861 << ");" << std::endl;
862}
864 startl() << "drawRect(" << rect << ");" << std::endl;
865}
867 startl() << "drawOval(" << bounds << ");" << std::endl;
868}
870 DlScalar radius) {
871 startl() << "drawCircle(" << center << ", " << radius << ");" << std::endl;
872}
874 startl() << "drawRRect(" << rrect << ");" << std::endl;
875}
877 const DlRoundRect& inner) {
878 startl() << "drawDRRect(outer: " << outer << ", " << std::endl;
879 startl() << " inner: " << inner << ");" << std::endl;
880}
882 startl() << "drawRSuperellipse(" << rse << ");" << std::endl;
883}
885 startl() << "drawPath(" << path << ");" << std::endl;
886}
888 DlScalar start_degrees,
889 DlScalar sweep_degrees,
890 bool use_center) {
891 startl() << "drawArc("
892 << oval_bounds << ", "
893 << start_degrees << ", "
894 << sweep_degrees << ", "
895 << "use_center: " << use_center
896 << ");" << std::endl;
897}
899 uint32_t count,
900 const DlPoint points[]) {
901 startl() << "drawPoints(" << mode << ", ";
902 out_array("points", count, points)
903 << ");" << std::endl;
904}
905void DisplayListStreamDispatcher::drawVertices(const std::shared_ptr<DlVertices>& vertices,
906 DlBlendMode mode) {
907 startl() << "drawVertices("
908 << "DlVertices("
909 << vertices->mode() << ", ";
910 out_array("vertices", vertices->vertex_count(), vertices->vertex_data()) << ", ";
911 out_array("texture_coords", vertices->vertex_count(), vertices->texture_coordinate_data()) << ", ";
912 out_array("colors", vertices->vertex_count(), vertices->colors()) << ", ";
913 out_array("indices", vertices->index_count(), vertices->indices())
914 << "), " << mode << ");" << std::endl;
915}
917 const DlPoint& point,
918 DlImageSampling sampling,
919 bool render_with_attributes) {
920 startl() << "drawImage(" << image.get() << "," << std::endl;
921 startl() << " " << point << ", "
922 << sampling << ", "
923 << "with attributes: " << render_with_attributes
924 << ");" << std::endl;
925}
927 const DlRect& src,
928 const DlRect& dst,
929 DlImageSampling sampling,
930 bool render_with_attributes,
931 DlSrcRectConstraint constraint) {
932 startl() << "drawImageRect(" << image.get() << "," << std::endl;
933 startl() << " src: " << src << "," << std::endl;
934 startl() << " dst: " << dst << "," << std::endl;
935 startl() << " " << sampling << ", "
936 << "with attributes: " << render_with_attributes << ", "
937 << constraint
938 << ");" << std::endl;
939}
941 const DlIRect& center,
942 const DlRect& dst,
943 DlFilterMode filter,
944 bool render_with_attributes) {
945 startl() << "drawImageNine(" << image.get() << "," << std::endl;
946 startl() << " center: " << center << "," << std::endl;
947 startl() << " dst: " << dst << "," << std::endl;
948 startl() << " " << filter << ", "
949 << "with attributes: " << render_with_attributes
950 << ");" << std::endl;
951}
952void DisplayListStreamDispatcher::drawAtlas(const sk_sp<DlImage> atlas,
953 const DlRSTransform xform[],
954 const DlRect tex[],
955 const DlColor colors[],
956 int count,
957 DlBlendMode mode,
958 DlImageSampling sampling,
959 const DlRect* cull_rect,
960 bool render_with_attributes) {
961 startl() << "drawAtlas(" << atlas.get() << ", ";
962 out_array("xforms", count, xform) << ", ";
963 out_array("tex_coords", count, tex) << ", ";
964 out_array("colors", count, colors) << ", "
965 << mode << ", " << sampling << ", cull: " << cull_rect << ", "
966 << "with attributes: " << render_with_attributes
967 << ");" << std::endl;
968}
970 const sk_sp<DisplayList> display_list, DlScalar opacity) {
971 startl() << "drawDisplayList("
972 << "ID: " << display_list->unique_id() << ", "
973 << "bounds: " << display_list->GetBounds() << ", "
974 << "opacity: " << opacity
975 << ");" << std::endl;
976}
977void DisplayListStreamDispatcher::drawText(const std::shared_ptr<DlText>& text,
978 DlScalar x,
979 DlScalar y) {
980 startl() << "drawText("
981 << text.get() << ", "
982 << x << ", " << y << ");" << std::endl;
983}
984
986 const DlColor color,
987 const DlScalar elevation,
988 bool transparent_occluder,
989 DlScalar dpr) {
990 startl() << "drawShadow("
991 << path << ", "
992 << color << ", "
993 << elevation << ", "
994 << transparent_occluder << ", "
995 << dpr
996 << ");" << std::endl;
997}
998// clang-format on
999
1000} // namespace flutter::testing
GLenum type
bool Equals(const DisplayList *other) const
void Dispatch(DlOpReceiver &ctx) const
virtual T type() const =0
DlBlurStyle style() const
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:32
virtual const DlBlendColorFilter * asBlend() const
virtual const DlMatrixColorFilter * asMatrix() const
const std::shared_ptr< const DlColorFilter > color_filter() const
virtual const DlRadialGradientColorSource * asRadialGradient() const
virtual const DlLinearGradientColorSource * asLinearGradient() const
virtual const DlImageColorSource * asImage() const
virtual const DlSweepGradientColorSource * asSweepGradient() const
virtual const DlConicalGradientColorSource * asConicalGradient() const
std::shared_ptr< DlImageFilter > inner() const
std::shared_ptr< DlImageFilter > outer() const
DlImageSampling sampling() const
DlTileMode horizontal_tile_mode() const
sk_sp< const DlImage > image() const
virtual const DlLocalMatrixImageFilter * asLocalMatrix() const
virtual const DlColorFilterImageFilter * asColorFilter() const
virtual const DlRuntimeEffectImageFilter * asRuntimeEffectFilter() const
virtual const DlMatrixImageFilter * asMatrix() const
virtual const DlComposeImageFilter * asCompose() const
virtual const DlBlurImageFilter * asBlur() const
virtual const DlDilateImageFilter * asDilate() const
virtual const DlErodeImageFilter * asErode() const
Represents an image whose allocation is (usually) resident on device memory.
Definition dl_image.h:32
const std::shared_ptr< DlImageFilter > image_filter() const
virtual const DlBlurMaskFilter * asBlur() const
void get_matrix(float matrix[20]) const
const DlMatrix & matrix() const
bool isAntiAlias() const
Definition dl_paint.h:57
DlStrokeCap getStrokeCap() const
Definition dl_paint.h:98
DlColor getColor() const
Definition dl_paint.h:69
DlBlendMode getBlendMode() const
Definition dl_paint.h:82
float getStrokeMiter() const
Definition dl_paint.h:120
DlStrokeJoin getStrokeJoin() const
Definition dl_paint.h:106
const std::shared_ptr< const DlMaskFilter > & getMaskFilter() const
Definition dl_paint.h:180
DlDrawStyle getDrawStyle() const
Definition dl_paint.h:90
const std::shared_ptr< const DlColorSource > & getColorSource() const
Definition dl_paint.h:126
const std::shared_ptr< DlImageFilter > & getImageFilter() const
Definition dl_paint.h:162
float getStrokeWidth() const
Definition dl_paint.h:114
const std::shared_ptr< const DlColorFilter > & getColorFilter() const
Definition dl_paint.h:144
bool isInvertColors() const
Definition dl_paint.h:63
const std::shared_ptr< std::vector< uint8_t > > & uniform_data() const
const std::vector< std::shared_ptr< DlColorSource > > & samplers() const
bool renders_with_attributes() const
bool content_is_unbounded() const
bool contains_backdrop_filter() const
bool can_distribute_opacity() const
void drawVertices(const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode) override
void drawShadow(const DlPath &path, const DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr) override
void drawImageNine(const sk_sp< DlImage > image, const DlIRect &center, const DlRect &dst, DlFilterMode filter, bool render_with_attributes) override
void clipRect(const DlRect &rect, DlClipOp clip_op, bool is_aa) override
void drawCircle(const DlPoint &center, DlScalar radius) override
void setImageFilter(const DlImageFilter *filter) override
void drawArc(const DlRect &oval_bounds, DlScalar start_degrees, DlScalar sweep_degrees, bool use_center) override
void transform2DAffine(DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt) override
void drawText(const std::shared_ptr< DlText > &text, DlScalar x, DlScalar y) override
void drawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity) override
void drawPoints(DlPointMode mode, uint32_t count, const DlPoint points[]) override
void drawImageRect(const sk_sp< DlImage > image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, bool render_with_attributes, DlSrcRectConstraint constraint) override
void drawImage(const sk_sp< DlImage > image, const DlPoint &point, DlImageSampling sampling, bool render_with_attributes) override
void setMaskFilter(const DlMaskFilter *filter) override
void clipPath(const DlPath &path, DlClipOp clip_op, bool is_aa) override
void clipRoundSuperellipse(const DlRoundSuperellipse &rse, DlClipOp clip_op, bool is_aa) override
void clipRoundRect(const DlRoundRect &rrect, DlClipOp clip_op, bool is_aa) override
void drawAtlas(const sk_sp< DlImage > atlas, const DlRSTransform xform[], const DlRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const DlRect *cull_rect, bool render_with_attributes) override
void drawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length) override
void drawRoundRect(const DlRoundRect &rrect) override
void clipOval(const DlRect &bounds, DlClipOp clip_op, bool is_aa) override
void transformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override
void setColorFilter(const DlColorFilter *filter) override
void drawDiffRoundRect(const DlRoundRect &outer, const DlRoundRect &inner) override
void drawOval(const DlRect &bounds) override
void saveLayer(const DlRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop, std::optional< int64_t > backdrop_id) override
void skew(DlScalar sx, DlScalar sy) override
void drawRoundSuperellipse(const DlRoundSuperellipse &rse) override
void drawLine(const DlPoint &p0, const DlPoint &p1) override
void drawColor(DlColor color, DlBlendMode mode) override
void translate(DlScalar tx, DlScalar ty) override
void scale(DlScalar sx, DlScalar sy) override
void setColorSource(const DlColorSource *source) override
#define FOR_EACH_DISPLAY_LIST_OP(V)
#define DLT_OSTREAM_CASE(enum_name, value_name)
#define DLT_OP_TYPE_CASE(V)
int32_t x
FlutterVulkanImage * image
#define FML_LOG(severity)
Definition logging.h:101
#define FML_DCHECK(condition)
Definition logging.h:122
std::u16string text
double y
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
DisplayListOpCategory
DlStrokeCap
Definition dl_paint.h:28
DlPointMode
Definition dl_types.h:15
@ kLines
draw each separate pair of points as a line segment
@ kPolygon
draw each pair of overlapping points as a line segment
@ kPoints
draw each point separately
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 switch_defs.h:52
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
Definition dl_vertices.h:18
DlDrawStyle
Definition dl_paint.h:19
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
impeller::FillType DlPathFillType
Definition dl_path.h:16
impeller::BlendMode DlBlendMode
impeller::Point DlPoint
DlSrcRectConstraint
Definition dl_types.h:21
BlendMode
Definition color.h:58
Definition ref_ptr.h:261
flutter::testing::DisplayListStreamDispatcher DisplayListStreamDispatcher
std::ostream & operator<<(std::ostream &out, const impeller::Arc &a)
Definition arc.h:141
int32_t width
constexpr DlColorSpace getColorSpace() const
Definition dl_color.h:118
constexpr DlScalar getRedF() const
Definition dl_color.h:114
constexpr DlScalar getAlphaF() const
Definition dl_color.h:113
constexpr DlScalar getBlueF() const
Definition dl_color.h:116
constexpr DlScalar getGreenF() const
Definition dl_color.h:115
std::vector< Point > points