1// Copyright (C) 2020 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 QQUICKGRAPHICSDEVICE_H
5#define QQUICKGRAPHICSDEVICE_H
6
7#include <QtQuick/qtquickglobal.h>
8
9#if QT_CONFIG(vulkan)
10#include <QtGui/qvulkaninstance.h>
11#endif
12
13#if QT_CONFIG(metal) || defined(Q_QDOC)
14Q_FORWARD_DECLARE_OBJC_CLASS(MTLDevice);
15Q_FORWARD_DECLARE_OBJC_CLASS(MTLCommandQueue);
16#endif
17
18QT_BEGIN_NAMESPACE
19
20class QQuickGraphicsDevicePrivate;
21class QOpenGLContext;
22class QRhi;
23class QRhiAdapter;
24
25class Q_QUICK_EXPORT QQuickGraphicsDevice
26{
27public:
28 QQuickGraphicsDevice();
29 ~QQuickGraphicsDevice();
30 QQuickGraphicsDevice(const QQuickGraphicsDevice &other);
31 QQuickGraphicsDevice &operator=(const QQuickGraphicsDevice &other);
32
33 bool isNull() const;
34
35#if QT_CONFIG(opengl) || defined(Q_QDOC)
36 static QQuickGraphicsDevice fromOpenGLContext(QOpenGLContext *context);
37#endif
38
39#if defined(Q_OS_WIN) || defined(Q_QDOC)
40 static QQuickGraphicsDevice fromAdapter(quint32 adapterLuidLow, qint32 adapterLuidHigh, int featureLevel = 0);
41 static QQuickGraphicsDevice fromDeviceAndContext(void *device, void *context);
42#endif
43
44#if QT_CONFIG(metal) || defined(Q_QDOC)
45 static QQuickGraphicsDevice fromDeviceAndCommandQueue(MTLDevice *device, MTLCommandQueue *commandQueue);
46#endif
47
48#if QT_CONFIG(vulkan) || defined(Q_QDOC)
49 static QQuickGraphicsDevice fromPhysicalDevice(VkPhysicalDevice physicalDevice);
50 static QQuickGraphicsDevice fromDeviceObjects(VkPhysicalDevice physicalDevice, VkDevice device, int queueFamilyIndex, int queueIndex = 0);
51#endif
52
53 static QQuickGraphicsDevice fromRhi(QRhi *rhi);
54 static QQuickGraphicsDevice fromRhiAdapter(QRhiAdapter *adapter);
55
56private:
57 void detach();
58 QQuickGraphicsDevicePrivate *d;
59 friend class QQuickGraphicsDevicePrivate;
60};
61
62QT_END_NAMESPACE
63
64#endif // QQUICKGRAPHICSDEVICE_H
65

source code of qtdeclarative/src/quick/items/qquickgraphicsdevice.h