blob: 8904c1799d38b1229b34ee17d8f332f70e4b7c4a [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 SkSVGDOM_DEFINED
9#define SkSVGDOM_DEFINED
10
11#include "SkRefCnt.h"
12#include "SkSize.h"
fmalita28d5b722016-09-12 17:06:47 -070013#include "SkSVGIDMapper.h"
fmalita6ceef3d2016-07-26 18:46:34 -070014#include "SkTemplates.h"
15
16class SkCanvas;
17class SkDOM;
18class SkStream;
19class SkSVGNode;
20
21class SkSVGDOM : public SkRefCnt {
22public:
fmalitae1baa7c2016-09-14 12:04:30 -070023 SkSVGDOM();
fmalita6ceef3d2016-07-26 18:46:34 -070024 ~SkSVGDOM() = default;
25
fmalitae1baa7c2016-09-14 12:04:30 -070026 static sk_sp<SkSVGDOM> MakeFromDOM(const SkDOM&);
27 static sk_sp<SkSVGDOM> MakeFromStream(SkStream&);
fmalita6ceef3d2016-07-26 18:46:34 -070028
fmalitae1baa7c2016-09-14 12:04:30 -070029 const SkSize& containerSize() const;
fmalita6ceef3d2016-07-26 18:46:34 -070030 void setContainerSize(const SkSize&);
fmalitae1baa7c2016-09-14 12:04:30 -070031
fmalitaca39d712016-08-12 13:17:11 -070032 void setRoot(sk_sp<SkSVGNode>);
fmalita6ceef3d2016-07-26 18:46:34 -070033
34 void render(SkCanvas*) const;
35
36private:
fmalitae1baa7c2016-09-14 12:04:30 -070037 SkSize intrinsicSize() const;
38
fmalita6ceef3d2016-07-26 18:46:34 -070039 SkSize fContainerSize;
40 sk_sp<SkSVGNode> fRoot;
fmalita28d5b722016-09-12 17:06:47 -070041 SkSVGIDMapper fIDMapper;
fmalita6ceef3d2016-07-26 18:46:34 -070042
43 typedef SkRefCnt INHERITED;
44};
45
46#endif // SkSVGDOM_DEFINED