2020-10-15 22:10:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSVGDOM_DEFINED
|
|
|
|
#define SkSVGDOM_DEFINED
|
|
|
|
|
2020-11-10 20:24:59 +00:00
|
|
|
#include "include/core/SkFontMgr.h"
|
2020-10-15 22:10:29 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/private/SkTemplates.h"
|
|
|
|
#include "modules/svg/include/SkSVGIDMapper.h"
|
|
|
|
|
|
|
|
class SkCanvas;
|
|
|
|
class SkDOM;
|
|
|
|
class SkStream;
|
|
|
|
class SkSVGNode;
|
2020-11-10 20:24:59 +00:00
|
|
|
class SkSVGSVG;
|
2020-10-15 22:10:29 +00:00
|
|
|
|
|
|
|
class SkSVGDOM : public SkRefCnt {
|
|
|
|
public:
|
2020-11-10 20:24:59 +00:00
|
|
|
class Builder final {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Specify a font manager for loading SVG fonts.
|
|
|
|
*/
|
|
|
|
Builder& setFontManager(sk_sp<SkFontMgr>);
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-11-10 20:24:59 +00:00
|
|
|
sk_sp<SkSVGDOM> make(SkStream&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
sk_sp<SkFontMgr> fFontMgr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static sk_sp<SkSVGDOM> MakeFromStream(SkStream& str) {
|
|
|
|
return Builder().make(str);
|
|
|
|
}
|
2020-10-15 22:10:29 +00:00
|
|
|
|
|
|
|
const SkSize& containerSize() const;
|
|
|
|
void setContainerSize(const SkSize&);
|
|
|
|
|
|
|
|
// Returns the node with the given id, or nullptr if not found.
|
|
|
|
sk_sp<SkSVGNode>* findNodeById(const char* id);
|
|
|
|
|
|
|
|
void render(SkCanvas*) const;
|
|
|
|
|
|
|
|
private:
|
2020-11-10 20:24:59 +00:00
|
|
|
SkSVGDOM(sk_sp<SkSVGSVG>, sk_sp<SkFontMgr>, SkSVGIDMapper&&);
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-11-10 20:24:59 +00:00
|
|
|
const sk_sp<SkSVGSVG> fRoot;
|
|
|
|
const sk_sp<SkFontMgr> fFontMgr;
|
|
|
|
const SkSVGIDMapper fIDMapper;
|
2020-10-15 22:10:29 +00:00
|
|
|
|
2020-11-10 20:24:59 +00:00
|
|
|
SkSize fContainerSize;
|
2020-10-15 22:10:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkSVGDOM_DEFINED
|