Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::FirstPassDispatcher Class Reference

#include <dl_dispatcher.h>

Inheritance diagram for impeller::FirstPassDispatcher:
flutter::IgnoreAttributeDispatchHelper flutter::IgnoreClipDispatchHelper flutter::IgnoreDrawDispatchHelper flutter::DlOpReceiver flutter::DlOpReceiver flutter::DlOpReceiver

Public Member Functions

 FirstPassDispatcher (const ContentContext &renderer, const Matrix &initial_matrix, const Rect cull_rect)
 
 ~FirstPassDispatcher ()
 
void save () override
 
void saveLayer (const DlRect &bounds, const flutter::SaveLayerOptions options, const flutter::DlImageFilter *backdrop, std::optional< int64_t > backdrop_id) override
 
void restore () override
 
void translate (DlScalar tx, DlScalar ty) override
 
void scale (DlScalar sx, DlScalar sy) override
 
void rotate (DlScalar degrees) override
 
void skew (DlScalar sx, DlScalar sy) override
 
void transform2DAffine (DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt) override
 
void transformFullPerspective (DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt) override
 
void transformReset () override
 
void drawText (const std::shared_ptr< flutter::DlText > &text, DlScalar x, DlScalar y) override
 
void drawDisplayList (const sk_sp< flutter::DisplayList > display_list, DlScalar opacity) override
 
void setDrawStyle (flutter::DlDrawStyle style) override
 
void setColor (flutter::DlColor color) override
 
void setStrokeWidth (DlScalar width) override
 
void setStrokeMiter (DlScalar limit) override
 
void setStrokeCap (flutter::DlStrokeCap cap) override
 
void setStrokeJoin (flutter::DlStrokeJoin join) override
 
void setImageFilter (const flutter::DlImageFilter *filter) override
 
std::pair< std::unordered_map< int64_t, BackdropData >, size_t > TakeBackdropData ()
 
- Public Member Functions inherited from flutter::IgnoreAttributeDispatchHelper
void setAntiAlias (bool aa) override
 
void setInvertColors (bool invert) override
 
void setStrokeCap (DlStrokeCap cap) override
 
void setStrokeJoin (DlStrokeJoin join) override
 
void setDrawStyle (DlDrawStyle style) override
 
void setStrokeWidth (float width) override
 
void setStrokeMiter (float limit) override
 
void setColor (DlColor color) override
 
void setBlendMode (DlBlendMode mode) override
 
void setColorSource (const DlColorSource *source) override
 
void setImageFilter (const DlImageFilter *filter) override
 
void setColorFilter (const DlColorFilter *filter) override
 
void setMaskFilter (const DlMaskFilter *filter) override
 
- Public Member Functions inherited from flutter::DlOpReceiver
virtual void save (uint32_t total_content_depth)
 
virtual void saveLayer (const DlRect &bounds, const SaveLayerOptions &options, uint32_t total_content_depth, DlBlendMode max_content_blend_mode, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt)
 
virtual void saveLayer (const DlRect *bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) final
 
- Public Member Functions inherited from flutter::IgnoreDrawDispatchHelper
void save () override
 
void saveLayer (const DlRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop, std::optional< int64_t > backdrop_id) override
 
void restore () override
 
void drawColor (DlColor color, DlBlendMode mode) override
 
void drawPaint () override
 
void drawLine (const DlPoint &p0, const DlPoint &p1) override
 
void drawDashedLine (const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length) override
 
void drawRect (const DlRect &rect) override
 
void drawOval (const DlRect &bounds) override
 
void drawCircle (const DlPoint &center, DlScalar radius) override
 
void drawRoundRect (const DlRoundRect &rrect) override
 
void drawDiffRoundRect (const DlRoundRect &outer, const DlRoundRect &inner) override
 
void drawRoundSuperellipse (const DlRoundSuperellipse &rse) override
 
void drawPath (const DlPath &path) override
 
