Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
flutter::DlSkPaintDispatchHelper Class Reference

#include <dl_sk_paint_dispatcher.h>

Inheritance diagram for flutter::DlSkPaintDispatchHelper:
flutter::DlOpReceiver flutter::DlSkCanvasDispatcher flutter::testing::MockDispatchHelper

Public Member Functions

 DlSkPaintDispatchHelper (SkScalar opacity=SK_Scalar1)
 
void setAntiAlias (bool aa) override
 
void setDrawStyle (DlDrawStyle style) override
 
void setColor (DlColor color) override
 
void setStrokeWidth (SkScalar width) override
 
void setStrokeMiter (SkScalar limit) override
 
void setStrokeCap (DlStrokeCap cap) override
 
void setStrokeJoin (DlStrokeJoin join) override
 
void setColorSource (const DlColorSource *source) override
 
void setColorFilter (const DlColorFilter *filter) override
 
void setInvertColors (bool invert) override
 
void setBlendMode (DlBlendMode mode) override
 
void setPathEffect (const DlPathEffect *effect) override
 
void setMaskFilter (const DlMaskFilter *filter) override
 
void setImageFilter (const DlImageFilter *filter) override
 
const SkPaintpaint (bool uses_shader=true)
 
SkScalar opacity ()
 
SkScalar combined_opacity ()
 
bool has_opacity ()
 
- 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 ()=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, 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 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
 

Protected Member Functions

void save_opacity (SkScalar opacity_for_children)
 
void restore_opacity ()
 

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 16 of file dl_sk_paint_dispatcher.h.

Constructor & Destructor Documentation

◆ DlSkPaintDispatchHelper()

flutter::DlSkPaintDispatchHelper::DlSkPaintDispatchHelper ( SkScalar  opacity = SK_Scalar1)
inlineexplicit

Definition at line 18 of file dl_sk_paint_dispatcher.h.

19 : current_color_(SK_ColorBLACK), opacity_(opacity) {
20 if (opacity < SK_Scalar1) {
21 paint_.setAlphaf(opacity);
22 }
23 }
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
#define SK_Scalar1
Definition SkScalar.h:18
void setAlphaf(float a)
Definition SkPaint.cpp:130

Member Function Documentation

◆ combined_opacity()

SkScalar flutter::DlSkPaintDispatchHelper::combined_opacity ( )
inline

Returns the combined opacity that includes both the current opacity attribute and the alpha of the most recent color. The most recently set color will have combined the two and stored the combined value in the alpha of the paint.

Definition at line 64 of file dl_sk_paint_dispatcher.h.

64{ return paint_.getAlphaf(); }
float getAlphaf() const
Definition SkPaint.h:261

◆ has_opacity()

bool flutter::DlSkPaintDispatchHelper::has_opacity ( )
inline

Returns true iff the current opacity attribute is not opaque, irrespective of the alpha of the current color

Definition at line 67 of file dl_sk_paint_dispatcher.h.

67{ return opacity_ < SK_Scalar1; }

◆ opacity()

SkScalar flutter::DlSkPaintDispatchHelper::opacity ( )
inline

Returns the current opacity attribute which is used to reduce the alpha of all setColor calls encountered in the streeam

Definition at line 59 of file dl_sk_paint_dispatcher.h.

59{ return opacity_; }

◆ paint()

const SkPaint & flutter::DlSkPaintDispatchHelper::paint ( bool  uses_shader = true)
inline

Definition at line 40 of file dl_sk_paint_dispatcher.h.

40 {
41 // On the Impeller backend, we will only support dithering of *gradients*,
42 // and it will be enabled by default (without the option to disable it).
43 // Until Skia support is completely removed, we only want to respect the
44 // dither flag for gradients (otherwise it will also apply to, for
45 // example, image ops and image sources, which are not dithered in
46 // Impeller) and only on those operations that use the color source.
47 //
48 // The color_source_gradient_ flag lets us know if the color source is
49 // a gradient and then the uses_shader flag passed in to this method by
50 // the rendering op lets us know if the color source is used (and is
51 // therefore the primary source of colors for the op).
52 //
53 // See https://github.com/flutter/flutter/issues/112498.
54 paint_.setDither(uses_shader && color_source_gradient_);
55 return paint_;
56 }
void setDither(bool dither)
Definition SkPaint.h:182

◆ restore_opacity()

void flutter::DlSkPaintDispatchHelper::restore_opacity ( )
protected

Definition at line 32 of file dl_sk_paint_dispatcher.cc.

32 {
33 if (save_stack_.empty()) {
34 return;
35 }
36 set_opacity(save_stack_.back().opacity);
37 save_stack_.pop_back();
38}

◆ save_opacity()

void flutter::DlSkPaintDispatchHelper::save_opacity ( SkScalar  opacity_for_children)
protected

Definition at line 28 of file dl_sk_paint_dispatcher.cc.

28 {
29 save_stack_.emplace_back(opacity_);
30 set_opacity(child_opacity);
31}

◆ setAntiAlias()

void flutter::DlSkPaintDispatchHelper::setAntiAlias ( bool  aa)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 40 of file dl_sk_paint_dispatcher.cc.

40 {
41 paint_.setAntiAlias(aa);
42}
void setAntiAlias(bool aa)
Definition SkPaint.h:170

