Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgthreadedrenderloop_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSGTHREADEDRENDERLOOP_P_H
5#define QSGTHREADEDRENDERLOOP_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QThread>
19#include <QtCore/QElapsedTimer>
20#include <private/qsgcontext_p.h>
21
23
25
26class QSGRenderThread;
27
29{
31public:
34
35 void show(QQuickWindow *) override {}
36 void hide(QQuickWindow *) override;
37 void resize(QQuickWindow *window) override;
38
39 void windowDestroyed(QQuickWindow *window) override;
40 void exposureChanged(QQuickWindow *window) override;
41
42 QImage grab(QQuickWindow *) override;
43
44 void update(QQuickWindow *window) override;
45 void maybeUpdate(QQuickWindow *window) override;
46 void handleUpdateRequest(QQuickWindow *window) override;
47
48 QSGContext *sceneGraphContext() const override;
49 QSGRenderContext *createRenderContext(QSGContext *) const override;
50
51 QAnimationDriver *animationDriver() const override;
52
53 void releaseResources(QQuickWindow *window) override;
54
55 bool event(QEvent *) override;
56 void postJob(QQuickWindow *window, QRunnable *job) override;
57
58 bool interleaveIncubation() const override;
59
60public Q_SLOTS:
61 void animationStarted();
62 void animationStopped();
63
64private:
65 struct Window {
66 QQuickWindow *window;
67 QSGRenderThread *thread;
68 QSurfaceFormat actualWindowFormat;
69 QElapsedTimer timeBetweenPolishAndSyncs;
70 float psTimeAccumulator;
71 int psTimeSampleCount;
72 uint updateDuringSync : 1;
73 uint forceRenderPass : 1;
74 uint badVSync : 1;
75 };
76
77 friend class QSGRenderThread;
78
79
80 Window *windowFor(QQuickWindow *window);
81 void releaseResources(Window *window, bool inDestructor);
82 bool checkAndResetForceUpdate(QQuickWindow *window);
83
84 bool anyoneShowing() const;
85 void initialize();
86
87 void startOrStopAnimationTimer();
88 void postUpdateRequest(Window *w);
89 void waitForReleaseComplete();
90 void polishAndSync(Window *w, bool inExpose = false);
91 void maybeUpdate(Window *window);
92
93 void handleExposure(QQuickWindow *w);
94 void handleObscurity(Window *w);
95 void releaseSwapchain(QQuickWindow *window);
96
97 bool eventFilter(QObject *watched, QEvent *event) override;
98
99 QSGContext *sg;
100 // Set of contexts that have been created but are now owned by
101 // a rendering thread yet, as the window has never been exposed.
102 mutable QSet<QSGRenderContext*> pendingRenderContexts;
103 QAnimationDriver *m_animation_driver;
104 QList<Window> m_windows;
105
106 int m_animation_timer;
107
108 bool m_lockedForSync;
109 bool m_inPolish = false;
110};
111
112QT_END_NAMESPACE
113
114#endif // QSGTHREADEDRENDERLOOP_P_H
QAnimationDriver * animationDriver() const override
void update(QQuickWindow *window) override
void renderWindow(QQuickWindow *window)
void releaseSwapchain(QQuickWindow *window)
void show(QQuickWindow *window) override
bool eventFilter(QObject *watched, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
QSGRenderContext * createRenderContext(QSGContext *) const override
void windowDestroyed(QQuickWindow *window) override
bool ensureRhi(QQuickWindow *window, WindowData &data)
QOffscreenSurface * offscreenSurface
void releaseResources(QQuickWindow *) override
void exposureChanged(QQuickWindow *window) override
QSGContext * sceneGraphContext() const override
QHash< QQuickWindow *, WindowData > m_windows
QSet< QSGRenderContext * > pendingRenderContexts
void handleUpdateRequest(QQuickWindow *) override
void hide(QQuickWindow *window) override
QImage grab(QQuickWindow *window) override
void maybeUpdate(QQuickWindow *window) override
bool interleaveIncubation() const override
bool event(QEvent *) override
This virtual function receives events to an object and should return true if the event e was recogniz...
QImage grab(QQuickWindow *) override
QSGRenderContext * createRenderContext(QSGContext *) const override
void show(QQuickWindow *) override
bool eventFilter(QObject *watched, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void postJob(QQuickWindow *window, QRunnable *job) override
QSGContext * sceneGraphContext() const override
void resize(QQuickWindow *window) override
void update(QQuickWindow *window) override
void handleUpdateRequest(QQuickWindow *window) override
QAnimationDriver * animationDriver() const override
void maybeUpdate(QQuickWindow *window) override
void exposureChanged(QQuickWindow *window) override
void releaseResources(QQuickWindow *window) override
void hide(QQuickWindow *) override
void windowDestroyed(QQuickWindow *window) override
bool qsg_useConsistentTiming()
#define ENABLE_DEFAULT_BACKEND
QSGRenderLoopType
@ BasicRenderLoop
@ ThreadedRenderLoop
QSGCustomEvents
@ WM_Exposed
@ WM_Obscure
@ WM_Grab
@ WM_PostJob
@ WM_TryRelease
@ WM_ReleaseSwapchain
@ WM_RequestSync
DEFINE_BOOL_CONFIG_OPTION(forceDiskCache, QML_FORCE_DISK_CACHE)