Flutter Engine
The Flutter Engine
Classes | Static Public Member Functions | Protected Member Functions | List of all members
SkSVGPattern Class Referencefinal

#include <SkSVGPattern.h>

Inheritance diagram for SkSVGPattern:
SkSVGHiddenContainer SkSVGContainer SkSVGTransformableNode SkSVGNode SkRefCnt SkRefCntBase

Static Public Member Functions

static sk_sp< SkSVGPatternMake ()
 

Protected Member Functions

 SkSVGPattern ()
 
bool parseAndSetAttribute (const char *, const char *) override
 
bool onAsPaint (const SkSVGRenderContext &, SkPaint *) const override
 
- Protected Member Functions inherited from SkSVGHiddenContainer
 SkSVGHiddenContainer (SkSVGTag t)
 
void onRender (const SkSVGRenderContext &) const final
 
- Protected Member Functions inherited from SkSVGContainer
 SkSVGContainer (SkSVGTag)
 
void onRender (const SkSVGRenderContext &) const override
 
SkPath onAsPath (const SkSVGRenderContext &) const override
 
SkRect onObjectBoundingBox (const SkSVGRenderContext &) const override
 
bool hasChildren () const final
 
template<typename NodeType , typename Func >
void forEachChild (Func func) const
 
- Protected Member Functions inherited from SkSVGTransformableNode
 SkSVGTransformableNode (SkSVGTag)
 
bool onPrepareToRender (SkSVGRenderContext *) const override
 
void onSetAttribute (SkSVGAttribute, const SkSVGValue &) override
 
void mapToParent (SkPath *) const
 
void mapToParent (SkRect *) const
 
- Protected Member Functions inherited from SkSVGNode
 SkSVGNode (SkSVGTag)
 
virtual bool onPrepareToRender (SkSVGRenderContext *) const
 
virtual void onRender (const SkSVGRenderContext &) const =0
 
virtual bool onAsPaint (const SkSVGRenderContext &, SkPaint *) const
 
virtual SkPath onAsPath (const SkSVGRenderContext &) const =0
 
virtual void onSetAttribute (SkSVGAttribute, const SkSVGValue &)
 
virtual bool hasChildren () const
 
virtual SkRect onObjectBoundingBox (const SkSVGRenderContext &) const
 

Additional Inherited Members

- Public Member Functions inherited from SkSVGContainer
void appendChild (sk_sp< SkSVGNode >) override
 
- Public Member Functions inherited from SkSVGTransformableNode
void setTransform (const SkSVGTransformType &t)
 
- Public Member Functions inherited from SkSVGNode
 ~SkSVGNode () override
 
SkSVGTag tag () const
 
virtual void appendChild (sk_sp< SkSVGNode >)=0
 
void render (const SkSVGRenderContext &) const
 
bool asPaint (const SkSVGRenderContext &, SkPaint *) const
 
SkPath asPath (const SkSVGRenderContext &) const
 
SkRect objectBoundingBox (const SkSVGRenderContext &) const
 
void setAttribute (SkSVGAttribute, const SkSVGValue &)
 
bool setAttribute (const char *attributeName, const char *attributeValue)
 
virtual bool parseAndSetAttribute (const char *name, const char *value)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
- Static Protected Member Functions inherited from SkSVGNode
static SkMatrix ComputeViewboxMatrix (const SkRect &, const SkRect &, SkSVGPreserveAspectRatio)
 
- Protected Attributes inherited from SkSVGContainer
skia_private::STArray< 1, sk_sp< SkSVGNode >, truefChildren
 

Detailed Description

Definition at line 16 of file SkSVGPattern.h.

Constructor & Destructor Documentation

◆ SkSVGPattern()

SkSVGPattern::SkSVGPattern ( )
protected

Definition at line 17 of file SkSVGPattern.cpp.

17: INHERITED(SkSVGTag::kPattern) {}

Member Function Documentation

◆ Make()

static sk_sp< SkSVGPattern > SkSVGPattern::Make ( )
inlinestatic

Definition at line 18 of file SkSVGPattern.h.

18 {
20 }

◆ onAsPaint()

bool SkSVGPattern::onAsPaint ( const SkSVGRenderContext ctx,
SkPaint paint 
) const
overrideprotectedvirtual

Reimplemented from SkSVGNode.

Definition at line 92 of file SkSVGPattern.cpp.

92 {
93 PatternAttributes attrs;
94 const auto* contentNode = this->resolveHref(ctx, &attrs);
95
96 const auto tile = ctx.lengthContext().resolveRect(
97 attrs.fX.isValid() ? *attrs.fX : SkSVGLength(0),
98 attrs.fY.isValid() ? *attrs.fY : SkSVGLength(0),
99 attrs.fWidth.isValid() ? *attrs.fWidth : SkSVGLength(0),
100 attrs.fHeight.isValid() ? *attrs.fHeight : SkSVGLength(0));
101
102 if (tile.isEmpty()) {
103 return false;
104 }
105
106 const SkMatrix* patternTransform = attrs.fPatternTransform.isValid()
107 ? attrs.fPatternTransform.get()
108 : nullptr;
109
110 SkPictureRecorder recorder;
111 SkSVGRenderContext recordingContext(ctx, recorder.beginRecording(tile));
112
113 // Cannot call into INHERITED:: because SkSVGHiddenContainer skips rendering.
114 contentNode->SkSVGContainer::onRender(recordingContext);
115
116 paint->setShader(recorder.finishRecordingAsPicture()->makeShader(
120 patternTransform,
121 &tile));
122 return true;
123}
SkScalar get(int index) const
Definition: SkMatrix.h:392
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, SkFilterMode mode, const SkMatrix *localMatrix, const SkRect *tileRect) const
SkRect resolveRect(const SkSVGLength &x, const SkSVGLength &y, const SkSVGLength &w, const SkSVGLength &h) const
const SkSVGLengthContext & lengthContext() const
const Paint & paint
Definition: color_source.cc:38

◆ parseAndSetAttribute()

bool SkSVGPattern::parseAndSetAttribute ( const char *  name,
const char *  value 
)
overrideprotectedvirtual

Reimplemented from SkSVGNode.

Definition at line 19 of file SkSVGPattern.cpp.

19 {
21 this->setX(SkSVGAttributeParser::parse<SkSVGLength>("x", name, value)) ||
22 this->setY(SkSVGAttributeParser::parse<SkSVGLength>("y", name, value)) ||
23 this->setWidth(SkSVGAttributeParser::parse<SkSVGLength>("width", name, value)) ||
24 this->setHeight(SkSVGAttributeParser::parse<SkSVGLength>("height", name, value)) ||
25 this->setPatternTransform(SkSVGAttributeParser::parse<SkSVGTransformType>(
26 "patternTransform", name, value)) ||
27 this->setHref(SkSVGAttributeParser::parse<SkSVGIRI>("xlink:href", name, value));
28}
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition: SkSVGNode.cpp:90
uint8_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

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