Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/qsgthreadedrenderloop.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | static inline int qsgrl_animation_interval() { | - | ||||||||||||||||||||||||
15 | qreal refreshRate = QGuiApplication::primaryScreen()->refreshRate(); | - | ||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||
17 | - | |||||||||||||||||||||||||
18 | if (refreshRate < 1
| 0 | ||||||||||||||||||||||||
19 | return never executed: 16;return 16; never executed: return 16; | 0 | ||||||||||||||||||||||||
20 | return never executed: int(1000 / refreshRate);return int(1000 / refreshRate); never executed: return int(1000 / refreshRate); | 0 | ||||||||||||||||||||||||
21 | } | - | ||||||||||||||||||||||||
22 | - | |||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||
24 | static QElapsedTimer threadTimer; | - | ||||||||||||||||||||||||
25 | static qint64 syncTime; | - | ||||||||||||||||||||||||
26 | static qint64 renderTime; | - | ||||||||||||||||||||||||
27 | static qint64 sinceLastTime; | - | ||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | extern __attribute__((visibility("default"))) QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); | - | ||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||
36 | const QEvent::Type WM_Obscure = QEvent::Type(QEvent::User + 1); | - | ||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | const QEvent::Type WM_RequestSync = QEvent::Type(QEvent::User + 2); | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | const QEvent::Type WM_RequestRepaint = QEvent::Type(QEvent::User + 3); | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | const QEvent::Type WM_TryRelease = QEvent::Type(QEvent::User + 4); | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | const QEvent::Type WM_Grab = QEvent::Type(QEvent::User + 5); | - | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | const QEvent::Type WM_PostJob = QEvent::Type(QEvent::User + 6); | - | ||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | template <typename T> T *windowFor(const QList<T> &list, QQuickWindow *window) | - | ||||||||||||||||||||||||
58 | { | - | ||||||||||||||||||||||||
59 | for (int i=0; i<list.size()
| 0 | ||||||||||||||||||||||||
60 | const T &t = list.at(i); | - | ||||||||||||||||||||||||
61 | if (t.window == window
| 0 | ||||||||||||||||||||||||
62 | return never executed: const_cast<T *>(&t);return const_cast<T *>(&t); never executed: return const_cast<T *>(&t); | 0 | ||||||||||||||||||||||||
63 | } never executed: end of block | 0 | ||||||||||||||||||||||||
64 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
65 | } | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | class WMWindowEvent : public QEvent | - | ||||||||||||||||||||||||
69 | { | - | ||||||||||||||||||||||||
70 | public: | - | ||||||||||||||||||||||||
71 | WMWindowEvent(QQuickWindow *c, QEvent::Type type) : QEvent(type), window(c) { } never executed: end of block | 0 | ||||||||||||||||||||||||
72 | QQuickWindow *window; | - | ||||||||||||||||||||||||
73 | }; | - | ||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | class WMTryReleaseEvent : public WMWindowEvent | - | ||||||||||||||||||||||||
76 | { | - | ||||||||||||||||||||||||
77 | public: | - | ||||||||||||||||||||||||
78 | WMTryReleaseEvent(QQuickWindow *win, bool destroy, QOffscreenSurface *fallback) | - | ||||||||||||||||||||||||
79 | : WMWindowEvent(win, WM_TryRelease) | - | ||||||||||||||||||||||||
80 | , inDestructor(destroy) | - | ||||||||||||||||||||||||
81 | , fallbackSurface(fallback) | - | ||||||||||||||||||||||||
82 | {} never executed: end of block | 0 | ||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | bool inDestructor; | - | ||||||||||||||||||||||||
85 | QOffscreenSurface *fallbackSurface; | - | ||||||||||||||||||||||||
86 | }; | - | ||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | class WMSyncEvent : public WMWindowEvent | - | ||||||||||||||||||||||||
89 | { | - | ||||||||||||||||||||||||
90 | public: | - | ||||||||||||||||||||||||
91 | WMSyncEvent(QQuickWindow *c, bool inExpose, bool force) | - | ||||||||||||||||||||||||
92 | : WMWindowEvent(c, WM_RequestSync) | - | ||||||||||||||||||||||||
93 | , size(c->size()) | - | ||||||||||||||||||||||||
94 | , syncInExpose(inExpose) | - | ||||||||||||||||||||||||
95 | , forceRenderPass(force) | - | ||||||||||||||||||||||||
96 | {} never executed: end of block | 0 | ||||||||||||||||||||||||
97 | QSize size; | - | ||||||||||||||||||||||||
98 | bool syncInExpose; | - | ||||||||||||||||||||||||
99 | bool forceRenderPass; | - | ||||||||||||||||||||||||
100 | }; | - | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | class WMGrabEvent : public WMWindowEvent | - | ||||||||||||||||||||||||
104 | { | - | ||||||||||||||||||||||||
105 | public: | - | ||||||||||||||||||||||||
106 | WMGrabEvent(QQuickWindow *c, QImage *result) : WMWindowEvent(c, WM_Grab), image(result) {} never executed: end of block | 0 | ||||||||||||||||||||||||
107 | QImage *image; | - | ||||||||||||||||||||||||
108 | }; | - | ||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||
110 | class WMJobEvent : public WMWindowEvent | - | ||||||||||||||||||||||||
111 | { | - | ||||||||||||||||||||||||
112 | public: | - | ||||||||||||||||||||||||
113 | WMJobEvent(QQuickWindow *c, QRunnable *postedJob) | - | ||||||||||||||||||||||||
114 | : WMWindowEvent(c, WM_PostJob), job(postedJob) {} never executed: end of block | 0 | ||||||||||||||||||||||||
115 | ~WMJobEvent() { delete job; } never executed: end of block | 0 | ||||||||||||||||||||||||
116 | QRunnable *job; | - | ||||||||||||||||||||||||
117 | }; | - | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | class QSGRenderThreadEventQueue : public QQueue<QEvent *> | - | ||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||
121 | public: | - | ||||||||||||||||||||||||
122 | QSGRenderThreadEventQueue() | - | ||||||||||||||||||||||||
123 | : waiting(false) | - | ||||||||||||||||||||||||
124 | { | - | ||||||||||||||||||||||||
125 | } never executed: end of block | 0 | ||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | void addEvent(QEvent *e) { | - | ||||||||||||||||||||||||
128 | mutex.lock(); | - | ||||||||||||||||||||||||
129 | enqueue(e); | - | ||||||||||||||||||||||||
130 | if (waiting
| 0 | ||||||||||||||||||||||||
131 | condition.wakeOne(); never executed: condition.wakeOne(); | 0 | ||||||||||||||||||||||||
132 | mutex.unlock(); | - | ||||||||||||||||||||||||
133 | } never executed: end of block | 0 | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | QEvent *takeEvent(bool wait) { | - | ||||||||||||||||||||||||
136 | mutex.lock(); | - | ||||||||||||||||||||||||
137 | if (size() == 0
| 0 | ||||||||||||||||||||||||
138 | waiting = true; | - | ||||||||||||||||||||||||
139 | condition.wait(&mutex); | - | ||||||||||||||||||||||||
140 | waiting = false; | - | ||||||||||||||||||||||||
141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
142 | QEvent *e = dequeue(); | - | ||||||||||||||||||||||||
143 | mutex.unlock(); | - | ||||||||||||||||||||||||
144 | return never executed: e;return e; never executed: return e; | 0 | ||||||||||||||||||||||||
145 | } | - | ||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||
147 | bool hasMoreEvents() { | - | ||||||||||||||||||||||||
148 | mutex.lock(); | - | ||||||||||||||||||||||||
149 | bool has = !isEmpty(); | - | ||||||||||||||||||||||||
150 | mutex.unlock(); | - | ||||||||||||||||||||||||
151 | return never executed: has;return has; never executed: return has; | 0 | ||||||||||||||||||||||||
152 | } | - | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | private: | - | ||||||||||||||||||||||||
155 | QMutex mutex; | - | ||||||||||||||||||||||||
156 | QWaitCondition condition; | - | ||||||||||||||||||||||||
157 | bool waiting; | - | ||||||||||||||||||||||||
158 | }; | - | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||
161 | class QSGRenderThread : public QThread | - | ||||||||||||||||||||||||
162 | { | - | ||||||||||||||||||||||||
163 | public: | - | ||||||||||||||||||||||||
164 | #pragma GCC diagnostic push | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - | ||||||||||||||||||||||||
167 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - | ||||||||||||||||||||||||
168 | #pragma GCC diagnostic ignored "-Wattributes" | - | ||||||||||||||||||||||||
169 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||||||||
170 | #pragma GCC diagnostic pop | - | ||||||||||||||||||||||||
171 | struct QPrivateSignal {}; | - | ||||||||||||||||||||||||
172 | public: | - | ||||||||||||||||||||||||
173 | QSGRenderThread(QSGThreadedRenderLoop *w, QSGRenderContext *renderContext) | - | ||||||||||||||||||||||||
174 | : wm(w) | - | ||||||||||||||||||||||||
175 | , gl(nullptr) | - | ||||||||||||||||||||||||
176 | , animatorDriver(nullptr) | - | ||||||||||||||||||||||||
177 | , pendingUpdate(0) | - | ||||||||||||||||||||||||
178 | , sleeping(false) | - | ||||||||||||||||||||||||
179 | , syncResultedInChanges(false) | - | ||||||||||||||||||||||||
180 | , active(false) | - | ||||||||||||||||||||||||
181 | , window(nullptr) | - | ||||||||||||||||||||||||
182 | , stopEventProcessing(false) | - | ||||||||||||||||||||||||
183 | { | - | ||||||||||||||||||||||||
184 | sgrc = static_cast<QSGDefaultRenderContext *>(renderContext); | - | ||||||||||||||||||||||||
185 | - | |||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | vsyncDelta = qsgrl_animation_interval(); | - | ||||||||||||||||||||||||
190 | } never executed: end of block | 0 | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | ~QSGRenderThread() | - | ||||||||||||||||||||||||
193 | { | - | ||||||||||||||||||||||||
194 | delete sgrc; | - | ||||||||||||||||||||||||
195 | } never executed: end of block | 0 | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | void invalidateOpenGL(QQuickWindow *window, bool inDestructor, QOffscreenSurface *backupSurface); | - | ||||||||||||||||||||||||
198 | void initializeOpenGL(); | - | ||||||||||||||||||||||||
199 | - | |||||||||||||||||||||||||
200 | bool event(QEvent *) override; | - | ||||||||||||||||||||||||
201 | void run() override; | - | ||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | void syncAndRender(); | - | ||||||||||||||||||||||||
204 | void sync(bool inExpose); | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | void requestRepaint() | - | ||||||||||||||||||||||||
207 | { | - | ||||||||||||||||||||||||
208 | if (sleeping
| 0 | ||||||||||||||||||||||||
209 | stopEventProcessing = true; never executed: stopEventProcessing = true; | 0 | ||||||||||||||||||||||||
210 | if (window
| 0 | ||||||||||||||||||||||||
211 | pendingUpdate |= RepaintRequest; never executed: pendingUpdate |= RepaintRequest; | 0 | ||||||||||||||||||||||||
212 | } never executed: end of block | 0 | ||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | void processEventsAndWaitForMore(); | - | ||||||||||||||||||||||||
215 | void processEvents(); | - | ||||||||||||||||||||||||
216 | void postEvent(QEvent *e); | - | ||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||
218 | public : | - | ||||||||||||||||||||||||
219 | void sceneGraphChanged() { | - | ||||||||||||||||||||||||
220 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 318, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "sceneGraphChanged"); | 0 | ||||||||||||||||||||||||
221 | syncResultedInChanges = true; | - | ||||||||||||||||||||||||
222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||
224 | public: | - | ||||||||||||||||||||||||
225 | enum UpdateRequest { | - | ||||||||||||||||||||||||
226 | SyncRequest = 0x01, | - | ||||||||||||||||||||||||
227 | RepaintRequest = 0x02, | - | ||||||||||||||||||||||||
228 | ExposeRequest = 0x04 | RepaintRequest | SyncRequest | - | ||||||||||||||||||||||||
229 | }; | - | ||||||||||||||||||||||||
230 | - | |||||||||||||||||||||||||
231 | QSGThreadedRenderLoop *wm; | - | ||||||||||||||||||||||||
232 | QOpenGLContext *gl; | - | ||||||||||||||||||||||||
233 | QSGDefaultRenderContext *sgrc; | - | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | QAnimationDriver *animatorDriver; | - | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | uint pendingUpdate; | - | ||||||||||||||||||||||||
238 | bool sleeping; | - | ||||||||||||||||||||||||
239 | bool syncResultedInChanges; | - | ||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||
241 | volatile bool active; | - | ||||||||||||||||||||||||
242 | - | |||||||||||||||||||||||||
243 | float vsyncDelta; | - | ||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | QMutex mutex; | - | ||||||||||||||||||||||||
246 | QWaitCondition waitCondition; | - | ||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | QElapsedTimer m_timer; | - | ||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||
250 | QQuickWindow *window; | - | ||||||||||||||||||||||||
251 | QSize windowSize; | - | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | - | |||||||||||||||||||||||||
254 | bool stopEventProcessing; | - | ||||||||||||||||||||||||
255 | QSGRenderThreadEventQueue eventQueue; | - | ||||||||||||||||||||||||
256 | }; | - | ||||||||||||||||||||||||
257 | - | |||||||||||||||||||||||||
258 | bool QSGRenderThread::event(QEvent *e) | - | ||||||||||||||||||||||||
259 | { | - | ||||||||||||||||||||||||
260 | switch ((int) e->type()) { | - | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | case never executed: WM_Obscure:case WM_Obscure: never executed: {case WM_Obscure: | 0 | ||||||||||||||||||||||||
263 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 361, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "WM_Obscure"); | 0 | ||||||||||||||||||||||||
264 | - | |||||||||||||||||||||||||
265 | ((!window || window == static_cast<WMWindowEvent *>(e)->window) ? static_cast<void>(0) : qt_assert("!window || window == static_cast<WMWindowEvent *>(e)->window", __FILE__, 363)); | - | ||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||
267 | mutex.lock(); | - | ||||||||||||||||||||||||
268 | if (window
| 0 | ||||||||||||||||||||||||
269 | QQuickWindowPrivate::get(window)->fireAboutToStop(); | - | ||||||||||||||||||||||||
270 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 368, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- window removed"); | 0 | ||||||||||||||||||||||||
271 | window = nullptr; | - | ||||||||||||||||||||||||
272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
273 | waitCondition.wakeOne(); | - | ||||||||||||||||||||||||
274 | mutex.unlock(); | - | ||||||||||||||||||||||||
275 | - | |||||||||||||||||||||||||
276 | return never executed: true;return true; never executed: }return true; | 0 | ||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||
278 | case never executed: WM_RequestSync:case WM_RequestSync: never executed: {case WM_RequestSync: | 0 | ||||||||||||||||||||||||
279 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 377, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "WM_RequestSync"); | 0 | ||||||||||||||||||||||||
280 | WMSyncEvent *se = static_cast<WMSyncEvent *>(e); | - | ||||||||||||||||||||||||
281 | if (sleeping
| 0 | ||||||||||||||||||||||||
282 | stopEventProcessing = true; never executed: stopEventProcessing = true; | 0 | ||||||||||||||||||||||||
283 | window = se->window; | - | ||||||||||||||||||||||||
284 | windowSize = se->size; | - | ||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | pendingUpdate |= SyncRequest; | - | ||||||||||||||||||||||||
287 | if (se->syncInExpose
| 0 | ||||||||||||||||||||||||
288 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- triggered from expose"); | 0 | ||||||||||||||||||||||||
289 | pendingUpdate |= ExposeRequest; | - | ||||||||||||||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
291 | if (se->forceRenderPass
| 0 | ||||||||||||||||||||||||
292 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 390, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- repaint regardless"); | 0 | ||||||||||||||||||||||||
293 | pendingUpdate |= RepaintRequest; | - | ||||||||||||||||||||||||
294 | } never executed: end of block | 0 | ||||||||||||||||||||||||
295 | return never executed: true;return true; never executed: }return true; | 0 | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | case never executed: WM_TryRelease:case WM_TryRelease: never executed: {case WM_TryRelease: | 0 | ||||||||||||||||||||||||
298 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 396, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "WM_TryRelease"); | 0 | ||||||||||||||||||||||||
299 | mutex.lock(); | - | ||||||||||||||||||||||||
300 | wm->m_lockedForSync = true; | - | ||||||||||||||||||||||||
301 | WMTryReleaseEvent *wme = static_cast<WMTryReleaseEvent *>(e); | - | ||||||||||||||||||||||||
302 | if (!window
| 0 | ||||||||||||||||||||||||
303 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 401, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- setting exit flag and invalidating OpenGL"); | 0 | ||||||||||||||||||||||||
304 | invalidateOpenGL(wme->window, wme->inDestructor, wme->fallbackSurface); | - | ||||||||||||||||||||||||
305 | active = gl; | - | ||||||||||||||||||||||||
306 | ((!wme->inDestructor || !active) ? static_cast<void>(0) : qt_assert_x("QSGRenderThread::invalidateOpenGL()", "Thread's active state is not set to false when shutting down", __FILE__, 404)); | - | ||||||||||||||||||||||||
307 | if (sleeping
| 0 | ||||||||||||||||||||||||
308 | stopEventProcessing = true; never executed: stopEventProcessing = true; | 0 | ||||||||||||||||||||||||
309 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
310 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 408, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- not releasing because window is still active"); | 0 | ||||||||||||||||||||||||
311 | if (window
| 0 | ||||||||||||||||||||||||
312 | QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
313 | if (d->renderer
| 0 | ||||||||||||||||||||||||
314 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 412, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- requesting renderer to release cached resources"); | 0 | ||||||||||||||||||||||||
315 | d->renderer->releaseCachedResources(); | - | ||||||||||||||||||||||||
316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
317 | } never executed: end of block | 0 | ||||||||||||||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
319 | waitCondition.wakeOne(); | - | ||||||||||||||||||||||||
320 | wm->m_lockedForSync = false; | - | ||||||||||||||||||||||||
321 | mutex.unlock(); | - | ||||||||||||||||||||||||
322 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
323 | } | - | ||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | case never executed: WM_Grab:case WM_Grab: never executed: {case WM_Grab: | 0 | ||||||||||||||||||||||||
326 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "WM_Grab"); | 0 | ||||||||||||||||||||||||
327 | WMGrabEvent *ce = static_cast<WMGrabEvent *>(e); | - | ||||||||||||||||||||||||
328 | ((ce->window) ? static_cast<void>(0) : qt_assert("ce->window", __FILE__, 426)); | - | ||||||||||||||||||||||||
329 | ((ce->window == window || !window) ? static_cast<void>(0) : qt_assert("ce->window == window || !window", __FILE__, 427)); | - | ||||||||||||||||||||||||
330 | mutex.lock(); | - | ||||||||||||||||||||||||
331 | if (ce->window
| 0 | ||||||||||||||||||||||||
332 | gl->makeCurrent(ce->window); | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 432, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- sync scene graph"); | 0 | ||||||||||||||||||||||||
335 | QQuickWindowPrivate *d = QQuickWindowPrivate::get(ce->window); | - | ||||||||||||||||||||||||
336 | d->syncSceneGraph(); | - | ||||||||||||||||||||||||
337 | sgrc->endSync(); | - | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 437, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- rendering scene graph"); | 0 | ||||||||||||||||||||||||
340 | QQuickWindowPrivate::get(ce->window)->renderSceneGraph(ce->window->size()); | - | ||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 440, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- grabbing result"); | 0 | ||||||||||||||||||||||||
343 | bool alpha = ce->window->format().alphaBufferSize() > 0
| 0 | ||||||||||||||||||||||||
344 | *ce->image = qt_gl_read_framebuffer(windowSize * ce->window->effectiveDevicePixelRatio(), alpha, alpha); | - | ||||||||||||||||||||||||
345 | ce->image->setDevicePixelRatio(ce->window->effectiveDevicePixelRatio()); | - | ||||||||||||||||||||||||
346 | } never executed: end of block | 0 | ||||||||||||||||||||||||
347 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 445, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- waking gui to handle result"); | 0 | ||||||||||||||||||||||||
348 | waitCondition.wakeOne(); | - | ||||||||||||||||||||||||
349 | mutex.unlock(); | - | ||||||||||||||||||||||||
350 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
351 | } | - | ||||||||||||||||||||||||
352 | - | |||||||||||||||||||||||||
353 | case never executed: WM_PostJob:case WM_PostJob: never executed: {case WM_PostJob: | 0 | ||||||||||||||||||||||||
354 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 452, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "WM_PostJob"); | 0 | ||||||||||||||||||||||||
355 | WMJobEvent *ce = static_cast<WMJobEvent *>(e); | - | ||||||||||||||||||||||||
356 | ((ce->window == window) ? static_cast<void>(0) : qt_assert("ce->window == window", __FILE__, 454)); | - | ||||||||||||||||||||||||
357 | if (window
| 0 | ||||||||||||||||||||||||
358 | gl->makeCurrent(window); | - | ||||||||||||||||||||||||
359 | ce->job->run(); | - | ||||||||||||||||||||||||
360 | delete ce->job; | - | ||||||||||||||||||||||||
361 | ce->job = nullptr; | - | ||||||||||||||||||||||||
362 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 460, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- job done"); | 0 | ||||||||||||||||||||||||
363 | } never executed: end of block | 0 | ||||||||||||||||||||||||
364 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
365 | } | - | ||||||||||||||||||||||||
366 | - | |||||||||||||||||||||||||
367 | case never executed: WM_RequestRepaint:case WM_RequestRepaint: never executed: case WM_RequestRepaint: | 0 | ||||||||||||||||||||||||
368 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 466, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "WM_RequestPaint"); | 0 | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | pendingUpdate |= RepaintRequest; | - | ||||||||||||||||||||||||
372 | break; never executed: break; | 0 | ||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
375 | break; never executed: break; | 0 | ||||||||||||||||||||||||
376 | } | - | ||||||||||||||||||||||||
377 | return never executed: QThread::event(e);return QThread::event(e); never executed: return QThread::event(e); | 0 | ||||||||||||||||||||||||
378 | } | - | ||||||||||||||||||||||||
379 | - | |||||||||||||||||||||||||
380 | void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor, QOffscreenSurface *fallback) | - | ||||||||||||||||||||||||
381 | { | - | ||||||||||||||||||||||||
382 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 480, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "invalidateOpenGL()"); | 0 | ||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||
384 | if (!gl
| 0 | ||||||||||||||||||||||||
385 | return; never executed: return; | 0 | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | if (!window
| 0 | ||||||||||||||||||||||||
388 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isWarningEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 486, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).warning("QSGThreadedRenderLoop:QSGRenderThread: no window to make current..."); | 0 | ||||||||||||||||||||||||
389 | return; never executed: return; | 0 | ||||||||||||||||||||||||
390 | } | - | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | bool wipeSG = inDestructor
| 0 | ||||||||||||||||||||||||
394 | bool wipeGL = inDestructor
| 0 | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | bool current = gl->makeCurrent(fallback ? static_cast<QSurface *>(fallback) : static_cast<QSurface *>(window)); | - | ||||||||||||||||||||||||
397 | if (__builtin_expect(!!(!current), false)
| 0 | ||||||||||||||||||||||||
398 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 496, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- cleanup without an OpenGL context"); | 0 | ||||||||||||||||||||||||
399 | } never executed: end of block | 0 | ||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||
401 | QQuickWindowPrivate *dd = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||
403 | - | |||||||||||||||||||||||||
404 | QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache(); | - | ||||||||||||||||||||||||
405 | - | |||||||||||||||||||||||||
406 | - | |||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | if (wipeSG
| 0 | ||||||||||||||||||||||||
409 | dd->cleanupNodesOnShutdown(); | - | ||||||||||||||||||||||||
410 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
411 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 509, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- persistent SG, avoiding cleanup"); | 0 | ||||||||||||||||||||||||
412 | if (current
| 0 | ||||||||||||||||||||||||
413 | gl->doneCurrent(); never executed: gl->doneCurrent(); | 0 | ||||||||||||||||||||||||
414 | return; never executed: return; | 0 | ||||||||||||||||||||||||
415 | } | - | ||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | sgrc->invalidate(); | - | ||||||||||||||||||||||||
418 | QCoreApplication::processEvents(); | - | ||||||||||||||||||||||||
419 | QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); | - | ||||||||||||||||||||||||
420 | if (inDestructor
| 0 | ||||||||||||||||||||||||
421 | delete dd->animationController; never executed: delete dd->animationController; | 0 | ||||||||||||||||||||||||
422 | if (current
| 0 | ||||||||||||||||||||||||
423 | gl->doneCurrent(); never executed: gl->doneCurrent(); | 0 | ||||||||||||||||||||||||
424 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 522, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- invalidating scene graph"); | 0 | ||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||
426 | if (wipeGL
| 0 | ||||||||||||||||||||||||
427 | delete gl; | - | ||||||||||||||||||||||||
428 | gl = nullptr; | - | ||||||||||||||||||||||||
429 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 527, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- invalidated OpenGL"); | 0 | ||||||||||||||||||||||||
430 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
431 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 529, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- persistent GL, avoiding cleanup"); | 0 | ||||||||||||||||||||||||
432 | } never executed: end of block | 0 | ||||||||||||||||||||||||
433 | } | - | ||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | void QSGRenderThread::sync(bool inExpose) | - | ||||||||||||||||||||||||
440 | { | - | ||||||||||||||||||||||||
441 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 539, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "sync()"); | 0 | ||||||||||||||||||||||||
442 | mutex.lock(); | - | ||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | ((wm->m_lockedForSync) ? static_cast<void>(0) : qt_assert_x("QSGRenderThread::sync()", "sync triggered on bad terms as gui is not already locked...", __FILE__, 542)); | - | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | bool current = false; | - | ||||||||||||||||||||||||
447 | if (windowSize.width() > 0
| 0 | ||||||||||||||||||||||||
448 | current = gl->makeCurrent(window); never executed: current = gl->makeCurrent(window); | 0 | ||||||||||||||||||||||||
449 | - | |||||||||||||||||||||||||
450 | if (!current
| 0 | ||||||||||||||||||||||||
451 | QQuickWindowPrivate::get(window)->cleanupNodesOnShutdown(); | - | ||||||||||||||||||||||||
452 | sgrc->invalidate(); | - | ||||||||||||||||||||||||
453 | current = gl->create()
| 0 | ||||||||||||||||||||||||
454 | if (current
| 0 | ||||||||||||||||||||||||
455 | sgrc->initialize(gl); never executed: sgrc->initialize(gl); | 0 | ||||||||||||||||||||||||
456 | } never executed: end of block | 0 | ||||||||||||||||||||||||
457 | if (current
| 0 | ||||||||||||||||||||||||
458 | QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
459 | bool hadRenderer = d->renderer != nullptr; | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | - | |||||||||||||||||||||||||
462 | if (d->renderer
| 0 | ||||||||||||||||||||||||
463 | d->renderer->clearChangedFlag(); never executed: d->renderer->clearChangedFlag(); | 0 | ||||||||||||||||||||||||
464 | d->syncSceneGraph(); | - | ||||||||||||||||||||||||
465 | sgrc->endSync(); | - | ||||||||||||||||||||||||
466 | if (!hadRenderer
| 0 | ||||||||||||||||||||||||
467 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 565, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- renderer was created"); | 0 | ||||||||||||||||||||||||
468 | syncResultedInChanges = true; | - | ||||||||||||||||||||||||
469 | connect(d->renderer, qFlagLocation("2""sceneGraphChanged()" "\0" __FILE__ ":" "567"), this, qFlagLocation("1""sceneGraphChanged()" "\0" __FILE__ ":" "567"), Qt::DirectConnection); | - | ||||||||||||||||||||||||
470 | } never executed: end of block | 0 | ||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||
472 | - | |||||||||||||||||||||||||
473 | - | |||||||||||||||||||||||||
474 | - | |||||||||||||||||||||||||
475 | QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); | - | ||||||||||||||||||||||||
476 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
477 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 575, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- window has bad size, sync aborted"); | 0 | ||||||||||||||||||||||||
478 | } never executed: end of block | 0 | ||||||||||||||||||||||||
479 | - | |||||||||||||||||||||||||
480 | if (!inExpose
| 0 | ||||||||||||||||||||||||
481 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 579, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- sync complete, waking Gui"); | 0 | ||||||||||||||||||||||||
482 | waitCondition.wakeOne(); | - | ||||||||||||||||||||||||
483 | mutex.unlock(); | - | ||||||||||||||||||||||||
484 | } never executed: end of block | 0 | ||||||||||||||||||||||||
485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||
487 | void QSGRenderThread::syncAndRender() | - | ||||||||||||||||||||||||
488 | { | - | ||||||||||||||||||||||||
489 | bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); | - | ||||||||||||||||||||||||
490 | if (profileFrames
| 0 | ||||||||||||||||||||||||
491 | sinceLastTime = threadTimer.nsecsElapsed(); | - | ||||||||||||||||||||||||
492 | threadTimer.start(); | - | ||||||||||||||||||||||||
493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
494 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0;(void)0; never executed: (void)0; | 0 | ||||||||||||||||||||||||
495 | - | |||||||||||||||||||||||||
496 | QElapsedTimer waitTimer; | - | ||||||||||||||||||||||||
497 | waitTimer.start(); | - | ||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||
499 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 597, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "syncAndRender()"); | 0 | ||||||||||||||||||||||||
500 | - | |||||||||||||||||||||||||
501 | syncResultedInChanges = false; | - | ||||||||||||||||||||||||
502 | QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||
504 | bool repaintRequested = (
| 0 | ||||||||||||||||||||||||
505 | bool syncRequested = pendingUpdate & SyncRequest; | - | ||||||||||||||||||||||||
506 | bool exposeRequested = (pendingUpdate & ExposeRequest) == ExposeRequest; | - | ||||||||||||||||||||||||
507 | pendingUpdate = 0; | - | ||||||||||||||||||||||||
508 | - | |||||||||||||||||||||||||
509 | if (syncRequested
| 0 | ||||||||||||||||||||||||
510 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 608, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- updatePending, doing sync"); | 0 | ||||||||||||||||||||||||
511 | sync(exposeRequested); | - | ||||||||||||||||||||||||
512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||
514 | if (profileFrames
| 0 | ||||||||||||||||||||||||
515 | syncTime = threadTimer.nsecsElapsed(); never executed: syncTime = threadTimer.nsecsElapsed(); | 0 | ||||||||||||||||||||||||
516 | - | |||||||||||||||||||||||||
517 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
518 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
519 | - | |||||||||||||||||||||||||
520 | if (!syncResultedInChanges
| 0 | ||||||||||||||||||||||||
521 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 619, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- no changes, render aborted"); | 0 | ||||||||||||||||||||||||
522 | int waitTime = vsyncDelta - (int) waitTimer.elapsed(); | - | ||||||||||||||||||||||||
523 | if (waitTime > 0
| 0 | ||||||||||||||||||||||||
524 | msleep(waitTime); never executed: msleep(waitTime); | 0 | ||||||||||||||||||||||||
525 | return; never executed: return; | 0 | ||||||||||||||||||||||||
526 | } | - | ||||||||||||||||||||||||
527 | - | |||||||||||||||||||||||||
528 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 626, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- rendering started"); | 0 | ||||||||||||||||||||||||
529 | - | |||||||||||||||||||||||||
530 | - | |||||||||||||||||||||||||
531 | if (animatorDriver->isRunning()
| 0 | ||||||||||||||||||||||||
532 | d->animationController->lock(); | - | ||||||||||||||||||||||||
533 | animatorDriver->advance(); | - | ||||||||||||||||||||||||
534 | d->animationController->unlock(); | - | ||||||||||||||||||||||||
535 | } never executed: end of block | 0 | ||||||||||||||||||||||||
536 | - | |||||||||||||||||||||||||
537 | bool current = false; | - | ||||||||||||||||||||||||
538 | if (d->renderer
| 0 | ||||||||||||||||||||||||
539 | current = gl->makeCurrent(window); never executed: current = gl->makeCurrent(window); | 0 | ||||||||||||||||||||||||
540 | - | |||||||||||||||||||||||||
541 | if (!current
| 0 | ||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||
544 | QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest))); | - | ||||||||||||||||||||||||
545 | } never executed: end of block | 0 | ||||||||||||||||||||||||
546 | if (current
| 0 | ||||||||||||||||||||||||
547 | d->renderSceneGraph(windowSize); | - | ||||||||||||||||||||||||
548 | if (profileFrames
| 0 | ||||||||||||||||||||||||
549 | renderTime = threadTimer.nsecsElapsed(); never executed: renderTime = threadTimer.nsecsElapsed(); | 0 | ||||||||||||||||||||||||
550 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
551 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
552 | if (!d->customRenderStage
| 0 | ||||||||||||||||||||||||
553 | gl->swapBuffers(window); never executed: gl->swapBuffers(window); | 0 | ||||||||||||||||||||||||
554 | d->fireFrameSwapped(); | - | ||||||||||||||||||||||||
555 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
556 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
557 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
558 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 656, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- window not ready, skipping render"); | 0 | ||||||||||||||||||||||||
559 | } never executed: end of block | 0 | ||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 659, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- rendering done"); | 0 | ||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | - | |||||||||||||||||||||||||
567 | - | |||||||||||||||||||||||||
568 | if (exposeRequested
| 0 | ||||||||||||||||||||||||
569 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 667, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "- wake Gui after initial expose"); | 0 | ||||||||||||||||||||||||
570 | waitCondition.wakeOne(); | - | ||||||||||||||||||||||||
571 | mutex.unlock(); | - | ||||||||||||||||||||||||
572 | } never executed: end of block | 0 | ||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||
574 | for (bool qt_category_enabled = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 677 , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) ; | 0 | ||||||||||||||||||||||||
575 | 0 | |||||||||||||||||||||||||
576 | 0 | |||||||||||||||||||||||||
577 | 0 | |||||||||||||||||||||||||
578 | 0 | |||||||||||||||||||||||||
579 | __FILE__ never executed: QMessageLogger( __FILE__ , 677 , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) ; | 0 | ||||||||||||||||||||||||
580 | , never executed: QMessageLogger( __FILE__ , 677 , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) ; | 0 | ||||||||||||||||||||||||
581 | 0 | |||||||||||||||||||||||||
582 | 0 | |||||||||||||||||||||||||
583 | 0 | |||||||||||||||||||||||||
584 | 0 | |||||||||||||||||||||||||
585 | 677 never executed: QMessageLogger( __FILE__ , 677 , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) ; | 0 | ||||||||||||||||||||||||
586 | , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) never executed: QMessageLogger( __FILE__ , 677 , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) ; | 0 | ||||||||||||||||||||||||
587 | 0 | |||||||||||||||||||||||||
588 | 0 | |||||||||||||||||||||||||
589 | 0 | |||||||||||||||||||||||||
590 | 0 | |||||||||||||||||||||||||
591 | ; never executed: QMessageLogger( __FILE__ , 677 , __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP().categoryName()).debug("Frame rendered with 'threaded' renderloop in %dms, sync=%d, render=%d, swap=%d - (on render thread)", int(threadTimer.elapsed()), int((syncTime/1000000)), int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)) ; | 0 | ||||||||||||||||||||||||
592 | - | |||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
595 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
596 | } | - | ||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||
598 | - | |||||||||||||||||||||||||
599 | - | |||||||||||||||||||||||||
600 | void QSGRenderThread::postEvent(QEvent *e) | - | ||||||||||||||||||||||||
601 | { | - | ||||||||||||||||||||||||
602 | eventQueue.addEvent(e); | - | ||||||||||||||||||||||||
603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
604 | - | |||||||||||||||||||||||||
605 | - | |||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | void QSGRenderThread::processEvents() | - | ||||||||||||||||||||||||
608 | { | - | ||||||||||||||||||||||||
609 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 695, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "--- begin processEvents()"); | 0 | ||||||||||||||||||||||||
610 | while (eventQueue.hasMoreEvents()
| 0 | ||||||||||||||||||||||||
611 | QEvent *e = eventQueue.takeEvent(false); | - | ||||||||||||||||||||||||
612 | event(e); | - | ||||||||||||||||||||||||
613 | delete e; | - | ||||||||||||||||||||||||
614 | } never executed: end of block | 0 | ||||||||||||||||||||||||
615 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 701, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "--- done processEvents()"); | 0 | ||||||||||||||||||||||||
616 | } never executed: end of block | 0 | ||||||||||||||||||||||||
617 | - | |||||||||||||||||||||||||
618 | void QSGRenderThread::processEventsAndWaitForMore() | - | ||||||||||||||||||||||||
619 | { | - | ||||||||||||||||||||||||
620 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 706, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "--- begin processEventsAndWaitForMore()"); | 0 | ||||||||||||||||||||||||
621 | stopEventProcessing = false; | - | ||||||||||||||||||||||||
622 | while (!stopEventProcessing
| 0 | ||||||||||||||||||||||||
623 | QEvent *e = eventQueue.takeEvent(true); | - | ||||||||||||||||||||||||
624 | event(e); | - | ||||||||||||||||||||||||
625 | delete e; | - | ||||||||||||||||||||||||
626 | } never executed: end of block | 0 | ||||||||||||||||||||||||
627 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 713, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "--- done processEventsAndWaitForMore()"); | 0 | ||||||||||||||||||||||||
628 | } never executed: end of block | 0 | ||||||||||||||||||||||||
629 | - | |||||||||||||||||||||||||
630 | void QSGRenderThread::run() | - | ||||||||||||||||||||||||
631 | { | - | ||||||||||||||||||||||||
632 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 718, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "run()"); | 0 | ||||||||||||||||||||||||
633 | animatorDriver = sgrc->sceneGraphContext()->createAnimationDriver(nullptr); | - | ||||||||||||||||||||||||
634 | animatorDriver->install(); | - | ||||||||||||||||||||||||
635 | if (QQmlDebugConnector::service<QQmlProfilerService>()
| 0 | ||||||||||||||||||||||||
636 | QQuickProfiler::registerAnimationCallback(); never executed: QQuickProfiler::registerAnimationCallback(); | 0 | ||||||||||||||||||||||||
637 | - | |||||||||||||||||||||||||
638 | while (active
| 0 | ||||||||||||||||||||||||
639 | - | |||||||||||||||||||||||||
640 | if (window
| 0 | ||||||||||||||||||||||||
641 | if (!sgrc->openglContext()
| 0 | ||||||||||||||||||||||||
642 | sgrc->initialize(gl); never executed: sgrc->initialize(gl); | 0 | ||||||||||||||||||||||||
643 | syncAndRender(); | - | ||||||||||||||||||||||||
644 | } never executed: end of block | 0 | ||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||
646 | processEvents(); | - | ||||||||||||||||||||||||
647 | QCoreApplication::processEvents(); | - | ||||||||||||||||||||||||
648 | - | |||||||||||||||||||||||||
649 | if (active
| 0 | ||||||||||||||||||||||||
650 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 736, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "done drawing, sleep..."); | 0 | ||||||||||||||||||||||||
651 | sleeping = true; | - | ||||||||||||||||||||||||
652 | processEventsAndWaitForMore(); | - | ||||||||||||||||||||||||
653 | sleeping = false; | - | ||||||||||||||||||||||||
654 | } never executed: end of block | 0 | ||||||||||||||||||||||||
655 | } never executed: end of block | 0 | ||||||||||||||||||||||||
656 | - | |||||||||||||||||||||||||
657 | ((!gl) ? static_cast<void>(0) : qt_assert_x("QSGRenderThread::run()", "The OpenGL context should be cleaned up before exiting the render thread...", __FILE__, 743)); | - | ||||||||||||||||||||||||
658 | - | |||||||||||||||||||||||||
659 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 745, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug(" (RT) %s", "run() completed"); | 0 | ||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | delete animatorDriver; | - | ||||||||||||||||||||||||
662 | animatorDriver = nullptr; | - | ||||||||||||||||||||||||
663 | - | |||||||||||||||||||||||||
664 | sgrc->moveToThread(wm->thread()); | - | ||||||||||||||||||||||||
665 | moveToThread(wm->thread()); | - | ||||||||||||||||||||||||
666 | } never executed: end of block | 0 | ||||||||||||||||||||||||
667 | - | |||||||||||||||||||||||||
668 | QSGThreadedRenderLoop::QSGThreadedRenderLoop() | - | ||||||||||||||||||||||||
669 | : sg(QSGContext::createDefaultContext()) | - | ||||||||||||||||||||||||
670 | , m_animation_timer(0) | - | ||||||||||||||||||||||||
671 | { | - | ||||||||||||||||||||||||
672 | - | |||||||||||||||||||||||||
673 | - | |||||||||||||||||||||||||
674 | - | |||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||
676 | m_animation_driver = sg->createAnimationDriver(this); | - | ||||||||||||||||||||||||
677 | - | |||||||||||||||||||||||||
678 | connect(m_animation_driver, qFlagLocation("2""started()" "\0" __FILE__ ":" "764"), this, qFlagLocation("1""animationStarted()" "\0" __FILE__ ":" "764")); | - | ||||||||||||||||||||||||
679 | connect(m_animation_driver, qFlagLocation("2""stopped()" "\0" __FILE__ ":" "765"), this, qFlagLocation("1""animationStopped()" "\0" __FILE__ ":" "765")); | - | ||||||||||||||||||||||||
680 | - | |||||||||||||||||||||||||
681 | m_animation_driver->install(); | - | ||||||||||||||||||||||||
682 | } never executed: end of block | 0 | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | QSGThreadedRenderLoop::~QSGThreadedRenderLoop() | - | ||||||||||||||||||||||||
685 | { | - | ||||||||||||||||||||||||
686 | delete sg; | - | ||||||||||||||||||||||||
687 | } never executed: end of block | 0 | ||||||||||||||||||||||||
688 | - | |||||||||||||||||||||||||
689 | QSGRenderContext *QSGThreadedRenderLoop::createRenderContext(QSGContext *sg) const | - | ||||||||||||||||||||||||
690 | { | - | ||||||||||||||||||||||||
691 | return never executed: sg->createRenderContext();return sg->createRenderContext(); never executed: return sg->createRenderContext(); | 0 | ||||||||||||||||||||||||
692 | } | - | ||||||||||||||||||||||||
693 | - | |||||||||||||||||||||||||
694 | void QSGThreadedRenderLoop::maybePostPolishRequest(Window *w) | - | ||||||||||||||||||||||||
695 | { | - | ||||||||||||||||||||||||
696 | w->window->requestUpdate(); | - | ||||||||||||||||||||||||
697 | } never executed: end of block | 0 | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | QAnimationDriver *QSGThreadedRenderLoop::animationDriver() const | - | ||||||||||||||||||||||||
700 | { | - | ||||||||||||||||||||||||
701 | return never executed: m_animation_driver;return m_animation_driver; never executed: return m_animation_driver; | 0 | ||||||||||||||||||||||||
702 | } | - | ||||||||||||||||||||||||
703 | - | |||||||||||||||||||||||||
704 | QSGContext *QSGThreadedRenderLoop::sceneGraphContext() const | - | ||||||||||||||||||||||||
705 | { | - | ||||||||||||||||||||||||
706 | return never executed: sg;return sg; never executed: return sg; | 0 | ||||||||||||||||||||||||
707 | } | - | ||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||
709 | bool QSGThreadedRenderLoop::anyoneShowing() const | - | ||||||||||||||||||||||||
710 | { | - | ||||||||||||||||||||||||
711 | for (int i=0; i<m_windows.size()
| 0 | ||||||||||||||||||||||||
712 | QQuickWindow *c = m_windows.at(i).window; | - | ||||||||||||||||||||||||
713 | if (c->isVisible()
| 0 | ||||||||||||||||||||||||
714 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
715 | } never executed: end of block | 0 | ||||||||||||||||||||||||
716 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
717 | } | - | ||||||||||||||||||||||||
718 | - | |||||||||||||||||||||||||
719 | bool QSGThreadedRenderLoop::interleaveIncubation() const | - | ||||||||||||||||||||||||
720 | { | - | ||||||||||||||||||||||||
721 | return never executed: m_animation_driver->isRunning() && anyoneShowing();return m_animation_driver->isRunning() && anyoneShowing(); never executed: return m_animation_driver->isRunning() && anyoneShowing(); | 0 | ||||||||||||||||||||||||
722 | } | - | ||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | void QSGThreadedRenderLoop::animationStarted() | - | ||||||||||||||||||||||||
725 | { | - | ||||||||||||||||||||||||
726 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 812, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- animationStarted()"); | 0 | ||||||||||||||||||||||||
727 | startOrStopAnimationTimer(); | - | ||||||||||||||||||||||||
728 | - | |||||||||||||||||||||||||
729 | for (int i=0; i<m_windows.size()
| 0 | ||||||||||||||||||||||||
730 | maybePostPolishRequest(const_cast<Window *>(&m_windows.at(i))); never executed: maybePostPolishRequest(const_cast<Window *>(&m_windows.at(i))); | 0 | ||||||||||||||||||||||||
731 | } never executed: end of block | 0 | ||||||||||||||||||||||||
732 | - | |||||||||||||||||||||||||
733 | void QSGThreadedRenderLoop::animationStopped() | - | ||||||||||||||||||||||||
734 | { | - | ||||||||||||||||||||||||
735 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 821, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- animationStopped()"); | 0 | ||||||||||||||||||||||||
736 | startOrStopAnimationTimer(); | - | ||||||||||||||||||||||||
737 | } never executed: end of block | 0 | ||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||
739 | - | |||||||||||||||||||||||||
740 | void QSGThreadedRenderLoop::startOrStopAnimationTimer() | - | ||||||||||||||||||||||||
741 | { | - | ||||||||||||||||||||||||
742 | int exposedWindows = 0; | - | ||||||||||||||||||||||||
743 | const Window *theOne = nullptr; | - | ||||||||||||||||||||||||
744 | for (int i=0; i<m_windows.size()
| 0 | ||||||||||||||||||||||||
745 | const Window &w = m_windows.at(i); | - | ||||||||||||||||||||||||
746 | if (w.window->isVisible()
| 0 | ||||||||||||||||||||||||
747 | ++exposedWindows; | - | ||||||||||||||||||||||||
748 | theOne = &w; | - | ||||||||||||||||||||||||
749 | } never executed: end of block | 0 | ||||||||||||||||||||||||
750 | } never executed: end of block | 0 | ||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | if (m_animation_timer != 0
| 0 | ||||||||||||||||||||||||
753 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 839, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("*** Stopping animation timer"); | 0 | ||||||||||||||||||||||||
754 | killTimer(m_animation_timer); | - | ||||||||||||||||||||||||
755 | m_animation_timer = 0; | - | ||||||||||||||||||||||||
756 | - | |||||||||||||||||||||||||
757 | if (m_animation_driver->isRunning()
| 0 | ||||||||||||||||||||||||
758 | maybePostPolishRequest(const_cast<Window *>(theOne)); never executed: maybePostPolishRequest(const_cast<Window *>(theOne)); | 0 | ||||||||||||||||||||||||
759 | } never executed: else if (m_animation_timer == 0end of block
| 0 | ||||||||||||||||||||||||
760 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 846, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("*** Starting animation timer"); | 0 | ||||||||||||||||||||||||
761 | m_animation_timer = startTimer(qsgrl_animation_interval()); | - | ||||||||||||||||||||||||
762 | } never executed: end of block | 0 | ||||||||||||||||||||||||
763 | } never executed: end of block | 0 | ||||||||||||||||||||||||
764 | void QSGThreadedRenderLoop::hide(QQuickWindow *window) | - | ||||||||||||||||||||||||
765 | { | - | ||||||||||||||||||||||||
766 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 864, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "hide()" << window; | 0 | ||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||
768 | if (window->isExposed()
| 0 | ||||||||||||||||||||||||
769 | handleObscurity(windowFor(m_windows, window)); never executed: handleObscurity(windowFor(m_windows, window)); | 0 | ||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||
771 | releaseResources(window); | - | ||||||||||||||||||||||||
772 | } never executed: end of block | 0 | ||||||||||||||||||||||||
773 | - | |||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | - | |||||||||||||||||||||||||
776 | - | |||||||||||||||||||||||||
777 | - | |||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | void QSGThreadedRenderLoop::windowDestroyed(QQuickWindow *window) | - | ||||||||||||||||||||||||
781 | { | - | ||||||||||||||||||||||||
782 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 880, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "begin windowDestroyed()" << window; | 0 | ||||||||||||||||||||||||
783 | - | |||||||||||||||||||||||||
784 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
785 | if (!w
| 0 | ||||||||||||||||||||||||
786 | return; never executed: return; | 0 | ||||||||||||||||||||||||
787 | - | |||||||||||||||||||||||||
788 | handleObscurity(w); | - | ||||||||||||||||||||||||
789 | releaseResources(w, true); | - | ||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | QSGRenderThread *thread = w->thread; | - | ||||||||||||||||||||||||
792 | while (thread->isRunning()
| 0 | ||||||||||||||||||||||||
793 | QThread::yieldCurrentThread(); never executed: QThread::yieldCurrentThread(); | 0 | ||||||||||||||||||||||||
794 | ((thread->thread() == QThread::currentThread()) ? static_cast<void>(0) : qt_assert("thread->thread() == QThread::currentThread()", __FILE__, 892)); | - | ||||||||||||||||||||||||
795 | delete thread; | - | ||||||||||||||||||||||||
796 | - | |||||||||||||||||||||||||
797 | for (int i=0; i<m_windows.size()
| 0 | ||||||||||||||||||||||||
798 | if (m_windows.at(i).window == window
| 0 | ||||||||||||||||||||||||
799 | m_windows.removeAt(i); | - | ||||||||||||||||||||||||
800 | break; never executed: break; | 0 | ||||||||||||||||||||||||
801 | } | - | ||||||||||||||||||||||||
802 | } never executed: end of block | 0 | ||||||||||||||||||||||||
803 | - | |||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | - | |||||||||||||||||||||||||
806 | - | |||||||||||||||||||||||||
807 | startOrStopAnimationTimer(); | - | ||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||
809 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 907, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "done windowDestroyed()" << window; | 0 | ||||||||||||||||||||||||
810 | } never executed: end of block | 0 | ||||||||||||||||||||||||
811 | - | |||||||||||||||||||||||||
812 | - | |||||||||||||||||||||||||
813 | void QSGThreadedRenderLoop::exposureChanged(QQuickWindow *window) | - | ||||||||||||||||||||||||
814 | { | - | ||||||||||||||||||||||||
815 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 913, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "exposureChanged()" << window; | 0 | ||||||||||||||||||||||||
816 | if (window->isExposed()
| 0 | ||||||||||||||||||||||||
817 | handleExposure(window); | - | ||||||||||||||||||||||||
818 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
819 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
820 | if (w
| 0 | ||||||||||||||||||||||||
821 | handleObscurity(w); never executed: handleObscurity(w); | 0 | ||||||||||||||||||||||||
822 | } never executed: end of block | 0 | ||||||||||||||||||||||||
823 | } | - | ||||||||||||||||||||||||
824 | - | |||||||||||||||||||||||||
825 | - | |||||||||||||||||||||||||
826 | - | |||||||||||||||||||||||||
827 | - | |||||||||||||||||||||||||
828 | - | |||||||||||||||||||||||||
829 | void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window) | - | ||||||||||||||||||||||||
830 | { | - | ||||||||||||||||||||||||
831 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 929, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "handleExposure()" << window; | 0 | ||||||||||||||||||||||||
832 | - | |||||||||||||||||||||||||
833 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
834 | if (!w
| 0 | ||||||||||||||||||||||||
835 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 933, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- adding window to list"); | 0 | ||||||||||||||||||||||||
836 | Window win; | - | ||||||||||||||||||||||||
837 | win.window = window; | - | ||||||||||||||||||||||||
838 | win.actualWindowFormat = window->format(); | - | ||||||||||||||||||||||||
839 | win.thread = new QSGRenderThread(this, QQuickWindowPrivate::get(window)->context); | - | ||||||||||||||||||||||||
840 | win.updateDuringSync = false; | - | ||||||||||||||||||||||||
841 | win.forceRenderPass = true; | - | ||||||||||||||||||||||||
842 | m_windows << win; | - | ||||||||||||||||||||||||
843 | w = &m_windows.last(); | - | ||||||||||||||||||||||||
844 | } never executed: end of block | 0 | ||||||||||||||||||||||||
845 | - | |||||||||||||||||||||||||
846 | - | |||||||||||||||||||||||||
847 | - | |||||||||||||||||||||||||
848 | w->thread->window = window; | - | ||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||
850 | if (w->window->width() <= 0
| 0 | ||||||||||||||||||||||||
851 | || (w->window->isTopLevel()
| 0 | ||||||||||||||||||||||||
852 | - | |||||||||||||||||||||||||
853 | QMessageLogger(__FILE__, 951, __PRETTY_FUNCTION__).warning().noquote().nospace() << "QSGThreadedRenderLoop: expose event received for window " | - | ||||||||||||||||||||||||
854 | << w->window << " with invalid geometry: " << w->window->geometry() | - | ||||||||||||||||||||||||
855 | << " on " << w->window->screen(); | - | ||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||
857 | } never executed: end of block | 0 | ||||||||||||||||||||||||
858 | - | |||||||||||||||||||||||||
859 | - | |||||||||||||||||||||||||
860 | - | |||||||||||||||||||||||||
861 | if (!w->window->handle()
| 0 | ||||||||||||||||||||||||
862 | w->window->create(); never executed: w->window->create(); | 0 | ||||||||||||||||||||||||
863 | - | |||||||||||||||||||||||||
864 | - | |||||||||||||||||||||||||
865 | if (!w->thread->isRunning()
| 0 | ||||||||||||||||||||||||
866 | - | |||||||||||||||||||||||||
867 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 965, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- starting render thread"); | 0 | ||||||||||||||||||||||||
868 | - | |||||||||||||||||||||||||
869 | if (!w->thread->gl
| 0 | ||||||||||||||||||||||||
870 | w->thread->gl = new QOpenGLContext(); | - | ||||||||||||||||||||||||
871 | if (qt_gl_global_share_context()
| 0 | ||||||||||||||||||||||||
872 | w->thread->gl->setShareContext(qt_gl_global_share_context()); never executed: w->thread->gl->setShareContext(qt_gl_global_share_context()); | 0 | ||||||||||||||||||||||||
873 | w->thread->gl->setFormat(w->window->requestedFormat()); | - | ||||||||||||||||||||||||
874 | w->thread->gl->setScreen(w->window->screen()); | - | ||||||||||||||||||||||||
875 | if (!w->thread->gl->create()
| 0 | ||||||||||||||||||||||||
876 | const bool isEs = w->thread->gl->isOpenGLES(); | - | ||||||||||||||||||||||||
877 | delete w->thread->gl; | - | ||||||||||||||||||||||||
878 | w->thread->gl = nullptr; | - | ||||||||||||||||||||||||
879 | handleContextCreationFailure(w->window, isEs); | - | ||||||||||||||||||||||||
880 | return; never executed: return; | 0 | ||||||||||||||||||||||||
881 | } | - | ||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||
883 | QQuickWindowPrivate::get(w->window)->fireOpenGLContextCreated(w->thread->gl); | - | ||||||||||||||||||||||||
884 | - | |||||||||||||||||||||||||
885 | w->thread->gl->moveToThread(w->thread); | - | ||||||||||||||||||||||||
886 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 984, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- OpenGL context created"); | 0 | ||||||||||||||||||||||||
887 | } never executed: end of block | 0 | ||||||||||||||||||||||||
888 | - | |||||||||||||||||||||||||
889 | QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; | - | ||||||||||||||||||||||||
890 | if (controller->thread() != w->thread
| 0 | ||||||||||||||||||||||||
891 | controller->moveToThread(w->thread); never executed: controller->moveToThread(w->thread); | 0 | ||||||||||||||||||||||||
892 | - | |||||||||||||||||||||||||
893 | w->thread->active = true; | - | ||||||||||||||||||||||||
894 | if (w->thread->thread() == QThread::currentThread()
| 0 | ||||||||||||||||||||||||
895 | w->thread->sgrc->moveToThread(w->thread); | - | ||||||||||||||||||||||||
896 | w->thread->moveToThread(w->thread); | - | ||||||||||||||||||||||||
897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
898 | w->thread->start(); | - | ||||||||||||||||||||||||
899 | if (!w->thread->isRunning()
| 0 | ||||||||||||||||||||||||
900 | QMessageLogger(__FILE__, 998, __PRETTY_FUNCTION__).fatal("Render thread failed to start, aborting application."); never executed: QMessageLogger(__FILE__, 998, __PRETTY_FUNCTION__).fatal("Render thread failed to start, aborting application."); | 0 | ||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||
902 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
903 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1001, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- render thread already running"); | 0 | ||||||||||||||||||||||||
904 | } never executed: end of block | 0 | ||||||||||||||||||||||||
905 | - | |||||||||||||||||||||||||
906 | polishAndSync(w, true); | - | ||||||||||||||||||||||||
907 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1005, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- done with handleExposure()"); | 0 | ||||||||||||||||||||||||
908 | - | |||||||||||||||||||||||||
909 | startOrStopAnimationTimer(); | - | ||||||||||||||||||||||||
910 | } never executed: end of block | 0 | ||||||||||||||||||||||||
911 | void QSGThreadedRenderLoop::handleObscurity(Window *w) | - | ||||||||||||||||||||||||
912 | { | - | ||||||||||||||||||||||||
913 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1019, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "handleObscurity()" << w->window; | 0 | ||||||||||||||||||||||||
914 | if (w->thread->isRunning()
| 0 | ||||||||||||||||||||||||
915 | w->thread->mutex.lock(); | - | ||||||||||||||||||||||||
916 | w->thread->postEvent(new WMWindowEvent(w->window, WM_Obscure)); | - | ||||||||||||||||||||||||
917 | w->thread->waitCondition.wait(&w->thread->mutex); | - | ||||||||||||||||||||||||
918 | w->thread->mutex.unlock(); | - | ||||||||||||||||||||||||
919 | } never executed: end of block | 0 | ||||||||||||||||||||||||
920 | startOrStopAnimationTimer(); | - | ||||||||||||||||||||||||
921 | } never executed: end of block | 0 | ||||||||||||||||||||||||
922 | - | |||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | void QSGThreadedRenderLoop::handleUpdateRequest(QQuickWindow *window) | - | ||||||||||||||||||||||||
925 | { | - | ||||||||||||||||||||||||
926 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1032, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- polish and sync update request"); | 0 | ||||||||||||||||||||||||
927 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
928 | if (w
| 0 | ||||||||||||||||||||||||
929 | polishAndSync(w); never executed: polishAndSync(w); | 0 | ||||||||||||||||||||||||
930 | } never executed: end of block | 0 | ||||||||||||||||||||||||
931 | - | |||||||||||||||||||||||||
932 | void QSGThreadedRenderLoop::maybeUpdate(QQuickWindow *window) | - | ||||||||||||||||||||||||
933 | { | - | ||||||||||||||||||||||||
934 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
935 | if (w
| 0 | ||||||||||||||||||||||||
936 | maybeUpdate(w); never executed: maybeUpdate(w); | 0 | ||||||||||||||||||||||||
937 | } never executed: end of block | 0 | ||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||
939 | - | |||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||
941 | - | |||||||||||||||||||||||||
942 | - | |||||||||||||||||||||||||
943 | void QSGThreadedRenderLoop::maybeUpdate(Window *w) | - | ||||||||||||||||||||||||
944 | { | - | ||||||||||||||||||||||||
945 | if (!QCoreApplication::instance()
| 0 | ||||||||||||||||||||||||
946 | return; never executed: return; | 0 | ||||||||||||||||||||||||
947 | - | |||||||||||||||||||||||||
948 | if (!w
| 0 | ||||||||||||||||||||||||
949 | return; never executed: return; | 0 | ||||||||||||||||||||||||
950 | - | |||||||||||||||||||||||||
951 | QThread *current = QThread::currentThread(); | - | ||||||||||||||||||||||||
952 | if (current != QCoreApplication::instance()->thread()
| 0 | ||||||||||||||||||||||||
953 | QMessageLogger(__FILE__, 1059, __PRETTY_FUNCTION__).warning() << "Updates can only be scheduled from GUI thread or from QQuickItem::updatePaintNode()"; | - | ||||||||||||||||||||||||
954 | return; never executed: return; | 0 | ||||||||||||||||||||||||
955 | } | - | ||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||
957 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1063, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "update from item" << w->window; | 0 | ||||||||||||||||||||||||
958 | - | |||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||
961 | if (current == w->thread
| 0 | ||||||||||||||||||||||||
962 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1068, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- on render thread"); | 0 | ||||||||||||||||||||||||
963 | w->updateDuringSync = true; | - | ||||||||||||||||||||||||
964 | return; never executed: return; | 0 | ||||||||||||||||||||||||
965 | } | - | ||||||||||||||||||||||||
966 | - | |||||||||||||||||||||||||
967 | maybePostPolishRequest(w); | - | ||||||||||||||||||||||||
968 | } never executed: end of block | 0 | ||||||||||||||||||||||||
969 | - | |||||||||||||||||||||||||
970 | - | |||||||||||||||||||||||||
971 | - | |||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | - | |||||||||||||||||||||||||
974 | - | |||||||||||||||||||||||||
975 | void QSGThreadedRenderLoop::update(QQuickWindow *window) | - | ||||||||||||||||||||||||
976 | { | - | ||||||||||||||||||||||||
977 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
978 | if (!w
| 0 | ||||||||||||||||||||||||
979 | return; never executed: return; | 0 | ||||||||||||||||||||||||
980 | - | |||||||||||||||||||||||||
981 | if (w->thread == QThread::currentThread()
| 0 | ||||||||||||||||||||||||
982 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1088, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "update on window - on render thread" << w->window; | 0 | ||||||||||||||||||||||||
983 | w->thread->requestRepaint(); | - | ||||||||||||||||||||||||
984 | return; never executed: return; | 0 | ||||||||||||||||||||||||
985 | } | - | ||||||||||||||||||||||||
986 | - | |||||||||||||||||||||||||
987 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1093, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "update on window" << w->window; | 0 | ||||||||||||||||||||||||
988 | - | |||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | w->forceRenderPass = true; | - | ||||||||||||||||||||||||
991 | maybeUpdate(w); | - | ||||||||||||||||||||||||
992 | } never executed: end of block | 0 | ||||||||||||||||||||||||
993 | - | |||||||||||||||||||||||||
994 | - | |||||||||||||||||||||||||
995 | void QSGThreadedRenderLoop::releaseResources(QQuickWindow *window) | - | ||||||||||||||||||||||||
996 | { | - | ||||||||||||||||||||||||
997 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
998 | if (w
| 0 | ||||||||||||||||||||||||
999 | releaseResources(w, false); never executed: releaseResources(w, false); | 0 | ||||||||||||||||||||||||
1000 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1001 | - | |||||||||||||||||||||||||
1002 | - | |||||||||||||||||||||||||
1003 | - | |||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||
1005 | - | |||||||||||||||||||||||||
1006 | void QSGThreadedRenderLoop::releaseResources(Window *w, bool inDestructor) | - | ||||||||||||||||||||||||
1007 | { | - | ||||||||||||||||||||||||
1008 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1114, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "releaseResources()" << (inDestructor ? "in destructor" : "in api-call") << w->window; | 0 | ||||||||||||||||||||||||
1009 | - | |||||||||||||||||||||||||
1010 | w->thread->mutex.lock(); | - | ||||||||||||||||||||||||
1011 | if (w->thread->isRunning()
| 0 | ||||||||||||||||||||||||
1012 | QQuickWindow *window = w->window; | - | ||||||||||||||||||||||||
1013 | - | |||||||||||||||||||||||||
1014 | - | |||||||||||||||||||||||||
1015 | - | |||||||||||||||||||||||||
1016 | - | |||||||||||||||||||||||||
1017 | - | |||||||||||||||||||||||||
1018 | - | |||||||||||||||||||||||||
1019 | - | |||||||||||||||||||||||||
1020 | QOffscreenSurface *fallback = nullptr; | - | ||||||||||||||||||||||||
1021 | if (!window->handle()
| 0 | ||||||||||||||||||||||||
1022 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1128, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- using fallback surface"); | 0 | ||||||||||||||||||||||||
1023 | fallback = new QOffscreenSurface(); | - | ||||||||||||||||||||||||
1024 | fallback->setFormat(w->actualWindowFormat); | - | ||||||||||||||||||||||||
1025 | fallback->create(); | - | ||||||||||||||||||||||||
1026 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1027 | - | |||||||||||||||||||||||||
1028 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1134, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- posting release request to render thread"); | 0 | ||||||||||||||||||||||||
1029 | w->thread->postEvent(new WMTryReleaseEvent(window, inDestructor, fallback)); | - | ||||||||||||||||||||||||
1030 | w->thread->waitCondition.wait(&w->thread->mutex); | - | ||||||||||||||||||||||||
1031 | delete fallback; | - | ||||||||||||||||||||||||
1032 | - | |||||||||||||||||||||||||
1033 | - | |||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | - | |||||||||||||||||||||||||
1036 | - | |||||||||||||||||||||||||
1037 | - | |||||||||||||||||||||||||
1038 | - | |||||||||||||||||||||||||
1039 | if (!w->thread->active
| 0 | ||||||||||||||||||||||||
1040 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1146, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << " - waiting for render thread to exit" << w->window; | 0 | ||||||||||||||||||||||||
1041 | w->thread->wait(); | - | ||||||||||||||||||||||||
1042 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1148, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << " - render thread finished" << w->window; | 0 | ||||||||||||||||||||||||
1043 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1044 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1045 | w->thread->mutex.unlock(); | - | ||||||||||||||||||||||||
1046 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | - | |||||||||||||||||||||||||
1050 | - | |||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) | - | ||||||||||||||||||||||||
1053 | { | - | ||||||||||||||||||||||||
1054 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1160, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "polishAndSync" << (inExpose ? "(in expose)" : "(normal)") << w->window; | 0 | ||||||||||||||||||||||||
1055 | - | |||||||||||||||||||||||||
1056 | QQuickWindow *window = w->window; | - | ||||||||||||||||||||||||
1057 | if (!w->thread
| 0 | ||||||||||||||||||||||||
1058 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1164, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- not exposed, abort"); | 0 | ||||||||||||||||||||||||
1059 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1060 | } | - | ||||||||||||||||||||||||
1061 | - | |||||||||||||||||||||||||
1062 | - | |||||||||||||||||||||||||
1063 | QQuickWindowPrivate::get(window)->flushFrameSynchronousEvents(); | - | ||||||||||||||||||||||||
1064 | - | |||||||||||||||||||||||||
1065 | w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
1066 | if (!w
| 0 | ||||||||||||||||||||||||
1067 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1173, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- removed after event flushing, abort"); | 0 | ||||||||||||||||||||||||
1068 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1069 | } | - | ||||||||||||||||||||||||
1070 | - | |||||||||||||||||||||||||
1071 | - | |||||||||||||||||||||||||
1072 | QElapsedTimer timer; | - | ||||||||||||||||||||||||
1073 | qint64 polishTime = 0; | - | ||||||||||||||||||||||||
1074 | qint64 waitTime = 0; | - | ||||||||||||||||||||||||
1075 | qint64 syncTime = 0; | - | ||||||||||||||||||||||||
1076 | bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); | - | ||||||||||||||||||||||||
1077 | if (profileFrames
| 0 | ||||||||||||||||||||||||
1078 | timer.start(); never executed: timer.start(); | 0 | ||||||||||||||||||||||||
1079 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0;(void)0; never executed: (void)0; | 0 | ||||||||||||||||||||||||
1080 | - | |||||||||||||||||||||||||
1081 | QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
1082 | d->polishItems(); | - | ||||||||||||||||||||||||
1083 | - | |||||||||||||||||||||||||
1084 | if (profileFrames
| 0 | ||||||||||||||||||||||||
1085 | polishTime = timer.nsecsElapsed(); never executed: polishTime = timer.nsecsElapsed(); | 0 | ||||||||||||||||||||||||
1086 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1087 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | w->updateDuringSync = false; | - | ||||||||||||||||||||||||
1090 | - | |||||||||||||||||||||||||
1091 | window->afterAnimating(); | - | ||||||||||||||||||||||||
1092 | - | |||||||||||||||||||||||||
1093 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1199, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- lock for sync"); | 0 | ||||||||||||||||||||||||
1094 | w->thread->mutex.lock(); | - | ||||||||||||||||||||||||
1095 | m_lockedForSync = true; | - | ||||||||||||||||||||||||
1096 | w->thread->postEvent(new WMSyncEvent(window, inExpose, w->forceRenderPass)); | - | ||||||||||||||||||||||||
1097 | w->forceRenderPass = false; | - | ||||||||||||||||||||||||
1098 | - | |||||||||||||||||||||||||
1099 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1205, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- wait for sync"); | 0 | ||||||||||||||||||||||||
1100 | if (profileFrames
| 0 | ||||||||||||||||||||||||
1101 | waitTime = timer.nsecsElapsed(); never executed: waitTime = timer.nsecsElapsed(); | 0 | ||||||||||||||||||||||||
1102 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1103 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1104 | w->thread->waitCondition.wait(&w->thread->mutex); | - | ||||||||||||||||||||||||
1105 | m_lockedForSync = false; | - | ||||||||||||||||||||||||
1106 | w->thread->mutex.unlock(); | - | ||||||||||||||||||||||||
1107 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1213, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- unlock after sync"); | 0 | ||||||||||||||||||||||||
1108 | - | |||||||||||||||||||||||||
1109 | if (profileFrames
| 0 | ||||||||||||||||||||||||
1110 | syncTime = timer.nsecsElapsed(); never executed: syncTime = timer.nsecsElapsed(); | 0 | ||||||||||||||||||||||||
1111 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1112 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1113 | - | |||||||||||||||||||||||||
1114 | if (m_animation_timer == 0
| 0 | ||||||||||||||||||||||||
1115 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1221, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- advancing animations"); | 0 | ||||||||||||||||||||||||
1116 | m_animation_driver->advance(); | - | ||||||||||||||||||||||||
1117 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1223, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- animations done.."); | 0 | ||||||||||||||||||||||||
1118 | - | |||||||||||||||||||||||||
1119 | maybePostPolishRequest(w); | - | ||||||||||||||||||||||||
1120 | timeToIncubate(); | - | ||||||||||||||||||||||||
1121 | } never executed: else if (w->updateDuringSyncend of block
| 0 | ||||||||||||||||||||||||
1122 | maybePostPolishRequest(w); | - | ||||||||||||||||||||||||
1123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1124 | - | |||||||||||||||||||||||||
1125 | for (bool qt_category_enabled = QSG_LOG_TIME_RENDERLOOP()().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1126 | << "Frame prepared with 'threaded' renderloop" never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1127 | << ", polish=" << (polishTime / 1000000) never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1128 | << ", lock=" << (waitTime - polishTime) / 1000000 never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1129 | << ", blockedForSync=" << (syncTime - waitTime) / 1000000 never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1130 | << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1131 | << " - (on Gui thread) " << window; never executed: QMessageLogger(__FILE__, 1231, __PRETTY_FUNCTION__, QSG_LOG_TIME_RENDERLOOP()().categoryName()).debug().nospace() << "Frame prepared with 'threaded' renderloop" << ", polish=" << (polishTime / 1000000) << ", lock=" << (waitTime - polishTime) / 1000000 << ", blockedForSync=" << (syncTime - waitTime) / 1000000 << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; | 0 | ||||||||||||||||||||||||
1132 | - | |||||||||||||||||||||||||
1133 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1134 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||||||||
1135 | } | - | ||||||||||||||||||||||||
1136 | - | |||||||||||||||||||||||||
1137 | bool QSGThreadedRenderLoop::event(QEvent *e) | - | ||||||||||||||||||||||||
1138 | { | - | ||||||||||||||||||||||||
1139 | switch ((int) e->type()) { | - | ||||||||||||||||||||||||
1140 | - | |||||||||||||||||||||||||
1141 | case never executed: QEvent::Timer:case QEvent::Timer: never executed: {case QEvent::Timer: | 0 | ||||||||||||||||||||||||
1142 | QTimerEvent *te = static_cast<QTimerEvent *>(e); | - | ||||||||||||||||||||||||
1143 | if (te->timerId() == m_animation_timer
| 0 | ||||||||||||||||||||||||
1144 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1250, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- ticking non-visual timer"); | 0 | ||||||||||||||||||||||||
1145 | m_animation_driver->advance(); | - | ||||||||||||||||||||||||
1146 | timeToIncubate(); | - | ||||||||||||||||||||||||
1147 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1148 | } | - | ||||||||||||||||||||||||
1149 | } | - | ||||||||||||||||||||||||
1150 | - | |||||||||||||||||||||||||
1151 | default never executed: :default: never executed: default: code before this statement never executed: default: | 0 | ||||||||||||||||||||||||
1152 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1153 | } | - | ||||||||||||||||||||||||
1154 | - | |||||||||||||||||||||||||
1155 | return never executed: QObject::event(e);return QObject::event(e); never executed: return QObject::event(e); | 0 | ||||||||||||||||||||||||
1156 | } | - | ||||||||||||||||||||||||
1157 | QImage QSGThreadedRenderLoop::grab(QQuickWindow *window) | - | ||||||||||||||||||||||||
1158 | { | - | ||||||||||||||||||||||||
1159 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1278, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug() << "grab()" << window; | 0 | ||||||||||||||||||||||||
1160 | - | |||||||||||||||||||||||||
1161 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
1162 | ((w) ? static_cast<void>(0) : qt_assert("w", __FILE__, 1281)); | - | ||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | if (!w->thread->isRunning()
| 0 | ||||||||||||||||||||||||
1165 | return never executed: QImage();return QImage(); never executed: return QImage(); | 0 | ||||||||||||||||||||||||
1166 | - | |||||||||||||||||||||||||
1167 | if (!window->handle()
| 0 | ||||||||||||||||||||||||
1168 | window->create(); never executed: window->create(); | 0 | ||||||||||||||||||||||||
1169 | - | |||||||||||||||||||||||||
1170 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1289, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- polishing items"); | 0 | ||||||||||||||||||||||||
1171 | QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); | - | ||||||||||||||||||||||||
1172 | d->polishItems(); | - | ||||||||||||||||||||||||
1173 | - | |||||||||||||||||||||||||
1174 | QImage result; | - | ||||||||||||||||||||||||
1175 | w->thread->mutex.lock(); | - | ||||||||||||||||||||||||
1176 | m_lockedForSync = true; | - | ||||||||||||||||||||||||
1177 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1296, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- posting grab event"); | 0 | ||||||||||||||||||||||||
1178 | w->thread->postEvent(new WMGrabEvent(window, &result)); | - | ||||||||||||||||||||||||
1179 | w->thread->waitCondition.wait(&w->thread->mutex); | - | ||||||||||||||||||||||||
1180 | m_lockedForSync = false; | - | ||||||||||||||||||||||||
1181 | w->thread->mutex.unlock(); | - | ||||||||||||||||||||||||
1182 | - | |||||||||||||||||||||||||
1183 | for (bool qt_category_enabled = QSG_LOG_RENDERLOOP().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger(__FILE__, 1302, __PRETTY_FUNCTION__, QSG_LOG_RENDERLOOP().categoryName()).debug("- grab complete"); | 0 | ||||||||||||||||||||||||
1184 | - | |||||||||||||||||||||||||
1185 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||
1186 | } | - | ||||||||||||||||||||||||
1187 | - | |||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | - | |||||||||||||||||||||||||
1190 | - | |||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | void QSGThreadedRenderLoop::postJob(QQuickWindow *window, QRunnable *job) | - | ||||||||||||||||||||||||
1193 | { | - | ||||||||||||||||||||||||
1194 | Window *w = windowFor(m_windows, window); | - | ||||||||||||||||||||||||
1195 | if (w
| 0 | ||||||||||||||||||||||||
1196 | w->thread->postEvent(new WMJobEvent(window, job)); never executed: w->thread->postEvent(new WMJobEvent(window, job)); | 0 | ||||||||||||||||||||||||
1197 | else | - | ||||||||||||||||||||||||
1198 | delete job; never executed: delete job; | 0 | ||||||||||||||||||||||||
1199 | } | - | ||||||||||||||||||||||||
1200 | - | |||||||||||||||||||||||||
1201 | - | |||||||||||||||||||||||||
1202 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |