Flutter Engine
The Flutter Engine
dl_dispatcher.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 <algorithm>
8#include <cstring>
9#include <memory>
10#include <optional>
11#include <utility>
12#include <vector>
13
14#include "flutter/fml/logging.h"
15#include "flutter/fml/trace_event.h"
32
33#if IMPELLER_ENABLE_3D
35#endif // IMPELLER_ENABLE_3D
36
37namespace impeller {
38
39#define UNIMPLEMENTED \
40 FML_DLOG(ERROR) << "Unimplemented detail in " << __FUNCTION__;
41
43 switch (mode) {
45 return BlendMode::kClear;
47 return BlendMode::kSource;
67 return BlendMode::kXor;
69 return BlendMode::kPlus;
77 return BlendMode::kDarken;
95 return BlendMode::kHue;
99 return BlendMode::kColor;
102 }
104}
105
107 switch (tile_mode) {
116 }
117}
118
122 switch (options) {
124 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kNearest;
125 desc.mip_filter = impeller::MipFilter::kBase;
126 desc.label = "Nearest Sampler";
127 break;
129 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear;
130 desc.mip_filter = impeller::MipFilter::kBase;
131 desc.label = "Linear Sampler";
132 break;
135 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear;
137 desc.label = "Mipmap Linear Sampler";
138 break;
139 }
140 return desc;
141}
142
146 switch (options) {
148 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kNearest;
149 desc.label = "Nearest Sampler";
150 break;
152 desc.min_filter = desc.mag_filter = impeller::MinMagFilter::kLinear;
153 desc.label = "Linear Sampler";
154 break;
155 default:
156 break;
157 }
158 return desc;
159}
160
161static Matrix ToMatrix(const SkMatrix& m) {
162 return Matrix{
163 // clang-format off
164 m[0], m[3], 0, m[6],
165 m[1], m[4], 0, m[7],
166 0, 0, 1, 0,
167 m[2], m[5], 0, m[8],
168 // clang-format on
169 };
170}
171
172// |flutter::DlOpReceiver|
174 // Nothing to do because AA is implicit.
175}
176
178 switch (style) {
180 return Paint::Style::kFill;
185 break;
186 }
187 return Paint::Style::kFill;
188}
189
190// |flutter::DlOpReceiver|
192 paint_.style = ToStyle(style);
193}
194
195// |flutter::DlOpReceiver|
197 paint_.color = {
198 color.getRedF(),
199 color.getGreenF(),
200 color.getBlueF(),
201 color.getAlphaF(),
202 };
203}
204
205// |flutter::DlOpReceiver|
207 paint_.stroke_width = width;
208}
209
210// |flutter::DlOpReceiver|
212 paint_.stroke_miter = limit;
213}
214
215// |flutter::DlOpReceiver|
217 switch (cap) {
219 paint_.stroke_cap = Cap::kButt;
220 break;
222 paint_.stroke_cap = Cap::kRound;
223 break;
225 paint_.stroke_cap = Cap::kSquare;
226 break;
227 }
228}
229
230// |flutter::DlOpReceiver|
232 switch (join) {
234 paint_.stroke_join = Join::kMiter;
235 break;
237 paint_.stroke_join = Join::kRound;
238 break;
240 paint_.stroke_join = Join::kBevel;
241 break;
242 }
243}
244
245static std::vector<Color> ToColors(const flutter::DlColor colors[], int count) {
246 auto result = std::vector<Color>();
247 if (colors == nullptr) {
248 return result;
249 }
250 for (int i = 0; i < count; i++) {
252 }
253 return result;
254}
255
256static std::optional<ColorSource::Type> ToColorSourceType(
258 switch (type) {
273#ifdef IMPELLER_ENABLE_3D
274 case flutter::DlColorSourceType::kScene:
276#endif // IMPELLER_ENABLE_3D
277 }
278}
279
280// |flutter::DlOpReceiver|
282 if (!source) {
284 return;
285 }
286
287 std::optional<ColorSource::Type> type = ToColorSourceType(source->type());
288
289 if (!type.has_value()) {
290 FML_LOG(ERROR) << "Requested ColorSourceType::kUnknown";
292 return;
293 }
294
295 switch (type.value()) {
297 const flutter::DlColorColorSource* color = source->asColor();
298
300 setColor(color->color());
302 return;
303 }
306 source->asLinearGradient();
308 auto start_point = skia_conversions::ToPoint(linear->start_point());
309 auto end_point = skia_conversions::ToPoint(linear->end_point());
310 std::vector<Color> colors;
311 std::vector<float> stops;
313
314 auto tile_mode = ToTileMode(linear->tile_mode());
315 auto matrix = ToMatrix(linear->matrix());
316
318 start_point, end_point, std::move(colors), std::move(stops),
319 tile_mode, matrix);
320 return;
321 }
323 const flutter::DlConicalGradientColorSource* conical_gradient =
324 source->asConicalGradient();
325 FML_DCHECK(conical_gradient);
326 Point center = skia_conversions::ToPoint(conical_gradient->end_center());
327 SkScalar radius = conical_gradient->end_radius();
328 Point focus_center =
329 skia_conversions::ToPoint(conical_gradient->start_center());
330 SkScalar focus_radius = conical_gradient->start_radius();
331 std::vector<Color> colors;
332 std::vector<float> stops;
333 skia_conversions::ConvertStops(conical_gradient, colors, stops);
334
335 auto tile_mode = ToTileMode(conical_gradient->tile_mode());
336 auto matrix = ToMatrix(conical_gradient->matrix());
337
339 center, radius, std::move(colors), std::move(stops), focus_center,
340 focus_radius, tile_mode, matrix);
341 return;
342 }
344 const flutter::DlRadialGradientColorSource* radialGradient =
345 source->asRadialGradient();
346 FML_DCHECK(radialGradient);
347 auto center = skia_conversions::ToPoint(radialGradient->center());
348 auto radius = radialGradient->radius();
349 std::vector<Color> colors;
350 std::vector<float> stops;
351 skia_conversions::ConvertStops(radialGradient, colors, stops);
352
353 auto tile_mode = ToTileMode(radialGradient->tile_mode());
354 auto matrix = ToMatrix(radialGradient->matrix());
355 paint_.color_source =
356 ColorSource::MakeRadialGradient(center, radius, std::move(colors),
357 std::move(stops), tile_mode, matrix);
358 return;
359 }
361 const flutter::DlSweepGradientColorSource* sweepGradient =
362 source->asSweepGradient();
363 FML_DCHECK(sweepGradient);
364
365 auto center = skia_conversions::ToPoint(sweepGradient->center());
366 auto start_angle = Degrees(sweepGradient->start());
367 auto end_angle = Degrees(sweepGradient->end());
368 std::vector<Color> colors;
369 std::vector<float> stops;
370 skia_conversions::ConvertStops(sweepGradient, colors, stops);
371
372 auto tile_mode = ToTileMode(sweepGradient->tile_mode());
373 auto matrix = ToMatrix(sweepGradient->matrix());
375 center, start_angle, end_angle, std::move(colors), std::move(stops),
376 tile_mode, matrix);
377 return;
378 }
380 const flutter::DlImageColorSource* image_color_source = source->asImage();
381 FML_DCHECK(image_color_source &&
382 image_color_source->image()->impeller_texture());
383 auto texture = image_color_source->image()->impeller_texture();
384 auto x_tile_mode = ToTileMode(image_color_source->horizontal_tile_mode());
385 auto y_tile_mode = ToTileMode(image_color_source->vertical_tile_mode());
386 auto desc = ToSamplerDescriptor(image_color_source->sampling());
387 auto matrix = ToMatrix(image_color_source->matrix());
388 paint_.color_source = ColorSource::MakeImage(texture, x_tile_mode,
389 y_tile_mode, desc, matrix);
390 return;
391 }
393 const flutter::DlRuntimeEffectColorSource* runtime_effect_color_source =
394 source->asRuntimeEffect();
395 auto runtime_stage =
396 runtime_effect_color_source->runtime_effect()->runtime_stage();
397 auto uniform_data = runtime_effect_color_source->uniform_data();
398 auto samplers = runtime_effect_color_source->samplers();
399
400 std::vector<RuntimeEffectContents::TextureInput> texture_inputs;
401
402 for (auto& sampler : samplers) {
403 if (sampler == nullptr) {
404 return;
405 }
406 auto* image = sampler->asImage();
407 if (!sampler->asImage()) {
409 return;
410 }
411 FML_DCHECK(image->image()->impeller_texture());
412 texture_inputs.push_back({
413 .sampler_descriptor = ToSamplerDescriptor(image->sampling()),
414 .texture = image->image()->impeller_texture(),
415 });
416 }
417
419 runtime_stage, uniform_data, texture_inputs);
420 return;
421 }
423#ifdef IMPELLER_ENABLE_3D
424 const flutter::DlSceneColorSource* scene_color_source = source->asScene();
425 std::shared_ptr<scene::Node> scene_node =
426 scene_color_source->scene_node();
427 Matrix camera_transform = scene_color_source->camera_matrix();
428
429 paint_.color_source =
430 ColorSource::MakeScene(scene_node, camera_transform);
431#else // IMPELLER_ENABLE_3D
432 FML_LOG(ERROR) << "ColorSourceType::kScene can only be used if Impeller "
433 "Scene is enabled.";
434#endif // IMPELLER_ENABLE_3D
435 return;
436 }
437 }
438}
439
440static std::shared_ptr<ColorFilter> ToColorFilter(
441 const flutter::DlColorFilter* filter) {
442 if (filter == nullptr) {
443 return nullptr;
444 }
445 switch (filter->type()) {
447 auto dl_blend = filter->asBlend();
448 auto blend_mode = ToBlendMode(dl_blend->mode());
449 auto color = skia_conversions::ToColor(dl_blend->color());
450 return ColorFilter::MakeBlend(blend_mode, color);
451 }
453 const flutter::DlMatrixColorFilter* dl_matrix = filter->asMatrix();
454 impeller::ColorMatrix color_matrix;
455 dl_matrix->get_matrix(color_matrix.array);
456 return ColorFilter::MakeMatrix(color_matrix);
457 }
462 }
463 return nullptr;
464}
465
466// |flutter::DlOpReceiver|
468 paint_.color_filter = ToColorFilter(filter);
469}
470
471// |flutter::DlOpReceiver|
473 paint_.invert_colors = invert;
474}
475
476// |flutter::DlOpReceiver|
478 paint_.blend_mode = ToBlendMode(dl_mode);
479}
480
482 switch (blur_style) {
491 }
492}
493
494// |flutter::DlOpReceiver|
496 // Needs https://github.com/flutter/flutter/issues/95434
497 if (filter == nullptr) {
498 paint_.mask_blur_descriptor = std::nullopt;
499 return;
500 }
501 switch (filter->type()) {
503 auto blur = filter->asBlur();
504
505 paint_.mask_blur_descriptor = {
506 .style = ToBlurStyle(blur->style()),
507 .sigma = Sigma(blur->sigma()),
508 .respect_ctm = blur->respectCTM(),
509 };
510 break;
511 }
512 }
513}
514
515static std::shared_ptr<ImageFilter> ToImageFilter(
516 const flutter::DlImageFilter* filter) {
517 if (filter == nullptr) {
518 return nullptr;
519 }
520
521 switch (filter->type()) {
523 auto blur = filter->asBlur();
524 auto sigma_x = Sigma(blur->sigma_x());
525 auto sigma_y = Sigma(blur->sigma_y());
526 auto tile_mode = ToTileMode(blur->tile_mode());
528 sigma_x, sigma_y, FilterContents::BlurStyle::kNormal, tile_mode);
529 }
531 auto dilate = filter->asDilate();
532 FML_DCHECK(dilate);
533 if (dilate->radius_x() < 0 || dilate->radius_y() < 0) {
534 return nullptr;
535 }
536 auto radius_x = Radius(dilate->radius_x());
537 auto radius_y = Radius(dilate->radius_y());
538 return ImageFilter::MakeDilate(radius_x, radius_y);
539 }
541 auto erode = filter->asErode();
542 FML_DCHECK(erode);
543 if (erode->radius_x() < 0 || erode->radius_y() < 0) {
544 return nullptr;
545 }
546 auto radius_x = Radius(erode->radius_x());
547 auto radius_y = Radius(erode->radius_y());
548 return ImageFilter::MakeErode(radius_x, radius_y);
549 }
551 auto matrix_filter = filter->asMatrix();
552 FML_DCHECK(matrix_filter);
553 auto matrix = ToMatrix(matrix_filter->matrix());
554 auto desc = ToSamplerDescriptor(matrix_filter->sampling());
556 }
558 auto compose = filter->asCompose();
559 FML_DCHECK(compose);
560 auto outer_dl_filter = compose->outer();
561 auto inner_dl_filter = compose->inner();
562 auto outer_filter = ToImageFilter(outer_dl_filter.get());
563 auto inner_filter = ToImageFilter(inner_dl_filter.get());
564 if (!outer_filter) {
565 return inner_filter;
566 }
567 if (!inner_filter) {
568 return outer_filter;
569 }
570 FML_DCHECK(outer_filter && inner_filter);
571
572 return ImageFilter::MakeCompose(*inner_filter, *outer_filter);
573 }
575 auto color_filter_image_filter = filter->asColorFilter();
576 FML_DCHECK(color_filter_image_filter);
577 auto color_filter =
578 ToColorFilter(color_filter_image_filter->color_filter().get());
579 if (!color_filter) {
580 return nullptr;
581 }
582 // When color filters are used as image filters, set the color filter's
583 // "absorb opacity" flag to false. For image filters, the snapshot
584 // opacity needs to be deferred until the result of the filter chain is
585 // being blended with the layer.
587 }
589 auto local_matrix_filter = filter->asLocalMatrix();
590 FML_DCHECK(local_matrix_filter);
591 auto internal_filter = local_matrix_filter->image_filter();
592 FML_DCHECK(internal_filter);
593
594 auto image_filter = ToImageFilter(internal_filter.get());
595 if (!image_filter) {
596 return nullptr;
597 }
598
599 auto matrix = ToMatrix(local_matrix_filter->matrix());
600 return ImageFilter::MakeLocalMatrix(matrix, *image_filter);
601 }
602 }
603}
604
605// |flutter::DlOpReceiver|
607 paint_.image_filter = ToImageFilter(filter);
608}
609
610// |flutter::DlOpReceiver|
611void DlDispatcherBase::save(uint32_t total_content_depth) {
612 GetCanvas().Save(total_content_depth);
613}
614
615// |flutter::DlOpReceiver|
618 uint32_t total_content_depth,
619 flutter::DlBlendMode max_content_mode,
621 auto paint = options.renders_with_attributes() ? paint_ : Paint{};
622 auto promise = options.content_is_clipped()
626 ToImageFilter(backdrop), promise, total_content_depth,
627 options.can_distribute_opacity());
628}
629
630// |flutter::DlOpReceiver|
632 GetCanvas().Restore();
633}
634
635// |flutter::DlOpReceiver|
637 GetCanvas().Translate({tx, ty, 0.0});
638}
639
640// |flutter::DlOpReceiver|
642 GetCanvas().Scale({sx, sy, 1.0});
643}
644
645// |flutter::DlOpReceiver|
647 GetCanvas().Rotate(Degrees{degrees});
648}
649
650// |flutter::DlOpReceiver|
652 GetCanvas().Skew(sx, sy);
653}
654
655// |flutter::DlOpReceiver|
657 SkScalar mxy,
658 SkScalar mxt,
659 SkScalar myx,
660 SkScalar myy,
661 SkScalar myt) {
662 // clang-format off
664 mxx, mxy, 0, mxt,
665 myx, myy, 0, myt,
666 0 , 0, 1, 0,
667 0 , 0, 0, 1
668 );
669 // clang-format on
670}
671
672// |flutter::DlOpReceiver|
674 SkScalar mxy,
675 SkScalar mxz,
676 SkScalar mxt,
677 SkScalar myx,
678 SkScalar myy,
679 SkScalar myz,
680 SkScalar myt,
681 SkScalar mzx,
682 SkScalar mzy,
683 SkScalar mzz,
684 SkScalar mzt,
685 SkScalar mwx,
686 SkScalar mwy,
687 SkScalar mwz,
688 SkScalar mwt) {
689 // The order of arguments is row-major but Impeller matrices are
690 // column-major.
691 // clang-format off
692 auto transform = Matrix{
693 mxx, myx, mzx, mwx,
694 mxy, myy, mzy, mwy,
695 mxz, myz, mzz, mwz,
696 mxt, myt, mzt, mwt
697 };
698 // clang-format on
700}
701
702// |flutter::DlOpReceiver|
705 GetCanvas().Transform(initial_matrix_);
706}
707
710 switch (clip_op) {
715 }
716}
717
718// |flutter::DlOpReceiver|
720 ClipOp clip_op,
721 bool is_aa) {
723 ToClipOperation(clip_op));
724}
725
726// |flutter::DlOpReceiver|
728 ClipOp sk_op,
729 bool is_aa) {
730 auto clip_op = ToClipOperation(sk_op);
731 if (rrect.isRect()) {
733 } else if (rrect.isOval()) {
735 } else if (rrect.isSimple()) {
738 clip_op);
739 } else {
741 }
742}
743
744// |flutter::DlOpReceiver|
745void DlDispatcherBase::clipPath(const SkPath& path, ClipOp sk_op, bool is_aa) {
747}
748
749const Path& DlDispatcherBase::GetOrCachePath(const CacheablePath& cache) {
750 if (cache.cached_impeller_path.IsEmpty() && !cache.sk_path.isEmpty()) {
751 cache.cached_impeller_path = skia_conversions::ToPath(cache.sk_path);
752 }
753 return cache.cached_impeller_path;
754}
755
756// |flutter::DlOpReceiver|
758 ClipOp sk_op,
759 bool is_aa) {
760 auto clip_op = ToClipOperation(sk_op);
761
762 SkRect rect;
763 if (cache.sk_path.isRect(&rect)) {
765 } else if (cache.sk_path.isOval(&rect)) {
767 } else {
769 if (cache.sk_path.isRRect(&rrect) && rrect.isSimple()) {
772 clip_op);
773 } else {
774 GetCanvas().ClipPath(GetOrCachePath(cache), clip_op);
775 }
776 }
777}
778
779// |flutter::DlOpReceiver|
781 flutter::DlBlendMode dl_mode) {
782 Paint paint;
784 paint.blend_mode = ToBlendMode(dl_mode);
786}
787
788// |flutter::DlOpReceiver|
790 GetCanvas().DrawPaint(paint_);
791}
792
793// |flutter::DlOpReceiver|
794void DlDispatcherBase::drawLine(const SkPoint& p0, const SkPoint& p1) {
796 skia_conversions::ToPoint(p1), paint_);
797}
798
800 const DlPoint& p1,
801 DlScalar on_length,
802 DlScalar off_length) {
803 Scalar length = p0.GetDistance(p1);
804 // Reasons to defer to regular DrawLine:
805 // length is non-positive - drawLine will draw appropriate "dot"
806 // off_length is non-positive - no gaps, drawLine will draw it solid
807 // on_length is negative - invalid dashing
808 // Note that a 0 length "on" dash will draw "dot"s every "off" distance apart
809 if (length > 0.0f && on_length >= 0.0f && off_length > 0.0f) {
810 Point delta = (p1 - p0) / length; // length > 0 already tested
812
813 Scalar consumed = 0.0f;
814 while (consumed < length) {
815 builder.MoveTo(p0 + delta * consumed);
816
817 Scalar dash_end = consumed + on_length;
818 if (dash_end < length) {
819 builder.LineTo(p0 + delta * dash_end);
820 } else {
821 builder.LineTo(p1);
822 // Should happen anyway due to the math, but let's make it explicit
823 // in case of bit errors. We're done with this line.
824 break;
825 }
826
827 consumed = dash_end + off_length;
828 }
829
830 Paint stroke_paint = paint_;
831 stroke_paint.style = Paint::Style::kStroke;
832 GetCanvas().DrawPath(builder.TakePath(), stroke_paint);
833 } else {
835 }
836}
837
838// |flutter::DlOpReceiver|
841}
842
843// |flutter::DlOpReceiver|
846}
847
848// |flutter::DlOpReceiver|
849void DlDispatcherBase::drawCircle(const SkPoint& center, SkScalar radius) {
850 GetCanvas().DrawCircle(skia_conversions::ToPoint(center), radius, paint_);
851}
852
853// |flutter::DlOpReceiver|
858 paint_);
859 } else {
861 }
862}
863
864// |flutter::DlOpReceiver|
865void DlDispatcherBase::drawDRRect(const SkRRect& outer, const SkRRect& inner) {
867 builder.AddPath(skia_conversions::ToPath(outer));
868 builder.AddPath(skia_conversions::ToPath(inner));
869 GetCanvas().DrawPath(builder.TakePath(FillType::kOdd), paint_);
870}
871
872// |flutter::DlOpReceiver|
875}
876
877// |flutter::DlOpReceiver|
879 SimplifyOrDrawPath(GetCanvas(), cache, paint_);
880}
881
882void DlDispatcherBase::SimplifyOrDrawPath(Canvas& canvas,
883 const CacheablePath& cache,
884 const Paint& paint) {
885 SkRect rect;
886
887 // We can't "optimize" a path into a rectangle if it's open.
888 bool closed;
889 if (cache.sk_path.isRect(&rect, &closed) && closed) {
891 return;
892 }
893
895 if (cache.sk_path.isRRect(&rrect) && rrect.isSimple()) {
898 return;
899 }
900
901 SkRect oval;
902 if (cache.sk_path.isOval(&oval)) {
904 return;
905 }
906
907 canvas.DrawPath(GetOrCachePath(cache), paint);
908}
909
910// |flutter::DlOpReceiver|
911void DlDispatcherBase::drawArc(const SkRect& oval_bounds,
912 SkScalar start_degrees,
913 SkScalar sweep_degrees,
914 bool use_center) {
916 builder.AddArc(skia_conversions::ToRect(oval_bounds), Degrees(start_degrees),
917 Degrees(sweep_degrees), use_center);
918 GetCanvas().DrawPath(builder.TakePath(), paint_);
919}
920
921// |flutter::DlOpReceiver|
923 uint32_t count,
924 const SkPoint points[]) {
925 Paint paint = paint_;
927 switch (mode) {
929 // Cap::kButt is also treated as a square.
930 auto point_style = paint.stroke_cap == Cap::kRound ? PointStyle::kRound
932 auto radius = paint.stroke_width;
933 if (radius > 0) {
934 radius /= 2.0;
935 }
937 paint, point_style);
938 } break;
940 for (uint32_t i = 1; i < count; i += 2) {
943 GetCanvas().DrawLine(p0, p1, paint);
944 }
945 break;
947 if (count > 1) {
949 for (uint32_t i = 1; i < count; i++) {
951 GetCanvas().DrawLine(p0, p1, paint);
952 p0 = p1;
953 }
954 }
955 break;
956 }
957}
958
959// |flutter::DlOpReceiver|
961 flutter::DlBlendMode dl_mode) {
962 GetCanvas().DrawVertices(MakeVertices(vertices), ToBlendMode(dl_mode),
963 paint_);
964}
965
966// |flutter::DlOpReceiver|
968 const SkPoint point,
970 bool render_with_attributes) {
971 if (!image) {
972 return;
973 }
974
975 auto texture = image->impeller_texture();
976 if (!texture) {
977 return;
978 }
979
980 const auto size = texture->GetSize();
981 const auto src = SkRect::MakeWH(size.width, size.height);
982 const auto dest =
983 SkRect::MakeXYWH(point.fX, point.fY, size.width, size.height);
984
985 drawImageRect(image, // image
986 src, // source rect
987 dest, // destination rect
988 sampling, // sampling options
989 render_with_attributes, // render with attributes
990 SrcRectConstraint::kStrict // constraint
991 );
992}
993
994// |flutter::DlOpReceiver|
997 const SkRect& src,
998 const SkRect& dst,
1000 bool render_with_attributes,
1001 SrcRectConstraint constraint = SrcRectConstraint::kFast) {
1003 std::make_shared<Image>(image->impeller_texture()), // image
1004 skia_conversions::ToRect(src), // source rect
1005 skia_conversions::ToRect(dst), // destination rect
1006 render_with_attributes ? paint_ : Paint(), // paint
1007 ToSamplerDescriptor(sampling) // sampling
1008 );
1009}
1010
1011// |flutter::DlOpReceiver|
1013 const SkIRect& center,
1014 const SkRect& dst,
1015 flutter::DlFilterMode filter,
1016 bool render_with_attributes) {
1018 converter.DrawNinePatch(
1019 std::make_shared<Image>(image->impeller_texture()),
1020 Rect::MakeLTRB(center.fLeft, center.fTop, center.fRight, center.fBottom),
1022 &paint_);
1023}
1024
1025// |flutter::DlOpReceiver|
1027 const SkRSXform xform[],
1028 const SkRect tex[],
1029 const flutter::DlColor colors[],
1030 int count,
1033 const SkRect* cull_rect,
1034 bool render_with_attributes) {
1035 GetCanvas().DrawAtlas(std::make_shared<Image>(atlas->impeller_texture()),
1040 skia_conversions::ToRect(cull_rect), paint_);
1041}
1042
1043// |flutter::DlOpReceiver|
1045 const sk_sp<flutter::DisplayList> display_list,
1046 SkScalar opacity) {
1047 // Save all values that must remain untouched after the operation.
1048 Paint saved_paint = paint_;
1049 Matrix saved_initial_matrix = initial_matrix_;
1050
1051 // Establish a new baseline for interpreting the new DL.
1052 // Matrix and clip are left untouched, the current
1053 // transform is saved as the new base matrix, and paint
1054 // values are reset to defaults.
1055 initial_matrix_ = GetCanvas().GetCurrentTransform();
1056 paint_ = Paint();
1057
1058 // Handle passed opacity in the most brute-force way by using
1059 // a SaveLayer. If the display_list is able to inherit the
1060 // opacity, this could also be handled by modulating all of its
1061 // attribute settings (for example, color), by the indicated
1062 // opacity.
1063 int restore_count = GetCanvas().GetSaveCount();
1064 if (opacity < SK_Scalar1) {
1065 Paint save_paint;
1066 save_paint.color = Color(0, 0, 0, opacity);
1068 save_paint, skia_conversions::ToRect(display_list->bounds()), nullptr,
1070 display_list->can_apply_group_opacity());
1071 } else {
1072 // The display list may alter the clip, which must be restored to the
1073 // current clip at the end of playback.
1074 GetCanvas().Save(display_list->total_depth());
1075 }
1076
1077 // TODO(131445): Remove this restriction if we can correctly cull with
1078 // perspective transforms.
1079 if (display_list->has_rtree() && !initial_matrix_.HasPerspective()) {
1080 // The canvas remembers the screen-space culling bounds clipped by
1081 // the surface and the history of clip calls. DisplayList can cull
1082 // the ops based on a rectangle expressed in its "destination bounds"
1083 // so we need the canvas to transform those into the current local
1084 // coordinate space into which the DisplayList will be rendered.
1085 auto cull_bounds = GetCanvas().GetCurrentLocalCullingBounds();
1086 if (cull_bounds.has_value()) {
1087 Rect cull_rect = cull_bounds.value();
1088 display_list->Dispatch(
1089 *this, SkRect::MakeLTRB(cull_rect.GetLeft(), cull_rect.GetTop(),
1090 cull_rect.GetRight(), cull_rect.GetBottom()));
1091 } else {
1092 display_list->Dispatch(*this);
1093 }
1094 } else {
1095 display_list->Dispatch(*this);
1096 }
1097
1098 // Restore all saved state back to what it was before we interpreted
1099 // the display_list
1100 GetCanvas().RestoreToCount(restore_count);
1101 initial_matrix_ = saved_initial_matrix;
1102 paint_ = saved_paint;
1103}
1104
1105// |flutter::DlOpReceiver|
1107 SkScalar x,
1108 SkScalar y) {
1109 // When running with Impeller enabled Skia text blobs are converted to
1110 // Impeller text frames in paragraph_skia.cc
1112}
1113
1115 const std::shared_ptr<TextFrame>& text_frame,
1116 SkScalar x,
1117 SkScalar y) {
1118 GetCanvas().DrawTextFrame(text_frame, //
1119 impeller::Point{x, y}, //
1120 paint_ //
1121 );
1122}
1123
1124// |flutter::DlOpReceiver|
1126 const flutter::DlColor color,
1127 const SkScalar elevation,
1128 bool transparent_occluder,
1129 SkScalar dpr) {
1131}
1132
1133// |flutter::DlOpReceiver|
1135 const flutter::DlColor color,
1136 const SkScalar elevation,
1137 bool transparent_occluder,
1138 SkScalar dpr) {
1140 spot_color.alpha *= 0.25;
1141
1142 // Compute the spot color -- ported from SkShadowUtils::ComputeTonalColors.
1143 {
1144 Scalar max =
1145 std::max(std::max(spot_color.red, spot_color.green), spot_color.blue);
1146 Scalar min =
1147 std::min(std::min(spot_color.red, spot_color.green), spot_color.blue);
1148 Scalar luminance = (min + max) * 0.5;
1149
1150 Scalar alpha_adjust =
1151 (2.6f + (-2.66667f + 1.06667f * spot_color.alpha) * spot_color.alpha) *
1152 spot_color.alpha;
1153 Scalar color_alpha =
1154 (3.544762f + (-4.891428f + 2.3466f * luminance) * luminance) *
1155 luminance;
1156 color_alpha = std::clamp(alpha_adjust * color_alpha, 0.0f, 1.0f);
1157
1158 Scalar greyscale_alpha =
1159 std::clamp(spot_color.alpha * (1 - 0.4f * luminance), 0.0f, 1.0f);
1160
1161 Scalar color_scale = color_alpha * (1 - greyscale_alpha);
1162 Scalar tonal_alpha = color_scale + greyscale_alpha;
1163 Scalar unpremul_scale = tonal_alpha != 0 ? color_scale / tonal_alpha : 0;
1164 spot_color = Color(unpremul_scale * spot_color.red,
1165 unpremul_scale * spot_color.green,
1166 unpremul_scale * spot_color.blue, tonal_alpha);
1167 }
1168
1169 Vector3 light_position(0, -1, 1);
1170 Scalar occluder_z = dpr * elevation;
1171
1172 constexpr Scalar kLightRadius = 800 / 600; // Light radius / light height
1173
1174 Paint paint;
1175 paint.style = Paint::Style::kFill;
1176 paint.color = spot_color;
1177 paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
1179 .sigma = Radius{kLightRadius * occluder_z /
1181 };
1182
1183 GetCanvas().Save(1u);
1185 Matrix::MakeTranslation(Vector2(0, -occluder_z * light_position.y)));
1186
1187 SimplifyOrDrawPath(GetCanvas(), cache, paint);
1188
1189 GetCanvas().Restore();
1190}
1191
1193 TRACE_EVENT0("impeller", "DisplayListDispatcher::EndRecordingAsPicture");
1195}
1196
1197/// Subclasses
1198
1199DlDispatcher::DlDispatcher() = default;
1200
1201DlDispatcher::DlDispatcher(IRect cull_rect) : canvas_(cull_rect) {}
1202
1203DlDispatcher::DlDispatcher(Rect cull_rect) : canvas_(cull_rect) {}
1204
1205Canvas& DlDispatcher::GetCanvas() {
1206 return canvas_;
1207}
1208
1210 const ContentContext& renderer,
1211 flutter::DlBlendMode max_root_blend_mode) {
1212 return !renderer.GetDeviceCapabilities().SupportsFramebufferFetch() &&
1213 ToBlendMode(max_root_blend_mode) > Entity::kLastPipelineBlendMode;
1214}
1215
1218 RenderTarget& render_target,
1219 bool has_root_backdrop_filter,
1220 flutter::DlBlendMode max_root_blend_mode,
1221 IRect cull_rect)
1222 : canvas_(renderer,
1223 render_target,
1224 has_root_backdrop_filter ||
1225 RequiresReadbackForBlends(renderer, max_root_blend_mode),
1226 cull_rect) {}
1227
1228Canvas& ExperimentalDlDispatcher::GetCanvas() {
1229 return canvas_;
1230}
1231
1232//// Text Frame Dispatcher
1233
1235 const Matrix& initial_matrix)
1236 : renderer_(renderer), matrix_(initial_matrix) {}
1237
1239 stack_.emplace_back(matrix_);
1240}
1241
1245 save();
1246}
1247
1249 matrix_ = stack_.back();
1250 stack_.pop_back();
1251}
1252
1254 matrix_ = matrix_.Translate({tx, ty});
1255}
1256
1258 matrix_ = matrix_.Scale({sx, sy, 1.0f});
1259}
1260
1262 matrix_ = matrix_ * Matrix::MakeRotationZ(Degrees(degrees));
1263}
1264
1266 matrix_ = matrix_ * Matrix::MakeSkew(sx, sy);
1267}
1268
1269// clang-format off
1270 // 2x3 2D affine subset of a 4x4 transform in row major order
1272 SkScalar myx, SkScalar myy, SkScalar myt) {
1273 matrix_ = matrix_ * Matrix::MakeColumn(
1274 mxx, myx, 0.0f, 0.0f,
1275 mxy, myy, 0.0f, 0.0f,
1276 0.0f, 0.0f, 1.0f, 0.0f,
1277 mxt, myt, 0.0f, 1.0f
1278 );
1279 }
1280
1281 // full 4x4 transform in row major order
1283 SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt,
1284 SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt,
1285 SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt,
1286 SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt) {
1287 matrix_ = matrix_ * Matrix::MakeColumn(
1288 mxx, myx, mzx, mwx,
1289 mxy, myy, mzy, mwy,
1290 mxz, myz, mzz, mwz,
1291 mxt, myt, mzt, mwt
1292 );
1293 }
1294// clang-format on
1295
1297 matrix_ = Matrix();
1298}
1299
1301 const std::shared_ptr<impeller::TextFrame>& text_frame,
1302 SkScalar x,
1303 SkScalar y) {
1304 GlyphProperties properties;
1305 if (paint_.style == Paint::Style::kStroke) {
1306 properties.stroke = true;
1307 properties.stroke_cap = paint_.stroke_cap;
1308 properties.stroke_join = paint_.stroke_join;
1309 properties.stroke_miter = paint_.stroke_miter;
1310 properties.stroke_width = paint_.stroke_width;
1311 }
1312 if (text_frame->HasColor()) {
1313 properties.color = paint_.color;
1314 }
1315 renderer_.GetLazyGlyphAtlas()->AddTextFrame(*text_frame, //
1316 matrix_.GetMaxBasisLengthXY(), //
1317 Point(x, y), //
1318 properties //
1319 );
1320}
1321
1323 const sk_sp<flutter::DisplayList> display_list,
1324 SkScalar opacity) {
1325 [[maybe_unused]] size_t stack_depth = stack_.size();
1326 save();
1327 display_list->Dispatch(*this);
1328 restore();
1329 FML_DCHECK(stack_depth == stack_.size());
1330}
1331
1332// |flutter::DlOpReceiver|
1334 paint_.style = ToStyle(style);
1335}
1336
1337// |flutter::DlOpReceiver|
1339 paint_.color = {
1340 color.getRedF(),
1341 color.getGreenF(),
1342 color.getBlueF(),
1343 color.getAlphaF(),
1344 };
1345}
1346
1347// |flutter::DlOpReceiver|
1349 paint_.stroke_width = width;
1350}
1351
1352// |flutter::DlOpReceiver|
1354 paint_.stroke_miter = limit;
1355}
1356
1357// |flutter::DlOpReceiver|
1359 switch (cap) {
1361 paint_.stroke_cap = Cap::kButt;
1362 break;
1364 paint_.stroke_cap = Cap::kRound;
1365 break;
1367 paint_.stroke_cap = Cap::kSquare;
1368 break;
1369 }
1370}
1371
1372// |flutter::DlOpReceiver|
1374 switch (join) {
1376 paint_.stroke_join = Join::kMiter;
1377 break;
1379 paint_.stroke_join = Join::kRound;
1380 break;
1382 paint_.stroke_join = Join::kBevel;
1383 break;
1384 }
1385}
1386
1387} // namespace impeller
const char * options
int count
Definition: FontMgrTest.cpp:50
static const int points[]
static unsigned clamp(SkFixed fx, int max)
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
#define SK_Scalar1
Definition: SkScalar.h:18
GLenum type
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
Definition: SkPath.h:59
SkVector getSimpleRadii() const
Definition: SkRRect.h:111
bool isOval() const
Definition: SkRRect.h:85
const SkRect & rect() const
Definition: SkRRect.h:264
bool isRect() const
Definition: SkRRect.h:84
bool isSimple() const
Definition: SkRRect.h:86
const SkRect & bounds() const
Definition: display_list.h:294
bool can_apply_group_opacity() const
Definition: display_list.h:305
uint32_t total_depth() const
Definition: display_list.h:290
bool has_rtree() const
Definition: display_list.h:296
void Dispatch(DlOpReceiver &ctx) const
virtual T type() const =0
@ 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
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
virtual const DlBlurMaskFilter * asBlur() const
void get_matrix(float matrix[20]) const
const SkMatrix & matrix() const
virtual void save()=0
const std::shared_ptr< std::vector< uint8_t > > uniform_data() const
const sk_sp< DlRuntimeEffect > runtime_effect() const
const std::vector< std::shared_ptr< DlColorSource > > samplers() const
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
Definition: dl_vertices.h:71
void DrawLine(const Point &p0, const Point &p1, const Paint &paint)
Definition: canvas.cc:485
const Matrix & GetCurrentTransform() const
Definition: canvas.cc:298
void DrawImageRect(const std::shared_ptr< Image > &image, Rect source, Rect dest, const Paint &paint, SamplerDescriptor sampler={}, SourceRectConstraint src_rect_constraint=SourceRectConstraint::kFast)
Definition: canvas.cc:766
void DrawVertices(const std::shared_ptr< VerticesGeometry > &vertices, BlendMode blend_mode, const Paint &paint)
Definition: canvas.cc:933
void DrawOval(const Rect &rect, const Paint &paint)
Definition: canvas.cc:514
void RestoreToCount(size_t count)
Definition: canvas.cc:335
void ClipPath(const Path &path, Entity::ClipOperation clip_op=Entity::ClipOperation::kIntersect)
Definition: canvas.cc:589
void ClipRRect(const Rect &rect, const Size &corner_radii, Entity::ClipOperation clip_op=Entity::ClipOperation::kIntersect)
Definition: canvas.cc:640
virtual bool Restore()
Definition: canvas.cc:257
size_t GetSaveCount() const
Definition: canvas.cc:331
void Transform(const Matrix &transform)
Definition: canvas.cc:294
void PreConcat(const Matrix &transform)
Definition: canvas.cc:286
virtual void SaveLayer(const Paint &paint, std::optional< Rect > bounds=std::nullopt, const std::shared_ptr< ImageFilter > &backdrop_filter=nullptr, ContentBoundsPromise bounds_promise=ContentBoundsPromise::kUnknown, uint32_t total_content_depth=kMaxDepth, bool can_distribute_opacity=false)
Definition: canvas.cc:842
void Rotate(Radians radians)
Definition: canvas.cc:327
void ResetTransform()
Definition: canvas.cc:290
virtual void DrawTextFrame(const std::shared_ptr< TextFrame > &text_frame, Point position, const Paint &paint)
Definition: canvas.cc:884
void DrawPaint(const Paint &paint)
Definition: canvas.cc:352
void ClipRect(const Rect &rect, Entity::ClipOperation clip_op=Entity::ClipOperation::kIntersect)
Definition: canvas.cc:599
void Skew(Scalar sx, Scalar sy)
Definition: canvas.cc:323
void Scale(const Vector2 &scale)
Definition: canvas.cc:315
const std::optional< Rect > GetCurrentLocalCullingBounds() const
Definition: canvas.cc:302
Picture EndRecordingAsPicture()
Definition: canvas.cc:804
void DrawPath(const Path &path, const Paint &paint)
Definition: canvas.cc:343
virtual void Save(uint32_t total_content_depth=kMaxDepth)
Definition: canvas.cc:184
void DrawPoints(std::vector< Point > points, Scalar radius, const Paint &paint, PointStyle point_style)
Definition: canvas.cc:733
void ClipOval(const Rect &bounds, Entity::ClipOperation clip_op=Entity::ClipOperation::kIntersect)
Definition: canvas.cc:620
void DrawRect(const Rect &rect, const Paint &paint)
Definition: canvas.cc:495
void DrawRRect(const Rect &rect, const Size &corner_radii, const Paint &paint)
Definition: canvas.cc:540
void DrawAtlas(const std::shared_ptr< Image > &atlas, std::vector< Matrix > transforms, std::vector< Rect > texture_coordinates, std::vector< Color > colors, BlendMode blend_mode, SamplerDescriptor sampler, std::optional< Rect > cull_rect, const Paint &paint)
Definition: canvas.cc:1020
void Translate(const Vector3 &offset)
Definition: canvas.cc:311
void DrawCircle(const Point &center, Scalar radius, const Paint &paint)
Definition: canvas.cc:566
static std::shared_ptr< ColorFilter > MakeMatrix(ColorMatrix color_matrix)
Definition: color_filter.cc:28
static std::shared_ptr< ColorFilter > MakeBlend(BlendMode blend_mode, Color color)
Definition: color_filter.cc:23
static std::shared_ptr< ColorFilter > MakeLinearToSrgb()
Definition: color_filter.cc:36
static std::shared_ptr< ColorFilter > MakeSrgbToLinear()
Definition: color_filter.cc:32
static ColorSource MakeLinearGradient(Point start_point, Point end_point, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeColor()
static ColorSource MakeRadialGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeImage(std::shared_ptr< Texture > texture, Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode, SamplerDescriptor sampler_descriptor, Matrix effect_transform)
static ColorSource MakeSweepGradient(Point center, Degrees start_angle, Degrees end_angle, std::vector< Color > colors, std::vector< Scalar > stops, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeConicalGradient(Point center, Scalar radius, std::vector< Color > colors, std::vector< Scalar > stops, Point focus_center, Scalar focus_radius, Entity::TileMode tile_mode, Matrix effect_transform)
static ColorSource MakeRuntimeEffect(std::shared_ptr< RuntimeStage > runtime_stage, std::shared_ptr< std::vector< uint8_t > > uniform_data, std::vector< RuntimeEffectContents::TextureInput > texture_inputs)
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
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 drawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length) override
void setImageFilter(const flutter::DlImageFilter *filter) override
void drawVertices(const flutter::DlVertices *vertices, flutter::DlBlendMode dl_mode) override
void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y) override
void setStrokeCap(flutter::DlStrokeCap cap) override
void drawPath(const SkPath &path) override
void setAntiAlias(bool aa) override
void drawPoints(PointMode mode, uint32_t count, const SkPoint points[]) override
void drawLine(const SkPoint &p0, const SkPoint &p1) override
void clipRect(const SkRect &rect, ClipOp clip_op, bool is_aa) override
void drawOval(const SkRect &bounds) override
void drawCircle(const SkPoint &center, SkScalar radius) override
void setStrokeJoin(flutter::DlStrokeJoin join) override
void setStrokeWidth(SkScalar width) override
void setColorFilter(const flutter::DlColorFilter *filter) override
void translate(SkScalar tx, SkScalar ty) override
void setDrawStyle(flutter::DlDrawStyle style) override
void clipRRect(const SkRRect &rrect, ClipOp clip_op, bool is_aa) override
void drawShadow(const SkPath &path, const flutter::DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr) override
void setStrokeMiter(SkScalar limit) override
void scale(SkScalar sx, SkScalar sy) override
void skew(SkScalar sx, SkScalar sy) override
void clipPath(const SkPath &path, ClipOp clip_op, bool is_aa) override
void setInvertColors(bool invert) override
void drawImage(const sk_sp< flutter::DlImage > image, const SkPoint point, flutter::DlImageSampling sampling, bool render_with_attributes) override
void drawImageNine(const sk_sp< flutter::DlImage > image, const SkIRect &center, const SkRect &dst, flutter::DlFilterMode filter, bool render_with_attributes) override
void drawAtlas(const sk_sp< flutter::DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const flutter::DlColor colors[], int count, flutter::DlBlendMode mode, flutter::DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes) override
void drawDRRect(const SkRRect &outer, const SkRRect &inner) override
void drawRect(const SkRect &rect) override
void drawDisplayList(const sk_sp< flutter::DisplayList > display_list, SkScalar opacity) override
void setColor(flutter::DlColor color) override
void drawImageRect(const sk_sp< flutter::DlImage > image, const SkRect &src, const SkRect &dst, flutter::DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint) override
void setMaskFilter(const flutter::DlMaskFilter *filter) override
virtual Canvas & GetCanvas()=0
void setColorSource(const flutter::DlColorSource *source) override
void transformReset() override
void setBlendMode(flutter::DlBlendMode mode) override
void drawArc(const SkRect &oval_bounds, SkScalar start_degrees, SkScalar sweep_degrees, bool use_center) override
void drawColor(flutter::DlColor color, flutter::DlBlendMode mode) override
void drawTextBlob(const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y) override
void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt) override
void saveLayer(const SkRect &bounds, const flutter::SaveLayerOptions &options, uint32_t total_content_depth, flutter::DlBlendMode max_content_mode, const flutter::DlImageFilter *backdrop) override
void rotate(SkScalar degrees) override
void drawRRect(const SkRRect &rrect) override
DlDispatcher()
Subclasses.
static constexpr BlendMode kLastPipelineBlendMode
Definition: entity.h:22
ExperimentalDlDispatcher(ContentContext &renderer, RenderTarget &render_target, bool has_root_backdrop_filter, flutter::DlBlendMode max_root_blend_mode, IRect cull_rect)
@ kNormal
Blurred inside and outside.
@ kOuter
Nothing inside, blurred outside.
@ kInner
Blurred inside, nothing outside.
@ kSolid
Solid inside, blurred outside.
static std::shared_ptr< ImageFilter > MakeMatrix(const Matrix &matrix, SamplerDescriptor sampler_descriptor)
Definition: image_filter.cc:39
static std::shared_ptr< ImageFilter > MakeLocalMatrix(const Matrix &matrix, const ImageFilter &internal_filter)
Definition: image_filter.cc:57
static std::shared_ptr< ImageFilter > MakeErode(Radius radius_x, Radius radius_y)
Definition: image_filter.cc:34
static std::shared_ptr< ImageFilter > MakeBlur(Sigma sigma_x, Sigma sigma_y, FilterContents::BlurStyle blur_style, Entity::TileMode tile_mode)
Definition: image_filter.cc:20
static std::shared_ptr< ImageFilter > MakeDilate(Radius radius_x, Radius radius_y)
Definition: image_filter.cc:29
static std::shared_ptr< ImageFilter > MakeFromColorFilter(const ColorFilter &color_filter)
Definition: image_filter.cc:52
static std::shared_ptr< ImageFilter > MakeCompose(const ImageFilter &inner, const ImageFilter &outer)
Definition: image_filter.cc:46
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition: path.h:52
void drawDisplayList(const sk_sp< flutter::DisplayList > display_list, SkScalar opacity) override
void rotate(SkScalar degrees) override
TextFrameDispatcher(const ContentContext &renderer, const Matrix &initial_matrix)
void setStrokeJoin(flutter::DlStrokeJoin join) override
void setStrokeWidth(SkScalar width) override
void skew(SkScalar sx, SkScalar sy) override
void setStrokeMiter(SkScalar limit) override
void saveLayer(const SkRect &bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter *backdrop) override
void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt) 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 scale(SkScalar sx, SkScalar sy) override
void translate(SkScalar tx, SkScalar ty) override
void setColor(flutter::DlColor color) override
void setStrokeCap(flutter::DlStrokeCap cap) override
void setDrawStyle(flutter::DlDrawStyle style) override
void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y) override
const Paint & paint
Definition: color_source.cc:38
#define UNIMPLEMENTED
DlColor color
SkBitmap source
Definition: examples.cpp:28
float SkScalar
Definition: extension.cpp:12
gboolean invert
GAsyncResult * result
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_UNREACHABLE()
Definition: logging.h:109
#define FML_DCHECK(condition)
Definition: logging.h:103
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
size_t length
FlTexture * texture
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
SkRect oval
Definition: SkRecords.h:249
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
SK_API sk_sp< SkShader > Color(SkColor)
string converter
Definition: cacheimages.py:19
DlStrokeJoin
Definition: dl_paint.h:37
@ kMiter
extends to miter limit
@ kBevel
connects outside edges
const SkPoint & ToSkPoint(const DlPoint &point)
DlStrokeCap
Definition: dl_paint.h:28
@ kRound
adds circle
@ kButt
no stroke extension
@ 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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
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
DlDrawStyle
Definition: dl_paint.h:19
@ kStrokeAndFill
both strokes and fills shapes
@ 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
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
@ kSrcOut
r = s * (1-da)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
dst
Definition: cp.py:12
std::vector< Point > ToPoints(const SkPoint points[], int count)
Path ToPath(const SkPath &path, Point shift)
void ConvertStops(const flutter::DlGradientColorSourceBase *gradient, std::vector< Color > &colors, std::vector< float > &stops)
Convert display list colors + stops into impeller colors and stops, taking care to ensure that the st...
Point ToPoint(const SkPoint &point)
Size ToSize(const SkPoint &point)
std::vector< Rect > ToRects(const SkRect tex[], int count)
std::vector< Matrix > ToRSXForms(const SkRSXform xform[], int count)
bool IsNearlySimpleRRect(const SkRRect &rr)
Like SkRRect.isSimple, but allows the corners to differ by kEhCloseEnough.
Rect ToRect(const SkRect &rect)
Color ToColor(const flutter::DlColor &color)
static BlendMode ToBlendMode(flutter::DlBlendMode mode)
Point Vector2
Definition: point.h:326
float Scalar
Definition: scalar.h:18
static Paint::Style ToStyle(flutter::DlDrawStyle style)
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
@ kBase
The texture is sampled as if it only had a single mipmap level.
static std::shared_ptr< ImageFilter > ToImageFilter(const flutter::DlImageFilter *filter)
@ kRound
Points are drawn as squares.
@ kSquare
Points are drawn as circles.
static std::optional< ColorSource::Type > ToColorSourceType(flutter::DlColorSourceType type)
static bool RequiresReadbackForBlends(const ContentContext &renderer, flutter::DlBlendMode max_root_blend_mode)
static Entity::ClipOperation ToClipOperation(flutter::DlCanvas::ClipOp clip_op)
static Matrix ToMatrix(const SkMatrix &m)
BlendMode
Definition: color.h:59
@ kMayClipContents
The caller claims the bounds are a subset of an estimate of the reasonably tight bounds but likely cl...
@ kContainsContents
The caller claims the bounds are a reasonably tight estimate of the coverage of the contents and shou...
static std::shared_ptr< ColorFilter > ToColorFilter(const flutter::DlColorFilter *filter)
static impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlImageSampling options)
static Entity::TileMode ToTileMode(flutter::DlTileMode tile_mode)
flutter::DlScalar DlScalar
Definition: dl_dispatcher.h:20
@ kNearest
Select nearest to the sample point. Most widely supported.
static std::vector< Color > ToColors(const flutter::DlColor colors[], int count)
static FilterContents::BlurStyle ToBlurStyle(flutter::DlBlurStyle blur_style)
std::shared_ptr< impeller::VerticesGeometry > MakeVertices(const flutter::DlVertices *vertices)
SK_API sk_sp< PrecompileColorFilter > Matrix()
dest
Definition: zip.py:79
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
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
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646
Scalar array[20]
Definition: color.h:118
Scalar blue
Definition: color.h:138
Scalar alpha
Definition: color.h:143
Scalar red
Definition: color.h:128
Scalar green
Definition: color.h:133
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
constexpr Scalar GetMaxBasisLengthXY() const
Definition: matrix.h:300
constexpr Matrix Translate(const Vector3 &t) const
Definition: matrix.h:240
constexpr Vector3 GetScale() const
Definition: matrix.h:311
static constexpr Matrix MakeColumn(Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15)
Definition: matrix.h:69
static constexpr Matrix MakeSkew(Scalar sx, Scalar sy)
Definition: matrix.h:117
constexpr Matrix Scale(const Vector3 &s) const
Definition: matrix.h:252
static Matrix MakeRotationZ(Radians r)
Definition: matrix.h:213
constexpr bool HasPerspective() const
Definition: matrix.h:330
FilterContents::BlurStyle style
Definition: paint.h:49
ColorSource color_source
Definition: paint.h:69
Cap stroke_cap
Definition: paint.h:72
Join stroke_join
Definition: paint.h:73
Scalar stroke_miter
Definition: paint.h:74
Style style
Definition: paint.h:75
bool invert_colors
Definition: paint.h:77
std::shared_ptr< ImageFilter > image_filter
Definition: paint.h:79
std::optional< MaskBlurDescriptor > mask_blur_descriptor
Definition: paint.h:81
Color color
Definition: paint.h:68
BlendMode blend_mode
Definition: paint.h:76
std::shared_ptr< ColorFilter > color_filter
Definition: paint.h:80
Scalar stroke_width
Definition: paint.h:71
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
Definition: sigma.h:48
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition: sigma.h:32
constexpr Type GetDistance(const TPoint &p) const
Definition: point.h:200
constexpr auto GetBottom() const
Definition: rect.h:347
constexpr auto GetTop() const
Definition: rect.h:343
constexpr auto GetLeft() const
Definition: rect.h:341
constexpr auto GetRight() const
Definition: rect.h:345
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129
#define ERROR(message)
Definition: elf_loader.cc:260
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131
static sk_sp< SkShader > linear(sk_sp< SkShader > shader)