/src/skia/modules/svg/include/SkSVGSVG.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2016 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 SkSVGSVG_DEFINED |
9 | | #define SkSVGSVG_DEFINED |
10 | | |
11 | | #include "include/core/SkRefCnt.h" |
12 | | #include "include/core/SkSize.h" |
13 | | #include "include/private/base/SkAPI.h" |
14 | | #include "modules/svg/include/SkSVGContainer.h" |
15 | | #include "modules/svg/include/SkSVGNode.h" |
16 | | #include "modules/svg/include/SkSVGTypes.h" |
17 | | #include "modules/svg/include/SkSVGValue.h" |
18 | | #include "src/base/SkTLazy.h" |
19 | | |
20 | | class SkSVGLengthContext; |
21 | | class SkSVGRenderContext; |
22 | | enum class SkSVGAttribute; |
23 | | |
24 | | class SK_API SkSVGSVG : public SkSVGContainer { |
25 | | public: |
26 | | enum class Type { |
27 | | kRoot, |
28 | | kInner, |
29 | | }; |
30 | 1.14k | static sk_sp<SkSVGSVG> Make(Type t = Type::kInner) { return sk_sp<SkSVGSVG>(new SkSVGSVG(t)); } |
31 | | |
32 | | SVG_ATTR(X , SkSVGLength, SkSVGLength(0)) |
33 | | SVG_ATTR(Y , SkSVGLength, SkSVGLength(0)) |
34 | | SVG_ATTR(Width , SkSVGLength, SkSVGLength(100, SkSVGLength::Unit::kPercentage)) |
35 | | SVG_ATTR(Height , SkSVGLength, SkSVGLength(100, SkSVGLength::Unit::kPercentage)) |
36 | | SVG_ATTR(PreserveAspectRatio, SkSVGPreserveAspectRatio, SkSVGPreserveAspectRatio()) |
37 | | |
38 | | SVG_OPTIONAL_ATTR(ViewBox, SkSVGViewBoxType) |
39 | | |
40 | | SkSize intrinsicSize(const SkSVGLengthContext&) const; |
41 | | |
42 | | void renderNode(const SkSVGRenderContext&, const SkSVGIRI& iri) const; |
43 | | |
44 | | protected: |
45 | | bool onPrepareToRender(SkSVGRenderContext*) const override; |
46 | | |
47 | | void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; |
48 | | |
49 | | private: |
50 | | explicit SkSVGSVG(Type t) |
51 | | : INHERITED(SkSVGTag::kSvg) |
52 | | , fType(t) |
53 | 1.14k | {} |
54 | | |
55 | | // Some attributes behave differently for the outermost svg element. |
56 | | const Type fType; |
57 | | |
58 | | using INHERITED = SkSVGContainer; |
59 | | }; |
60 | | |
61 | | #endif // SkSVGSVG_DEFINED |