Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 setPathEffect (const DlPathEffect *effect) 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 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, const DlImageFilter *backdrop=nullptr)
 
virtual void saveLayer (const SkRect *bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr) final
 
virtual void drawLine (const SkPoint &p0, const SkPoint &p1)=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 drawImageNine (const sk_sp< DlImage > image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, 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 201 of file dl_complexity_helper.h.

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

◆ 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 218 of file dl_complexity_helper.h.

222 {
223 int verb_count = path.countVerbs();
224 std::vector<uint8_t> verbs(verb_count);
225 path.getVerbs(verbs.data(), verbs.size());
226
227 unsigned int complexity = 0;
228 for (int i = 0; i < verb_count; i++) {
229 switch (verbs[i]) {
231 complexity += line_verb_cost;
232 break;
234 complexity += quad_verb_cost;
235 break;
237 complexity += conic_verb_cost;
238 break;
240 complexity += cubic_verb_cost;
241 break;
242 }
243 }
244 return complexity;
245 }
@ kConic_Verb
Definition SkPath.h:1461
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459
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 215 of file dl_complexity_helper.h.

215{ return ceiling_; }

◆ ComplexityScore()

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

Definition at line 182 of file dl_complexity_helper.h.

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

◆ CurrentComplexityScore()

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

Definition at line 216 of file dl_complexity_helper.h.

216{ 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 161 of file dl_complexity_helper.h.

169 {
170 if (IsComplex()) {
171 return;
172 }
173 // This API just does a series of drawImage calls from the atlas
174 // This is equivalent to calling drawImageRect lots of times
175 for (int i = 0; i < count; i++) {
176 ImageRect(SkISize::Make(tex[i].width(), tex[i].height()), true,
177 render_with_attributes, true);
178 }
179 }
int count
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 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)

◆ 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 147 of file dl_complexity_helper.h.

153 {
154 if (IsComplex()) {
155 return;
156 }
158 render_with_attributes, constraint == SrcRectConstraint::kStrict);
159 }
SkISize dimensions() const
Definition SkImage.h:297
virtual bool isTextureBacked() const =0
sk_sp< SkImage > image
Definition examples.cpp:29

◆ 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 }

◆ DrawStyle()

DlDrawStyle flutter::ComplexityCalculatorHelper::DrawStyle ( )
inlineprotected

Definition at line 213 of file dl_complexity_helper.h.

213{ return current_paint_.getDrawStyle(); }
DlDrawStyle getDrawStyle() const
Definition dl_paint.h:92

◆ 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 211 of file dl_complexity_helper.h.

211{ return current_paint_.isAntiAlias(); }
bool isAntiAlias() const
Definition dl_paint.h:58

◆ IsComplex()

bool flutter::ComplexityCalculatorHelper::IsComplex ( )
inlineprotected

Definition at line 214 of file dl_complexity_helper.h.

214{ return is_complex_; }

◆ IsHairline()

bool flutter::ComplexityCalculatorHelper::IsHairline ( )
inlineprotected

Definition at line 212 of file dl_complexity_helper.h.

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

◆ 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:59

◆ 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 122 of file dl_complexity_helper.h.

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

◆ 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 114 of file dl_complexity_helper.h.

114{}

◆ setPathEffect()

void flutter::ComplexityCalculatorHelper::setPathEffect ( const DlPathEffect effect)
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 126 of file dl_complexity_helper.h.

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

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