Flutter Engine
 
Loading...
Searching...
No Matches
flutter::ComplexityCalculatorHelper Class Referenceabstract

#include <dl_complexity_helper.h>

Inheritance diagram for flutter::ComplexityCalculatorHelper:
flutter::DlOpReceiver flutter::IgnoreClipDispatchHelper flutter::IgnoreTransformDispatchHelper flutter::DlOpReceiver flutter::DlOpReceiver

Public Member Functions

 ComplexityCalculatorHelper (unsigned int ceiling)
 
virtual ~ComplexityCalculatorHelper ()=default
 
void setInvertColors (bool invert) override
 
void setStrokeCap (DlStrokeCap cap) override
 
void setStrokeJoin (DlStrokeJoin join) override
 
void setStrokeMiter (DlScalar 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
 
void save () override
 
void restore () override
 
void setAntiAlias (bool aa) override
 
void setDrawStyle (DlDrawStyle style) override
 
void setStrokeWidth (DlScalar width) override
 
void drawColor (DlColor color, DlBlendMode mode) override
 
void drawPaint () override
 
void drawImageRect (const sk_sp< DlImage > image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, bool render_with_attributes, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast) 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
 
unsigned int ComplexityScore ()
 
- Public Member Functions inherited from flutter::DlOpReceiver
virtual void save (uint32_t total_content_depth)
 
virtual void saveLayer (const DlRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt)=0
 
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
 
virtual void drawLine (const DlPoint &p0, const DlPoint &p1)=0
 
virtual void drawDashedLine (const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length)=0
 
virtual void drawRect (const DlRect &rect)=0
 
virtual void drawOval (const DlRect &bounds)=0
 
virtual void drawCircle (const DlPoint &center, DlScalar radius)=0
 
virtual void drawRoundRect (const DlRoundRect &rrect)=0
 
virtual void drawDiffRoundRect (const DlRoundRect &outer, const DlRoundRect &inner)=0
 
virtual void drawRoundSuperellipse (const DlRoundSuperellipse &rse)=0
 
virtual void drawPath (const DlPath &path)=0
 
virtual void drawArc (const DlRect &oval_bounds, DlScalar start_degrees, DlScalar sweep_degrees, bool use_center)=0
 
virtual void drawPoints (DlPointMode mode, uint32_t count, const DlPoint points[])=0
 
virtual void drawVertices (const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode)=0
 
virtual void drawImage (const sk_sp< DlImage > image, const DlPoint &point, DlImageSampling sampling, bool render_with_attributes)=0
 
virtual void drawImageNine (const sk_sp< DlImage > image, const DlIRect &center, const DlRect &dst, DlFilterMode filter, bool render_with_attributes)=0
 
virtual void drawDisplayList (const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1)=0
 
virtual void drawText (const std::shared_ptr< DlText > &text, DlScalar x, DlScalar y)=0
 
virtual void drawShadow (const DlPath &path, const DlColor color, const DlScalar elevation, bool transparent_occluder, DlScalar dpr)=0
 
- Public Member Functions inherited from flutter::IgnoreTransformDispatchHelper
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
 

Protected Member Functions

void AccumulateComplexity (unsigned int complexity)
 
bool IsAntiAliased ()
 
bool IsHairline ()
 
DlDrawStyle DrawStyle ()
 
bool IsComplex ()
 
unsigned int Ceiling ()
 
unsigned int CurrentComplexityScore ()
 
unsigned int CalculatePathComplexity (const DlPath &dl_path, unsigned int line_verb_cost, unsigned int quad_verb_cost, unsigned int conic_verb_cost, unsigned int cubic_verb_cost)
 
virtual void ImageRect (const DlISize &size, bool texture_backed, bool render_with_attributes, bool enforce_src_edges)=0
 
virtual unsigned int BatchedComplexity ()=0
 

Additional Inherited Members

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

Detailed Description

Definition at line 95 of file dl_complexity_helper.h.

Constructor & Destructor Documentation

◆ ComplexityCalculatorHelper()

flutter::ComplexityCalculatorHelper::ComplexityCalculatorHelper ( unsigned int  ceiling)
inlineexplicit

Definition at line 100 of file dl_complexity_helper.h.

101 : ceiling_(ceiling) {}

◆ ~ComplexityCalculatorHelper()

virtual flutter::ComplexityCalculatorHelper::~ComplexityCalculatorHelper ( )
virtualdefault

Member Function Documentation

◆ AccumulateComplexity()

void flutter::ComplexityCalculatorHelper::AccumulateComplexity ( unsigned int  complexity)
inlineprotected

Definition at line 202 of file dl_complexity_helper.h.

202 {
203 // Check to see if we will overflow by accumulating this complexity score
204 if (ceiling_ - complexity_score_ < complexity) {
205 is_complex_ = true;
206 return;
207 }
208
209 complexity_score_ += complexity;
210 }

Referenced by drawColor(), and drawPaint().

◆ BatchedComplexity()

virtual unsigned int flutter::ComplexityCalculatorHelper::BatchedComplexity ( )
protectedpure virtual

Referenced by ComplexityScore().

◆ CalculatePathComplexity()

unsigned int flutter::ComplexityCalculatorHelper::CalculatePathComplexity ( const DlPath dl_path,
unsigned int  line_verb_cost,
unsigned int  quad_verb_cost,
unsigned int  conic_verb_cost,
unsigned int  cubic_verb_cost 
)
protected

Definition at line 42 of file dl_complexity_helper.cc.

47 {
48 DlComplexityPathReceiver receiver;
49 dl_path.Dispatch(receiver);
50 return (line_verb_cost * receiver.line_verb_count) +
51 (quad_verb_cost * receiver.quad_verb_count) +
52 (conic_verb_cost * receiver.conic_verb_count) +
53 (cubic_verb_cost * receiver.cubic_verb_count);
54}

References flutter::DlPath::Dispatch().

◆ Ceiling()

unsigned int flutter::ComplexityCalculatorHelper::Ceiling ( )
inlineprotected

Definition at line 216 of file dl_complexity_helper.h.

216{ return ceiling_; }

Referenced by ComplexityScore().

◆ ComplexityScore()

unsigned int flutter::ComplexityCalculatorHelper::ComplexityScore ( )
inline

Definition at line 183 of file dl_complexity_helper.h.

183 {
184 // We hit our ceiling, so return that
185 if (IsComplex()) {
186 return Ceiling();
187 }
188
189 // Calculate the impact of any draw ops where the complexity is dependent
190 // on the number of calls made.
191 unsigned int batched_complexity = BatchedComplexity();
192
193 // Check for overflow
194 if (Ceiling() - complexity_score_ < batched_complexity) {
195 return Ceiling();
196 }
197
198 return complexity_score_ + batched_complexity;
199 }
virtual unsigned int BatchedComplexity()=0

References BatchedComplexity(), Ceiling(), and IsComplex().

◆ CurrentComplexityScore()

unsigned int flutter::ComplexityCalculatorHelper::CurrentComplexityScore ( )
inlineprotected

Definition at line 217 of file dl_complexity_helper.h.

217{ return complexity_score_; }

◆ drawAtlas()

void flutter::ComplexityCalculatorHelper::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 
)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 162 of file dl_complexity_helper.h.

