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
4#ifndef QQUICKGRAPHICSINFO_P_H
5#define QQUICKGRAPHICSINFO_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/qobject.h>
19#include <QtCore/qpointer.h>
20#include <QtQml/qqml.h>
21#include <QtGui/qsurfaceformat.h>
22#include <QtQuick/qsgrendererinterface.h>
23#include <QtCore/private/qglobal_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QQuickItem;
28class QQuickWindow;
29
30class QQuickGraphicsInfo : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY(GraphicsApi api READ api NOTIFY apiChanged FINAL)
34 Q_PROPERTY(ShaderType shaderType READ shaderType NOTIFY shaderTypeChanged FINAL)
35 Q_PROPERTY(ShaderCompilationType shaderCompilationType READ shaderCompilationType NOTIFY shaderCompilationTypeChanged FINAL)
36 Q_PROPERTY(ShaderSourceType shaderSourceType READ shaderSourceType NOTIFY shaderSourceTypeChanged FINAL)
37
38 Q_PROPERTY(int majorVersion READ majorVersion NOTIFY majorVersionChanged FINAL)
39 Q_PROPERTY(int minorVersion READ minorVersion NOTIFY minorVersionChanged FINAL)
40 Q_PROPERTY(OpenGLContextProfile profile READ profile NOTIFY profileChanged FINAL)
41 Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
42
43 QML_NAMED_ELEMENT(GraphicsInfo)
44 QML_ADDED_IN_VERSION(2, 8)
45 QML_UNCREATABLE("GraphicsInfo is only available via attached properties.")
46 QML_ATTACHED(QQuickGraphicsInfo)
47
48public:
49 enum GraphicsApi {
50 Unknown = QSGRendererInterface::Unknown,
51 Software = QSGRendererInterface::Software,
52 OpenVG = QSGRendererInterface::OpenVG,
53 OpenGL = QSGRendererInterface::OpenGL,
54 Direct3D11 = QSGRendererInterface::Direct3D11,
55 Vulkan = QSGRendererInterface::Vulkan,
56 Metal = QSGRendererInterface::Metal,
57 Null = QSGRendererInterface::Null,
58 Direct3D12 = QSGRendererInterface::Direct3D12,
59
60 OpenGLRhi = QSGRendererInterface::OpenGLRhi,
61 Direct3D11Rhi = QSGRendererInterface::Direct3D11Rhi,
62 VulkanRhi = QSGRendererInterface::VulkanRhi,
63 MetalRhi = QSGRendererInterface::MetalRhi,
64 NullRhi = QSGRendererInterface::NullRhi
65 };
66 Q_ENUM(GraphicsApi)
67
68 enum ShaderType {
69 UnknownShadingLanguage = QSGRendererInterface::UnknownShadingLanguage,
70 GLSL = QSGRendererInterface::GLSL,
71 HLSL = QSGRendererInterface::HLSL,
72 RhiShader = QSGRendererInterface::RhiShader
73 };
74 Q_ENUM(ShaderType)
75
76 enum ShaderCompilationType {
77 RuntimeCompilation = QSGRendererInterface::RuntimeCompilation,
78 OfflineCompilation = QSGRendererInterface::OfflineCompilation
79 };
80 Q_ENUM(ShaderCompilationType)
81
82 enum ShaderSourceType {
83 ShaderSourceString = QSGRendererInterface::ShaderSourceString,
84 ShaderSourceFile = QSGRendererInterface::ShaderSourceFile,
85 ShaderByteCode = QSGRendererInterface::ShaderByteCode
86 };
87 Q_ENUM(ShaderSourceType)
88
89 enum OpenGLContextProfile {
90 OpenGLNoProfile = QSurfaceFormat::NoProfile,
91 OpenGLCoreProfile = QSurfaceFormat::CoreProfile,
92 OpenGLCompatibilityProfile = QSurfaceFormat::CompatibilityProfile
93 };
94 Q_ENUM(OpenGLContextProfile)
95
96 enum RenderableType {
97 SurfaceFormatUnspecified = QSurfaceFormat::DefaultRenderableType,
98 SurfaceFormatOpenGL = QSurfaceFormat::OpenGL,
99 SurfaceFormatOpenGLES = QSurfaceFormat::OpenGLES
100 };
101 Q_ENUM(RenderableType)
102
103 QQuickGraphicsInfo(QQuickItem *item = nullptr);
104
105 static QQuickGraphicsInfo *qmlAttachedProperties(QObject *object);
106
107 GraphicsApi api() const { return m_api; }
108 ShaderType shaderType() const { return m_shaderType; }
109 ShaderCompilationType shaderCompilationType() const { return m_shaderCompilationType; }
110 ShaderSourceType shaderSourceType() const { return m_shaderSourceType; }
111
112 int majorVersion() const { return m_majorVersion; }
113 int minorVersion() const { return m_minorVersion; }
114 OpenGLContextProfile profile() const { return m_profile; }
115 RenderableType renderableType() const { return m_renderableType; }
116
117Q_SIGNALS:
118 void apiChanged();
119 void shaderTypeChanged();
120 void shaderCompilationTypeChanged();
121 void shaderSourceTypeChanged();
122
123 void majorVersionChanged();
124 void minorVersionChanged();
125 void profileChanged();
126 void renderableTypeChanged();
127
128private Q_SLOTS:
129 void updateInfo();
130 void setWindow(QQuickWindow *window);
131
132private:
133 QPointer<QQuickWindow> m_window;
134 GraphicsApi m_api;
135 ShaderType m_shaderType;
136 ShaderCompilationType m_shaderCompilationType;
137 ShaderSourceType m_shaderSourceType;
138 int m_majorVersion;
139 int m_minorVersion;
140 OpenGLContextProfile m_profile;
141 RenderableType m_renderableType;
142};
143
144QT_END_NAMESPACE
145
146#endif // QQUICKGRAPHICSINFO_P_H
147

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