OpenCoverage

qsgsoftwarerenderloop.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.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 "qsgsoftwarerenderloop_p.h"-
41-
42#include "qsgsoftwarecontext_p.h"-
43-
44#include <QtCore/QCoreApplication>-
45-
46#include <private/qquickwindow_p.h>-
47#include <QElapsedTimer>-
48#include <private/qquickprofiler_p.h>-
49#include <private/qsgsoftwarerenderer_p.h>-
50#include <qpa/qplatformbackingstore.h>-
51-
52#include <QtGui/QBackingStore>-
53-
54QT_BEGIN_NAMESPACE-
55-
56QSGSoftwareRenderLoop::QSGSoftwareRenderLoop()-
57{-
58 sg = new QSGSoftwareContext();-
59 rc = sg->createRenderContext();-
60}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
61-
62QSGSoftwareRenderLoop::~QSGSoftwareRenderLoop()-
63{-
64 delete rc;-
65 delete sg;-
66}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
67-
68void QSGSoftwareRenderLoop::show(QQuickWindow *window)-
69{-
70 WindowData data;-
71 data.updatePending = false;-
72 data.grabOnly = false;-
73 m_windows[window] = data;-
74-
75 if (m_backingStores[window] == nullptr) {
m_backingStore...ow] == nullptrDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
76 m_backingStores[window] = new QBackingStore(window);-
77 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
78-
79 maybeUpdate(window);-
80}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
81-
82void QSGSoftwareRenderLoop::hide(QQuickWindow *window)-
83{-
84 QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);-
85 cd->fireAboutToStop();-
86}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
87-
88void QSGSoftwareRenderLoop::windowDestroyed(QQuickWindow *window)-
89{-
90 m_windows.remove(window);-
91 delete m_backingStores[window];-
92 m_backingStores.remove(window);-
93 hide(window);-
94-
95 QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);-
96 d->cleanupNodesOnShutdown();-
97-
98 if (m_windows.size() == 0) {
m_windows.size() == 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-12
99 rc->invalidate();-
100 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
101}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
102-
103void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window, bool isNewExpose)-
104{-
105 QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);-
106 if (!m_windows.contains(window))
!m_windows.contains(window)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
107 return;
never executed: return;
0
108-
109 WindowData &data = const_cast<WindowData &>(m_windows[window]);-
110-
111 //If were not in grabOnly mode, dont render a non-renderable window-
112 if (!data.grabOnly && !cd->isRenderable())
!data.grabOnlyDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
!cd->isRenderable()Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
0-16
113 return;
never executed: return;
0
114-
115 //Resize the backing store if necessary-
116 if (m_backingStores[window]->size() != window->size()) {
m_backingStore...window->size()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
8-16
117 m_backingStores[window]->resize(window->size());-
118 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
119-
120 // ### create QPainter and set up pointer to current window/painter-
121 QSGSoftwareRenderContext *ctx = static_cast<QSGSoftwareRenderContext*>(cd->context);-
122 ctx->initializeIfNeeded();-
123-
124 bool alsoSwap = data.updatePending;-
125 data.updatePending = false;-
126-
127 if (!data.grabOnly) {
!data.grabOnlyDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
8-16
128 cd->flushFrameSynchronousEvents();-
129 // Event delivery/processing triggered the window to be deleted or stop rendering.-
130 if (!m_windows.contains(window))
!m_windows.contains(window)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
0-16
131 return;
never executed: return;
0
132 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickshape
16
133 QElapsedTimer renderTimer;-
134 qint64 renderTime = 0, syncTime = 0, polishTime = 0;-
135 bool profileFrames = QSG_RASTER_LOG_TIME_RENDERLOOP().isDebugEnabled();-
136 if (profileFrames)
profileFramesDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
137 renderTimer.start();
never executed: renderTimer.start();
0
138 Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishFrame);
never executed: end of block
executed 24 times by 1 test: (void)0;
Executed by:
  • tst_qquickshape
QQuickProfiler...ileSceneGraph)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
139-
140 cd->polishItems();-
141-
142 if (profileFrames)
profileFramesDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
143 polishTime = renderTimer.nsecsElapsed();
never executed: polishTime = renderTimer.nsecsElapsed();
0
144 Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
never executed: end of block
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
QQuickProfiler...ileSceneGraph)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
145 QQuickProfiler::SceneGraphRenderLoopFrame,
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
24
146 QQuickProfiler::SceneGraphPolishPolish);
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
24
147-
148 emit window->afterAnimating();-
149-
150 cd->syncSceneGraph();-
151 rc->endSync();-
152-
153 if (profileFrames)
profileFramesDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
154 syncTime = renderTimer.nsecsElapsed();
never executed: syncTime = renderTimer.nsecsElapsed();
0
155 Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
never executed: end of block
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
QQuickProfiler...ileSceneGraph)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
156 QQuickProfiler::SceneGraphRenderLoopSync);
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
24
157-
158 //Tell the renderer about the windows backing store-
159 auto softwareRenderer = static_cast<QSGSoftwareRenderer*>(cd->renderer);-
160 if (softwareRenderer)
softwareRendererDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-24
161 softwareRenderer->setBackingStore(m_backingStores[window]);
executed 24 times by 1 test: softwareRenderer->setBackingStore(m_backingStores[window]);
Executed by:
  • tst_qquickshape
24
162-
163 cd->renderSceneGraph(window->size());-
164-
165 if (profileFrames)
profileFramesDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
166 renderTime = renderTimer.nsecsElapsed();
never executed: renderTime = renderTimer.nsecsElapsed();
0
167 Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
never executed: end of block
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
QQuickProfiler...ileSceneGraph)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
168 QQuickProfiler::SceneGraphRenderLoopRender);
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
24
169-
170 if (data.grabOnly) {
data.grabOnlyDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
8-16
171 grabContent = m_backingStores[window]->handle()->toImage();-
172 data.grabOnly = false;-
173 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
174-
175 if (alsoSwap && window->isVisible()) {
alsoSwapDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
window->isVisible()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-16
176 //Flush backingstore to window-
177 if (!isNewExpose)
!isNewExposeDescription
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
0-16
178 m_backingStores[window]->flush(softwareRenderer->flushRegion());
never executed: m_backingStores[window]->flush(softwareRenderer->flushRegion());
0
179 else-
180 m_backingStores[window]->flush(QRegion(QRect(QPoint(0,0), window->size())));
executed 16 times by 1 test: m_backingStores[window]->flush(QRegion(QRect(QPoint(0,0), window->size())));
Executed by:
  • tst_qquickshape
16
181 cd->fireFrameSwapped();-
182 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickshape
16
183-
184 qint64 swapTime = 0;-
185 if (profileFrames)
profileFramesDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
186 swapTime = renderTimer.nsecsElapsed();
never executed: swapTime = renderTimer.nsecsElapsed();
0
187 Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
never executed: end of block
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
QQuickProfiler...ileSceneGraph)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
188 QQuickProfiler::SceneGraphRenderLoopSwap);
executed 24 times by 1 test: (void)0 ;
Executed by:
  • tst_qquickshape
24
189-
190 if (QSG_RASTER_LOG_TIME_RENDERLOOP().isDebugEnabled()) {
QSG_RASTER_LOG...DebugEnabled()Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickshape
0-24
191 static QTime lastFrameTime = QTime::currentTime();-
192 qCDebug(QSG_RASTER_LOG_TIME_RENDERLOOP,
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
193 "Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d",
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
194 int(swapTime / 1000000),
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
195 int(polishTime / 1000000),
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
196 int((syncTime - polishTime) / 1000000),
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
197 int((renderTime - syncTime) / 1000000),
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
198 int((swapTime - renderTime) / 1000000),
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
199 int(lastFrameTime.msecsTo(QTime::currentTime())));
never executed: QMessageLogger( __FILE__ , 199 , __PRETTY_FUNCTION__, QSG_RASTER_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'software' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", int(swapTime / 1000000), int(polishTime / 1000000), int((syncTime - polishTime) / 1000000), int((renderTime - syncTime) / 1000000), int((swapTime - renderTime) / 1000000), int(lastFrameTime.msecsTo(QTime::currentTime()))) ;
0
200 lastFrameTime = QTime::currentTime();-
201 }
never executed: end of block
0
202-
203 // Might have been set during syncSceneGraph()-
204 if (data.updatePending)
data.updatePendingDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
8-16
205 maybeUpdate(window);
executed 8 times by 1 test: maybeUpdate(window);
Executed by:
  • tst_qquickshape
8
206}
executed 24 times by 1 test: end of block
Executed by:
  • tst_qquickshape
24
207-
208void QSGSoftwareRenderLoop::exposureChanged(QQuickWindow *window)-
209{-
210 if (window->isExposed()) {
window->isExposed()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-16
211 m_windows[window].updatePending = true;-
212 renderWindow(window, true);-
213 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickshape
16
214}
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickshape
16
215-
216QImage QSGSoftwareRenderLoop::grab(QQuickWindow *window)-
217{-
218 //If the window was never shown, create a new backing store-
219 if (!m_backingStores.contains(window)) {
!m_backingStor...ntains(window)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
0-8
220 m_backingStores[window] = new QBackingStore(window);-
221 // Call create on window to make sure platform window is created-
222 window->create();-
223 }
never executed: end of block
0
224-
225 //If there is no WindowData, add one-
226 if (!m_windows.contains(window)) {
!m_windows.contains(window)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
0-8
227 WindowData data;-
228 data.updatePending = false;-
229 m_windows[window] = data;-
230 }
never executed: end of block
0
231-
232 m_windows[window].grabOnly = true;-
233-
234 renderWindow(window);-
235-
236 QImage grabbed = grabContent;-
237 grabbed.detach();-
238 grabContent = QImage();-
239 return grabbed;
executed 8 times by 1 test: return grabbed;
Executed by:
  • tst_qquickshape
8
240}-
241-
242-
243-
244void QSGSoftwareRenderLoop::maybeUpdate(QQuickWindow *window)-
245{-
246 if (!m_windows.contains(window))
!m_windows.contains(window)Description
TRUEevaluated 92 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 64 times by 1 test
Evaluated by:
  • tst_qquickshape
64-92
247 return;
executed 92 times by 1 test: return;
Executed by:
  • tst_qquickshape
92
248-
249 m_windows[window].updatePending = true;-
250 window->requestUpdate();-
251}
executed 64 times by 1 test: end of block
Executed by:
  • tst_qquickshape
64
252-
253QSurface::SurfaceType QSGSoftwareRenderLoop::windowSurfaceType() const-
254{-
255 return QSurface::RasterSurface;
executed 12 times by 1 test: return QSurface::RasterSurface;
Executed by:
  • tst_qquickshape
12
256}-
257-
258-
259-
260QSGContext *QSGSoftwareRenderLoop::sceneGraphContext() const-
261{-
262 return sg;
executed 12 times by 1 test: return sg;
Executed by:
  • tst_qquickshape
12
263}-
264-
265-
266void QSGSoftwareRenderLoop::handleUpdateRequest(QQuickWindow *window)-
267{-
268 renderWindow(window);-
269}
never executed: end of block
0
270-
271QT_END_NAMESPACE-
272-
273#include "moc_qsgsoftwarerenderloop_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0