OpenCoverage

qquickgraphicsinfo.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickgraphicsinfo.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickgraphicsinfo_p.h"-
41#include "qquickwindow.h"-
42#include "qquickitem.h"-
43#include <QtGui/qopenglcontext.h>-
44-
45QT_BEGIN_NAMESPACE-
46-
47/*!-
48 \qmltype GraphicsInfo-
49 \instantiates QQuickGraphicsInfo-
50 \inqmlmodule QtQuick-
51 \ingroup qtquick-visual-
52 \since 5.8-
53 \since QtQuick 2.8-
54 \brief Provides information about the used Qt Quick backend.-
55-
56 The GraphicsInfo attached type provides information about the scenegraph-
57 backend used to render the contents of the associated window.-
58-
59 If the item to which the properties are attached is not currently-
60 associated with any window, the properties are set to default values. When-
61 the associated window changes, the properties will update.-
62 */-
63-
64QQuickGraphicsInfo::QQuickGraphicsInfo(QQuickItem *item)-
65 : QObject(item)-
66 , m_window(nullptr)-
67 , m_api(Unknown)-
68 , m_shaderType(UnknownShadingLanguage)-
69 , m_shaderCompilationType(ShaderCompilationType(0))-
70 , m_shaderSourceType(ShaderSourceType(0))-
71 , m_majorVersion(2)-
72 , m_minorVersion(0)-
73 , m_profile(OpenGLNoProfile)-
74 , m_renderableType(SurfaceFormatUnspecified)-
75{-
76 connect(item, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(setWindow(QQuickWindow*)));-
77 setWindow(item->window());-
78}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
2
79-
80QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)-
81{-
82 if (QQuickItem *item = qobject_cast<QQuickItem *>(object))
QQuickItem *it...tem *>(object)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEnever evaluated
0-2
83 return new QQuickGraphicsInfo(item);
executed 2 times by 1 test: return new QQuickGraphicsInfo(item);
Executed by:
  • tst_qquickgraphicsinfo
2
84-
85 return nullptr;
never executed: return nullptr;
0
86}-
87-
88/*!-
89 \qmlproperty enumeration QtQuick::GraphicsInfo::api-
90-
91 This property describes the graphics API that is currently in use.-
92-
93 The possible values are:-
94 \list-
95 \li GraphicsInfo.Unknown - the default value when no active scenegraph is associated with the item-
96 \li GraphicsInfo.Software - Qt Quick's software renderer based on QPainter with the raster paint engine-
97 \li GraphicsInfo.OpenGL - OpenGL or OpenGL ES-
98 \li GraphicsInfo.Direct3D12 - Direct3D 12-
99 \endlist-
100 */-
101-
102/*!-
103 \qmlproperty enumeration QtQuick::GraphicsInfo::shaderType-
104-
105 This property contains the shading language supported by the Qt Quick-
106 backend the application is using.-
107-
108 \list-
109 \li GraphicsInfo.UnknownShadingLanguage - Not yet known due to no window and scenegraph associated-
110 \li GraphicsInfo.GLSL - GLSL or GLSL ES-
111 \li GraphicsInfo.HLSL - HLSL-
112 \endlist-
113-
114 \note The value is only up-to-date once the item is associated with a-
115 window. Bindings relying on the value have to keep this in mind since the-
116 value may change from GraphicsInfo.UnknownShadingLanguage to the actual-
117 value after component initialization is complete. This is particularly-
118 relevant for ShaderEffect items inside ShaderEffectSource items set as-
119 property values.-
120-
121 \since 5.8-
122 \since QtQuick 2.8-
123-
124 \sa shaderCompilationType, shaderSourceType-
125*/-
126-
127/*!-
128 \qmlproperty enumeration QtQuick::GraphicsInfo::shaderCompilationType-
129-
130 This property contains a bitmask of the shader compilation approaches-
131 supported by the Qt Quick backend the application is using.-
132-
133 \list-
134 \li GraphicsInfo.RuntimeCompilation-
135 \li GraphicsInfo.OfflineCompilation-
136 \endlist-
137-
138 With OpenGL the value is GraphicsInfo.RuntimeCompilation, which corresponds-
139 to the traditional way of using ShaderEffect. Non-OpenGL backends are-
140 expected to focus more on GraphicsInfo.OfflineCompilation, however.-
141-
142 \note The value is only up-to-date once the item is associated with a-
143 window. Bindings relying on the value have to keep this in mind since the-
144 value may change from \c 0 to the actual bitmask after component-
145 initialization is complete. This is particularly relevant for ShaderEffect-
146 items inside ShaderEffectSource items set as property values.-
147-
148 \since 5.8-
149 \since QtQuick 2.8-
150-
151 \sa shaderType, shaderSourceType-
152*/-
153-
154/*!-
155 \qmlproperty enumeration QtQuick::GraphicsInfo::shaderSourceType-
156-
157 This property contains a bitmask of the supported ways of providing shader-
158 sources.-
159-
160 \list-
161 \li GraphicsInfo.ShaderSourceString-
162 \li GraphicsInfo.ShaderSourceFile-
163 \li GraphicsInfo.ShaderByteCode-
164 \endlist-
165-
166 With OpenGL the value is GraphicsInfo.ShaderSourceString, which corresponds-
167 to the traditional way of inlining GLSL source code into QML. Other,-
168 non-OpenGL Qt Quick backends may however decide not to support inlined-
169 shader sources, or even shader sources at all. In this case shaders are-
170 expected to be pre-compiled into formats like SPIR-V or D3D shader-
171 bytecode.-
172-
173 \note The value is only up-to-date once the item is associated with a-
174 window. Bindings relying on the value have to keep this in mind since the-
175 value may change from \c 0 to the actual bitmask after component-
176 initialization is complete. This is particularly relevant for ShaderEffect-
177 items inside ShaderEffectSource items set as property values.-
178-
179 \since 5.8-
180 \since QtQuick 2.8-
181-
182 \sa shaderType, shaderCompilationType-
183*/-
184-
185/*!-
186 \qmlproperty int QtQuick::GraphicsInfo::majorVersion-
187-
188 This property holds the major version of the graphics API in use.-
189-
190 With OpenGL the default version is \c 2.0.-
191-
192 \sa minorVersion, profile-
193 */-
194-
195/*!-
196 \qmlproperty int QtQuick::GraphicsInfo::minorVersion-
197-
198 This property holds the minor version of the graphics API in use.-
199-
200 With OpenGL the default version is \c 2.0.-
201-
202 \sa majorVersion, profile-
203 */-
204-
205/*!-
206 \qmlproperty enumeration QtQuick::GraphicsInfo::profile-
207-
208 This property holds the configured OpenGL context profile.-
209-
210 The possible values are:-
211 \list-
212 \li GraphicsInfo.OpenGLNoProfile (default) - OpenGL version is lower than 3.2 or OpenGL is not in use.-
213 \li GraphicsInfo.OpenGLCoreProfile - Functionality deprecated in OpenGL version 3.0 is not available.-
214 \li GraphicsInfo.OpenGLCompatibilityProfile - Functionality from earlier OpenGL versions is available.-
215 \endlist-
216-
217 Reusable QML components will typically use this property in bindings in order to-
218 choose between core and non core profile compatible shader sources.-
219-
220 \sa majorVersion, minorVersion, QSurfaceFormat-
221 */-
222-
223/*!-
224 \qmlproperty enumeration QtQuick::GraphicsInfo::renderableType-
225-
226 This property holds the renderable type. The value has no meaning for APIs-
227 other than OpenGL.-
228-
229 The possible values are:-
230 \list-
231 \li GraphicsInfo.SurfaceFormatUnspecified (default) - Unspecified rendering method-
232 \li GraphicsInfo.SurfaceFormatOpenGL - Desktop OpenGL or other graphics API-
233 \li GraphicsInfo.SurfaceFormatOpenGLES - OpenGL ES-
234 \endlist-
235-
236 \sa QSurfaceFormat-
237 */-
238-
239void QQuickGraphicsInfo::updateInfo()-
240{-
241 // The queries via the RIF do not depend on isSceneGraphInitialized(), they only need a window.-
242 if (m_window) {
m_windowDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
2-4
243 QSGRendererInterface *rif = m_window->rendererInterface();-
244 if (rif) {
rifDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEnever evaluated
0-2
245 GraphicsApi newAPI = GraphicsApi(rif->graphicsApi());-
246 if (m_api != newAPI) {
m_api != newAPIDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEnever evaluated
0-2
247 m_api = newAPI;-
248 emit apiChanged();-
249 m_shaderType = ShaderType(rif->shaderType());-
250 emit shaderTypeChanged();-
251 m_shaderCompilationType = ShaderCompilationType(int(rif->shaderCompilationType()));-
252 emit shaderCompilationTypeChanged();-
253 m_shaderSourceType = ShaderSourceType(int(rif->shaderSourceType()));-
254 emit shaderSourceTypeChanged();-
255 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
2
256 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
2
257 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
2
258-
259 QSurfaceFormat format = QSurfaceFormat::defaultFormat();-
260#if QT_CONFIG(opengl)-
261 if (m_window && m_window->isSceneGraphInitialized()) {
m_window->isSc...hInitialized()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
0-2
262 QOpenGLContext *context = m_window->openglContext();-
263 if (context)
contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
264 format = context->format();
never executed: format = context->format();
0
265 }
never executed: end of block
0
266#endif-
267 if (m_majorVersion != format.majorVersion()) {
m_majorVersion...majorVersion()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
0-6
268 m_majorVersion = format.majorVersion();-
269 emit majorVersionChanged();-
270 }
never executed: end of block
0
271 if (m_minorVersion != format.minorVersion()) {
m_minorVersion...minorVersion()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
0-6
272 m_minorVersion = format.minorVersion();-
273 emit minorVersionChanged();-
274 }
never executed: end of block
0
275 OpenGLContextProfile profile = static_cast<OpenGLContextProfile>(format.profile());-
276 if (m_profile != profile) {
m_profile != profileDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
0-6
277 m_profile = profile;-
278 emit profileChanged();-
279 }
never executed: end of block
0
280 RenderableType renderableType = static_cast<RenderableType>(format.renderableType());-
281 if (m_renderableType != renderableType) {
m_renderableTy...renderableTypeDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
0-6
282 m_renderableType = renderableType;-
283 emit renderableTypeChanged();-
284 }
never executed: end of block
0
285}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
6
286-
287void QQuickGraphicsInfo::setWindow(QQuickWindow *window)-
288{-
289 if (m_window != window) {
m_window != windowDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
2-4
290 if (m_window) {
m_windowDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
2
291 disconnect(m_window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));-
292 disconnect(m_window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));-
293 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
2
294 if (window) {
windowDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickgraphicsinfo
2
295 connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));-
296 connect(window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));-
297 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
2
298 m_window = window;-
299 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
4
300 updateInfo();-
301}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickgraphicsinfo
6
302-
303QT_END_NAMESPACE-
304-
305#include "moc_qquickgraphicsinfo_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0