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 QOPENGL_P_H
5#define QOPENGL_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 <QtGui/private/qtguiglobal_p.h>
19#include <qopengl.h>
20#include <private/qopenglcontext_p.h>
21#include <QtCore/qset.h>
22#include <QtCore/qstring.h>
23#include <QtCore/qversionnumber.h>
24
25QT_BEGIN_NAMESPACE
26
27class QJsonDocument;
28
29class Q_GUI_EXPORT QOpenGLExtensionMatcher
30{
31public:
32 QOpenGLExtensionMatcher();
33
34 bool match(const QByteArray &extension) const
35 {
36 return m_extensions.contains(value: extension);
37 }
38
39 QSet<QByteArray> extensions() const { return m_extensions; }
40
41private:
42 QSet<QByteArray> m_extensions;
43};
44
45class Q_GUI_EXPORT QOpenGLConfig
46{
47public:
48 struct Q_GUI_EXPORT Gpu {
49 Gpu() : vendorId(0), deviceId(0) {}
50 bool isValid() const { return deviceId || !glVendor.isEmpty(); }
51 bool equals(const Gpu &other) const {
52 return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion
53 && driverDescription == other.driverDescription && glVendor == other.glVendor;
54 }
55
56 uint vendorId;
57 uint deviceId;
58 QVersionNumber driverVersion;
59 QByteArray driverDescription;
60 QByteArray glVendor;
61
62 static Gpu fromDevice(uint vendorId, uint deviceId, QVersionNumber driverVersion, const QByteArray &driverDescription) {
63 Gpu gpu;
64 gpu.vendorId = vendorId;
65 gpu.deviceId = deviceId;
66 gpu.driverVersion = driverVersion;
67 gpu.driverDescription = driverDescription;
68 return gpu;
69 }
70
71 static Gpu fromGLVendor(const QByteArray &glVendor) {
72 Gpu gpu;
73 gpu.glVendor = glVendor;
74 return gpu;
75 }
76
77 static Gpu fromContext();
78 };
79
80 static QSet<QString> gpuFeatures(const Gpu &gpu,
81 const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion,
82 const QJsonDocument &doc);
83 static QSet<QString> gpuFeatures(const Gpu &gpu,
84 const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion,
85 const QString &fileName);
86 static QSet<QString> gpuFeatures(const Gpu &gpu, const QJsonDocument &doc);
87 static QSet<QString> gpuFeatures(const Gpu &gpu, const QString &fileName);
88};
89
90inline bool operator==(const QOpenGLConfig::Gpu &a, const QOpenGLConfig::Gpu &b)
91{
92 return a.equals(other: b);
93}
94
95inline bool operator!=(const QOpenGLConfig::Gpu &a, const QOpenGLConfig::Gpu &b)
96{
97 return !a.equals(other: b);
98}
99
100inline size_t qHash(const QOpenGLConfig::Gpu &gpu, size_t seed = 0)
101{
102 return (qHash(key: gpu.vendorId) + qHash(key: gpu.deviceId) + qHash(key: gpu.driverVersion)) ^ seed;
103}
104
105QT_END_NAMESPACE
106
107#endif // QOPENGL_H
108

source code of qtbase/src/gui/opengl/qopengl_p.h