Flutter Engine
The Flutter Engine
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
5#include "flutter/testing/display_list_testing.h"
6
7#include <iomanip>
8
9#include "flutter/display_list/display_list.h"
10
11namespace flutter {
12namespace testing {
13
14// clang-format off
16 if (a->Equals(b)) {
17 return true;
18 }
19 FML_LOG(ERROR) << std::endl
20 << std::endl
21 << *a << std::endl
22 << "not identical to ..." << std::endl
23 << std::endl
24 << *b;
25 return false;
26}
27
29 if (a->Equals(b)) {
30 FML_LOG(ERROR) << std::endl
31 << "DisplayLists are both the same:" << std::endl
32 << *a;
33 return false;
34 }
35 return true;
36}
37
38} // namespace testing
39} // namespace flutter
40
41namespace std {
42
58
60
61std::ostream& operator<<(std::ostream& os,
62 const DisplayList& display_list) {
63 DisplayListStreamDispatcher dispatcher(os);
64 os << std::boolalpha;
65 os << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
66 os << "DisplayList {" << std::endl;
67 display_list.Dispatch(dispatcher);
68 os << "}" << std::endl;
69 return os;
70}
71
72std::ostream& operator<<(std::ostream& os, const DlPaint& paint) {
73 os << "DlPaint("
74 << "isaa: " << paint.isAntiAlias() << ", "
75 << paint.getColor() << ", "
76 << paint.getBlendMode() << ", "
77 << paint.getDrawStyle();
78 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
79 os << ", width: " << paint.getStrokeWidth()
80 << ", miter: " << paint.getStrokeMiter()
81 << ", " << paint.getStrokeCap()
82 << ", " << paint.getStrokeJoin();
83 }
84 if (paint.getColorSource()) {
85 os << ", " << paint.getColorSource();
86 }
87 if (paint.getColorFilter()) {
88 os << ", " << paint.getColorFilter();
89 }
90 if (paint.getImageFilter()) {
91 os << ", " << paint.getImageFilter();
92 }
93 if (paint.getMaskFilter()) {
94 os << ", " << paint.getMaskFilter();
95 }
96 if (paint.isInvertColors()) {
97 os << ", invertColors: " << paint.isInvertColors();
98 }
99 return os << ")";
100}
101
102std::ostream& operator<<(std::ostream& os, const DlBlendMode& mode) {
103 switch (mode) {
104 case DlBlendMode::kClear: return os << "BlendMode::kClear";
105 case DlBlendMode::kSrc: return os << "BlendMode::kSrc";
106 case DlBlendMode::kDst: return os << "BlendMode::kDst";
107 case DlBlendMode::kSrcOver: return os << "BlendMode::kSrcOver";
108 case DlBlendMode::kDstOver: return os << "BlendMode::kDstOver";
109 case DlBlendMode::kSrcIn: return os << "BlendMode::kSrcIn";
110 case DlBlendMode::kDstIn: return os << "BlendMode::kDstIn";
111 case DlBlendMode::kSrcOut: return os << "BlendMode::kSrcOut";
112 case DlBlendMode::kDstOut: return os << "BlendMode::kDstOut";
113 case DlBlendMode::kSrcATop: return os << "BlendMode::kSrcATop";
114 case DlBlendMode::kDstATop: return os << "BlendMode::kDstATop";
115 case DlBlendMode::kXor: return os << "BlendMode::kXor";
116 case DlBlendMode::kPlus: return os << "BlendMode::kPlus";
117 case DlBlendMode::kModulate: return os << "BlendMode::kModulate";
118 case DlBlendMode::kScreen: return os << "BlendMode::kScreen";
119
120 case DlBlendMode::kOverlay: return os << "BlendMode::kOverlay";
121 case DlBlendMode::kDarken: return os << "BlendMode::kDarken";
122 case DlBlendMode::kLighten: return os << "BlendMode::kLighten";
123 case DlBlendMode::kColorDodge: return os << "BlendMode::kColorDodge";
124 case DlBlendMode::kColorBurn: return os << "BlendMode::kColorBurn";
125 case DlBlendMode::kHardLight: return os << "BlendMode::kHardLight";
126 case DlBlendMode::kSoftLight: return os << "BlendMode::kSoftLight";
127 case DlBlendMode::kDifference: return os << "BlendMode::kDifference";
128 case DlBlendMode::kExclusion: return os << "BlendMode::kExclusion";
129 case DlBlendMode::kMultiply: return os << "BlendMode::kMultiply";
130
131 case DlBlendMode::kHue: return os << "BlendMode::kHue";
132 case DlBlendMode::kSaturation: return os << "BlendMode::kSaturation";
133 case DlBlendMode::kColor: return os << "BlendMode::kColor";
134 case DlBlendMode::kLuminosity: return os << "BlendMode::kLuminosity";
135
136 default: return os << "BlendMode::????";
137 }
138}
139
140std::ostream& operator<<(std::ostream& os, const SaveLayerOptions& options) {
141 return os << "SaveLayerOptions("
142 << "renders_with_attributes: " << options.renders_with_attributes()
143 << ", "
144 << "can_distribute_opacity: " << options.can_distribute_opacity()
145 << ", "
146 << "contains_backdrop: " << options.contains_backdrop_filter()
147 << ")";
148}
149
150static std::ostream& operator<<(std::ostream& os, const SkPoint& point) {
151 return os << "SkPoint(" << point.fX << ", " << point.fY << ")";
152}
153
154static std::ostream& operator<<(std::ostream& os, const SkIRect& rect) {
155 return os << "SkIRect("
156 << "left: " << rect.fLeft << ", "
157 << "top: " << rect.fTop << ", "
158 << "right: " << rect.fRight << ", "
159 << "bottom: " << rect.fBottom
160 << ")";
161}
162
163static std::ostream& operator<<(std::ostream& os, const SkRect& rect) {
164 return os << "SkRect("
165 << "left: " << rect.fLeft << ", "
166 << "top: " << rect.fTop << ", "
167 << "right: " << rect.fRight << ", "
168 << "bottom: " << rect.fBottom
169 << ")";
170}
171
172static std::ostream& operator<<(std::ostream& os, const SkRect* rect) {
173 return rect ? (os << "&" << *rect) : os << "no rect";
174}
175
176static std::ostream& operator<<(std::ostream& os, const SkRRect& rrect) {
177 return os << "SkRRect("
178 << rrect.rect() << ", "
179 << "ul: (" << rrect.radii(SkRRect::kUpperLeft_Corner).fX << ", "
181 << "ur: (" << rrect.radii(SkRRect::kUpperRight_Corner).fX << ", "
183 << "lr: (" << rrect.radii(SkRRect::kLowerRight_Corner).fX << ", "
185 << "ll: (" << rrect.radii(SkRRect::kLowerLeft_Corner).fX << ", "
187 << ")";
188}
189
190static std::ostream& operator<<(std::ostream& os, const SkPath& path) {
191 return os << "SkPath("
192 << "bounds: " << path.getBounds()
193 // should iterate over verbs and coordinates...
194 << ")";
195}
196
197static std::ostream& operator<<(std::ostream& os, const SkMatrix& matrix) {
198 return os << "SkMatrix("
199 << "[" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << "], "
200 << "[" << matrix[3] << ", " << matrix[4] << ", " << matrix[5] << "], "
201 << "[" << matrix[6] << ", " << matrix[7] << ", " << matrix[8] << "]"
202 << ")";
203}
204
205static std::ostream& operator<<(std::ostream& os, const SkMatrix* matrix) {
206 if (matrix) return os << "&" << *matrix;
207 return os << "no matrix";
208}
209
210static std::ostream& operator<<(std::ostream& os, const SkRSXform& xform) {
211 return os << "SkRSXform("
212 << "scos: " << xform.fSCos << ", "
213 << "ssin: " << xform.fSSin << ", "
214 << "tx: " << xform.fTx << ", "
215 << "ty: " << xform.fTy << ")";
216}
217
218std::ostream& operator<<(std::ostream& os, const DlCanvas::ClipOp& op) {
219 switch (op) {
220 case DlCanvas::ClipOp::kDifference: return os << "ClipOp::kDifference";
221 case DlCanvas::ClipOp::kIntersect: return os << "ClipOp::kIntersect";
222 }
223}
224
225std::ostream& operator<<(std::ostream& os, const DlCanvas::SrcRectConstraint& constraint) {
226 switch (constraint) {
228 return os << "SrcRectConstraint::kFast";
230 return os << "SrcRectConstraint::kStrict";
231 }
232}
233
234std::ostream& operator<<(std::ostream& os, const DlStrokeCap& cap) {
235 switch (cap) {
236 case DlStrokeCap::kButt: return os << "Cap::kButt";
237 case DlStrokeCap::kRound: return os << "Cap::kRound";
238 case DlStrokeCap::kSquare: return os << "Cap::kSquare";
239 }
240}
241
242std::ostream& operator<<(std::ostream& os, const DlStrokeJoin& join) {
243 switch (join) {
244 case DlStrokeJoin::kMiter: return os << "Join::kMiter";
245 case DlStrokeJoin::kRound: return os << "Join::kRound";
246 case DlStrokeJoin::kBevel: return os << "Join::kBevel";
247 }
248}
249
250std::ostream& operator<<(std::ostream& os, const DlDrawStyle& style) {
251 switch (style) {
252 case DlDrawStyle::kFill: return os << "Style::kFill";
253 case DlDrawStyle::kStroke: return os << "Style::kStroke";
254 case DlDrawStyle::kStrokeAndFill: return os << "Style::kStrokeAnFill";
255 }
256}
257
258std::ostream& operator<<(std::ostream& os, const DlBlurStyle& style) {
259 switch (style) {
260 case DlBlurStyle::kNormal: return os << "BlurStyle::kNormal";
261 case DlBlurStyle::kSolid: return os << "BlurStyle::kSolid";
262 case DlBlurStyle::kOuter: return os << "BlurStyle::kOuter";
263 case DlBlurStyle::kInner: return os << "BlurStyle::kInner";
264 }
265}
266
267std::ostream& operator<<(std::ostream& os, const DlCanvas::PointMode& mode) {
268 switch (mode) {
269 case DlCanvas::PointMode::kPoints: return os << "PointMode::kPoints";
270 case DlCanvas::PointMode::kLines: return os << "PointMode::kLines";
271 case DlCanvas::PointMode::kPolygon: return os << "PointMode::kPolygon";
272 }
273}
274
275std::ostream& operator<<(std::ostream& os, const DlFilterMode& mode) {
276 switch (mode) {
277 case DlFilterMode::kNearest: return os << "FilterMode::kNearest";
278 case DlFilterMode::kLinear: return os << "FilterMode::kLinear";
279
280 default: return os << "FilterMode::????";
281 }
282}
283
284std::ostream& operator<<(std::ostream& os, const DlColor& color) {
285 return os << "DlColor(" << std::hex << color.argb() << std::dec << ")";
286}
287
288std::ostream& operator<<(std::ostream& os, DlImageSampling sampling) {
289 switch (sampling) {
291 return os << "NearestSampling";
292 }
294 return os << "LinearSampling";
295 }
297 return os << "MipmapSampling";
298 }
300 return os << "CubicSampling";
301 }
302 }
303}
304
305static std::ostream& operator<<(std::ostream& os, const SkTextBlob* blob) {
306 if (blob == nullptr) {
307 return os << "no text";
308 }
309 return os << "&SkTextBlob(ID: " << blob->uniqueID() << ", " << blob->bounds() << ")";
310}
311
312static std::ostream& operator<<(std::ostream& os,
313 const impeller::TextFrame* frame) {
314 if (frame == nullptr) {
315 return os << "no text";
316 }
317 auto bounds = frame->GetBounds();
318 return os << "&TextFrame("
319 << bounds.GetLeft() << ", " << bounds.GetTop() << " => "
320 << bounds.GetRight() << ", " << bounds.GetBottom() << ")";
321}
322
323std::ostream& operator<<(std::ostream& os, const DlVertexMode& mode) {
324 switch (mode) {
325 case DlVertexMode::kTriangles: return os << "VertexMode::kTriangles";
326 case DlVertexMode::kTriangleStrip: return os << "VertexMode::kTriangleStrip";
327 case DlVertexMode::kTriangleFan: return os << "VertexMode::kTriangleFan";
328
329 default: return os << "VertexMode::????";
330 }
331}
332
333std::ostream& operator<<(std::ostream& os, const DlTileMode& mode) {
334 switch (mode) {
335 case DlTileMode::kClamp: return os << "TileMode::kClamp";
336 case DlTileMode::kRepeat: return os << "TileMode::kRepeat";
337 case DlTileMode::kMirror: return os << "TileMode::kMirror";
338 case DlTileMode::kDecal: return os << "TileMode::kDecal";
339
340 default: return os << "TileMode::????";
341 }
342}
343
344std::ostream& operator<<(std::ostream& os, const DlImage* image) {
345 if (image == nullptr) {
346 return os << "null image";
347 }
348 os << "&DlImage(" << image->width() << " x " << image->height() << ", ";
349 if (image->skia_image()) {
350 os << "skia(" << image->skia_image().get() << "), ";
351 }
352 if (image->impeller_texture()) {
353 os << "impeller(" << image->impeller_texture().get() << "), ";
354 }
355 return os << "isTextureBacked: " << image->isTextureBacked() << ")";
356}
357
358} // namespace std
359
360namespace flutter {
361namespace testing {
362
363std::ostream& DisplayListStreamDispatcher::startl() {
364 for (int i = 0; i < cur_indent_; i++) {
365 os_ << " ";
366 }
367 return os_;
368}
369
370template <class T>
371std::ostream& DisplayListStreamDispatcher::out_array(std::string name, // NOLINT(performance-unnecessary-value-param)
372 int count,
373 const T array[]) {
374 if (array == nullptr || count < 0) {
375 return os_ << "no " << name;
376 }
377 os_ << name << "[" << count << "] = [" << std::endl;
378 indent();
379 indent();
380 for (int i = 0; i < count; i++) {
381 startl() << array[i] << "," << std::endl;
382 }
383 outdent();
384 startl() << "]";
385 outdent();
386 return os_;
387}
388
390 startl() << "setAntiAlias(" << aa << ");" << std::endl;
391}
393 startl() << "setStyle(" << style << ");" << std::endl;
394}
396 startl() << "setColor(" << color << ");" << std::endl;
397}
399 startl() << "setStrokeWidth(" << width << ");" << std::endl;
400}
402 startl() << "setStrokeMiter(" << limit << ");" << std::endl;
403}
405 startl() << "setStrokeCap(" << cap << ");" << std::endl;
406}
408 startl() << "setStrokeJoin(" << join << ");" << std::endl;
409}
411 if (source == nullptr) {
412 startl() << "setColorSource(no ColorSource);" << std::endl;
413 return;
414 }
415 startl() << "setColorSource(";
416 switch (source->type()) {
418 const DlColorColorSource* color_src = source->asColor();
419 FML_DCHECK(color_src);
420 os_ << "DlColorColorSource(" << color_src->color() << ")";
421 break;
422 }
424 const DlImageColorSource* image_src = source->asImage();
425 FML_DCHECK(image_src);
426 os_ << "DlImageColorSource(image: " << image_src->image()
427 << ", hMode: " << image_src->horizontal_tile_mode()
428 << ", vMode: " << image_src->vertical_tile_mode()
429 << ", " << image_src->sampling()
430 << ", " << image_src->matrix_ptr()
431 << ")";
432 break;
433 }
435 const DlLinearGradientColorSource* linear_src = source->asLinearGradient();
436 FML_DCHECK(linear_src);
437 os_ << "DlLinearGradientSource("
438 << "start: " << linear_src->start_point()
439 << ", end: " << linear_src->end_point() << ", ";
440 out_array("colors", linear_src->stop_count(), linear_src->colors()) << ", ";
441 out_array("stops", linear_src->stop_count(), linear_src->stops()) << ", "
442 << linear_src->tile_mode() << ", " << linear_src->matrix_ptr() << ")";
443 break;
444 }
446 const DlRadialGradientColorSource* radial_src = source->asRadialGradient();
447 FML_DCHECK(radial_src);
448 os_ << "DlRadialGradientSource("
449 << "center: " << radial_src->center()
450 << ", radius: " << radial_src->radius() << ", ";
451 out_array("colors", radial_src->stop_count(), radial_src->colors()) << ", ";
452 out_array("stops", radial_src->stop_count(), radial_src->stops()) << ", "
453 << radial_src->tile_mode() << ", " << radial_src->matrix_ptr() << ")";
454 break;
455 }
457 const DlConicalGradientColorSource* conical_src = source->asConicalGradient();
458 FML_DCHECK(conical_src);
459 os_ << "DlConicalGradientColorSource("
460 << "start center: " << conical_src->start_center()
461 << ", start radius: " << conical_src->start_radius()
462 << ", end center: " << conical_src->end_center()
463 << ", end radius: " << conical_src->end_radius() << ", ";
464 out_array("colors", conical_src->stop_count(), conical_src->colors()) << ", ";
465 out_array("stops", conical_src->stop_count(), conical_src->stops()) << ", "
466 << conical_src->tile_mode() << ", " << conical_src->matrix_ptr() << ")";
467 break;
468 }
470 const DlSweepGradientColorSource* sweep_src = source->asSweepGradient();
471 FML_DCHECK(sweep_src);
472 os_ << "DlSweepGradientColorSource("
473 << "center: " << sweep_src->center()
474 << ", start: " << sweep_src->start() << ", "
475 << ", end: " << sweep_src->end() << ", ";
476 out_array("colors", sweep_src->stop_count(), sweep_src->colors()) << ", ";
477 out_array("stops", sweep_src->stop_count(), sweep_src->stops()) << ", "
478 << sweep_src->tile_mode() << ", " << sweep_src->matrix_ptr() << ")";
479 break;
480 }
481 default:
482 os_ << "?DlUnknownColorSource?()";
483 break;
484 }
485 os_ << ");" << std::endl;
486}
487void DisplayListStreamDispatcher::out(const DlColorFilter& filter) {
488 switch (filter.type()) {
490 const DlBlendColorFilter* blend = filter.asBlend();
492 os_ << "DlBlendColorFilter(" << blend->color() << ", "
493 << static_cast<int>(blend->mode()) << ")";
494 break;
495 }
497 const DlMatrixColorFilter* matrix = filter.asMatrix();
499 float values[20];
500 matrix->get_matrix(values);
501 os_ << "DlMatrixColorFilter(matrix[20] = [" << std::endl;
502 indent();
503 for (int i = 0; i < 20; i += 5) {
504 startl() << values[i] << ", "
505 << values[i+1] << ", "
506 << values[i+2] << ", "
507 << values[i+3] << ", "
508 << values[i+4] << ","
509 << std::endl;
510 }
511 outdent();
512 startl() << "]";
513 break;
514 }
516 os_ << "DlSrgbToLinearGammaColorFilter()";
517 break;
518 }
520 os_ << "DlLinearToSrgbGammaColorFilter()";
521 break;
522 }
523 default:
524 os_ << "?DlUnknownColorFilter?()";
525 break;
526 }
527}
528void DisplayListStreamDispatcher::out(const DlColorFilter* filter) {
529 if (filter == nullptr) {
530 os_ << "no ColorFilter";
531 } else {
532 os_ << "&";
533 out(*filter);
534 }
535}
537 startl() << "setColorFilter(";
538 out(filter);
539 os_ << ");" << std::endl;
540}
542 startl() << "setInvertColors(" << invert << ");" << std::endl;
543}
545 startl() << "setBlendMode(" << mode << ");" << std::endl;
546}
548 if (filter == nullptr) {
549 startl() << "setMaskFilter(no MaskFilter);" << std::endl;
550 return;
551 }
552 startl() << "setMaskFilter(";
553 switch (filter->type()) {
555 const DlBlurMaskFilter* blur = filter->asBlur();
556 FML_DCHECK(blur);
557 os_ << "DlMaskFilter(" << blur->style() << ", " << blur->sigma() << ")";
558 break;
559 }
560 default:
561 os_ << "?DlUnknownMaskFilter?()";
562 break;
563 }
564 os_ << ");" << std::endl;
565}
566void DisplayListStreamDispatcher::out(const DlImageFilter& filter) {
567 switch (filter.type()) {
569 const DlBlurImageFilter* blur = filter.asBlur();
570 FML_DCHECK(blur);
571 os_ << "DlBlurImageFilter(" << blur->sigma_x() << ", "
572 << blur->sigma_y() << ", "
573 << blur->tile_mode() << ")";
574 break;
575 }
577 const DlDilateImageFilter* dilate = filter.asDilate();
578 FML_DCHECK(dilate);
579 os_ << "DlDilateImageFilter(" << dilate->radius_x() << ", " << dilate->radius_y() << ")";
580 break;
581 }
583 const DlErodeImageFilter* erode = filter.asErode();
584 FML_DCHECK(erode);
585 os_ << "DlDilateImageFilter(" << erode->radius_x() << ", " << erode->radius_y() << ")";
586 break;
587 }
589 const DlMatrixImageFilter* matrix = filter.asMatrix();
591 os_ << "DlMatrixImageFilter(" << matrix->matrix() << ", " << matrix->sampling() << ")";
592 break;
593 }
595 const DlComposeImageFilter* compose = filter.asCompose();
596 FML_DCHECK(compose);
597 os_ << "DlComposeImageFilter(" << std::endl;
598 indent();
599 startl() << "outer: ";
600 indent(7);
601 out(compose->outer().get());
602 os_ << "," << std::endl;
603 outdent(7);
604 startl() << "inner: ";
605 indent(7);
606 out(compose->inner().get());
607 os_ << std::endl;
608 outdent(7);
609 outdent();
610 startl() << ")";
611 break;
612 }
614 const DlColorFilterImageFilter* color_filter = filter.asColorFilter();
616 os_ << "DlColorFilterImageFilter(";
617 out(*color_filter->color_filter());
618 os_ << ")";
619 break;
620 }
622 const DlLocalMatrixImageFilter* local_matrix = filter.asLocalMatrix();
623 FML_DCHECK(local_matrix);
624 os_ << "DlLocalMatrixImageFilter(" << local_matrix->matrix();
625 os_ << "," << std::endl;
626 indent(25);
627 startl() << "filter: ";
628 out(local_matrix->image_filter().get());
629 os_ << std::endl;
630 outdent(25);
631 startl() << ")";
632 break;
633 }
634 }
635}
636void DisplayListStreamDispatcher::out(const DlImageFilter* filter) {
637 if (filter == nullptr) {
638 os_ << "no ImageFilter";
639 } else {
640 os_ << "&";
641 indent(1);
642 out(*filter);
643 outdent(1);
644 }
645}
647 startl() << "setImageFilter(";
648 indent(15);
649 out(filter);
650 outdent(15);
651 os_ << ");" << std::endl;
652}
654 startl() << "save();" << std::endl;
655 startl() << "{" << std::endl;
656 indent();
657}
660 const DlImageFilter* backdrop) {
661 startl() << "saveLayer(" << bounds << ", " << options;
662 if (backdrop) {
663 os_ << "," << std::endl;
664 indent(10);
665 startl() << "backdrop: ";
666 out(backdrop);
667 outdent(10);
668 } else {
669 os_ << ", no backdrop";
670 }
671 os_ << ");" << std::endl;
672 startl() << "{" << std::endl;
673 indent();
674}
676 outdent();
677 startl() << "}" << std::endl;
678 startl() << "restore();" << std::endl;
679}
680
682 startl() << "translate(" << tx << ", " << ty << ");" << std::endl;
683}
685 startl() << "scale(" << sx << ", " << sy << ");" << std::endl;
686}
688 startl() << "rotate(" << degrees << ");" << std::endl;
689}
691 startl() << "skew(" << sx << ", " << sy << ");" << std::endl;
692}
694 SkScalar mxx, SkScalar mxy, SkScalar mxt,
695 SkScalar myx, SkScalar myy, SkScalar myt) {
696 startl() << "transform2DAffine(" << std::endl;
697 indent();
698 {
699 startl()
700 << "[" << mxx << ", " << mxy << ", " << mxt << "], "
701 << std::endl;
702 startl()
703 << "[" << myx << ", " << myy << ", " << myt << "], "
704 << std::endl;
705 }
706 outdent();
707 startl() << ");" << std::endl;
708}
710 SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
711 SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
712 SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
713 SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) {
714 startl() << "transformFullPerspective(" << std::endl;
715 indent();
716 {
717 startl()
718 << "[" << mxx << ", " << mxy << ", " << mxz << ", " << mxt << "], "
719 << std::endl;
720 startl()
721 << "[" << myx << ", " << myy << ", " << myz << ", " << myt << "], "
722 << std::endl;
723 startl()
724 << "[" << mzx << ", " << mzy << ", " << mzz << ", " << mzt << "], "
725 << std::endl;
726 startl()
727 << "[" << mwx << ", " << mwy << ", " << mwz << ", " << mwt << "]"
728 << std::endl;
729 }
730 outdent();
731 startl() << ");" << std::endl;
732}
734 startl() << "transformReset();" << std::endl;
735}
736
738 bool is_aa) {
739 startl() << "clipRect("
740 << rect << ", "
741 << clip_op << ", "
742 << "isaa: " << is_aa
743 << ");" << std::endl;
744}
746 ClipOp clip_op,
747 bool is_aa) {
748 startl() << "clipRRect("
749 << rrect << ", "
750 << clip_op << ", "
751 << "isaa: " << is_aa
752 << ");" << std::endl;
753}
755 bool is_aa) {
756 startl() << "clipPath("
757 << path << ", "
758 << clip_op << ", "
759 << "isaa: " << is_aa
760 << ");" << std::endl;
761}
762
764 startl() << "drawColor("
765 << color << ", "
766 << mode
767 << ");" << std::endl;
768}
770 startl() << "drawPaint();" << std::endl;
771}
773 const SkPoint& p1) {
774 startl() << "drawLine(" << p0 << ", " << p1 << ");" << std::endl;
775}
777 const DlPoint& p1,
778 DlScalar on_length,
779 DlScalar off_length) {
780 startl() << "drawDashedLine("
781 << p0 << ", "
782 << p1 << ", "
783 << on_length << ", "
784 << off_length
785 << ");" << std::endl;
786}
788 startl() << "drawRect(" << rect << ");" << std::endl;
789}
791 startl() << "drawOval(" << bounds << ");" << std::endl;
792}
794 SkScalar radius) {
795 startl() << "drawCircle(" << center << ", " << radius << ");" << std::endl;
796}
798 startl() << "drawRRect(" << rrect << ");" << std::endl;
799}
801 const SkRRect& inner) {
802 startl() << "drawDRRect(outer: " << outer << ", " << std::endl;
803 startl() << " inner: " << inner << ");" << std::endl;
804}
806 startl() << "drawPath(" << path << ");" << std::endl;
807}
809 SkScalar start_degrees,
810 SkScalar sweep_degrees,
811 bool use_center) {
812 startl() << "drawArc("
813 << oval_bounds << ", "
814 << start_degrees << ", "
815 << sweep_degrees << ", "
816 << "use_center: " << use_center
817 << ");" << std::endl;
818}
820 uint32_t count,
821 const SkPoint points[]) {
822 startl() << "drawPoints(" << mode << ", ";
823 out_array("points", count, points)
824 << ");" << std::endl;
825}
828 startl() << "drawVertices("
829 << "DlVertices("
830 << vertices->mode() << ", ";
831 out_array("vertices", vertices->vertex_count(), vertices->vertices()) << ", ";
832 out_array("texture_coords", vertices->vertex_count(), vertices->texture_coordinates()) << ", ";
833 out_array("colors", vertices->vertex_count(), vertices->colors()) << ", ";
834 out_array("indices", vertices->index_count(), vertices->indices())
835 << "), " << mode << ");" << std::endl;
836}
838 const SkPoint point,
840 bool render_with_attributes) {
841 startl() << "drawImage(" << image.get() << "," << std::endl;
842 startl() << " " << point << ", "
843 << sampling << ", "
844 << "with attributes: " << render_with_attributes
845 << ");" << std::endl;
846}
848 const SkRect& src,
849 const SkRect& dst,
851 bool render_with_attributes,
852 SrcRectConstraint constraint) {
853 startl() << "drawImageRect(" << image.get() << "," << std::endl;
854 startl() << " src: " << src << "," << std::endl;
855 startl() << " dst: " << dst << "," << std::endl;
856 startl() << " " << sampling << ", "
857 << "with attributes: " << render_with_attributes << ", "
858 << constraint
859 << ");" << std::endl;
860}
862 const SkIRect& center,
863 const SkRect& dst,
864 DlFilterMode filter,
865 bool render_with_attributes) {
866 startl() << "drawImageNine(" << image.get() << "," << std::endl;
867 startl() << " center: " << center << "," << std::endl;
868 startl() << " dst: " << dst << "," << std::endl;
869 startl() << " " << filter << ", "
870 << "with attributes: " << render_with_attributes
871 << ");" << std::endl;
872}
874 const SkRSXform xform[],
875 const SkRect tex[],
876 const DlColor colors[],
877 int count,
880 const SkRect* cull_rect,
881 bool render_with_attributes) {
882 startl() << "drawAtlas(" << atlas.get() << ", ";
883 out_array("xforms", count, xform) << ", ";
884 out_array("tex_coords", count, tex) << ", ";
885 out_array("colors", count, colors) << ", "
886 << mode << ", " << sampling << ", cull: " << cull_rect << ", "
887 << "with attributes: " << render_with_attributes
888 << ");" << std::endl;
889}
891 const sk_sp<DisplayList> display_list, SkScalar opacity) {
892 startl() << "drawDisplayList("
893 << "ID: " << display_list->unique_id() << ", "
894 << "bounds: " << display_list->bounds() << ", "
895 << "opacity: " << opacity
896 << ");" << std::endl;
897}
899 SkScalar x,
900 SkScalar y) {
901 startl() << "drawTextBlob("
902 << blob.get() << ", "
903 << x << ", " << y << ");" << std::endl;
904}
905
907 const std::shared_ptr<impeller::TextFrame>& text_frame,
908 SkScalar x,
909 SkScalar y) {
910 startl() << "drawTextFrame("
911 << text_frame.get() << ", "
912 << x << ", " << y << ");" << std::endl;
913}
914
916 const DlColor color,
917 const SkScalar elevation,
918 bool transparent_occluder,
919 SkScalar dpr) {
920 startl() << "drawShadow("
921 << path << ", "
922 << color << ", "
923 << elevation << ", "
924 << transparent_occluder << ", "
925 << dpr
926 << ");" << std::endl;
927}
928// clang-format on
929
930} // namespace testing
931} // namespace flutter
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
int width() const
Definition: SkImage.h:285
virtual bool isTextureBacked() const =0
int height() const
Definition: SkImage.h:291
Definition: SkPath.h:59
const SkRect & rect() const
Definition: SkRRect.h:264
SkVector radii(Corner corner) const
Definition: SkRRect.h:271
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
uint32_t uniqueID() const
Definition: SkTextBlob.h:59
const SkRect & bounds() const
Definition: SkTextBlob.h:53
void Dispatch(DlOpReceiver &ctx) const
virtual T type() const =0
DlTileMode tile_mode() const
DlBlurStyle style() const
SkScalar sigma() const
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
@ 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
virtual const DlBlendColorFilter * asBlend() const
virtual const DlMatrixColorFilter * asMatrix() const
const DlColor * colors() const
DlImageSampling sampling() const
DlTileMode vertical_tile_mode() const
DlTileMode horizontal_tile_mode() const
sk_sp< const DlImage > image() const
virtual const DlLocalMatrixImageFilter * asLocalMatrix() const
virtual const DlColorFilterImageFilter * asColorFilter() 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:30
const SkPoint & start_point() const
virtual const DlBlurMaskFilter * asBlur() const
const SkMatrix * matrix_ptr() const
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
const DlColor * colors() const
Definition: dl_vertices.h:217
int vertex_count() const
Definition: dl_vertices.h:202
DlVertexMode mode() const
Definition: dl_vertices.h:198
int index_count() const
Definition: dl_vertices.h:223
const SkPoint * vertices() const
Returns a pointer to the vertex information. Should be non-null.
Definition: dl_vertices.h:205
const uint16_t * indices() const
Definition: dl_vertices.h:227
const SkPoint * texture_coordinates() const
Definition: dl_vertices.h:211
void drawOval(const SkRect &bounds) override
void setImageFilter(const DlImageFilter *filter) override
void drawVertices(const DlVertices *vertices, DlBlendMode mode) override
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
Represents a collection of shaped text runs.
Definition: text_frame.h:19
T * get() const
Definition: SkRefCnt.h:303
const Paint & paint
Definition: color_source.cc:38
DlColor color
SkBitmap source
Definition: examples.cpp:28
double frame
Definition: examples.cpp:31
float SkScalar
Definition: extension.cpp:12
static bool b
struct MyStruct a[10]
gboolean invert
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_DCHECK(condition)
Definition: logging.h:103
static SkColor blend(SkColor dst, SkColor src, void(*mode)(float, float, float, float *, float *, float *))
Definition: hsl.cpp:142
double y
double x
sk_sp< const SkImage > atlas
Definition: SkRecords.h:331
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
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
@ kMiter
extends to miter limit
@ kBevel
connects outside edges
DlStrokeCap
Definition: dl_paint.h:28
@ kRound
adds circle
@ kSquare
adds square
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
@ kTriangles
The vertices are taken 3 at a time to form a triangle.
DlDrawStyle
Definition: dl_paint.h:19
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
@ kNormal
fuzzy inside and outside
@ kOuter
nothing inside, fuzzy outside
@ kInner
fuzzy inside, nothing outside
@ kSolid
solid inside, fuzzy outside
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
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kScreen
r = s + d - s*d
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kColor
hue and saturation of source with luminosity of destination
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
dst
Definition: cp.py:12
Definition: ref_ptr.h:256
flutter::DlCanvas DlCanvas
flutter::DlImage DlImage
flutter::testing::DisplayListStreamDispatcher DisplayListStreamDispatcher
std::ostream & operator<<(std::ostream &out, const impeller::Color &c)
Definition: color.h:961
flutter::DisplayList DisplayList
flutter::DlColor DlColor
flutter::DlPaint DlPaint
flutter::SaveLayerOptions SaveLayerOptions
#define T
Definition: precompiler.cc:65
int32_t width
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741
Definition: SkRect.h:32
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
SkScalar fTy
Definition: SkRSXform.h:45
SkScalar fSCos
Definition: SkRSXform.h:42
SkScalar fTx
Definition: SkRSXform.h:44
SkScalar fSSin
Definition: SkRSXform.h:43
constexpr uint32_t argb() const
Definition: dl_color.h:82
#define ERROR(message)
Definition: elf_loader.cc:260