OpenCoverage

qsgcontext.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/qsgcontext.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 <QtQuick/private/qsgcontext_p.h>-
41#include <QtQuick/private/qsgtexture_p.h>-
42#include <QtQuick/private/qquickpixmapcache_p.h>-
43#include <QtQuick/private/qsgadaptationlayer_p.h>-
44-
45#include <QGuiApplication>-
46#include <QScreen>-
47#include <QQuickWindow>-
48-
49#include <private/qqmlglobal_p.h>-
50-
51#include <QtQuick/private/qsgtexture_p.h>-
52#include <QtGui/private/qguiapplication_p.h>-
53#include <QtCore/private/qabstractanimation_p.h>-
54-
55#include <private/qobject_p.h>-
56#include <qmutex.h>-
57-
58/*-
59 Comments about this class from Gunnar:-
60-
61 The QSGContext class is right now two things.. The first is the-
62 adaptation layer and central storage ground for all the things-
63 in the scene graph, like textures and materials. This part really-
64 belongs inside the scene graph coreapi.-
65-
66 The other part is the QML adaptation classes, like how to implement-
67 rectangle nodes. This is not part of the scene graph core API, but-
68 more part of the QML adaptation of scene graph.-
69-
70 If we ever move the scene graph core API into its own thing, this class-
71 needs to be split in two. Right now its one because we're lazy when it comes-
72 to defining plugin interfaces..-
73*/-
74-
75QT_BEGIN_NAMESPACE-
76-
77// Used for very high-level info about the renderering and gl context-
78// Includes GL_VERSION, type of render loop, atlas size, etc.-
79Q_LOGGING_CATEGORY(QSG_LOG_INFO, "qt.scenegraph.general")
executed 6642 times by 91 tests: return category;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
6642
80-
81// Used to debug the renderloop logic. Primarily useful for platform integrators-
82// and when investigating the render loop logic.-
83Q_LOGGING_CATEGORY(QSG_LOG_RENDERLOOP, "qt.scenegraph.renderloop")
executed 1707 times by 38 tests: return category;
Executed by:
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdroparea
  • tst_qquickdynamicpropertyanimation
  • tst_qquickflipable
  • tst_qquickfocusscope
  • tst_qquickgraphicsinfo
  • tst_qquickgridview
  • tst_qquickimage
  • tst_qquickitem
  • tst_qquickitemlayer
  • tst_qquicklistview
  • tst_qquickmousearea
  • tst_qquickopenglinfo
  • tst_qquickparticlesystem
  • ...
1707
84-
85-
86// GLSL shader compilation-
87Q_LOGGING_CATEGORY(QSG_LOG_TIME_COMPILATION, "qt.scenegraph.time.compilation")
executed 9008 times by 70 tests: return category;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
9008
88-
89// polish, animations, sync, render and swap in the render loop-
90Q_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERLOOP, "qt.scenegraph.time.renderloop")
executed 100522 times by 74 tests: return category;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
100522
91-
92// Texture uploads and swizzling-
93Q_LOGGING_CATEGORY(QSG_LOG_TIME_TEXTURE, "qt.scenegraph.time.texture")
executed 813 times by 33 tests: return category;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickpainteditem
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickshadereffect
  • ...
813
94-
95// Glyph preparation (only for distance fields atm)-
96Q_LOGGING_CATEGORY(QSG_LOG_TIME_GLYPH, "qt.scenegraph.time.glyph")
executed 4686 times by 24 tests: return category;
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_qquickdraghandler
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickmousearea
  • tst_qquickpathview
  • tst_qquickpincharea
  • tst_qquickpositioners
  • tst_qquickrepeater
  • tst_qquickspringanimation
  • tst_qquicktaphandler
  • tst_qquicktext
  • tst_qquicktextedit
  • tst_qquicktextinput
  • tst_scenegraph
  • tst_touchmouse
