/src/skia/modules/svg/include/SkSVGUse.h
Line | Count | Source |
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 "include/core/SkPath.h" |
12 | | #include "include/core/SkRect.h" |
13 | | #include "include/core/SkRefCnt.h" |
14 | | #include "include/private/base/SkAPI.h" |
15 | | #include "modules/svg/include/SkSVGNode.h" |
16 | | #include "modules/svg/include/SkSVGTransformableNode.h" |
17 | | #include "modules/svg/include/SkSVGTypes.h" |
18 | | |
19 | | class SkSVGRenderContext; |
20 | | |
21 | | /** |
22 | | * Implements support for <use> (reference) elements. |
23 | | * (https://www.w3.org/TR/SVG11/struct.html#UseElement) |
24 | | */ |
25 | | class SK_API SkSVGUse final : public SkSVGTransformableNode { |
26 | | public: |
27 | 47 | static sk_sp<SkSVGUse> Make() { return sk_sp<SkSVGUse>(new SkSVGUse()); } |
28 | | |
29 | | void appendChild(sk_sp<SkSVGNode>) override; |
30 | | |
31 | | SVG_ATTR(X , SkSVGLength, SkSVGLength(0)) |
32 | | SVG_ATTR(Y , SkSVGLength, SkSVGLength(0)) |
33 | | SVG_ATTR(Href, SkSVGIRI , SkSVGIRI()) |
34 | | |
35 | | protected: |
36 | | bool onPrepareToRender(SkSVGRenderContext*) const override; |
37 | | void onRender(const SkSVGRenderContext&) const override; |
38 | | SkPath onAsPath(const SkSVGRenderContext&) const override; |
39 | | SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override; |
40 | | |
41 | | private: |
42 | | SkSVGUse(); |
43 | | |
44 | | bool parseAndSetAttribute(const char*, const char*) override; |
45 | | |
46 | | using INHERITED = SkSVGTransformableNode; |
47 | | }; |
48 | | |
49 | | #endif // SkSVGUse_DEFINED |