1 /* 2 * Copyright 2017 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkSVGUse_DEFINED 9 #define SkSVGUse_DEFINED 10 11 #include "SkSVGTransformableNode.h" 12 #include "SkSVGTypes.h" 13 14 /** 15 * Implements support for <use> (reference) elements. 16 * (https://www.w3.org/TR/SVG/struct.html#UseElement) 17 */ 18 class SkSVGUse final : public SkSVGTransformableNode { 19 public: 20 ~SkSVGUse() override = default; 21 Make()22 static sk_sp<SkSVGUse> Make() { return sk_sp<SkSVGUse>(new SkSVGUse()); } 23 24 void appendChild(sk_sp<SkSVGNode>) override; 25 26 void setHref(const SkSVGStringType&); 27 void setX(const SkSVGLength&); 28 void setY(const SkSVGLength&); 29 30 protected: 31 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; 32 33 bool onPrepareToRender(SkSVGRenderContext*) const override; 34 void onRender(const SkSVGRenderContext&) const override; 35 SkPath onAsPath(const SkSVGRenderContext&) const override; 36 37 private: 38 SkSVGUse(); 39 40 SkSVGStringType fHref; 41 SkSVGLength fX = SkSVGLength(0); 42 SkSVGLength fY = SkSVGLength(0); 43 44 typedef SkSVGTransformableNode INHERITED; 45 }; 46 47 #endif // SkSVGUse_DEFINED 48