blob: 0dfeb766fd86a1dc9401dc695fe7046c03424e20 [file] [log] [blame]
fmalita6ceef3d2016-07-26 18:46:34 -07001/*
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 "SkSVGContainer.h"
fmalitabffc2562016-08-03 10:21:11 -070012#include "SkSVGTypes.h"
fmalita397a5172016-08-08 11:38:55 -070013#include "SkTLazy.h"
fmalita6ceef3d2016-07-26 18:46:34 -070014
fmalitae1baa7c2016-09-14 12:04:30 -070015class SkSVGLengthContext;
16
fmalita6ceef3d2016-07-26 18:46:34 -070017class SkSVGSVG : public SkSVGContainer {
18public:
Brian Salomond3b65972017-03-22 12:05:03 -040019 ~SkSVGSVG() override = default;
fmalita6ceef3d2016-07-26 18:46:34 -070020
21 static sk_sp<SkSVGSVG> Make() { return sk_sp<SkSVGSVG>(new SkSVGSVG()); }
22
fmalitabffc2562016-08-03 10:21:11 -070023 void setX(const SkSVGLength&);
24 void setY(const SkSVGLength&);
25 void setWidth(const SkSVGLength&);
26 void setHeight(const SkSVGLength&);
fmalita397a5172016-08-08 11:38:55 -070027 void setViewBox(const SkSVGViewBoxType&);
fmalitabffc2562016-08-03 10:21:11 -070028
fmalitae1baa7c2016-09-14 12:04:30 -070029 SkSize intrinsicSize(const SkSVGLengthContext&) const;
30
fmalitabffc2562016-08-03 10:21:11 -070031protected:
fmalita397a5172016-08-08 11:38:55 -070032 bool onPrepareToRender(SkSVGRenderContext*) const override;
33
fmalitabffc2562016-08-03 10:21:11 -070034 void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
35
fmalita6ceef3d2016-07-26 18:46:34 -070036private:
37 SkSVGSVG();
38
fmalitabffc2562016-08-03 10:21:11 -070039 SkSVGLength fX = SkSVGLength(0);
40 SkSVGLength fY = SkSVGLength(0);
41 SkSVGLength fWidth = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
42 SkSVGLength fHeight = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
43
fmalita397a5172016-08-08 11:38:55 -070044 SkTLazy<SkSVGViewBoxType> fViewBox;
45
fmalita6ceef3d2016-07-26 18:46:34 -070046 typedef SkSVGContainer INHERITED;
47};
48
49#endif // SkSVGSVG_DEFINED