4686
97-
98// Timing inside the renderer base class-
99Q_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERER, "qt.scenegraph.time.renderer")
executed 152142 times by 77 tests: return category;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • ...
152142
100-
101bool qsg_useConsistentTiming()-
102{-
103 int use = -1;-
104 if (use < 0) {
use < 0Description
TRUEevaluated 196 times by 89 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
FALSEnever evaluated
0-196
105 use = !qEnvironmentVariableIsEmpty("QSG_FIXED_ANIMATION_STEP") && qgetenv("QSG_FIXED_ANIMATION_STEP") != "no"
!qEnvironmentV...IMATION_STEP")Description
TRUEnever evaluated
FALSEevaluated 196 times by 89 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
qgetenv("QSG_F...STEP") != "no"Description
TRUEnever evaluated
FALSEnever evaluated
0-196
106 ? 1 : 0;-
107 qCDebug(QSG_LOG_INFO, "Using %s", bool(use) ? "fixed animation steps" : "sg animation driver");
never executed: QMessageLogger(__FILE__, 107, __PRETTY_FUNCTION__, QSG_LOG_INFO().categoryName()).debug("Using %s", bool(use) ? "fixed animation steps" : "sg animation driver");
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 196 times by 89 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
0-196
108 }
executed 196 times by 89 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
196
109 return bool(use);
executed 196 times by 89 tests: return bool(use);
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
196
110}-
111-
112class QSGAnimationDriver : public QAnimationDriver-
113{-
114 Q_OBJECT-
115public:-
116 enum Mode {-
117 VSyncMode,-
118 TimerMode-
119 };-
120-
121 QSGAnimationDriver(QObject *parent)-
122 : QAnimationDriver(parent)-
123 , m_time(0)-
124 , m_vsync(0)-
125 , m_mode(VSyncMode)-
126 , m_lag(0)-
127 , m_bad(0)-
128 , m_good(0)-
129 {-
130 QScreen *screen = QGuiApplication::primaryScreen();-
131 if (screen && !qsg_useConsistentTiming()) {
screenDescription
TRUEnever evaluated
FALSEnever evaluated
!qsg_useConsistentTiming()Description
TRUEnever evaluated
FALSEnever evaluated
0
132 m_vsync = 1000.0 / screen->refreshRate();-
133 if (m_vsync <= 0)
m_vsync <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
134 m_mode = TimerMode;
never executed: m_mode = TimerMode;
0
135 } else {
never executed: end of block
0
136 m_mode = TimerMode;-
137 if (qsg_useConsistentTiming())
qsg_useConsistentTiming()Description
TRUEnever evaluated
FALSEnever evaluated
0
138 QUnifiedTimer::instance(true)->setConsistentTiming(true);
never executed: QUnifiedTimer::instance(true)->setConsistentTiming(true);
0
139 }
never executed: end of block
0
140 if (m_mode == VSyncMode)
m_mode == VSyncModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
141 qCDebug(QSG_LOG_INFO, "Animation Driver: using vsync: %.2f ms", m_vsync);
never executed: QMessageLogger(__FILE__, 141, __PRETTY_FUNCTION__, QSG_LOG_INFO().categoryName()).debug("Animation Driver: using vsync: %.2f ms", m_vsync);
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
142 else-
143 qCDebug(QSG_LOG_INFO, "Animation Driver: using walltime");
never executed: QMessageLogger(__FILE__, 143, __PRETTY_FUNCTION__, QSG_LOG_INFO().categoryName()).debug("Animation Driver: using walltime");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
144 }
never executed: end of block
0
145-
146 void start() override-
147 {-
148 m_time = 0;-
149 m_timer.start();-
150 m_wallTime.restart();-
151 QAnimationDriver::start();-
152 }
never executed: end of block
0
153-
154 qint64 elapsed() const override-
155 {-
156 return m_mode == VSyncMode
never executed: return m_mode == VSyncMode ? qint64(m_time) : qint64(m_time) + m_wallTime.elapsed();
0
157 ? qint64(m_time)
never executed: return m_mode == VSyncMode ? qint64(m_time) : qint64(m_time) + m_wallTime.elapsed();
0
158 : qint64(m_time) + m_wallTime.elapsed();
never executed: return m_mode == VSyncMode ? qint64(m_time) : qint64(m_time) + m_wallTime.elapsed();
0
159 }-
160-
161 void advance() override-
162 {-
163 qint64 delta = m_timer.restart();-
164-
165 if (m_mode == VSyncMode) {
m_mode == VSyncModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
166 // If a frame is skipped, either because rendering was slow or because-
167 // the QML was slow, we accept it and continue advancing with a single-
168 // vsync tick. The reason for this is that by the time we notice this-
169 // on the GUI thread, the temporal distortion has already gone to screen-
170 // and by catching up, we will introduce a second distortion which will-
171 // worse. We accept that the animation time falls behind wall time because-
172 // it comes out looking better.-
173 // Only when multiple bad frames are hit in a row, do we consider-
174 // switching. A few really bad frames and we switch right away. For frames-
175 // just above the vsync delta, we tolerate a bit more since a buffered-
176 // driver can have vsync deltas on the form: 4, 21, 21, 2, 23, 16, and-
177 // still manage to put the frames to screen at 16 ms intervals. In addition-
178 // to that, we tolerate a 25% margin of error on the value of m_vsync-
179 // reported from the system as this value is often not precise.-
180-
181 m_time += m_vsync;-
182-
183 if (delta > m_vsync * 1.25) {
delta > m_vsync * 1.25Description
TRUEnever evaluated
FALSEnever evaluated
0
184 m_lag += (delta / m_vsync);-
185 m_bad++;-
186 // We tolerate one bad frame without resorting to timer based. This is-
187 // done to cope with a slow loader frame followed by smooth animation.-
188 // However, on the second frame with massive lag, we switch.-
189 if (m_lag > 10 && m_bad > 2) {
m_lag > 10Description
TRUEnever evaluated
FALSEnever evaluated
m_bad > 2Description
TRUEnever evaluated
FALSEnever evaluated
0
190 m_mode = TimerMode;-
191 qCDebug(QSG_LOG_INFO, "animation driver switched to timer mode");
never executed: QMessageLogger(__FILE__, 191, __PRETTY_FUNCTION__, QSG_LOG_INFO().categoryName()).debug("animation driver switched to timer mode");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
192 m_wallTime.restart();-
193 }
never executed: end of block
0
194 } else {
never executed: end of block
0
195 m_lag = 0;-
196 m_bad = 0;-
197 }
never executed: end of block
0
198-
199 } else {-
200 if (delta < 1.25 * m_vsync) {
delta < 1.25 * m_vsyncDescription
TRUEnever evaluated
FALSEnever evaluated
0
201 ++m_good;-
202 } else {
never executed: end of block
0
203 m_good = 0;-
204 }
never executed: end of block
0
205-
206 // We've been solid for a while, switch back to vsync mode. Tolerance-
207 // for switching back is lower than switching to timer mode, as we-
208 // want to stay in vsync mode as much as possible.-
209 if (m_good > 10 && !qsg_useConsistentTiming()) {
m_good > 10Description
TRUEnever evaluated
FALSEnever evaluated
!qsg_useConsistentTiming()Description
TRUEnever evaluated
FALSEnever evaluated
0
210 m_time = elapsed();-
211 m_mode = VSyncMode;-
212 m_bad = 0;-
213 m_lag = 0;-
214 qCDebug(QSG_LOG_INFO, "animation driver switched to vsync mode");
never executed: QMessageLogger(__FILE__, 214, __PRETTY_FUNCTION__, QSG_LOG_INFO().categoryName()).debug("animation driver switched to vsync mode");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
215 }
never executed: end of block
0
216 }
never executed: end of block
0
217-
218 advanceAnimation();-
219 }
never executed: end of block
0
220-
221 double m_time;-
222 double m_vsync;-
223 Mode m_mode;-
224 QElapsedTimer m_timer;-
225 QElapsedTimer m_wallTime;-
226 double m_lag;-
227 int m_bad;-
228 int m_good;-
229};-
230-
231/*!-
232 \class QSGContext-
233-
234 \brief The QSGContext holds the scene graph entry points for one QML engine.-
235-
236 The context is not ready for use until it has a QOpenGLContext. Once that happens,-
237 the scene graph population can start.-
238-
239 \internal-
240 */-
241-
242QSGContext::QSGContext(QObject *parent) :-
243 QObject(parent)-
244{-
245}
executed 202 times by 91 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
202
246-
247QSGContext::~QSGContext()-
248{-
249}-
250-
251void QSGContext::renderContextInitialized(QSGRenderContext *)-
252{-
253}-
254-
255void QSGContext::renderContextInvalidated(QSGRenderContext *)-
256{-
257}-
258-
259-
260/*!-
261 Convenience factory function for creating a colored rectangle with the given geometry.-
262 */-
263QSGInternalRectangleNode *QSGContext::createInternalRectangleNode(const QRectF &rect, const QColor &c)-
264{-
265 QSGInternalRectangleNode *node = createInternalRectangleNode();-
266 node->setRect(rect);-
267 node->setColor(c);-
268 node->update();-
269 return node;
executed 304 times by 7 tests: return node;
Executed by:
  • tst_examples
  • tst_qquickfocusscope
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquicktext
  • tst_qquicktextedit
  • tst_qquicktextinput
304
270}-
271-
272/*!-
273 Creates a new shader effect helper instance. This function is called on the-
274 gui thread, unlike the others. This is necessary in order to provide-
275 adaptable, backend-specific shader effect functionality to the gui thread too.-
276 */-
277QSGGuiThreadShaderEffectManager *QSGContext::createGuiThreadShaderEffectManager()-
278{-
279 return nullptr;
never executed: return nullptr;
0
280}-
281-
282/*!-
283 Creates a new shader effect node. The default of returning nullptr is-
284 valid as long as the backend does not claim SupportsShaderEffectNode or-
285 ignoring ShaderEffect elements is acceptable.-
286 */-
287QSGShaderEffectNode *QSGContext::createShaderEffectNode(QSGRenderContext *, QSGGuiThreadShaderEffectManager *)-
288{-
289 return nullptr;
never executed: return nullptr;
0
290}-
291-
292/*!-
293 Creates a new animation driver.-
294 */-
295QAnimationDriver *QSGContext::createAnimationDriver(QObject *parent)-
296{-
297 return new QSGAnimationDriver(parent);
never executed: return new QSGAnimationDriver(parent);
0
298}-
299-
300QSize QSGContext::minimumFBOSize() const-
301{-
302 return QSize(1, 1);
executed 235 times by 8 tests: return QSize(1, 1);
Executed by:
  • tst_examples
  • tst_qquickcustomparticle
  • tst_qquickframebufferobject
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquickpainteditem
  • tst_qquickshadereffect
  • tst_qquicktext
235
303}-
304-
305/*!-
306 Returns a pointer to the (presumably) global renderer interface.-
307-
308 \note This function may be called on the gui thread in order to get access-
309 to QSGRendererInterface::graphicsApi() and other getters.-
310-
311 \note it is expected that the simple queries (graphicsApi, shaderType,-
312 etc.) are available regardless of the render context validity (i.e.-
313 scenegraph status). This does not apply to engine-specific getters like-
314 getResource(). In the end this means that this function must always return-
315 a valid object in subclasses, even when renderContext->isValid() is false.-
316 The typical pattern is to implement the QSGRendererInterface in the-
317 QSGContext or QSGRenderContext subclass itself, whichever is more suitable.-
318 */-
319QSGRendererInterface *QSGContext::rendererInterface(QSGRenderContext *renderContext)-
320{-
321 Q_UNUSED(renderContext);-
322 qWarning("QSGRendererInterface not implemented");-
323 return nullptr;
never executed: return nullptr;
0
324}-
325-
326QSGRenderContext::QSGRenderContext(QSGContext *context)-
327 : m_sg(context)-
328{-
329}
executed 316 times by 91 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_nodestest
  • tst_qqmlcomponent
  • tst_qqmldebugjs
  • tst_qqmlimport
  • tst_qqmltypeloader
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickapplication
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdesignersupport
  • tst_qquickdrag
  • tst_qquickdraghandler
  • ...
