Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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
15
18
19namespace flutter::testing {
20
21// clang-format off
23 if (a->Equals(b)) {
24 return true;
25 }
26 FML_LOG(ERROR) << std::endl
27 << std::endl
28 << *a << std::endl
29 << "not identical to ..." << std::endl
30 << std::endl
31 << *b;
32 return false;
33}
34
36 if (a->Equals(b)) {
37 FML_LOG(ERROR) << std::endl
38 << "DisplayLists are both the same:" << std::endl
39 << *a;
40 return false;
41 }
42 return true;
43}
44
45} // namespace flutter::testing
46
47namespace std {
48
68
70
71std::ostream& operator<<(std::ostream& os,
72 const DisplayList& display_list) {
73 DisplayListStreamDispatcher dispatcher(os);
74 os << std::boolalpha;
75 os << std::setprecision(std::numeric_limits<double>::digits10 + 1);
76 os << "DisplayList {" << std::endl;
77 display_list.Dispatch(dispatcher);
78 os << "}" << std::endl;
79 return os;
80}
81
82std::ostream& operator<<(std::ostream& os, const DlPaint& paint) {
83 os << "DlPaint("
84 << "isaa: " << paint.isAntiAlias() << ", "
85 << paint.getColor() << ", "
86 << paint.getBlendMode() << ", "
87 << paint.getDrawStyle();
88 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
89 os << ", width: " << paint.getStrokeWidth()
90 << ", miter: " << paint.getStrokeMiter()
91 << ", " << paint.getStrokeCap()
92 << ", " << paint.getStrokeJoin();
93 }
94 if (paint.getColorSource()) {
95 os << ", " << paint.getColorSource();
96 }
97 if (paint.getColorFilter()) {
98 os << ", " << paint.getColorFilter();
99 }
100 if (paint.getImageFilter()) {
101 os << ", " << paint.getImageFilter();
102 }
103 if (paint.getMaskFilter()) {
104 os << ", " << paint.getMaskFilter();
105 }
106 if (paint.isInvertColors()) {
107 os << ", invertColors: " << paint.isInvertColors();
108 }
109 return os << ")";
110}
111
112#define DLT_OSTREAM_CASE(enum_name, value_name) \
113 case enum_name::k##value_name: return os << #enum_name "::k" #value_name
114
115extern std::ostream& operator<<(std::ostream& os,
117 switch (type) {
118#define DLT_OP_TYPE_CASE(V) DLT_OSTREAM_CASE(DisplayListOpType, V);
120 DLT_OP_TYPE_CASE(InvalidOp)
121
122#undef DLT_OP_TYPE_CASE
123 }
124 // Not a valid enum, should never happen, but in case we encounter bad data.
125 return os << "DisplayListOpType::???";
126}
127
128extern std::ostream& operator<<(
129 std::ostream& os, const flutter::DisplayListOpCategory& category) {
130 switch (category) {
139 DLT_OSTREAM_CASE(DisplayListOpCategory, InvalidCategory);
140 }
141 // Not a valid enum, should never happen, but in case we encounter bad data.
142 return os << "DisplayListOpCategory::???";
143}
144
145extern std::ostream& operator<<(
146 std::ostream& os, const flutter::DlPathFillType& type) {
147 switch (type) {
150 }
151}
152
153#undef DLT_OSTREAM_CASE
154
155std::ostream& operator<<(std::ostream& os, const SaveLayerOptions& options) {
156 return os << "SaveLayerOptions("
157 << "renders_with_attributes: " << options.renders_with_attributes()
158 << ", "
159 << "can_distribute_opacity: " << options.can_distribute_opacity()
160 << ", "
161 << "contains_backdrop: " << options.contains_backdrop_filter()
162 << ", "
163 << "is_unbounded: " << options.content_is_unbounded()
164 << ")";
165}
166
167static std::ostream& operator<<(std::ostream& os, const SkRect& rect) {
168 return os << "SkRect("
169 << "left: " << rect.fLeft << ", "
170 << "top: " << rect.fTop << ", "
171 << "right: " << rect.fRight << ", "
172 << "bottom: " << rect.fBottom
173 << ")";
174}
175
176extern std::ostream& operator<<(std::ostream& os, const DlPath& path) {
177 return os << "DlPath("
178 << "bounds: " << path.GetBounds()
179 // should iterate over verbs and coordinates...
180 << ")";
181}
182
183extern std::ostream& operator<<(std::ostream& os, const flutter::testing::DlVerbosePath& path) {
184 DisplayListStreamDispatcher dispatcher(os, 0);
185 dispatcher.out(path);
186 return os;
187}
188
189std::ostream& operator<<(std::ostream& os, const flutter::DlClipOp& op) {
190 switch (op) {
191 case flutter::DlClipOp::kDifference: return os << "DlClipOp::kDifference";
192 case flutter::DlClipOp::kIntersect: return os << "DlClipOp::kIntersect";
193 }
194}
195
196std::ostream& operator<<(std::ostream& os, const flutter::DlSrcRectConstraint& constraint) {
197 switch (constraint) {
199 return os << "SrcRectConstraint::kFast";
201 return os << "SrcRectConstraint::kStrict";
202 }
203}
204
205std::ostream& operator<<(std::ostream& os, const DlStrokeCap& cap) {
206 switch (cap) {
207 case DlStrokeCap::kButt: return os << "Cap::kButt";
208 case DlStrokeCap::kRound: return os << "Cap::kRound";
209 case DlStrokeCap::kSquare: return os << "Cap::kSquare";
210 }
211}
212
213std::ostream& operator<<(std::ostream& os, const DlStrokeJoin& join) {
214 switch (join) {
215 case DlStrokeJoin::kMiter: return os << "Join::kMiter";
216 case DlStrokeJoin::kRound: return os << "Join::kRound";
217 case DlStrokeJoin::kBevel: return os << "Join::kBevel";
218 }
219}
220
221std::ostream& operator<<(std::ostream& os, const DlDrawStyle& style) {
222 switch (style) {
223 case DlDrawStyle::kFill: return os << "Style::kFill";
224 case DlDrawStyle::kStroke: return os << "Style::kStroke";
225 case DlDrawStyle::kStrokeAndFill: return os << "Style::kStrokeAnFill";
226 }
227}
228
229std::ostream& operator<<(std::ostream& os, const DlBlurStyle& style) {
230 switch (style) {
231 case DlBlurStyle::kNormal: return os << "BlurStyle::kNormal";
232 case DlBlurStyle::kSolid: return os << "BlurStyle::kSolid";
233 case DlBlurStyle::kOuter: return os << "BlurStyle::kOuter";
234 case DlBlurStyle::kInner: return os << "BlurStyle::kInner";
235 }
236}
237
238std::ostream& operator<<(std::ostream& os, const flutter::DlPointMode& mode) {
239 switch (mode) {
240 case flutter::DlPointMode::kPoints: return os << "PointMode::kPoints";
241 case flutter::DlPointMode::kLines: return os << "PointMode::kLines";
242 case flutter::DlPointMode::kPolygon: return os << "PointMode::kPolygon";
243 }
244}
245
246std::ostream& operator<<(std::ostream& os, const DlFilterMode& mode) {
247 switch (mode) {
248 case DlFilterMode::kNearest: return os << "FilterMode::kNearest";
249 case DlFilterMode::kLinear: return os << "FilterMode::kLinear";
250
251 default: return os << "FilterMode::????";
252 }
253}
254
255std::ostream& operator<<(std::ostream& os, const DlColor& color) {
256 const char* color_space;
257 switch(color.getColorSpace()) {
259 color_space = "srgb";
260 break;
262 color_space = "srgb_xr";
263 break;
265 color_space = "p3";
266 break;
267 }
268 return os << "DlColor(" << //
269 color.getAlphaF() << ", " << //
270 color.getRedF() << ", " << //
271 color.getGreenF() << ", " << //
272 color.getBlueF() << ", " << //
273 color_space << ")";
274}
275
276std::ostream& operator<<(std::ostream& os, DlImageSampling sampling) {
277 switch (sampling) {
278 case DlImageSampling::kNearestNeighbor: {
279 return os << "NearestSampling";
280 }
281 case DlImageSampling::kLinear: {
282 return os << "LinearSampling";
283 }
284 case DlImageSampling::kMipmapLinear: {
285 return os << "MipmapSampling";
286 }
287 case DlImageSampling::kCubic: {
288 return os << "CubicSampling";
289 }
290 }
291}
292
293static std::ostream& operator<<(std::ostream& os, const flutter::DlText* text) {
294 auto blob = text->GetTextBlob();
295 if (blob != nullptr) {
296 return os << "&SkTextBlob(ID: " << blob->uniqueID() << ", " << blob->bounds() << ")";
297 }
298 auto frame = text->GetTextFrame();
299 if (frame != nullptr) {
300 auto bounds = frame->GetBounds();
301 return os << "&TextFrame("
302 << bounds.GetLeft() << ", " << bounds.GetTop() << " => "
303 << bounds.GetRight() << ", " << bounds.GetBottom() << ")";
304 }
305 return os << "no text";
306}
307
308std::ostream& operator<<(std::ostream& os, const DlVertexMode& mode) {
309 switch (mode) {
310 case DlVertexMode::kTriangles: return os << "VertexMode::kTriangles";
311 case DlVertexMode::kTriangleStrip: return os << "VertexMode::kTriangleStrip";
312 case DlVertexMode::kTriangleFan: return os << "VertexMode::kTriangleFan";
313
314 default: return os << "VertexMode::????";
315 }
316}
317
318std::ostream& operator<<(std::ostream& os, const DlTileMode& mode) {
319 switch (mode) {
320 case DlTileMode::kClamp: return os << "TileMode::kClamp";
321 case DlTileMode::kRepeat: return os << "TileMode::kRepeat";
322 case DlTileMode::kMirror: return os << "TileMode::kMirror";
323 case DlTileMode::kDecal: return os << "TileMode::kDecal";
324
325 default: return os << "TileMode::????";
326 }
327}
328
329std::ostream& operator<<(std::ostream& os, const DlImage* image) {
330 if (image == nullptr) {
331 return os << "null image";
332 }
333 os << "&DlImage(" << image->width() << " x " << image->height() << ", ";
334 auto skia_image = image->asSkiaImage();
335 if (skia_image && skia_image->skia_image()) {
336 os << "skia(" << skia_image->skia_image().get() << "), ";
337 }
338 return os << "type: " << (image->GetImageType() == DlImage::Type::kSkia ? "Skia" : "Impeller") << ")";
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,
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
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:34
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
impeller::ShaderType type
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