Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 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 "modules/svg/include/SkSVGTransformableNode.h" |
| 12 | #include "modules/svg/include/SkSVGTypes.h" |
| 13 | |
| 14 | /** |
| 15 | * Implements support for <use> (reference) elements. |
| 16 | * (https://www.w3.org/TR/SVG11/struct.html#UseElement) |
| 17 | */ |
| 18 | class SkSVGUse final : public SkSVGTransformableNode { |
| 19 | public: |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 20 | static sk_sp<SkSVGUse> Make() { return sk_sp<SkSVGUse>(new SkSVGUse()); } |
| 21 | |
| 22 | void appendChild(sk_sp<SkSVGNode>) override; |
| 23 | |
Tyler Denniston | 3df6c20 | 2021-01-14 15:37:38 -0500 | [diff] [blame] | 24 | SVG_ATTR(X , SkSVGLength, SkSVGLength(0)) |
| 25 | SVG_ATTR(Y , SkSVGLength, SkSVGLength(0)) |
| 26 | SVG_ATTR(Href, SkSVGIRI , SkSVGIRI()) |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 27 | |
| 28 | protected: |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 29 | bool onPrepareToRender(SkSVGRenderContext*) const override; |
| 30 | void onRender(const SkSVGRenderContext&) const override; |
| 31 | SkPath onAsPath(const SkSVGRenderContext&) const override; |
Tyler Denniston | f548a02 | 2020-10-27 15:02:02 -0400 | [diff] [blame] | 32 | SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | SkSVGUse(); |
| 36 | |
Tyler Denniston | 3df6c20 | 2021-01-14 15:37:38 -0500 | [diff] [blame] | 37 | bool parseAndSetAttribute(const char*, const char*) override; |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 38 | |
| 39 | using INHERITED = SkSVGTransformableNode; |
| 40 | }; |
| 41 | |
| 42 | #endif // SkSVGUse_DEFINED |