316
330-
331QSGRenderContext::~QSGRenderContext()-
332{-
333}-
334-
335void QSGRenderContext::initialize(void *context)-
336{-
337 Q_UNUSED(context);-
338}
never executed: end of block
0
339-
340void QSGRenderContext::invalidate()-
341{-
342}-
343-
344void QSGRenderContext::endSync()-
345{-
346 qDeleteAll(m_texturesToDelete);-
347 m_texturesToDelete.clear();-
348}
executed 50315 times by 76 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlcomponent
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • ...
50315
349-
350/*!-
351 Factory function for scene graph backends of the distance-field glyph cache.-
352 */-
353QSGDistanceFieldGlyphCache *QSGRenderContext::distanceFieldGlyphCache(const QRawFont &)-
354{-
355 return nullptr;
never executed: return nullptr;
0
356}-
357-
358-
359void QSGRenderContext::registerFontengineForCleanup(QFontEngine *engine)-
360{-
361 engine->ref.ref();-
362 m_fontEnginesToClean << engine;-
363}
executed 16 times by 1 test: end of block
Executed by:
  • tst_scenegraph
16
364-
365/*!-
366 Factory function for the scene graph renderers.-
367-
368 The renderers are used for the toplevel renderer and once for every-
369 QQuickShaderEffectSource used in the QML scene.-
370 */-
371-
372QSGTexture *QSGRenderContext::textureForFactory(QQuickTextureFactory *factory, QQuickWindow *window)-
373{-
374 if (!factory)
!factoryDescription
TRUEevaluated 112 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
FALSEevaluated 5161 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
112-5161
375 return nullptr;
executed 112 times by 2 tests: return nullptr;
Executed by:
  • tst_examples
  • tst_qquickimage
112
376-
377 m_mutex.lock();-
378 QSGTexture *texture = m_textures.value(factory);-
379 m_mutex.unlock();-
380-
381 if (!texture) {
!textureDescription
TRUEevaluated 367 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
FALSEevaluated 4794 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
367-4794
382 texture = factory->createTexture(window);-
383-
384 m_mutex.lock();-
385 m_textures.insert(factory, texture);-
386 m_mutex.unlock();-
387-
388 connect(factory, SIGNAL(destroyed(QObject*)), this, SLOT(textureFactoryDestroyed(QObject*)), Qt::DirectConnection);-
389 }
executed 367 times by 8 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
367
390 return texture;
executed 5161 times by 8 tests: return texture;
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
5161
391}-
392-
393void QSGRenderContext::textureFactoryDestroyed(QObject *o)-
394{-
395 m_mutex.lock();-
396 m_texturesToDelete << m_textures.take(static_cast<QQuickTextureFactory *>(o));-
397 m_mutex.unlock();-
398}
executed 359 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickshadereffect
  • tst_scenegraph
359
399-
400/*!-
401 Return the texture corresponding to a texture factory.-
402-
403 This may optionally manipulate the texture in some way; for example by returning-
404 an atlased texture.-
405-
406 This function is not a replacement for textureForFactory; both should be used-
407 for a single texture (this might atlas, while the other might cache).-
408*/-
409QSGTexture *QSGRenderContext::compressedTextureForFactory(const QSGCompressedTextureFactory *) const-
410{-
411 return nullptr;
never executed: return nullptr;
0
412}-
413-
414#include "qsgcontext.moc"-
415#include "moc_qsgcontext_p.cpp"-
416-
417QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0