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
qsgsoftwarecontext.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
// Qt-Security score:significant reason:default
4
5
#
include
"qsgsoftwarecontext_p.h"
6
7
#
include
"qsgsoftwareinternalrectanglenode_p.h"
8
#
include
"qsgsoftwareinternalimagenode_p.h"
9
#
include
"qsgsoftwarepainternode_p.h"
10
#
include
"qsgsoftwarepixmaptexture_p.h"
11
#
include
"qsgsoftwareglyphnode_p.h"
12
#
include
"qsgsoftwarepublicnodes_p.h"
13
#
include
"qsgsoftwarelayer_p.h"
14
#
include
"qsgsoftwarerenderer_p.h"
15
#
if
QT_CONFIG
(
quick_sprite
)
16
#
include
"qsgsoftwarespritenode_p.h"
17
#
endif
18
19
#
include
<
QtCore
/
QCoreApplication
>
20
#
include
<
QtCore
/
QElapsedTimer
>
21
22
#
include
<
QtGui
/
QWindow
>
23
#
include
<
QtQuick
/
private
/
qquickwindow_p
.
h
>
24
#
include
<
QtQuick
/
private
/
qquickitem_p
.
h
>
25
26
QT_BEGIN_NAMESPACE
27
28
QSGSoftwareRenderContext::QSGSoftwareRenderContext(QSGContext *ctx)
29
: QSGRenderContext(ctx)
30
, m_initialized(
false
)
31
, m_activePainter(
nullptr
)
32
{
33
}
34
35
QSGSoftwareContext::QSGSoftwareContext(QObject *parent)
36
: QSGContext(parent)
37
{
38
}
39
40
QSGInternalRectangleNode *QSGSoftwareContext::createInternalRectangleNode()
41
{
42
return
new
QSGSoftwareInternalRectangleNode();
43
}
44
45
QSGInternalImageNode *QSGSoftwareContext::createInternalImageNode(QSGRenderContext *renderContext)
46
{
47
Q_UNUSED(renderContext);
48
return
new
QSGSoftwareInternalImageNode();
49
}
50
51
QSGPainterNode *QSGSoftwareContext::createPainterNode(QQuickPaintedItem *item)
52
{
53
return
new
QSGSoftwarePainterNode(item);
54
}
55
56
QSGGlyphNode *QSGSoftwareContext::createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType)
57
{
58
Q_UNUSED(rc);
59
Q_UNUSED(renderType);
60
return
new
QSGSoftwareGlyphNode();
61
}
62
63
QSGTextNode::RenderType QSGSoftwareContext::processTextRenderType(QSGTextNode::RenderType renderType)
64
{
65
Q_UNUSED(renderType);
66
return
QSGTextNode::NativeRendering;
67
}
68
69
QSGLayer *QSGSoftwareContext::createLayer(QSGRenderContext *renderContext)
70
{
71
return
new
QSGSoftwareLayer(renderContext);
72
}
73
74
QSurfaceFormat QSGSoftwareContext::defaultSurfaceFormat()
const
75
{
76
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
77
format.setRenderableType(QSurfaceFormat::DefaultRenderableType);
78
format.setMajorVersion(0);
79
format.setMinorVersion(0);
80
if
(QQuickWindow::hasDefaultAlphaBuffer())
81
format.setAlphaBufferSize(8);
82
return
format;
83
}
84
85
void
QSGSoftwareRenderContext::initializeIfNeeded()
86
{
87
if
(m_initialized)
88
return
;
89
m_initialized =
true
;
90
emit initialized();
91
}
92
93
void
QSGSoftwareRenderContext::invalidate()
94
{
95
qDeleteAll(m_texturesToDelete);
96
m_texturesToDelete.clear();
97
98
qDeleteAll(m_textures);
99
m_textures.clear();
100
101
Q_ASSERT(m_fontEnginesToClean.isEmpty());
102
103
qDeleteAll(m_glyphCaches);
104
m_glyphCaches.clear();
105
106
qDeleteAll(m_staleGlyphCaches);
107
m_staleGlyphCaches.clear();
108
109
m_sg->renderContextInvalidated(
this
);
110
emit invalidated();
111
}
112
113
QSGTexture *QSGSoftwareRenderContext::createTexture(
const
QImage &image, uint flags)
const
114
{
115
return
new
QSGSoftwarePixmapTexture(image, flags);
116
}
117
118
QSGRenderer *QSGSoftwareRenderContext::createRenderer(QSGRendererInterface::RenderMode)
119
{
120
return
new
QSGSoftwareRenderer(
this
);
121
}
122
123
124
void
QSGSoftwareRenderContext::renderNextFrame(QSGRenderer *renderer)
125
{
126
renderer->renderScene();
127
}
128
129
int
QSGSoftwareRenderContext::maxTextureSize()
const
130
{
131
return
2048;
132
}
133
134
QSGRendererInterface *QSGSoftwareContext::rendererInterface(QSGRenderContext *renderContext)
135
{
136
Q_UNUSED(renderContext);
137
return
this
;
138
}
139
140
QSGRectangleNode *QSGSoftwareContext::createRectangleNode()
141
{
142
return
new
QSGSoftwareRectangleNode;
143
}
144
145
QSGImageNode *QSGSoftwareContext::createImageNode()
146
{
147
return
new
QSGSoftwareImageNode;
148
}
149
150
QSGNinePatchNode *QSGSoftwareContext::createNinePatchNode()
151
{
152
return
new
QSGSoftwareNinePatchNode;
153
}
154
155
#
if
QT_CONFIG
(
quick_sprite
)
156
QSGSpriteNode *QSGSoftwareContext::createSpriteNode()
157
{
158
return
new
QSGSoftwareSpriteNode;
159
}
160
#
endif
161
162
QSGRendererInterface::GraphicsApi QSGSoftwareContext::graphicsApi()
const
163
{
164
return
Software;
165
}
166
167
QSGRendererInterface::ShaderType QSGSoftwareContext::shaderType()
const
168
{
169
return
UnknownShadingLanguage;
170
}
171
172
QSGRendererInterface::ShaderCompilationTypes QSGSoftwareContext::shaderCompilationType()
const
173
{
174
return
{};
175
}
176
177
QSGRendererInterface::ShaderSourceTypes QSGSoftwareContext::shaderSourceType()
const
178
{
179
return
{};
180
}
181
182
void
*QSGSoftwareContext::getResource(QQuickWindow *window, Resource resource)
const
183
{
184
if
(!window)
185
return
nullptr
;
186
187
auto
cd = QQuickWindowPrivate::get(window);
188
189
if
(resource == PainterResource)
190
return
window->isSceneGraphInitialized() ?
static_cast
<QSGSoftwareRenderContext *>(cd->context)->m_activePainter :
nullptr
;
191
else
if
(resource == RedirectPaintDevice)
192
return
cd->redirect.rt.sw.paintDevice;
193
194
return
nullptr
;
195
}
196
197
QT_END_NAMESPACE
198
199
#
include
"moc_qsgsoftwarecontext_p.cpp"
qtdeclarative
src
quick
scenegraph
adaptations
software
qsgsoftwarecontext.cpp
Generated on
for Qt by
1.18.0