2 * Copyright 2016 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkSVGSVG_DEFINED
9 #define SkSVGSVG_DEFINED
11 #include "modules/svg/include/SkSVGContainer.h"
12 #include "modules/svg/include/SkSVGTypes.h"
13 #include "src/core/SkTLazy.h"
15 class SkSVGLengthContext;
17 class SkSVGSVG : public SkSVGContainer {
23 static sk_sp<SkSVGSVG> Make(Type t = Type::kInner) { return sk_sp<SkSVGSVG>(new SkSVGSVG(t)); }
25 SVG_ATTR(X , SkSVGLength, SkSVGLength(0))
26 SVG_ATTR(Y , SkSVGLength, SkSVGLength(0))
27 SVG_ATTR(Width , SkSVGLength, SkSVGLength(100, SkSVGLength::Unit::kPercentage))
28 SVG_ATTR(Height , SkSVGLength, SkSVGLength(100, SkSVGLength::Unit::kPercentage))
29 SVG_ATTR(PreserveAspectRatio, SkSVGPreserveAspectRatio, SkSVGPreserveAspectRatio())
31 SVG_OPTIONAL_ATTR(ViewBox, SkSVGViewBoxType)
33 SkSize intrinsicSize(const SkSVGLengthContext&) const;
35 void renderNode(const SkSVGRenderContext&, const SkSVGIRI& iri) const;
38 bool onPrepareToRender(SkSVGRenderContext*) const override;
40 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
43 explicit SkSVGSVG(Type t)
44 : INHERITED(SkSVGTag::kSvg)
48 // Some attributes behave differently for the outermost svg element.
51 using INHERITED = SkSVGContainer;
54 #endif // SkSVGSVG_DEFINED