Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsgopenvgcontext.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qsgopenvgcontext_p.h"
5
#
include
"qsgopenvgrenderer_p.h"
6
#
include
"qsgopenvgpublicnodes.h"
7
#
include
"qsgopenvgtexture.h"
8
#
include
"qsgopenvglayer.h"
9
#
include
"qsgopenvgglyphnode_p.h"
10
#
include
"qsgopenvgfontglyphcache.h"
11
#
include
"qsgopenvgpainternode.h"
12
#
if
QT_CONFIG
(
quick_sprite
)
13
#
include
"qsgopenvgspritenode.h"
14
#
endif
15
16
#
include
"qopenvgcontext_p.h"
17
18
#
include
<
private
/
qsgrenderer_p
.
h
>
19
#
include
"qsgopenvginternalrectanglenode.h"
20
#
include
"qsgopenvginternalimagenode.h"
21
22
// polish, animations, sync, render and swap in the render loop
23
Q_LOGGING_CATEGORY
(QSG_OPENVG_LOG_TIME_RENDERLOOP,
"qt.scenegraph.time.renderloop"
)
24
25
QT_BEGIN_NAMESPACE
26
27
QSGOpenVGRenderContext::QSGOpenVGRenderContext(QSGContext *context)
28
: QSGRenderContext(context)
29
, m_vgContext(
nullptr
)
30
, m_glyphCacheManager(
nullptr
)
31
{
32
33
}
34
35
void
QSGOpenVGRenderContext
::
initialize
(
const
QSGRenderContext::InitParams *params)
36
{
37
const
InitParams
*vgparams =
static_cast
<
const
InitParams
*>(params);
38
if
(vgparams
->
sType
!=
INIT_PARAMS_MAGIC
)
39
qFatal(
"Invalid OpenVG render context parameters"
);
40
41
m_vgContext = vgparams->context;
42
QSGRenderContext::initialize(params);
43
emit initialized();
44
}
45
46
void
QSGOpenVGRenderContext
::
invalidate
()
47
{
48
m_vgContext =
nullptr
;
49
delete
m_glyphCacheManager;
50
m_glyphCacheManager =
nullptr
;
51
QSGRenderContext::invalidate();
52
emit invalidated();
53
}
54
55
void
QSGOpenVGRenderContext
::
renderNextFrame
(QSGRenderer *renderer)
56
{
57
renderer->renderScene();
58
}
59
60
QSGTexture
*
QSGOpenVGRenderContext
::
createTexture
(
const
QImage &image, uint flags)
const
61
{
62
QImage tmp = image;
63
64
// Make sure image is not larger than maxTextureSize
65
int
maxSize =
maxTextureSize
(
)
;
66
if
(tmp.width() > maxSize || tmp.height() > maxSize) {
67
tmp = tmp.scaled(qMin(maxSize, tmp.width()), qMin(maxSize, tmp.height()), Qt::IgnoreAspectRatio, Qt::FastTransformation);
68
}
69
70
return
new
QSGOpenVGTexture
(tmp, flags);
71
}
72
73
QSGRenderer
*
QSGOpenVGRenderContext
::
createRenderer
(
QSGRendererInterface
::
RenderMode
)
74
{
75
return
new
QSGOpenVGRenderer(
this
);
76
}
77
78
QSGOpenVGContext
::QSGOpenVGContext(QObject *parent)
79
{
80
Q_UNUSED(parent);
81
}
82
83
QSGRenderContext *
QSGOpenVGContext
::
createRenderContext
()
84
{
85
return
new
QSGOpenVGRenderContext(
this
);
86
}
87
88
QSGRectangleNode
*
QSGOpenVGContext
::
createRectangleNode
()
89
{
90
return
new
QSGOpenVGRectangleNode
;
91
}
92
93
QSGImageNode
*
QSGOpenVGContext
::
createImageNode
()
94
{
95
return
new
QSGOpenVGImageNode
;
96
}
97
98
QSGPainterNode
*
QSGOpenVGContext
::
createPainterNode
(QQuickPaintedItem *item)
99
{
100
Q_UNUSED(item);
101
return
new
QSGOpenVGPainterNode
(item);
102
}
103
104
QSGGlyphNode *
QSGOpenVGContext
::createGlyphNode(QSGRenderContext *rc,
bool
preferNativeGlyphNode,
int
renderTypeQuality)
105
{
106
Q_UNUSED(preferNativeGlyphNode);
107
Q_UNUSED(renderTypeQuality);
108
return
new
QSGOpenVGGlyphNode
(
rc
)
;
109
}
110
111
QSGNinePatchNode
*
QSGOpenVGContext
::
createNinePatchNode
()
112
{
113
return
new
QSGOpenVGNinePatchNode
;
114
}
115
116
QSGLayer *
QSGOpenVGContext
::createLayer(QSGRenderContext *renderContext)
117
{
118
return
new
QSGOpenVGLayer(renderContext);
119
}
120
121
QSurfaceFormat
QSGOpenVGContext
::
defaultSurfaceFormat
()
const
122
{
123
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
124
format.setRenderableType(QSurfaceFormat::OpenVG);
125
format.setMajorVersion(1);
126
return
format;
127
}
128
129
QSGInternalRectangleNode
*
QSGOpenVGContext
::
createInternalRectangleNode
()
130
{
131
return
new
QSGOpenVGInternalRectangleNode
(
)
;
132
}
133
134
QSGInternalImageNode *
QSGOpenVGContext
::createInternalImageNode(QSGRenderContext *)
135
{
136
return
new
QSGOpenVGInternalImageNode
(
)
;
137
}
138
139
int
QSGOpenVGRenderContext
::
maxTextureSize
()
const
140
{
141
VGint width = vgGeti(VG_MAX_IMAGE_WIDTH);
142
VGint height = vgGeti(VG_MAX_IMAGE_HEIGHT);
143
144
return
qMin(width, height);
145
}
146
147
#
if
QT_CONFIG
(
quick_sprite
)
148
QSGSpriteNode *QSGOpenVGContext::createSpriteNode()
149
{
150
return
new
QSGOpenVGSpriteNode();
151
}
152
#
endif
153
154
QSGRendererInterface *
QSGOpenVGContext
::rendererInterface(QSGRenderContext *renderContext)
155
{
156
return
static_cast
<QSGOpenVGRenderContext *>(renderContext);
157
}
158
159
QSGRendererInterface
::
GraphicsApi
QSGOpenVGRenderContext
::
graphicsApi
()
const
160
{
161
return
OpenVG;
162
}
163
164
QSGRendererInterface
::
ShaderType
QSGOpenVGRenderContext
::
shaderType
()
const
165
{
166
return
UnknownShadingLanguage;
167
}
168
169
QSGRendererInterface
::
ShaderCompilationTypes
QSGOpenVGRenderContext
::
shaderCompilationType
()
const
170
{
171
return
0;
172
}
173
174
QSGRendererInterface
::
ShaderSourceTypes
QSGOpenVGRenderContext
::
shaderSourceType
()
const
175
{
176
return
0;
177
}
178
179
QSGOpenVGFontGlyphCache
*
QSGOpenVGRenderContext
::
glyphCache
(
const
QRawFont &rawFont)
180
{
181
if
(!m_glyphCacheManager)
182
m_glyphCacheManager =
new
QSGOpenVGFontGlyphCacheManager
;
183
184
QSGOpenVGFontGlyphCache
*cache = m_glyphCacheManager->cache(rawFont);
185
if
(!cache) {
186
cache =
new
QSGOpenVGFontGlyphCache
(m_glyphCacheManager, rawFont);
187
m_glyphCacheManager->insertCache(rawFont, cache);
188
}
189
190
return
cache;
191
}
192
193
QT_END_NAMESPACE
QSGOpenVGContext
Definition
qsgopenvgcontext_p.h:53
QSGOpenVGContext::defaultSurfaceFormat
QSurfaceFormat defaultSurfaceFormat() const override
Definition
qsgopenvgcontext.cpp:121
QSGOpenVGContext::createNinePatchNode
QSGNinePatchNode * createNinePatchNode() override
Definition
qsgopenvgcontext.cpp:111
QSGOpenVGContext::createRenderContext
QSGRenderContext * createRenderContext() override
Definition
qsgopenvgcontext.cpp:83
QSGOpenVGContext::createImageNode
QSGImageNode * createImageNode() override
Definition
qsgopenvgcontext.cpp:93
QSGOpenVGContext::createInternalRectangleNode
QSGInternalRectangleNode * createInternalRectangleNode() override
Definition
qsgopenvgcontext.cpp:129
QSGOpenVGContext::createRectangleNode
QSGRectangleNode * createRectangleNode() override
Definition
qsgopenvgcontext.cpp:88
QSGOpenVGContext::createPainterNode
QSGPainterNode * createPainterNode(QQuickPaintedItem *item) override
Definition
qsgopenvgcontext.cpp:98
QSGOpenVGFontGlyphCacheManager
Definition
qsgopenvgfontglyphcache.h:16
QSGOpenVGFontGlyphCache
Definition
qsgopenvgfontglyphcache.h:29
QSGOpenVGGlyphNode
Definition
qsgopenvgglyphnode_p.h:22
QSGOpenVGGlyphNode::QSGOpenVGGlyphNode
QSGOpenVGGlyphNode(QSGRenderContext *rc)
Definition
qsgopenvgglyphnode.cpp:14
QSGOpenVGImageNode
Definition
qsgopenvgpublicnodes.h:41
QSGOpenVGInternalImageNode
Definition
qsgopenvginternalimagenode.h:15
QSGOpenVGInternalImageNode::QSGOpenVGInternalImageNode
QSGOpenVGInternalImageNode()
Definition
qsgopenvginternalimagenode.cpp:11
QSGOpenVGInternalRectangleNode
Definition
qsgopenvginternalrectanglenode.h:16
QSGOpenVGInternalRectangleNode::QSGOpenVGInternalRectangleNode
QSGOpenVGInternalRectangleNode()
Definition
qsgopenvginternalrectanglenode.cpp:9
QSGOpenVGNinePatchNode
Definition
qsgopenvgpublicnodes.h:82
QSGOpenVGPainterNode
Definition
qsgopenvgpainternode.h:16
QSGOpenVGRectangleNode
Definition
qsgopenvgpublicnodes.h:13
QSGOpenVGRenderContext
Definition
qsgopenvgcontext_p.h:19
QSGOpenVGRenderContext::shaderSourceType
ShaderSourceTypes shaderSourceType() const override
Definition
qsgopenvgcontext.cpp:174
QSGOpenVGRenderContext::renderNextFrame
void renderNextFrame(QSGRenderer *renderer) override
Definition
qsgopenvgcontext.cpp:55
QSGOpenVGRenderContext::maxTextureSize
int maxTextureSize() const override
Definition
qsgopenvgcontext.cpp:139
QSGOpenVGRenderContext::INIT_PARAMS_MAGIC
static const int INIT_PARAMS_MAGIC
Definition
qsgopenvgcontext_p.h:24
QSGOpenVGRenderContext::shaderType
ShaderType shaderType() const override
Definition
qsgopenvgcontext.cpp:164
QSGOpenVGRenderContext::graphicsApi
GraphicsApi graphicsApi() const override
Returns the graphics API that is in use by the Qt Quick scenegraph.
Definition
qsgopenvgcontext.cpp:159
QSGOpenVGRenderContext::initialize
void initialize(const QSGRenderContext::InitParams *params) override
Definition
qsgopenvgcontext.cpp:35
QSGOpenVGRenderContext::invalidate
void invalidate() override
Definition
qsgopenvgcontext.cpp:46
QSGOpenVGRenderContext::shaderCompilationType
ShaderCompilationTypes shaderCompilationType() const override
Definition
qsgopenvgcontext.cpp:169
QSGOpenVGRenderContext::createRenderer
QSGRenderer * createRenderer(QSGRendererInterface::RenderMode renderMode=QSGRendererInterface::RenderMode2D) override
Definition
qsgopenvgcontext.cpp:73
QSGOpenVGRenderContext::createTexture
QSGTexture * createTexture(const QImage &image, uint flags) const override
Definition
qsgopenvgcontext.cpp:60
QSGOpenVGRenderContext::glyphCache
QSGOpenVGFontGlyphCache * glyphCache(const QRawFont &rawFont)
Definition
qsgopenvgcontext.cpp:179
QSGOpenVGTexture
Definition
qsgopenvgtexture.h:14
Q_LOGGING_CATEGORY
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
QSGOpenVGRenderContext::InitParams
Definition
qsgopenvgcontext_p.h:25
QSGOpenVGRenderContext::InitParams::sType
int sType
Definition
qsgopenvgcontext_p.h:26
qtdeclarative
src
plugins
scenegraph
openvg
qsgopenvgcontext.cpp
Generated on
for Qt by
1.18.0