blob: 4a87f9925d96f988de337ed5d321bad4dcf87107 [file] [log] [blame]
Florin Malitab3418102020-10-15 18:10:29 -04001/*
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 */
18class SkSVGUse final : public SkSVGTransformableNode {
19public:
20 ~SkSVGUse() override = default;
21
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
30protected:
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
37private:
38 SkSVGUse();
39
40 SkSVGStringType fHref;
41 SkSVGLength fX = SkSVGLength(0);
42 SkSVGLength fY = SkSVGLength(0);
43
44 using INHERITED = SkSVGTransformableNode;
45};
46
47#endif // SkSVGUse_DEFINED