8#ifndef SkSVGNode_DEFINED
9#define SkSVGNode_DEFINED
64#define SVG_PRES_ATTR(attr_name, attr_type, attr_inherited) \
66 bool set##attr_name(SkSVGAttributeParser::ParseResult< \
67 SkSVGProperty<attr_type, attr_inherited>>&& pr) {\
68 if (pr.isValid()) { this->set##attr_name(std::move(*pr)); } \
69 return pr.isValid(); \
73 const SkSVGProperty<attr_type, attr_inherited>& get##attr_name() const { \
74 return fPresentationAttributes.f##attr_name; \
76 void set##attr_name(const SkSVGProperty<attr_type, attr_inherited>& v) { \
77 auto* dest = &fPresentationAttributes.f##attr_name; \
78 if (!dest->isInheritable() || v.isValue()) { \
82 dest->set(SkSVGPropertyState::kInherit); \
85 void set##attr_name(SkSVGProperty<attr_type, attr_inherited>&& v) { \
86 auto* dest = &fPresentationAttributes.f##attr_name; \
87 if (!dest->isInheritable() || v.isValue()) { \
89 *dest = std::move(v); \
91 dest->set(SkSVGPropertyState::kInherit); \
109 bool setAttribute(
const char* attributeName,
const char* attributeValue);
112 virtual bool parseAndSetAttribute(
const char*
name,
const char* value);
187#define _SVG_ATTR_SETTERS(attr_name, attr_type, attr_default, set_cp, set_mv) \
189 bool set##attr_name( \
190 const SkSVGAttributeParser::ParseResult<attr_type>& pr) { \
191 if (pr.isValid()) { this->set##attr_name(*pr); } \
192 return pr.isValid(); \
194 bool set##attr_name( \
195 SkSVGAttributeParser::ParseResult<attr_type>&& pr) { \
196 if (pr.isValid()) { this->set##attr_name(std::move(*pr)); } \
197 return pr.isValid(); \
200 void set##attr_name(const attr_type& a) { set_cp(a); } \
201 void set##attr_name(attr_type&& a) { set_mv(std::move(a)); }
203#define SVG_ATTR(attr_name, attr_type, attr_default) \
205 attr_type f##attr_name = attr_default; \
207 const attr_type& get##attr_name() const { return f##attr_name; } \
209 attr_name, attr_type, attr_default, \
210 [this](const attr_type& a) { this->f##attr_name = a; }, \
211 [this](attr_type&& a) { this->f##attr_name = std::move(a); })
213#define SVG_OPTIONAL_ATTR(attr_name, attr_type) \
215 SkTLazy<attr_type> f##attr_name; \
217 const SkTLazy<attr_type>& get##attr_name() const { return f##attr_name; } \
219 attr_name, attr_type, attr_default, \
220 [this](const attr_type& a) { this->f##attr_name.set(a); }, \
221 [this](attr_type&& a) { this->f##attr_name.set(std::move(a)); })
static sk_sp< SkImage > render(const SkPicture &p)
#define INHERITED(method,...)
#define SVG_PRES_ATTR(attr_name, attr_type, attr_inherited)
virtual SkRect onObjectBoundingBox(const SkSVGRenderContext &) const
virtual void appendChild(sk_sp< SkSVGNode >)=0
virtual void onSetAttribute(SkSVGAttribute, const SkSVGValue &)
virtual bool hasChildren() const
virtual SkPath onAsPath(const SkSVGRenderContext &) const =0
static constexpr SkRect MakeEmpty()