Flutter Engine
 
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 infomation. Collects things like text frames and backdrop filters.

Definition at line 311 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 966 of file dl_dispatcher.cc.

969 : renderer_(renderer), matrix_(initial_matrix) {
970 cull_rect_state_.push_back(cull_rect);
971}

◆ ~FirstPassDispatcher()

impeller::FirstPassDispatcher::~FirstPassDispatcher ( )

Definition at line 973 of file dl_dispatcher.cc.

973 {
974 FML_DCHECK(cull_rect_state_.size() == 1);
975}
#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 1120 of file dl_dispatcher.cc.

1122 {
1123 [[maybe_unused]] size_t stack_depth = stack_.size();
1124 save();
1125 Paint old_paint = paint_;
1126 paint_ = Paint{};
1127 bool old_has_image_filter = has_image_filter_;
1128 has_image_filter_ = false;
1129
1130 if (matrix_.HasPerspective()) {
1131 display_list->Dispatch(*this);
1132 } else {
1133 Rect local_cull_bounds = GetCurrentLocalCullingBounds();
1134 if (local_cull_bounds.IsMaximum()) {
1135 display_list->Dispatch(*this);
1136 } else if (!local_cull_bounds.IsEmpty()) {
1137 DlIRect cull_rect = DlIRect::RoundOut(local_cull_bounds);
1138 display_list->Dispatch(*this, cull_rect);
1139 }
1140 }
1141
1142 restore();
1143 paint_ = old_paint;
1144 has_image_filter_ = old_has_image_filter;
1145 FML_DCHECK(stack_depth == stack_.size());
1146}
flutter::DlIRect DlIRect
TRect< Scalar > Rect
Definition rect.h:788
constexpr bool HasPerspective() const
Definition matrix.h:418
RoundOut(const TRect< U > &r)
Definition rect.h:679

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 1079 of file dl_dispatcher.cc.

1081 {
1082 GlyphProperties properties;
1083 auto text_frame = text->GetTextFrame();
1084 if (text_frame == nullptr) {
1085 return;
1086 }
1087
1088 if (paint_.style == Paint::Style::kStroke) {
1089 properties.stroke = paint_.stroke;
1090 }
1091
1092 if (text_frame->HasColor()) {
1093 // Alpha is always applied when rendering, remove it here so
1094 // we do not double-apply the alpha.
1095 properties.color = paint_.color.WithAlpha(1.0);
1096 }
1098 (matrix_ * Matrix::MakeTranslation(Point(x, y))).GetMaxBasisLengthXY());
1099
1100 renderer_.GetLazyGlyphAtlas()->AddTextFrame(
1101 text_frame, //
1102 scale, //
1103 Point(x, y), //
1104 matrix_,
1105 (properties.stroke.has_value() || text_frame->HasColor()) //
1106 ? std::optional<GlyphProperties>(properties) //
1107 : std::nullopt //
1108 );
1109}
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas() const
void scale(DlScalar sx, DlScalar sy) override
static Rational RoundScaledFontSize(Scalar scale)
Definition text_frame.cc:55
int32_t x
std::u16string text
double y
TPoint< Scalar > Point
Definition point.h:327
Definition ref_ptr.h:261
constexpr Color WithAlpha(Scalar new_alpha) const
Definition color.h:278
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition matrix.h:95
Style style
Definition paint.h:81
Color color
Definition paint.h:75
StrokeParameters stroke
Definition paint.h:80

References impeller::Paint::color, impeller::GlyphProperties::color, impeller::ContentContext::GetLazyGlyphAtlas(), impeller::Paint::kStroke, impeller::Matrix::MakeTranslation(), impeller::TextFrame::RoundScaledFontSize(), scale(), impeller::Paint::stroke, impeller::GlyphProperties::stroke, impeller::Paint::style, text, impeller::Color::WithAlpha(), x, and y.

◆ restore()

void impeller::FirstPassDispatcher::restore ( )
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1023 of file dl_dispatcher.cc.

1023 {
1024 matrix_ = stack_.back();
1025 stack_.pop_back();
1026 cull_rect_state_.pop_back();
1027}

Referenced by drawDisplayList().

◆ rotate()

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

Implements flutter::DlOpReceiver.

Definition at line 1037 of file dl_dispatcher.cc.

1037 {
1038 matrix_ = matrix_ * Matrix::MakeRotationZ(Degrees(degrees));
1039}
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 977 of file dl_dispatcher.cc.

977 {
978 stack_.emplace_back(matrix_);
979 cull_rect_state_.push_back(cull_rect_state_.back());
980}

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 982 of file dl_dispatcher.cc.

985 {
986 save();
987
988 backdrop_count_ += (backdrop == nullptr ? 0 : 1);
989 if (backdrop != nullptr && backdrop_id.has_value()) {
990 std::shared_ptr<flutter::DlImageFilter> shared_backdrop =
991 backdrop->shared();
992 std::unordered_map<int64_t, BackdropData>::iterator existing =
993 backdrop_data_.find(backdrop_id.value());
994 if (existing == backdrop_data_.end()) {
995 backdrop_data_[backdrop_id.value()] =
996 BackdropData{.backdrop_count = 1, .last_backdrop = shared_backdrop};
997 } else {
998 BackdropData& data = existing->second;
999 data.backdrop_count++;
1000 if (data.all_filters_equal) {
1001 data.all_filters_equal = (*data.last_backdrop == *shared_backdrop);
1002 data.last_backdrop = shared_backdrop;
1003 }
1004 }
1005 }
1006
1007 // This dispatcher does not track enough state to accurately compute
1008 // cull rects with image filters.
1009 auto global_cull_rect = cull_rect_state_.back();
1010 if (has_image_filter_ || global_cull_rect.IsMaximum()) {
1011 cull_rect_state_.back() = Rect::MakeMaximum();
1012 } else {
1013 auto global_save_bounds = bounds.TransformBounds(matrix_);
1014 auto new_cull_rect = global_cull_rect.Intersection(global_save_bounds);
1015 if (new_cull_rect.has_value()) {
1016 cull_rect_state_.back() = new_cull_rect.value();
1017 } else {
1018 cull_rect_state_.back() = Rect::MakeLTRB(0, 0, 0, 0);
1019 }
1020 }
1021}
virtual std::shared_ptr< D > shared() const =0
static constexpr TRect MakeMaximum()
Definition rect.h:188
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129
std::shared_ptr< const fml::Mapping > data

References impeller::BackdropData::backdrop_count, data, 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 1033 of file dl_dispatcher.cc.

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

References impeller::Matrix::Scale().

Referenced by drawText().

◆ setColor()

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

Implements flutter::DlOpReceiver.

Definition at line 1154 of file dl_dispatcher.cc.

1154 {
1155 paint_.color = skia_conversions::ToColor(color);
1156}
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 1149 of file dl_dispatcher.cc.

1149 {
1150 paint_.style = ToStyle(style);
1151}
static Paint::Style ToStyle(flutter::DlDrawStyle style)

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

◆ setImageFilter()

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

Implements flutter::DlOpReceiver.

Definition at line 1199 of file dl_dispatcher.cc.

1199 {
1200 if (filter == nullptr) {
1201 has_image_filter_ = false;
1202 } else {
1203 has_image_filter_ = true;
1204 }
1205}

◆ setStrokeCap()

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

Implements flutter::DlOpReceiver.

Definition at line 1169 of file dl_dispatcher.cc.

1169 {
1170 switch (cap) {
1172 paint_.stroke.cap = Cap::kButt;
1173 break;
1175 paint_.stroke.cap = Cap::kRound;
1176 break;
1178 paint_.stroke.cap = Cap::kSquare;
1179 break;
1180 }
1181}
@ kRound
adds circle
@ kButt
no stroke extension
@ kSquare
adds square

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 1184 of file dl_dispatcher.cc.

1184 {
1185 switch (join) {
1187 paint_.stroke.join = Join::kMiter;
1188 break;
1190 paint_.stroke.join = Join::kRound;
1191 break;
1193 paint_.stroke.join = Join::kBevel;
1194 break;
1195 }
1196}
@ 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 1164 of file dl_dispatcher.cc.

1164 {
1165 paint_.stroke.miter_limit = limit;
1166}

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

◆ setStrokeWidth()

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

Implements flutter::DlOpReceiver.

Definition at line 1159 of file dl_dispatcher.cc.

1159 {
1160 paint_.stroke.width = width;
1161}
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 1041 of file dl_dispatcher.cc.

1041 {
1042 matrix_ = matrix_ * Matrix::MakeSkew(sx, sy);
1043}
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 1208 of file dl_dispatcher.cc.

1208 {
1209 std::unordered_map<int64_t, BackdropData> temp;
1210 std::swap(temp, backdrop_data_);
1211 return std::make_pair(temp, backdrop_count_);
1212}

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 1047 of file dl_dispatcher.cc.

1049 {
1050 matrix_ = matrix_ * Matrix::MakeColumn(
1051 mxx, myx, 0.0f, 0.0f,
1052 mxy, myy, 0.0f, 0.0f,
1053 0.0f, 0.0f, 1.0f, 0.0f,
1054 mxt, myt, 0.0f, 1.0f
1055 );
1056}
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 1061 of file dl_dispatcher.cc.

1065 {
1066 matrix_ = matrix_ * Matrix::MakeColumn(
1067 mxx, myx, mzx, mwx,
1068 mxy, myy, mzy, mwy,
1069 mxz, myz, mzz, mwz,
1070 mxt, myt, mzt, mwt
1071 );
1072}

References impeller::Matrix::MakeColumn().

◆ transformReset()

void impeller::FirstPassDispatcher::transformReset ( )
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 1075 of file dl_dispatcher.cc.

1075 {
1076 matrix_ = Matrix();
1077}

◆ translate()

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

Implements flutter::DlOpReceiver.

Definition at line 1029 of file dl_dispatcher.cc.

1029 {
1030 matrix_ = matrix_.Translate({tx, ty});
1031}
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: