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

#include <SkSVGUse.h>

Inheritance diagram for SkSVGUse:
SkSVGTransformableNode SkSVGNode SkRefCnt SkRefCntBase

Public Member Functions

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 Public Member Functions

static sk_sp< SkSVGUseMake ()
 

Protected Member Functions

bool onPrepareToRender (SkSVGRenderContext *) const override
 
void onRender (const SkSVGRenderContext &) const override
 
SkPath onAsPath (const SkSVGRenderContext &) const override
 
SkRect onObjectBoundingBox (const SkSVGRenderContext &) const override
 
- 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

- Static Protected Member Functions inherited from SkSVGNode
static SkMatrix ComputeViewboxMatrix (const SkRect &, const SkRect &, SkSVGPreserveAspectRatio)
 

Detailed Description

Implements support for <use> (reference) elements. (https://www.w3.org/TR/SVG11/struct.html#UseElement)

Definition at line 18 of file SkSVGUse.h.

Member Function Documentation

◆ appendChild()

void SkSVGUse::appendChild ( sk_sp< SkSVGNode )
overridevirtual

Implements SkSVGNode.

Definition at line 16 of file SkSVGUse.cpp.

16 {
17 SkDebugf("cannot append child nodes to this element.\n");
18}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1

◆ Make()

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

Definition at line 20 of file SkSVGUse.h.

20{ return sk_sp<SkSVGUse>(new SkSVGUse()); }

◆ onAsPath()

SkPath SkSVGUse::onAsPath ( const SkSVGRenderContext ctx) const
overrideprotectedvirtual

Implements SkSVGNode.

Definition at line 52 of file SkSVGUse.cpp.

52 {
53 const auto ref = ctx.findNodeById(fHref);
54 if (!ref) {
55 return SkPath();
56 }
57
58 return ref->asPath(ctx);
59}
Definition: SkPath.h:59
void ref() const
Definition: SkRefCnt.h:62
BorrowedNode findNodeById(const SkSVGIRI &) const

◆ onObjectBoundingBox()

SkRect SkSVGUse::onObjectBoundingBox ( const SkSVGRenderContext ctx) const
overrideprotectedvirtual

Reimplemented from SkSVGNode.

Definition at line 61 of file SkSVGUse.cpp.

61 {
62 const auto ref = ctx.findNodeById(fHref);
63 if (!ref) {
64 return SkRect::MakeEmpty();
65 }
66
67 const SkSVGLengthContext& lctx = ctx.lengthContext();
70
71 SkRect bounds = ref->objectBoundingBox(ctx);
72 bounds.offset(x, y);
73
74 return bounds;
75}
SkScalar resolve(const SkSVGLength &, LengthType) const
const SkSVGLengthContext & lengthContext() const
float SkScalar
Definition: extension.cpp:12
double y
double x
Optional< SkRect > bounds
Definition: SkRecords.h:189
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595

◆ onPrepareToRender()

bool SkSVGUse::onPrepareToRender ( SkSVGRenderContext ctx) const
overrideprotectedvirtual

Reimplemented from SkSVGTransformableNode.

Definition at line 27 of file SkSVGUse.cpp.

27 {
28 if (fHref.iri().isEmpty() || !INHERITED::onPrepareToRender(ctx)) {
29 return false;
30 }
31
32 if (fX.value() || fY.value()) {
33 // Restored when the local SkSVGRenderContext leaves scope.
34 ctx->saveOnce();
35 ctx->canvas()->translate(fX.value(), fY.value());
36 }
37
38 // TODO: width/height override for <svg> targets.
39
40 return true;
41}
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
SkCanvas * canvas() const
bool onPrepareToRender(SkSVGRenderContext *) const override

◆ onRender()

void SkSVGUse::onRender ( const SkSVGRenderContext ctx) const
overrideprotectedvirtual

Implements SkSVGNode.

Definition at line 43 of file SkSVGUse.cpp.

43 {
44 const auto ref = ctx.findNodeById(fHref);
45 if (!ref) {
46 return;
47 }
48
49 ref->render(ctx);
50}

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