blob: 74bc49e240d7332901181250c8deab35a3b7cf68 [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
Tyler Denniston1f4cd072021-02-05 09:08:33 -050029 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 SVG_ATTR(PreserveAspectRatio, SkSVGPreserveAspectRatio, SkSVGPreserveAspectRatio())
Tyler Denniston8ca46262021-02-02 16:16:21 -050035
36protected:
37 bool parseAndSetAttribute(const char*, const char*) override;
38
39private:
40 SkSVGImage() : INHERITED(SkSVGTag::kImage) {}
41
Tyler Denniston1f4cd072021-02-05 09:08:33 -050042 SkRect resolveImageRect(const SkRect&, const SkRect&) const;
43
Tyler Denniston8ca46262021-02-02 16:16:21 -050044 using INHERITED = SkSVGTransformableNode;
45};
46
47#endif // SkSVGImage_DEFINED