1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQuick module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQUICKGRAPHICSINFO_P_H
41#define QQUICKGRAPHICSINFO_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtCore/qobject.h>
55#include <QtCore/qpointer.h>
56#include <QtQml/qqml.h>
57#include <QtGui/qsurfaceformat.h>
58#include <QtQuick/qsgrendererinterface.h>
59
60QT_BEGIN_NAMESPACE
61
62class QQuickItem;
63class QQuickWindow;
64
65class QQuickGraphicsInfo : public QObject
66{
67 Q_OBJECT
68 Q_PROPERTY(GraphicsApi api READ api NOTIFY apiChanged FINAL)
69 Q_PROPERTY(ShaderType shaderType READ shaderType NOTIFY shaderTypeChanged FINAL)
70 Q_PROPERTY(ShaderCompilationType shaderCompilationType READ shaderCompilationType NOTIFY shaderCompilationTypeChanged FINAL)
71 Q_PROPERTY(ShaderSourceType shaderSourceType READ shaderSourceType NOTIFY shaderSourceTypeChanged FINAL)
72
73 Q_PROPERTY(int majorVersion READ majorVersion NOTIFY majorVersionChanged FINAL)
74 Q_PROPERTY(int minorVersion READ minorVersion NOTIFY minorVersionChanged FINAL)
75 Q_PROPERTY(OpenGLContextProfile profile READ profile NOTIFY profileChanged FINAL)
76 Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
77
78 QML_NAMED_ELEMENT(GraphicsInfo)
79 QML_ADDED_IN_MINOR_VERSION(8)
80 QML_UNCREATABLE("GraphicsInfo is only available via attached properties.")
81 QML_ATTACHED(QQuickGraphicsInfo)
82
83public:
84 enum GraphicsApi {
85 Unknown = QSGRendererInterface::Unknown,
86 Software = QSGRendererInterface::Software,
87 OpenGL = QSGRendererInterface::OpenGL,
88 Direct3D12 = QSGRendererInterface::Direct3D12,
89 OpenVG = QSGRendererInterface::OpenVG,
90 OpenGLRhi = QSGRendererInterface::OpenGLRhi,
91 Direct3D11Rhi = QSGRendererInterface::Direct3D11Rhi,
92 VulkanRhi = QSGRendererInterface::VulkanRhi,
93 MetalRhi = QSGRendererInterface::MetalRhi,
94 NullRhi = QSGRendererInterface::NullRhi
95 };
96 Q_ENUM(GraphicsApi)
97
98 enum ShaderType {
99 UnknownShadingLanguage = QSGRendererInterface::UnknownShadingLanguage,
100 GLSL = QSGRendererInterface::GLSL,
101 HLSL = QSGRendererInterface::HLSL,
102 RhiShader = QSGRendererInterface::RhiShader
103 };
104 Q_ENUM(ShaderType)
105
106 enum ShaderCompilationType {
107 RuntimeCompilation = QSGRendererInterface::RuntimeCompilation,
108 OfflineCompilation = QSGRendererInterface::OfflineCompilation
109 };
110 Q_ENUM(ShaderCompilationType)
111
112 enum ShaderSourceType {
113 ShaderSourceString = QSGRendererInterface::ShaderSourceString,
114 ShaderSourceFile = QSGRendererInterface::ShaderSourceFile,
115 ShaderByteCode = QSGRendererInterface::ShaderByteCode
116 };
117 Q_ENUM(ShaderSourceType)
118
119 enum OpenGLContextProfile {
120 OpenGLNoProfile = QSurfaceFormat::NoProfile,
121 OpenGLCoreProfile = QSurfaceFormat::CoreProfile,
122 OpenGLCompatibilityProfile = QSurfaceFormat::CompatibilityProfile
123 };
124 Q_ENUM(OpenGLContextProfile)
125
126 enum RenderableType {
127 SurfaceFormatUnspecified = QSurfaceFormat::DefaultRenderableType,
128 SurfaceFormatOpenGL = QSurfaceFormat::OpenGL,
129 SurfaceFormatOpenGLES = QSurfaceFormat::OpenGLES
130 };
131 Q_ENUM(RenderableType)
132
133 QQuickGraphicsInfo(QQuickItem *item = 0);
134
135 static QQuickGraphicsInfo *qmlAttachedProperties(QObject *object);
136
137 GraphicsApi api() const { return m_api; }
138 ShaderType shaderType() const { return m_shaderType; }
139 ShaderCompilationType shaderCompilationType() const { return m_shaderCompilationType; }
140 ShaderSourceType shaderSourceType() const { return m_shaderSourceType; }
141
142 int majorVersion() const { return m_majorVersion; }
143 int minorVersion() const { return m_minorVersion; }
144 OpenGLContextProfile profile() const { return m_profile; }
145 RenderableType renderableType() const { return m_renderableType; }
146
147Q_SIGNALS:
148 void apiChanged();
149 void shaderTypeChanged();
150 void shaderCompilationTypeChanged();
151 void shaderSourceTypeChanged();
152
153 void majorVersionChanged();
154 void minorVersionChanged();
155 void profileChanged();
156 void renderableTypeChanged();
157
158private Q_SLOTS:
159 void updateInfo();
160 void setWindow(QQuickWindow *window);
161
162private:
163 QPointer<QQuickWindow> m_window;
164 GraphicsApi m_api;
165 ShaderType m_shaderType;
166 ShaderCompilationType m_shaderCompilationType;
167 ShaderSourceType m_shaderSourceType;
168 int m_majorVersion;
169 int m_minorVersion;
170 OpenGLContextProfile m_profile;
171 RenderableType m_renderableType;
172};
173
174QT_END_NAMESPACE
175
176#endif // QQUICKGRAPHICSINFO_P_H
177

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