Tyler Denniston | 8ca4626 | 2021-02-02 16:16:21 -0500 | [diff] [blame^] | 1 | /* |
| 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 | |
| 14 | class SkSVGImage final : public SkSVGTransformableNode { |
| 15 | public: |
| 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 | |
| 35 | protected: |
| 36 | bool parseAndSetAttribute(const char*, const char*) override; |
| 37 | |
| 38 | private: |
| 39 | SkSVGImage() : INHERITED(SkSVGTag::kImage) {} |
| 40 | |
| 41 | using INHERITED = SkSVGTransformableNode; |
| 42 | }; |
| 43 | |
| 44 | #endif // SkSVGImage_DEFINED |