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

#include <SkSGClipEffect.h>

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

Public Member Functions

 ~ClipEffect () override
 
- 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< ClipEffectMake (sk_sp< RenderNode > child, sk_sp< GeometryNode > clip, bool aa=false, bool force_clip=false)
 

Protected Member Functions

 ClipEffect (sk_sp< RenderNode >, sk_sp< GeometryNode >, bool aa, bool force_clip)
 
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

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

Detailed Description

Concrete Effect node, applying a clip to its descendants.

Definition at line 30 of file SkSGClipEffect.h.

Constructor & Destructor Documentation

◆ ~ClipEffect()

sksg::ClipEffect::~ClipEffect ( )
override

Definition at line 30 of file SkSGClipEffect.cpp.

30 {
31 this->unobserveInval(fClipNode);
32}
void unobserveInval(const sk_sp< Node > &)
Definition: SkSGNode.cpp:84

◆ ClipEffect()

sksg::ClipEffect::ClipEffect ( sk_sp< RenderNode child,
sk_sp< GeometryNode clip,
bool  aa,
bool  force_clip 
)
protected

Definition at line 22 of file SkSGClipEffect.cpp.

23 : INHERITED(std::move(child))
24 , fClipNode(std::move(clip))
25 , fAntiAlias(aa)
26 , fForceClip(force_clip) {
27 this->observeInval(fClipNode);
28}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
void observeInval(const sk_sp< Node > &)
Definition: SkSGNode.cpp:61

Member Function Documentation

◆ Make()

static sk_sp< ClipEffect > sksg::ClipEffect::Make ( sk_sp< RenderNode child,
sk_sp< GeometryNode clip,
bool  aa = false,
bool  force_clip = false 
)
inlinestatic

Definition at line 32 of file SkSGClipEffect.h.

33 {
34 return (child && clip)
35 ? sk_sp<ClipEffect>(new ClipEffect(std::move(child), std::move(clip), aa, force_clip))
36 : nullptr;
37 }
ClipEffect(sk_sp< RenderNode >, sk_sp< GeometryNode >, bool aa, bool force_clip)

◆ onNodeAt()

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

Implements sksg::RenderNode.

Definition at line 43 of file SkSGClipEffect.cpp.

43 {
44 return fClipNode->contains(p) ? this->INHERITED::onNodeAt(p) : nullptr;
45}
const RenderNode * onNodeAt(const SkPoint &) const override

◆ onRender()

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

Implements sksg::RenderNode.

Definition at line 34 of file SkSGClipEffect.cpp.

34 {
35 SkAutoCanvasRestore acr(canvas, !fNoop);
36 if (!fNoop) {
37 fClipNode->clip(canvas, fAntiAlias);
38 }
39
40 this->INHERITED::onRender(canvas, ctx);
41}
void onRender(SkCanvas *, const RenderContext *) const override

◆ onRevalidate()

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

Implements sksg::Node.

Definition at line 47 of file SkSGClipEffect.cpp.

47 {
48 SkASSERT(this->hasInval());
49
50 const auto clipBounds = fClipNode->revalidate(ic, ctm);
51 auto childBounds = this->INHERITED::onRevalidate(ic, ctm);
52
53 // When the child node is fully contained within the clip, it is usually safe to elide.
54 // An exception is clip-dependent sizing for saveLayer buffers, where the clip is always
55 // significant. For those cases, we provide a mechanism to disable elision.
56 fNoop = !fForceClip && fClipNode->asPath().conservativelyContainsRect(childBounds);
57
58 return childBounds.intersect(clipBounds) ? childBounds : SkRect::MakeEmpty();
59}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkRect onRevalidate(InvalidationController *, const SkMatrix &) override
bool hasInval() const
Definition: SkSGNode.h:60
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595

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