void drawArc (const DlRect &oval_bounds, DlScalar start_degrees, DlScalar sweep_degrees, bool use_center) override
 
void drawPoints (DlPointMode mode, uint32_t count, const DlPoint points[]) override
 
void drawVertices (const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode) override
 
void drawImage (const sk_sp< DlImage > image, const DlPoint &point, DlImageSampling sampling, bool render_with_attributes) override
 
void drawImageRect (const sk_sp< DlImage > image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, bool render_with_attributes, DlSrcRectConstraint constraint) override
 
void drawImageNine (const sk_sp< DlImage > image, const DlIRect &center, const DlRect &dst, DlFilterMode filter, bool render_with_attributes) override
 
void drawAtlas (const sk_sp< DlImage > atlas, const DlRSTransform xform[], const DlRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const DlRect *cull_rect, bool render_with_attributes) override
 
void drawDisplayList (const sk_sp< DisplayList > display_list, DlScalar opacity) override
 
void drawText (const std::shared_ptr< DlText > &text, DlScalar x, DlScalar y) override
 
void drawShadow (const DlPath &path, const DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr) override
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::DlOpReceiver
static constexpr int kMaxDrawPointsCount = ((1 << 29) - 1)
 

Detailed Description

Performs a first pass over the display list to collect information that will be useful in a second pass by the CanvasDlDispatcher. This class collects things like text frames and backdrop filters.

Definition at line 359 of file dl_dispatcher.h.

Constructor & Destructor Documentation

◆ FirstPassDispatcher()

impeller::FirstPassDispatcher::FirstPassDispatcher ( const ContentContext renderer,
const Matrix initial_matrix,
const Rect  cull_rect 
)

Definition at line 980 of file dl_dispatcher.cc.

983 : renderer_(renderer), matrix_(initial_matrix) {
984 cull_rect_state_.push_back(cull_rect);
985}

◆ ~FirstPassDispatcher()

impeller::FirstPassDispatcher::~FirstPassDispatcher ( )

Definition at line 987 of file dl_dispatcher.cc.

987 {
988 FML_DCHECK(cull_rect_state_.size() == 1);
989}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK.

Member Function Documentation

◆ drawDisplayList()

