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
qbackingstorerhisupport_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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// Qt-Security score:significant reason:default
4
5#ifndef QBACKINGSTORERHISUPPORT_P_H
6#define QBACKINGSTORERHISUPPORT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20#include <QtGui/qwindow.h>
21#include <QtGui/qsurfaceformat.h>
22#include <QtGui/qoffscreensurface.h>
23#include <rhi/qrhi.h>
24#include <qpa/qplatformbackingstore.h>
25
27
28class Q_GUI_EXPORT QBackingStoreRhiSupport
29{
30public:
31 ~QBackingStoreRhiSupport();
32
33 void reset();
34
35 void setFormat(const QSurfaceFormat &format) { m_format = format; }
36 void setWindow(QWindow *window) { m_window = window; }
37 void setConfig(const QPlatformBackingStoreRhiConfig &config) { m_config = config; }
38
39 bool create();
40
41 QRhiSwapChain *swapChainForWindow(QWindow *window);
42
43 static QSurface::SurfaceType surfaceTypeForConfig(const QPlatformBackingStoreRhiConfig &config);
44
45 static bool checkForceRhi(QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType);
46
47 static QRhi::Implementation apiToRhiBackend(QPlatformBackingStoreRhiConfig::Api api);
48
49 QRhi *rhi() const { return m_rhi; }
50
51private:
52 QSurfaceFormat m_format;
53 QWindow *m_window = nullptr;
54 QPlatformBackingStoreRhiConfig m_config;
55 QRhi *m_rhi = nullptr;
56 QOffscreenSurface *m_openGLFallbackSurface = nullptr;
57 struct SwapchainData {
58 QRhiSwapChain *swapchain = nullptr;
59 QRhiRenderPassDescriptor *renderPassDescriptor = nullptr;
60 QObject *windowWatcher = nullptr;
61 void reset();
62 };
63 QHash<QWindow *, SwapchainData> m_swapchains;
64 friend class QBackingStoreRhiSupportWindowWatcher;
65};
66
68{
69public:
70 QBackingStoreRhiSupportWindowWatcher(QBackingStoreRhiSupport *rhiSupport) : m_rhiSupport(rhiSupport) { }
71 bool eventFilter(QObject *obj, QEvent *ev) override;
72private:
73 QBackingStoreRhiSupport *m_rhiSupport;
74};
75
76QT_END_NAMESPACE
77
78#endif // QBACKINGSTORERHISUPPORT_P_H
QBackingStoreRhiSupportWindowWatcher(QBackingStoreRhiSupport *rhiSupport)
bool eventFilter(QObject *obj, QEvent *ev) override
Filters events if this object has been installed as an event filter for the watched object.
Combined button and popup list for selecting options.