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

#include <SkSGRenderEffect.h>

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

Public Member Functions

 ~ShaderEffect () override
 
void setShader (sk_sp< Shader >)
 
- 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
 

Static Public Member Functions

static sk_sp< ShaderEffectMake (sk_sp< RenderNode > child, sk_sp< Shader > shader=nullptr)
 

Protected Member Functions

void onRender (SkCanvas *, const RenderContext *) 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

- Protected Types inherited from sksg::Node
enum  InvalTraits { kBubbleDamage_Trait = 1 << 0 , kOverrideDamage_Trait = 1 << 1 }
 

Detailed Description

Attaches a shader to the render DAG.

Definition at line 64 of file SkSGRenderEffect.h.

Constructor & Destructor Documentation

◆ ~ShaderEffect()

sksg::ShaderEffect::~ShaderEffect ( )
override

Definition at line 54 of file SkSGRenderEffect.cpp.

54 {
55 if (fShader) {
56 this->unobserveInval(fShader);
57 }
58}
void unobserveInval(const sk_sp< Node > &)
Definition: SkSGNode.cpp:84

Member Function Documentation

◆ Make()

sk_sp< ShaderEffect > sksg::ShaderEffect::Make ( sk_sp< RenderNode child,
sk_sp< Shader shader = nullptr 
)
static

Definition at line 41 of file SkSGRenderEffect.cpp.

41 {
42 return child ? sk_sp<ShaderEffect>(new ShaderEffect(std::move(child), std::move(shader)))
43 : nullptr;
44}

◆ onRender()

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

Reimplemented from sksg::EffectNode.

Definition at line 79 of file SkSGRenderEffect.cpp.

79 {
80 const auto local_ctx = ScopedRenderContext(canvas, ctx)
81 .modulateShader(fShader ? fShader->getShader() : nullptr, canvas->getTotalMatrix());
82
83 this->INHERITED::onRender(canvas, local_ctx);
84}
SkMatrix getTotalMatrix() const
Definition: SkCanvas.cpp:1629
void onRender(SkCanvas *, const RenderContext *) const override

◆ onRevalidate()

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

Reimplemented from sksg::EffectNode.

Definition at line 71 of file SkSGRenderEffect.cpp.

71 {
72 if (fShader) {
73 fShader->revalidate(ic, ctm);
74 }
75
76 return this->INHERITED::onRevalidate(ic, ctm);
77}
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override

◆ setShader()

void sksg::ShaderEffect::setShader ( sk_sp< Shader sh)

Definition at line 60 of file SkSGRenderEffect.cpp.

60 {
61 if (fShader) {
62 this->unobserveInval(fShader);
63 }
64
65 fShader = std::move(sh);
66
67 if (fShader) {
68 this->observeInval(fShader);
69 }
70}
void observeInval(const sk_sp< Node > &)
Definition: SkSGNode.cpp:61
sh
Definition: run_sh.py:10

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