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

#include <SkSGImage.h>

Inheritance diagram for sksg::Image:
sksg::RenderNode sksg::Node SkRefCnt SkRefCntBase

Static Public Member Functions

static sk_sp< ImageMake (sk_sp< SkImage > image)
 

Protected Member Functions

 Image (sk_sp< SkImage >)
 
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::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 rendering node, wrapping an SkImage.

Definition at line 31 of file SkSGImage.h.

Constructor & Destructor Documentation

◆ Image()

sksg::Image::Image ( sk_sp< SkImage image)
explicitprotected

Definition at line 18 of file SkSGImage.cpp.

18: fImage(std::move(image)) {}
sk_sp< const SkImage > image
Definition: SkRecords.h:269

Member Function Documentation

◆ Make()

static sk_sp< Image > sksg::Image::Make ( sk_sp< SkImage image)
inlinestatic

Definition at line 33 of file SkSGImage.h.

33 {
34 return sk_sp<Image>(new Image(std::move(image)));
35 }
Image(sk_sp< SkImage >)
Definition: SkSGImage.cpp:18

◆ onNodeAt()

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

Implements sksg::RenderNode.

Definition at line 41 of file SkSGImage.cpp.

41 {
42 SkASSERT(this->bounds().contains(p.x(), p.y()));
43 return this;
44}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const SkRect & bounds() const
Definition: SkSGNode.h:55
constexpr bool contains(std::string_view str, std::string_view needle)
Definition: SkStringView.h:41
constexpr float x() const
Definition: SkPoint_impl.h:181

◆ onRender()

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

Implements sksg::RenderNode.

Definition at line 20 of file SkSGImage.cpp.

20 {
21 if (!fImage) {
22 return;
23 }
24
26 paint.setAntiAlias(fAntiAlias);
27
28 sksg::RenderNode::ScopedRenderContext local_ctx(canvas, ctx);
29 if (ctx) {
30 if (ctx->fMaskShader) {
31 // Mask shaders cannot be applied via drawImage - we need layer isolation.
32 // TODO: remove after clipShader conversion.
33 local_ctx.setIsolation(this->bounds(), canvas->getTotalMatrix(), true);
34 }
35 local_ctx->modulatePaint(canvas->getTotalMatrix(), &paint);
36 }
37
38 canvas->drawImage(fImage, 0, 0, fSamplingOptions, &paint);
39}
SkMatrix getTotalMatrix() const
Definition: SkCanvas.cpp:1629
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
const Paint & paint
Definition: color_source.cc:38

◆ onRevalidate()

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

Implements sksg::Node.

Definition at line 46 of file SkSGImage.cpp.

46 {
47 return fImage ? SkRect::Make(fImage->bounds()) : SkRect::MakeEmpty();
48}
SkIRect bounds() const
Definition: SkImage.h:303
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

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