Flutter Engine
 
Loading...
Searching...
No Matches
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 setMaskFilter (const DlMaskFilter *filter) override
 
void setImageFilter (const DlImageFilter *filter) override
 
const SkPaint & paint (bool uses_shader=true)
 
SkScalar opacity ()
 
SkScalar combined_opacity ()
 
bool has_opacity ()
 
- Public Member Functions inherited from flutter::DlOpReceiver
virtual void setStrokeWidth (float width)=0
 
virtual void setStrokeMiter (float limit)=0
 
virtual void save ()=0
 
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 restore ()=0
 
virtual void saveLayer (const DlRect *bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) final
 
virtual void translate (DlScalar tx, DlScalar ty)=0
 
virtual void scale (DlScalar sx, DlScalar sy)=0
 
virtual void rotate (DlScalar degrees)=0
 
virtual void skew (DlScalar sx, DlScalar sy)=0
 
virtual void transform2DAffine (DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt)=0
 
virtual 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)=0
 
virtual void transformReset ()=0
 
virtual void clipRect (const DlRect &rect, DlClipOp clip_op, bool is_aa)=0
 
virtual void clipOval (const DlRect &bounds, DlClipOp clip_op, bool is_aa)=0
 
virtual void clipRoundRect (const DlRoundRect &rrect, DlClipOp clip_op, bool is_aa)=0
 
virtual void clipRoundSuperellipse (const DlRoundSuperellipse &rse, DlClipOp clip_op, bool is_aa)=0
 
virtual void clipPath (const DlPath &path, DlClipOp clip_op, bool is_aa)=0
 
virtual void drawColor (DlColor color, DlBlendMode mode)=0
 
virtual void drawPaint ()=0
 
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 drawImageRect (const sk_sp< DlImage > image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, bool render_with_attributes, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast)=0
 
virtual void drawImageNine (const sk_sp< DlImage > image, const DlIRect &center, const DlRect &dst, DlFilterMode filter, bool render_with_attributes)=0
 
virtual 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)=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
 

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)
 

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_(DlColor::kBlack()), opacity_(opacity) {
20 if (opacity < SK_Scalar1) {
21 paint_.setAlphaf(opacity);
22 }
23 }
static constexpr DlColor kBlack()
Definition dl_color.h:69

References opacity().

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

63{ return paint_.getAlphaf(); }

Referenced by flutter::DlSkCanvasDispatcher::drawDisplayList(), and flutter::DlSkCanvasDispatcher::saveLayer().

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

66{ return opacity_ < SK_Scalar1; }

Referenced by flutter::DlSkCanvasDispatcher::safe_paint(), and setColor().

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

58{ return opacity_; }

Referenced by DlSkPaintDispatchHelper(), flutter::DlSkCanvasDispatcher::drawColor(), flutter::DlSkCanvasDispatcher::drawDisplayList(), flutter::DlSkCanvasDispatcher::safe_paint(), flutter::DlSkCanvasDispatcher::save(), flutter::DlSkCanvasDispatcher::saveLayer(), and setColor().

◆ paint()

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

Definition at line 39 of file dl_sk_paint_dispatcher.h.

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

Referenced by flutter::DlSkCanvasDispatcher::drawArc(), flutter::DlSkCanvasDispatcher::drawCircle(), flutter::DlSkCanvasDispatcher::drawDashedLine(), flutter::DlSkCanvasDispatcher::drawDiffRoundRect(), flutter::DlSkCanvasDispatcher::drawLine(), flutter::DlSkCanvasDispatcher::drawOval(), flutter::DlSkCanvasDispatcher::drawPaint(), flutter::DlSkCanvasDispatcher::drawPath(), flutter::DlSkCanvasDispatcher::drawPoints(), flutter::DlSkCanvasDispatcher::drawRect(), flutter::DlSkCanvasDispatcher::drawRoundRect(), flutter::DlSkCanvasDispatcher::drawRoundSuperellipse(), flutter::DlSkCanvasDispatcher::drawText(), flutter::DlSkCanvasDispatcher::drawVertices(), flutter::DlSkCanvasDispatcher::safe_paint(), flutter::DlSkCanvasDispatcher::saveLayer(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), flutter::testing::TEST(), and flutter::testing::TEST().

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

Referenced by flutter::DlSkCanvasDispatcher::restore(), and flutter::testing::MockDispatchHelper::restore().

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

Referenced by flutter::DlSkCanvasDispatcher::save(), flutter::testing::MockDispatchHelper::save(), and flutter::DlSkCanvasDispatcher::saveLayer().

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

◆ 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}
SkPaint ToSk(const DlPaint &paint)

References flutter::mode, and flutter::ToSk().

◆ 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_ = color;
64 paint_.setColor(ToSkColor4f(color));
65 if (has_opacity()) {
66 paint_.setAlphaf(paint_.getAlphaf() * opacity());
67 }
68}
SkColor4f ToSkColor4f(DlColor color)

References has_opacity(), opacity(), and flutter::ToSkColor4f().

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

References flutter::ToSk().

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

References flutter::DlColorSource::isGradient(), and flutter::ToSk().

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

References flutter::ToSk().

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

References flutter::ToSk().

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

◆ setMaskFilter()

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

Implements flutter::DlOpReceiver.

Definition at line 91 of file dl_sk_paint_dispatcher.cc.

91 {
92 paint_.setMaskFilter(ToSk(filter));
93}

References flutter::ToSk().

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

References flutter::ToSk().

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

References flutter::ToSk().

◆ setStrokeMiter()

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

Definition at line 59 of file dl_sk_paint_dispatcher.cc.

59 {
60 paint_.setStrokeMiter(limit);
61}

◆ setStrokeWidth()

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

Definition at line 56 of file dl_sk_paint_dispatcher.cc.

56 {
57 paint_.setStrokeWidth(width);
58}
int32_t width

References width.


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