Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
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 (SkScalar 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 (SkScalar width) override
 
void drawColor (DlColor color, DlBlendMode mode) override
 
void drawPaint () override
 
void drawImageRect (const sk_sp< DlImage > image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint=SrcRectConstraint::kFast) override
 
void drawAtlas (const sk_sp< DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes) override
 
unsigned int ComplexityScore ()
 
- Public Member Functions inherited from flutter::DlOpReceiver
virtual bool PrefersImpellerPaths () const
 
virtual void clipPath (const CacheablePath &cache, ClipOp clip_op, bool is_aa)
 
virtual void drawPath (const CacheablePath &cache)
 
virtual void drawShadow (const CacheablePath &cache, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr)
 
virtual void setAntiAlias (bool aa)=0
 
virtual void setDrawStyle (DlDrawStyle style)=0
 
virtual void setColor (DlColor color)=0
 
virtual void setStrokeWidth (float width)=0
 
virtual void setStrokeMiter (float limit)=0
 
virtual void setStrokeCap (DlStrokeCap cap)=0
 
virtual void setStrokeJoin (DlStrokeJoin join)=0
 
virtual void setColorSource (const DlColorSource *source)=0
 
virtual void setColorFilter (const DlColorFilter *filter)=0
 
virtual void setInvertColors (bool invert)=0
 
virtual void setBlendMode (DlBlendMode mode)=0
 
virtual void setMaskFilter (const DlMaskFilter *filter)=0
 
virtual void setImageFilter (const DlImageFilter *filter)=0
 
virtual void save ()=0
 
virtual void save (uint32_t total_content_depth)
 
virtual void saveLayer (const SkRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr)=0
 
virtual void saveLayer (const SkRect &bounds, const SaveLayerOptions &options, uint32_t total_content_depth, DlBlendMode max_content_blend_mode, const DlImageFilter *backdrop=nullptr)
 
virtual void restore ()=0
 
virtual void saveLayer (const SkRect *bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr) final
 
virtual void translate (SkScalar tx, SkScalar ty)=0
 
virtual void scale (SkScalar sx, SkScalar sy)=0
 
virtual void rotate (SkScalar degrees)=0
 
virtual void skew (SkScalar sx, SkScalar sy)=0
 
virtual void transform2DAffine (SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt)=0
 
virtual 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)=0
 
virtual void transformReset ()=0
 
virtual void clipRect (const SkRect &rect, ClipOp clip_op, bool is_aa)=0
 
virtual void clipRRect (const SkRRect &rrect, ClipOp clip_op, bool is_aa)=0
 
virtual void clipPath (const SkPath &path, ClipOp clip_op, bool is_aa)=0
 
virtual void drawColor (DlColor color, DlBlendMode mode)=0
 
virtual void drawPaint ()=0
 
virtual void drawLine (const SkPoint &p0, const SkPoint &p1)=0
 
virtual void drawDashedLine (const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length)=0
 
virtual void drawRect (const SkRect &rect)=0
 
virtual void drawOval (const SkRect &bounds)=0
 
virtual void drawCircle (const SkPoint &center, SkScalar radius)=0
 
virtual void drawRRect (const SkRRect &rrect)=0
 
virtual void drawDRRect (const SkRRect &outer, const SkRRect &inner)=0
 
virtual void drawPath (const SkPath &path)=0
 
virtual void drawArc (const SkRect &oval_bounds, SkScalar start_degrees, SkScalar sweep_degrees, bool use_center)=0
 
virtual void drawPoints (PointMode mode, uint32_t count, const SkPoint points[])=0
 
virtual void drawVertices (const DlVertices *vertices, DlBlendMode mode)=0
 
virtual void drawImage (const sk_sp< DlImage > image, const SkPoint point, DlImageSampling sampling, bool render_with_attributes)=0
 
virtual void drawImageRect (const sk_sp< DlImage > image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint=SrcRectConstraint::kFast)=0
 
virtual void drawImageNine (const sk_sp< DlImage > image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, bool render_with_attributes)=0
 
virtual void drawAtlas (const sk_sp< DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes)=0
 
virtual void drawDisplayList (const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1)=0
 
virtual void drawTextBlob (const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y)=0
 
virtual void drawTextFrame (const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y)=0
 
virtual void drawShadow (const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr)=0
 
- Public Member Functions inherited from flutter::IgnoreTransformDispatchHelper
void translate (SkScalar tx, SkScalar ty) override
 
void scale (SkScalar sx, SkScalar sy) override
 
void rotate (SkScalar degrees) override
 
void skew (SkScalar sx, SkScalar sy) 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 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 SkPath &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 SkISize &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)
 
- Protected Types inherited from flutter::DlOpReceiver
using ClipOp = DlCanvas::ClipOp
 
using PointMode = DlCanvas::PointMode
 
using SrcRectConstraint = DlCanvas::SrcRectConstraint
 

Detailed Description

Definition at line 94 of file dl_complexity_helper.h.

Constructor & Destructor Documentation

◆ ComplexityCalculatorHelper()

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

Definition at line 99 of file dl_complexity_helper.h.

100 : ceiling_(ceiling) {}

◆ ~ComplexityCalculatorHelper()

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

Member Function Documentation

◆ AccumulateComplexity()

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

Definition at line 200 of file dl_complexity_helper.h.

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

◆ BatchedComplexity()

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

◆ CalculatePathComplexity()

unsigned int flutter::ComplexityCalculatorHelper::CalculatePathComplexity ( const SkPath path,
unsigned int  line_verb_cost,
unsigned int  quad_verb_cost,
unsigned int  conic_verb_cost,
unsigned int  cubic_verb_cost 
)
inlineprotected

Definition at line 217 of file dl_complexity_helper.h.

221 {
222 int verb_count = path.countVerbs();
223 std::vector<uint8_t> verbs(verb_count);
224 path.getVerbs(verbs.data(), verbs.size());
225
226 unsigned int complexity = 0;
227 for (int i = 0; i < verb_count; i++) {
228 switch (verbs[i]) {
229 case SkPath::Verb::kLine_Verb:
230 complexity += line_verb_cost;
231 break;
232 case SkPath::Verb::kQuad_Verb:
233 complexity += quad_verb_cost;
234 break;
235 case SkPath::Verb::kConic_Verb:
236 complexity += conic_verb_cost;
237 break;
238 case SkPath::Verb::kCubic_Verb:
239 complexity += cubic_verb_cost;
240 break;
241 }
242 }
243 return complexity;
244 }
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

◆ Ceiling()

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

Definition at line 214 of file dl_complexity_helper.h.

214{ return ceiling_; }

◆ ComplexityScore()

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

Definition at line 181 of file dl_complexity_helper.h.

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

◆ CurrentComplexityScore()

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

Definition at line 215 of file dl_complexity_helper.h.

215{ return complexity_score_; }

◆ drawAtlas()

void flutter::ComplexityCalculatorHelper::drawAtlas ( const sk_sp< DlImage atlas,
const SkRSXform  xform[],
const SkRect  tex[],
const DlColor  colors[],
int  count,
DlBlendMode  mode,
DlImageSampling  sampling,
const SkRect cull_rect,
bool  render_with_attributes 
)
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 160 of file dl_complexity_helper.h.

168 {
169 if (IsComplex()) {
170 return;
171 }
172 // This API just does a series of drawImage calls from the atlas
173 // This is equivalent to calling drawImageRect lots of times
174 for (int i = 0; i < count; i++) {
175 ImageRect(SkISize::Make(tex[i].width(), tex[i].height()), true,
176 render_with_attributes, true);
177 }
178 }
int count
Definition: FontMgrTest.cpp:50
virtual void ImageRect(const SkISize &size, bool texture_backed, bool render_with_attributes, bool enforce_src_edges)=0
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ drawColor()

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

