Flutter Engine
The Flutter Engine
Static Public Member Functions | Protected Member Functions | List of all members
sksg::OpacityEffect Class Referencefinal

#include <SkSGOpacityEffect.h>

Inheritance diagram for sksg::OpacityEffect:
sksg::EffectNode sksg::RenderNode sksg::Node SkRefCnt SkRefCntBase

Static Public Member Functions

static sk_sp< OpacityEffectMake (sk_sp< RenderNode > child, float opacity=1)
 

Protected Member Functions

 OpacityEffect (sk_sp< RenderNode >, float)
 
void onRender (SkCanvas *, const RenderContext *) const override
 
const RenderNodeonNodeAt (const SkPoint &) const override
 
SkRect onRevalidate (InvalidationController *, const SkMatrix &) override
 
- Protected Member Functions inherited from sksg::EffectNode
 EffectNode (sk_sp< RenderNode >, uint32_t inval_traits=0)
 
 ~EffectNode () override
 
void onRender (SkCanvas *, const RenderContext *) const override
 
const RenderNodeonNodeAt (const SkPoint &) const override
 
SkRect onRevalidate (InvalidationController *, const SkMatrix &) override
 
const sk_sp< RenderNode > & getChild () const
 
- Protected Member Functions inherited from sksg::RenderNode
 RenderNode (uint32_t inval_traits=0)
 
virtual void onRender (SkCanvas *, const RenderContext *) const =0
 
virtual const RenderNodeonNodeAt (const SkPoint &p) const =0
 
- Protected Member Functions inherited from sksg::Node
 Node (uint32_t invalTraits)
 
 ~Node () override
 
const SkRectbounds () const
 
bool hasInval () const
 
virtual SkRect onRevalidate (InvalidationController *, const SkMatrix &ctm)=0
 
void observeInval (const sk_sp< Node > &)
 
void unobserveInval (const sk_sp< Node > &)
 

Additional Inherited Members

- Public Member Functions inherited from sksg::RenderNode
void render (SkCanvas *, const RenderContext *=nullptr) const
 
const RenderNodenodeAt (const SkPoint &point) const
 
bool isVisible () const
 
void setVisible (bool)
 
- Public Member Functions inherited from sksg::Node
const SkRectrevalidate (InvalidationController *, const SkMatrix &)
 
void invalidate (bool damage=true)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
- Protected Types inherited from sksg::Node
enum  InvalTraits { kBubbleDamage_Trait = 1 << 0 , kOverrideDamage_Trait = 1 << 1 }
 

Detailed Description

Concrete Effect node, applying opacity to its descendants.

Definition at line 30 of file SkSGOpacityEffect.h.

Constructor & Destructor Documentation

◆ OpacityEffect()

sksg::OpacityEffect::OpacityEffect ( sk_sp< RenderNode child,
float  opacity 
)
protected

Definition at line 18 of file SkSGOpacityEffect.cpp.

19 : INHERITED(std::move(child))
20 , fOpacity(opacity) {}

Member Function Documentation

◆ Make()

static sk_sp< OpacityEffect > sksg::OpacityEffect::Make ( sk_sp< RenderNode child,
float  opacity = 1 
)
inlinestatic

Definition at line 32 of file SkSGOpacityEffect.h.

32 {
33 return child ? sk_sp<OpacityEffect>(new OpacityEffect(std::move(child), opacity)) : nullptr;
34 }
OpacityEffect(sk_sp< RenderNode >, float)

◆ onNodeAt()

const RenderNode * sksg::OpacityEffect::onNodeAt ( const SkPoint p) const
overrideprotectedvirtual

Reimplemented from sksg::EffectNode.

Definition at line 38 of file SkSGOpacityEffect.cpp.

38 {
39 return (fOpacity > 0) ? this->INHERITED::onNodeAt(p) : nullptr;
40}
const RenderNode * onNodeAt(const SkPoint &) const override

◆ onRender()

void sksg::OpacityEffect::onRender ( SkCanvas canvas,
const RenderContext ctx 
) const
overrideprotectedvirtual

Reimplemented from sksg::EffectNode.

Definition at line 22 of file SkSGOpacityEffect.cpp.

22 {
23 // opacity <= 0 disables rendering
24 if (fOpacity <= 0)
25 return;
26
27 // opacity >= 1 has no effect
28 if (fOpacity >= 1) {
29 this->INHERITED::onRender(canvas, ctx);
30 return;
31 }
32
33 const auto local_context = ScopedRenderContext(canvas, ctx).modulateOpacity(fOpacity);
34
35 this->INHERITED::onRender(canvas, local_context);
36}
void onRender(SkCanvas *, const RenderContext *) const override

◆ onRevalidate()

SkRect sksg::OpacityEffect::onRevalidate ( InvalidationController ic,
const SkMatrix ctm 
)
overrideprotectedvirtual

Reimplemented from sksg::EffectNode.

Definition at line 42 of file SkSGOpacityEffect.cpp.

42 {
43 SkASSERT(this->hasInval());
44
45 // opacity <= 0 disables rendering AND revalidation for the sub-DAG
46 return fOpacity > 0 ? this->INHERITED::onRevalidate(ic, ctm) : SkRect::MakeEmpty();
47}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
bool hasInval() const
Definition: SkSGNode.h:60

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