Flutter Engine
The Flutter Engine
third_party
skia
modules
svg
include
SkSVGDOM.h
Go to the documentation of this file.
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 SkSVGDOM_DEFINED
9
#define SkSVGDOM_DEFINED
10
11
#include "
include/core/SkFontMgr.h
"
12
#include "
include/core/SkRefCnt.h
"
13
#include "
include/core/SkSize.h
"
14
#include "
include/private/base/SkTemplates.h
"
15
#include "
modules/skresources/include/SkResources.h
"
16
#include "
modules/skshaper/include/SkShaper_factory.h
"
17
#include "
modules/svg/include/SkSVGIDMapper.h
"
18
19
class
SkCanvas
;
20
class
SkDOM
;
21
class
SkStream
;
22
class
SkSVGNode
;
23
struct
SkSVGPresentationContext
;
24
class
SkSVGSVG
;
25
26
class
SK_API
SkSVGDOM
:
public
SkRefCnt
{
27
public
:
28
class
Builder
final {
29
public
:
30
/**
31
* Specify a font manager for loading fonts (e.g. from the system) to render <text>
32
* SVG nodes.
33
* If this is not set, but a font is required as part of rendering, the text will
34
* not be displayed.
35
*/
36
Builder
& setFontManager(
sk_sp<SkFontMgr>
);
37
38
/**
39
* Specify a resource provider for loading images etc.
40
*/
41
Builder
& setResourceProvider(
sk_sp<skresources::ResourceProvider>
);
42
43
/**
44
* Specify the callbacks for dealing with shaping text. See also
45
* modules/skshaper/utils/FactoryHelpers.h
46
*/
47
Builder
& setTextShapingFactory(
sk_sp<SkShapers::Factory>
);
48
49
sk_sp<SkSVGDOM>
make
(
SkStream
&)
const
;
50
51
private
:
52
sk_sp<SkFontMgr>
fFontMgr;
53
sk_sp<skresources::ResourceProvider>
fResourceProvider;
54
sk_sp<SkShapers::Factory>
fTextShapingFactory;
55
};
56
57
static
sk_sp<SkSVGDOM>
MakeFromStream
(
SkStream
& str) {
58
return
Builder
().make(str);
59
}
60
61
/**
62
* Returns the root (outermost) SVG element.
63
*/
64
SkSVGSVG
*
getRoot
()
const
{
return
fRoot.get(); }
65
66
/**
67
* Specify a "container size" for the SVG dom.
68
*
69
* This is used to resolve the initial viewport when the root SVG width/height are specified
70
* in relative units.
71
*
72
* If the root dimensions are in absolute units, then the container size has no effect since
73
* the initial viewport is fixed.
74
*/
75
void
setContainerSize(
const
SkSize
&);
76
77
/**
78
* DEPRECATED: use getRoot()->intrinsicSize() to query the root element intrinsic size.
79
*
80
* Returns the SVG dom container size.
81
*
82
* If the client specified a container size via setContainerSize(), then the same size is
83
* returned.
84
*
85
* When unspecified by clients, this returns the intrinsic size of the root element, as defined
86
* by its width/height attributes. If either width or height is specified in relative units
87
* (e.g. "100%"), then the corresponding intrinsic size dimension is zero.
88
*/
89
const
SkSize
& containerSize()
const
;
90
91
// Returns the node with the given id, or nullptr if not found.
92
sk_sp<SkSVGNode>
* findNodeById(
const
char
*
id
);
93
94
void
render
(
SkCanvas
*)
const
;
95
96
/** Render the node with the given id as if it were the only child of the root. */
97
void
renderNode(
SkCanvas
*,
SkSVGPresentationContext
&,
const
char
*
id
)
const
;
98
99
private
:
100
SkSVGDOM
(
sk_sp<SkSVGSVG>
,
101
sk_sp<SkFontMgr>
,
102
sk_sp<skresources::ResourceProvider>
,
103
SkSVGIDMapper
&&,
104
sk_sp<SkShapers::Factory>
);
105
106
const
sk_sp<SkSVGSVG>
fRoot;
107
const
sk_sp<SkFontMgr>
fFontMgr;
108
const
sk_sp<SkShapers::Factory>
fTextShapingFactory;
109
const
sk_sp<skresources::ResourceProvider>
fResourceProvider;
110
const
SkSVGIDMapper
fIDMapper;
111
SkSize
fContainerSize;
112
};
113
114
#endif
// SkSVGDOM_DEFINED
SK_API
#define SK_API
Definition:
SkAPI.h:35
SkFontMgr.h
SkRefCnt.h
SkResources.h
SkSVGIDMapper.h
SkShaper_factory.h
SkSize.h
SkTemplates.h
SkCanvas
Definition:
SkCanvas.h:106
SkDOM
Definition:
SkDOM.h:24
SkRefCnt
Definition:
SkRefCnt.h:119
SkSVGDOM::Builder
Definition:
SkSVGDOM.h:28
SkSVGDOM
Definition:
SkSVGDOM.h:26
SkSVGDOM::MakeFromStream
static sk_sp< SkSVGDOM > MakeFromStream(SkStream &str)
Definition:
SkSVGDOM.h:57
SkSVGDOM::getRoot
SkSVGSVG * getRoot() const
Definition:
SkSVGDOM.h:64
SkSVGNode
Definition:
SkSVGNode.h:102
SkSVGSVG
Definition:
SkSVGSVG.h:17
SkStream
Definition:
SkStream.h:29
sk_sp< SkFontMgr >
skia_private::THashMap
Definition:
SkTHash.h:442
flutter::testing::Builder
DlVertices::Builder Builder
Definition:
dl_vertices_unittests.cc:372
scripts.idlrenderer.render
def render(idl_node, indent_str=' ')
Definition:
idlrenderer.py:9
skiagm::make
static void make(SkBitmap *bitmap, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace)
Definition:
encode_srgb.cpp:35
SkSVGPresentationContext
Definition:
SkSVGRenderContext.h:52
SkSize
Definition:
SkSize.h:52
Generated on Sun Jun 23 2024 21:56:07 for Flutter Engine by
1.9.4