blob: dba5a99ce7c4452026ace74b88bda894e8b78274 [file] [log] [blame]
Tyler Denniston8ca46262021-02-02 16:16:21 -05001/*
2 * Copyright 2021 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 SkSVGImage_DEFINED
9#define SkSVGImage_DEFINED
10
11#include "modules/svg/include/SkSVGTransformableNode.h"
12#include "modules/svg/include/SkSVGTypes.h"
13
14class SkSVGImage final : public SkSVGTransformableNode {
15public:
16 static sk_sp<SkSVGImage> Make() {
17 return sk_sp<SkSVGImage>(new SkSVGImage());
18 }
19
20 void appendChild(sk_sp<SkSVGNode>) override {
21 SkDebugf("cannot append child nodes to this element.\n");
22 }
23
24 bool onPrepareToRender(SkSVGRenderContext*) const override;
25 void onRender(const SkSVGRenderContext&) const override;
26 SkPath onAsPath(const SkSVGRenderContext&) const override;
27 SkRect onObjectBoundingBox(const SkSVGRenderContext&) const override;
28
29 SVG_ATTR(X , SkSVGLength, SkSVGLength(0))
30 SVG_ATTR(Y , SkSVGLength, SkSVGLength(0))
31 SVG_ATTR(Width , SkSVGLength, SkSVGLength(0))
32 SVG_ATTR(Height, SkSVGLength, SkSVGLength(0))
33 SVG_ATTR(Href , SkSVGIRI , SkSVGIRI())
34
35protected:
36 bool parseAndSetAttribute(const char*, const char*) override;
37
38private:
39 SkSVGImage() : INHERITED(SkSVGTag::kImage) {}
40
41 using INHERITED = SkSVGTransformableNode;
42};
43
44#endif // SkSVGImage_DEFINED