void impeller::FirstPassDispatcher::drawDisplayList ( const sk_sp< flutter::DisplayList display_list,
DlScalar  opacity 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1128 of file dl_dispatcher.cc.

1130 {
1131 [[maybe_unused]] size_t stack_depth = stack_.size();
1132 save();
1133 Paint old_paint = paint_;
1134 paint_ = Paint{};
1135 bool old_has_image_filter = has_image_filter_;
1136 has_image_filter_ = false;
1137
1138 if (matrix_.HasPerspective()) {
1139 display_list->Dispatch(*this);
1140 } else {
1141 Rect local_cull_bounds = GetCurrentLocalCullingBounds();
1142 if (local_cull_bounds.IsMaximum()) {
1143 display_list->Dispatch(*this);
1144 } else if (!local_cull_bounds.IsEmpty()) {
1145 DlIRect cull_rect = DlIRect::RoundOut(local_cull_bounds);
1146 display_list->Dispatch(*this, cull_rect);
1147 }
1148 }
1149
1150 restore();
1151 paint_ = old_paint;
1152 has_image_filter_ = old_has_image_filter;
1153 FML_DCHECK(stack_depth == stack_.size());
1154}
flutter::DlIRect DlIRect
TRect< Scalar > Rect
Definition rect.h:822
constexpr bool HasPerspective() const
Definition matrix.h:426
RoundOut(const TRect< U > &r)
Definition rect.h:713

References FML_DCHECK, impeller::Matrix::HasPerspective(), impeller::TRect< T >::IsEmpty(), impeller::TRect< T >::IsMaximum(), restore(), impeller::TRect< T >::RoundOut(), and save().

◆ drawText()

void impeller::FirstPassDispatcher::drawText ( const std::shared_ptr< flutter::DlText > &  text,
DlScalar  x,
DlScalar  y 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1093 of file dl_dispatcher.cc.

1095 {
1096 GlyphProperties properties;
1097 auto text_frame = text->GetTextFrame();
1098 if (text_frame == nullptr) {
1099 return;
1100 }
1101
1102 properties.stroke = paint_.GetStroke();
1103
1104 if (text_frame->HasColor()) {
1105 // Alpha is always applied when rendering, remove it here so
1106 // we do not double-apply the alpha.
1107 properties.tone_or_color = paint_.color.WithAlpha(1.0);
1108 } else {
1109 properties.tone_or_color = GlyphProperties::ComputeTone(paint_.color);
1110 }
1111
1112 renderer_.GetLazyGlyphAtlas()->AddTextFrame(text_frame, //
1113 Point(x, y), //
1114 matrix_, //
1115 properties //
1116 );
1117}
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
int32_t x
std::u16string text
double y
TPoint< Scalar > Point
Definition point.h:426
constexpr Color WithAlpha(Scalar new_alpha) const
Definition color.h:283
static Tone ComputeTone(const Color &c)
std::optional< StrokeParameters > GetStroke() const
Return an optional StrokeParameters if this Paint is a stroked Paint, otherwise return a nullopt.
Definition paint.h:95
Color color
Definition paint.h:79

References impeller::Paint::color, impeller::GlyphProperties::ComputeTone(), impeller::ContentContext::GetLazyGlyphAtlas(), impeller::Paint::GetStroke(), impeller::GlyphProperties::stroke, text, impeller::GlyphProperties::tone_or_color, impeller::Color::WithAlpha(), x, and y.

◆ restore()

void impeller::FirstPassDispatcher::restore ( )
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1037 of file dl_dispatcher.cc.

1037 {
1038 matrix_ = stack_.back();
1039 stack_.pop_back();
1040 cull_rect_state_.pop_back();
1041}

Referenced by drawDisplayList().

◆ rotate()

void impeller::FirstPassDispatcher::rotate ( DlScalar  degrees)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1051 of file dl_dispatcher.cc.

1051 {
1052 matrix_ = matrix_ * Matrix::MakeRotationZ(Degrees(degrees));
1053}
static Matrix MakeRotationZ(Radians r)
Definition matrix.h:223

References impeller::Matrix::MakeRotationZ().

◆ save()

void impeller::FirstPassDispatcher::save ( )
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 991 of file dl_dispatcher.cc.

991 {
992 stack_.emplace_back(matrix_);
993 cull_rect_state_.push_back(cull_rect_state_.back());
994}

Referenced by drawDisplayList(), and saveLayer().

◆ saveLayer()

void impeller::FirstPassDispatcher::saveLayer ( const DlRect bounds,
const flutter::SaveLayerOptions  options,
const flutter::DlImageFilter backdrop,
std::optional< int64_t >  backdrop_id 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 996 of file dl_dispatcher.cc.

999 {
1000 save();
1001
1002 backdrop_count_ += (backdrop == nullptr ? 0 : 1);
1003 if (backdrop != nullptr && backdrop_id.has_value()) {
1004 std::shared_ptr<flutter::DlImageFilter> shared_backdrop =
1005 backdrop->shared();
1006 std::unordered_map<int64_t, BackdropData>::iterator existing =
1007 backdrop_data_.find(backdrop_id.value());
1008 if (existing == backdrop_data_.end()) {
1009 backdrop_data_[backdrop_id.value()] =
1010 BackdropData{.backdrop_count = 1, .last_backdrop = shared_backdrop};
1011 } else {
1012 BackdropData& data = existing->second;
1013 data.backdrop_count++;
1014 if (data.all_filters_equal) {
1015 data.all_filters_equal = (*data.last_backdrop == *shared_backdrop);
1016 data.last_backdrop = shared_backdrop;
1017 }
1018 }
1019 }
1020
1021 // This dispatcher does not track enough state to accurately compute
1022 // cull rects with image filters.
1023 auto global_cull_rect = cull_rect_state_.back();
1024 if (has_image_filter_ || global_cull_rect.IsMaximum()) {
1025 cull_rect_state_.back() = Rect::MakeMaximum();
1026 } else {
1027 auto global_save_bounds = bounds.TransformBounds(matrix_);
1028 auto new_cull_rect = global_cull_rect.Intersection(global_save_bounds);
1029 if (new_cull_rect.has_value()) {
1030 cull_rect_state_.back() = new_cull_rect.value();
1031 } else {
1032 cull_rect_state_.back() = Rect::MakeLTRB(0, 0, 0, 0);
1033 }
1034 }
1035}
virtual std::shared_ptr< D > shared() const =0
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
static constexpr TRect MakeMaximum()
Definition rect.h:212
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129

References impeller::BackdropData::backdrop_count, impeller::TRect< T >::Intersection(), impeller::TRect< Scalar >::MakeLTRB(), impeller::TRect< Scalar >::MakeMaximum(), save(), flutter::DlAttribute< D, T >::shared(), and impeller::TRect< T >::TransformBounds().

◆ scale()

void impeller::FirstPassDispatcher::scale ( DlScalar  sx,
DlScalar  sy 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1047 of file dl_dispatcher.cc.

1047 {
1048 matrix_ = matrix_.Scale({sx, sy, 1.0f});
1049}
constexpr Matrix Scale(const Vector3 &s) const
Definition matrix.h:275

References impeller::Matrix::Scale().

◆ setColor()

void impeller::FirstPassDispatcher::setColor ( flutter::DlColor  color)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1162 of file dl_dispatcher.cc.

1162 {
1163 paint_.color = skia_conversions::ToColor(color);
1164}
Color ToColor(const flutter::DlColor &color)

References impeller::Paint::color, and impeller::skia_conversions::ToColor().

◆ setDrawStyle()

void impeller::FirstPassDispatcher::setDrawStyle ( flutter::DlDrawStyle  style)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1157 of file dl_dispatcher.cc.

1157 {
1158 paint_.style = ToStyle(style);
1159}
static Paint::Style ToStyle(flutter::DlDrawStyle style)
Style style
Definition paint.h:85

References impeller::Paint::style, and impeller::ToStyle().

◆ setImageFilter()

void impeller::FirstPassDispatcher::setImageFilter ( const flutter::DlImageFilter filter)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1207 of file dl_dispatcher.cc.

1207 {
1208 if (filter == nullptr) {
1209 has_image_filter_ = false;
1210 } else {
1211 has_image_filter_ = true;
1212 }
1213}

◆ setStrokeCap()

void impeller::FirstPassDispatcher::setStrokeCap ( flutter::DlStrokeCap  cap)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1177 of file dl_dispatcher.cc.

1177 {
1178 switch (cap) {
1180 paint_.stroke.cap = Cap::kButt;
1181 break;
1183 paint_.stroke.cap = Cap::kRound;
1184 break;
1186 paint_.stroke.cap = Cap::kSquare;
1187 break;
1188 }
1189}
@ kRound
adds circle
@ kButt
no stroke extension
@ kSquare
adds square
StrokeParameters stroke
Definition paint.h:84

References impeller::StrokeParameters::cap, flutter::kButt, impeller::kButt, flutter::kRound, impeller::kRound, flutter::kSquare, impeller::kSquare, and impeller::Paint::stroke.

◆ setStrokeJoin()

void impeller::FirstPassDispatcher::setStrokeJoin ( flutter::DlStrokeJoin  join)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1192 of file dl_dispatcher.cc.

1192 {
1193 switch (join) {
1195 paint_.stroke.join = Join::kMiter;
1196 break;
1198 paint_.stroke.join = Join::kRound;
1199 break;
1201 paint_.stroke.join = Join::kBevel;
1202 break;
1203 }
1204}
@ kMiter
extends to miter limit
@ kBevel
connects outside edges

References impeller::StrokeParameters::join, flutter::kBevel, impeller::kBevel, flutter::kMiter, impeller::kMiter, flutter::kRound, impeller::kRound, and impeller::Paint::stroke.

◆ setStrokeMiter()

void impeller::FirstPassDispatcher::setStrokeMiter ( DlScalar  limit)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1172 of file dl_dispatcher.cc.

1172 {
1173 paint_.stroke.miter_limit = limit;
1174}

References impeller::StrokeParameters::miter_limit, and impeller::Paint::stroke.

◆ setStrokeWidth()

void impeller::FirstPassDispatcher::setStrokeWidth ( DlScalar  width)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1167 of file dl_dispatcher.cc.

1167 {
1168 paint_.stroke.width = width;
1169}
int32_t width

References impeller::Paint::stroke, impeller::StrokeParameters::width, and width.

◆ skew()

void impeller::FirstPassDispatcher::skew ( DlScalar  sx,
DlScalar  sy 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1055 of file dl_dispatcher.cc.

1055 {
1056 matrix_ = matrix_ * Matrix::MakeSkew(sx, sy);
1057}
static constexpr Matrix MakeSkew(Scalar sx, Scalar sy)
Definition matrix.h:127

References impeller::Matrix::MakeSkew().

◆ TakeBackdropData()

std::pair< std::unordered_map< int64_t, BackdropData >, size_t > impeller::FirstPassDispatcher::TakeBackdropData ( )

Definition at line 1222 of file dl_dispatcher.cc.

1222 {
1223 std::unordered_map<int64_t, BackdropData> temp;
1224 std::swap(temp, backdrop_data_);
1225 return std::make_pair(temp, backdrop_count_);
1226}

Referenced by impeller::DisplayListToTexture(), and impeller::RenderToTarget().

◆ transform2DAffine()

void impeller::FirstPassDispatcher::transform2DAffine ( DlScalar  mxx,
DlScalar  mxy,
DlScalar  mxt,
DlScalar  myx,
DlScalar  myy,
DlScalar  myt 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1061 of file dl_dispatcher.cc.

1063 {
1064 matrix_ = matrix_ * Matrix::MakeColumn(
1065 mxx, myx, 0.0f, 0.0f,
1066 mxy, myy, 0.0f, 0.0f,
1067 0.0f, 0.0f, 1.0f, 0.0f,
1068 mxt, myt, 0.0f, 1.0f
1069 );
1070}
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

References impeller::Matrix::MakeColumn().

◆ transformFullPerspective()

void impeller::FirstPassDispatcher::transformFullPerspective ( DlScalar  mxx,
DlScalar  mxy,
DlScalar  mxz,
DlScalar  mxt,
DlScalar  myx,
DlScalar  myy,
DlScalar  myz,
DlScalar  myt,
DlScalar  mzx,
DlScalar  mzy,
DlScalar  mzz,
DlScalar  mzt,
DlScalar  mwx,
DlScalar  mwy,
DlScalar  mwz,
DlScalar  mwt 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1075 of file dl_dispatcher.cc.

1079 {
1080 matrix_ = matrix_ * Matrix::MakeColumn(
1081 mxx, myx, mzx, mwx,
1082 mxy, myy, mzy, mwy,
1083 mxz, myz, mzz, mwz,
1084 mxt, myt, mzt, mwt
1085 );
1086}

References impeller::Matrix::MakeColumn().

◆ transformReset()

void impeller::FirstPassDispatcher::transformReset ( )
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1089 of file dl_dispatcher.cc.

1089 {
1090 matrix_ = Matrix();
1091}

◆ translate()

void impeller::FirstPassDispatcher::translate ( DlScalar  tx,
DlScalar  ty 
)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1043 of file dl_dispatcher.cc.

1043 {
1044 matrix_ = matrix_.Translate({tx, ty});
1045}
constexpr Matrix Translate(const Vector3 &t) const
Definition matrix.h:263

References impeller::Matrix::Translate().


The documentation for this class was generated from the following files: