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 QSGSOFTWARETHREADEDRENDERLOOP_H
5#define QSGSOFTWARETHREADEDRENDERLOOP_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 <private/qsgrenderloop_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class QSGSoftwareRenderThread;
23class QSGSoftwareContext;
24
25class QSGSoftwareThreadedRenderLoop : public QSGRenderLoop
26{
27 Q_OBJECT
28public:
29 QSGSoftwareThreadedRenderLoop();
30 ~QSGSoftwareThreadedRenderLoop();
31
32 void show(QQuickWindow *window) override;
33 void hide(QQuickWindow *window) override;
34 void resize(QQuickWindow *window) override;
35 void windowDestroyed(QQuickWindow *window) override;
36 void exposureChanged(QQuickWindow *window) override;
37 QImage grab(QQuickWindow *window) override;
38 void update(QQuickWindow *window) override;
39 void maybeUpdate(QQuickWindow *window) override;
40 void handleUpdateRequest(QQuickWindow *window) override;
41 QAnimationDriver *animationDriver() const override;
42 QSGContext *sceneGraphContext() const override;
43 QSGRenderContext *createRenderContext(QSGContext *) const override;
44 void releaseResources(QQuickWindow *window) override;
45 void postJob(QQuickWindow *window, QRunnable *job) override;
46 QSurface::SurfaceType windowSurfaceType() const override;
47 bool interleaveIncubation() const override;
48 int flags() const override;
49
50 bool event(QEvent *e) override;
51
52public Q_SLOTS:
53 void onAnimationStarted();
54 void onAnimationStopped();
55
56private:
57 struct WindowData {
58 QQuickWindow *window;
59 QSGSoftwareRenderThread *thread;
60 uint updateDuringSync : 1;
61 uint forceRenderPass : 1;
62 };
63
64 WindowData *windowFor(QQuickWindow *window);
65
66 void startOrStopAnimationTimer();
67 void handleExposure(QQuickWindow *window);
68 void handleObscurity(WindowData *w);
69 void scheduleUpdate(WindowData *w);
70 void handleResourceRelease(WindowData *w, bool destroying);
71 void polishAndSync(WindowData *w, bool inExpose);
72
73 QSGSoftwareContext *m_sg;
74 QAnimationDriver *m_anim;
75 int animationTimer = 0;
76 bool lockedForSync = false;
77 QList<WindowData> m_windows;
78
79 friend class QSGSoftwareRenderThread;
80};
81
82QT_END_NAMESPACE
83
84#endif // QSGSOFTWARETHREADEDRENDERLOOP_H
85

source code of qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop_p.h