170 {
171 if (IsComplex()) {
172 return;
173 }
174 // This API just does a series of drawImage calls from the atlas
175 // This is equivalent to calling drawImageRect lots of times
176 for (int i = 0; i < count; i++) {
177 ImageRect(DlIRect::RoundOut(tex[i]).GetSize(), true,
178 render_with_attributes, true);
179 }
180 }
virtual void ImageRect(const DlISize &size, bool texture_backed, bool render_with_attributes, bool enforce_src_edges)=0
RoundOut(const TRect< U > &r)
Definition rect.h:679

References i, ImageRect(), IsComplex(), and impeller::TRect< T >::RoundOut().

◆ drawColor()

void flutter::ComplexityCalculatorHelper::drawColor ( DlColor  color,
DlBlendMode  mode 
)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 130 of file dl_complexity_helper.h.

130 {
131 if (IsComplex()) {
132 return;
133 }
134 // Placeholder value here. This is a relatively cheap operation.
136 }
void AccumulateComplexity(unsigned int complexity)

References AccumulateComplexity(), and IsComplex().

◆ drawImageRect()

void flutter::ComplexityCalculatorHelper::drawImageRect ( const sk_sp< DlImage image,
const DlRect src,
const DlRect dst,
DlImageSampling  sampling,
bool  render_with_attributes,
DlSrcRectConstraint  constraint = DlSrcRectConstraint::kFast 
)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 147 of file dl_complexity_helper.h.

153 {
154 if (IsComplex()) {
155 return;
156 }
157 ImageRect(image->GetBounds().GetSize(), image->isTextureBacked(),
158 render_with_attributes,
159 constraint == DlSrcRectConstraint::kStrict);
160 }
FlutterVulkanImage * image

References image, ImageRect(), IsComplex(), and flutter::kStrict.

◆ drawPaint()

void flutter::ComplexityCalculatorHelper::drawPaint ( )
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 138 of file dl_complexity_helper.h.

138 {
139 if (IsComplex()) {
140 return;
141 }
142 // Placeholder value here. This can be cheap (e.g. effectively a drawColor),
143 // or expensive (e.g. a bitmap shader with an image filter)
145 }

References AccumulateComplexity(), and IsComplex().

◆ DrawStyle()

DlDrawStyle flutter::ComplexityCalculatorHelper::DrawStyle ( )
inlineprotected

Definition at line 214 of file dl_complexity_helper.h.

214{ return current_paint_.getDrawStyle(); }
DlDrawStyle getDrawStyle() const
Definition dl_paint.h:90

References flutter::DlPaint::getDrawStyle().

◆ ImageRect()

virtual void flutter::ComplexityCalculatorHelper::ImageRect ( const DlISize size,
bool  texture_backed,
bool  render_with_attributes,
bool  enforce_src_edges 
)
protectedpure virtual

Referenced by drawAtlas(), and drawImageRect().

◆ IsAntiAliased()

bool flutter::ComplexityCalculatorHelper::IsAntiAliased ( )
inlineprotected

Definition at line 212 of file dl_complexity_helper.h.

212{ return current_paint_.isAntiAlias(); }
bool isAntiAlias() const
Definition dl_paint.h:57

References flutter::DlPaint::isAntiAlias().

◆ IsComplex()

bool flutter::ComplexityCalculatorHelper::IsComplex ( )
inlineprotected

Definition at line 215 of file dl_complexity_helper.h.

215{ return is_complex_; }

Referenced by ComplexityScore(), drawAtlas(), drawColor(), drawImageRect(), and drawPaint().

◆ IsHairline()

bool flutter::ComplexityCalculatorHelper::IsHairline ( )
inlineprotected

Definition at line 213 of file dl_complexity_helper.h.

213{ return current_paint_.getStrokeWidth() == 0.0f; }
float getStrokeWidth() const
Definition dl_paint.h:114

References flutter::DlPaint::getStrokeWidth().

◆ restore()

void flutter::ComplexityCalculatorHelper::restore ( )
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 118 of file dl_complexity_helper.h.

118{}

◆ save()

void flutter::ComplexityCalculatorHelper::save ( )
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 116 of file dl_complexity_helper.h.

116{}

◆ setAntiAlias()

void flutter::ComplexityCalculatorHelper::setAntiAlias ( bool  aa)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 120 of file dl_complexity_helper.h.

120{ current_paint_.setAntiAlias(aa); }
DlPaint & setAntiAlias(bool isAntiAlias)
Definition dl_paint.h:58

References flutter::DlPaint::setAntiAlias().

◆ setBlendMode()

void flutter::ComplexityCalculatorHelper::setBlendMode ( DlBlendMode  mode)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 110 of file dl_complexity_helper.h.

110{}

◆ setColor()

void flutter::ComplexityCalculatorHelper::setColor ( DlColor  color)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 109 of file dl_complexity_helper.h.

109{}

◆ setColorFilter()

void flutter::ComplexityCalculatorHelper::setColorFilter ( const DlColorFilter filter)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 113 of file dl_complexity_helper.h.

113{}

◆ setColorSource()

void flutter::ComplexityCalculatorHelper::setColorSource ( const DlColorSource source)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 111 of file dl_complexity_helper.h.

111{}

◆ setDrawStyle()

void flutter::ComplexityCalculatorHelper::setDrawStyle ( DlDrawStyle  style)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 122 of file dl_complexity_helper.h.

122 {
123 current_paint_.setDrawStyle(style);
124 }
DlPaint & setDrawStyle(DlDrawStyle style)
Definition dl_paint.h:93

References flutter::DlPaint::setDrawStyle().

◆ setImageFilter()

void flutter::ComplexityCalculatorHelper::setImageFilter ( const DlImageFilter filter)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 112 of file dl_complexity_helper.h.

112{}

◆ setInvertColors()

void flutter::ComplexityCalculatorHelper::setInvertColors ( bool  invert)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 105 of file dl_complexity_helper.h.

105{}

◆ setMaskFilter()

void flutter::ComplexityCalculatorHelper::setMaskFilter ( const DlMaskFilter filter)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 114 of file dl_complexity_helper.h.

114{}

◆ setStrokeCap()

void flutter::ComplexityCalculatorHelper::setStrokeCap ( DlStrokeCap  cap)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 106 of file dl_complexity_helper.h.

106{}

◆ setStrokeJoin()

void flutter::ComplexityCalculatorHelper::setStrokeJoin ( DlStrokeJoin  join)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 107 of file dl_complexity_helper.h.

107{}

◆ setStrokeMiter()

void flutter::ComplexityCalculatorHelper::setStrokeMiter ( DlScalar  limit)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 108 of file dl_complexity_helper.h.

108{}

◆ setStrokeWidth()

void flutter::ComplexityCalculatorHelper::setStrokeWidth ( DlScalar  width)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 126 of file dl_complexity_helper.h.

126 {
127 current_paint_.setStrokeWidth(width);
128 }
DlPaint & setStrokeWidth(float width)
Definition dl_paint.h:115
int32_t width

References flutter::DlPaint::setStrokeWidth(), and width.


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