Implements flutter::DlOpReceiver.

Definition at line 129 of file dl_complexity_helper.h.

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

◆ drawImageRect()

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

Implements flutter::DlOpReceiver.

Definition at line 146 of file dl_complexity_helper.h.

152 {
153 if (IsComplex()) {
154 return;
155 }
157 render_with_attributes, constraint == SrcRectConstraint::kStrict);
158 }
SkISize dimensions() const
Definition: SkImage.h:297
virtual bool isTextureBacked() const =0
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ drawPaint()

void flutter::ComplexityCalculatorHelper::drawPaint ( )
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 137 of file dl_complexity_helper.h.

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

◆ DrawStyle()

DlDrawStyle flutter::ComplexityCalculatorHelper::DrawStyle ( )
inlineprotected

Definition at line 212 of file dl_complexity_helper.h.

212{ return current_paint_.getDrawStyle(); }
DlDrawStyle getDrawStyle() const
Definition: dl_paint.h:91

◆ ImageRect()

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

◆ IsAntiAliased()

bool flutter::ComplexityCalculatorHelper::IsAntiAliased ( )
inlineprotected

Definition at line 210 of file dl_complexity_helper.h.

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

◆ IsComplex()

bool flutter::ComplexityCalculatorHelper::IsComplex ( )
inlineprotected

Definition at line 213 of file dl_complexity_helper.h.

213{ return is_complex_; }

◆ IsHairline()

bool flutter::ComplexityCalculatorHelper::IsHairline ( )
inlineprotected

Definition at line 211 of file dl_complexity_helper.h.

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

◆ restore()

void flutter::ComplexityCalculatorHelper::restore ( )
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 117 of file dl_complexity_helper.h.

117{}

◆ save()

void flutter::ComplexityCalculatorHelper::save ( )
inlineoverridevirtual

Implements flutter::DlOpReceiver.

Definition at line 115 of file dl_complexity_helper.h.

115{}

◆ setAntiAlias()

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

Implements flutter::DlOpReceiver.

Definition at line 119 of file dl_complexity_helper.h.

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

◆ setBlendMode()

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

Implements flutter::DlOpReceiver.

Definition at line 109 of file dl_complexity_helper.h.

109{}

◆ setColor()

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

Implements flutter::DlOpReceiver.

Definition at line 108 of file dl_complexity_helper.h.

108{}

◆ setColorFilter()

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

Implements flutter::DlOpReceiver.

Definition at line 112 of file dl_complexity_helper.h.

112{}

◆ setColorSource()

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

Implements flutter::DlOpReceiver.

Definition at line 110 of file dl_complexity_helper.h.

110{}

◆ setDrawStyle()

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

Implements flutter::DlOpReceiver.

Definition at line 121 of file dl_complexity_helper.h.

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

◆ setImageFilter()

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

Implements flutter::DlOpReceiver.

Definition at line 111 of file dl_complexity_helper.h.

111{}

◆ setInvertColors()

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

Implements flutter::DlOpReceiver.

Definition at line 104 of file dl_complexity_helper.h.

104{}

◆ setMaskFilter()

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

Implements flutter::DlOpReceiver.

Definition at line 113 of file dl_complexity_helper.h.

113{}

◆ setStrokeCap()

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

Implements flutter::DlOpReceiver.

Definition at line 105 of file dl_complexity_helper.h.

105{}

◆ setStrokeJoin()

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

Implements flutter::DlOpReceiver.

Definition at line 106 of file dl_complexity_helper.h.

106{}

◆ setStrokeMiter()

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

Implements flutter::DlOpReceiver.

Definition at line 107 of file dl_complexity_helper.h.

107{}

◆ setStrokeWidth()

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

Implements flutter::DlOpReceiver.

Definition at line 125 of file dl_complexity_helper.h.

125 {
126 current_paint_.setStrokeWidth(width);
127 }
DlPaint & setStrokeWidth(float width)
Definition: dl_paint.h:116

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