◆ setBlendMode()

void flutter::DlSkPaintDispatchHelper::setBlendMode ( DlBlendMode  mode)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 69 of file dl_sk_paint_dispatcher.cc.

69 {
70 paint_.setBlendMode(ToSk(mode));
71}
void setBlendMode(SkBlendMode mode)
Definition SkPaint.cpp:151
SkPaint ToSk(const DlPaint &paint)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition switches.h:228

◆ setColor()

void flutter::DlSkPaintDispatchHelper::setColor ( DlColor  color)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 62 of file dl_sk_paint_dispatcher.cc.

62 {
63 current_color_ = ToSk(color);
64 paint_.setColor(ToSk(color));
65 if (has_opacity()) {
66 paint_.setAlphaf(paint_.getAlphaf() * opacity());
67 }
68}
SkColor4f color
void setColor(SkColor color)
Definition SkPaint.cpp:119

◆ setColorFilter()

void flutter::DlSkPaintDispatchHelper::setColorFilter ( const DlColorFilter filter)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 87 of file dl_sk_paint_dispatcher.cc.

87 {
88 sk_color_filter_ = ToSk(filter);
89 paint_.setColorFilter(makeColorFilter());
90}
void setColorFilter(sk_sp< SkColorFilter > colorFilter)

◆ setColorSource()

void flutter::DlSkPaintDispatchHelper::setColorSource ( const DlColorSource source)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 72 of file dl_sk_paint_dispatcher.cc.

72 {
73 // On the Impeller backend, we only support dithering of *gradients*, and
74 // so we need to set the dither flag whenever we render a gradient.
75 //
76 // In this method we can determine whether or not the source is a gradient,
77 // but we don't have the other half of the information which is what
78 // rendering op is being performed. So, we simply record whether the
79 // source is a gradient here and let the |paint()| method figure out
80 // the rest (i.e. whether the color source will be used).
81 color_source_gradient_ = source && source->isGradient();
82 paint_.setShader(ToSk(source));
83}
void setShader(sk_sp< SkShader > shader)
SkBitmap source
Definition examples.cpp:28

◆ setDrawStyle()

void flutter::DlSkPaintDispatchHelper::setDrawStyle ( DlDrawStyle  style)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 53 of file dl_sk_paint_dispatcher.cc.

53 {
54 paint_.setStyle(ToSk(style));
55}
void setStyle(Style style)
Definition SkPaint.cpp:105

◆ setImageFilter()

void flutter::DlSkPaintDispatchHelper::setImageFilter ( const DlImageFilter filter)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 84 of file dl_sk_paint_dispatcher.cc.

84 {
85 paint_.setImageFilter(ToSk(filter));
86}
void setImageFilter(sk_sp< SkImageFilter > imageFilter)

◆ setInvertColors()

void flutter::DlSkPaintDispatchHelper::setInvertColors ( bool  invert)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 43 of file dl_sk_paint_dispatcher.cc.

43 {
44 invert_colors_ = invert;
45 paint_.setColorFilter(makeColorFilter());
46}
gboolean invert

◆ setMaskFilter()

void flutter::DlSkPaintDispatchHelper::setMaskFilter ( const DlMaskFilter filter)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 94 of file dl_sk_paint_dispatcher.cc.

94 {
95 paint_.setMaskFilter(ToSk(filter));
96}
void setMaskFilter(sk_sp< SkMaskFilter > maskFilter)

◆ setPathEffect()

void flutter::DlSkPaintDispatchHelper::setPathEffect ( const DlPathEffect effect)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 91 of file dl_sk_paint_dispatcher.cc.

91 {
92 paint_.setPathEffect(ToSk(effect));
93}
void setPathEffect(sk_sp< SkPathEffect > pathEffect)

◆ setStrokeCap()

void flutter::DlSkPaintDispatchHelper::setStrokeCap ( DlStrokeCap  cap)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 47 of file dl_sk_paint_dispatcher.cc.

47 {
48 paint_.setStrokeCap(ToSk(cap));
49}
void setStrokeCap(Cap cap)
Definition SkPaint.cpp:179

◆ setStrokeJoin()

void flutter::DlSkPaintDispatchHelper::setStrokeJoin ( DlStrokeJoin  join)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 50 of file dl_sk_paint_dispatcher.cc.

50 {
51 paint_.setStrokeJoin(ToSk(join));
52}
void setStrokeJoin(Join join)
Definition SkPaint.cpp:189

◆ setStrokeMiter()

void flutter::DlSkPaintDispatchHelper::setStrokeMiter ( SkScalar  limit)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 59 of file dl_sk_paint_dispatcher.cc.

59 {
60 paint_.setStrokeMiter(limit);
61}
void setStrokeMiter(SkScalar miter)
Definition SkPaint.cpp:169

◆ setStrokeWidth()

void flutter::DlSkPaintDispatchHelper::setStrokeWidth ( SkScalar  width)
overridevirtual

Implements flutter::DlOpReceiver.

Definition at line 56 of file dl_sk_paint_dispatcher.cc.

56 {
57 paint_.setStrokeWidth(width);
58}
void setStrokeWidth(SkScalar width)
Definition SkPaint.cpp:159
int32_t width

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