1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "openglconfiguration.h"
using namespace Qt::StringLiterals;
QT_BEGIN_NAMESPACE_AM
QVariantMap OpenGLConfiguration::toMap() const
{
static OpenGLConfiguration def;
QVariantMap map;
if (desktopProfile != def.desktopProfile)
map[u"desktopProfile"_s] = desktopProfile;
if (esMajorVersion != def.esMajorVersion)
map[u"esMajorVersion"_s] = esMajorVersion;
if (esMinorVersion != def.esMinorVersion)
map[u"esMinorVersion"_s] = esMinorVersion;
return map;
}
OpenGLConfiguration OpenGLConfiguration::fromMap(const QVariantMap &map)
{
OpenGLConfiguration cfg;
cfg.desktopProfile = map.value(u"desktopProfile"_s, cfg.desktopProfile).toString();
cfg.esMajorVersion = map.value(u"esMajorVersion"_s, cfg.esMajorVersion).toInt();
cfg.esMinorVersion = map.value(u"esMinorVersion"_s, cfg.esMinorVersion).toInt();
return cfg;
}
OpenGLConfiguration OpenGLConfiguration::fromYaml(YamlParser &yp)
{
OpenGLConfiguration cfg;
yp.parseFields({
{ "desktopProfile", false, YamlParser::Scalar, [&]() {
cfg.desktopProfile = yp.parseString(); } },
{ "esMajorVersion", false, YamlParser::Scalar, [&]() {
cfg.esMajorVersion = yp.parseInt(2); } },
{ "esMinorVersion", false, YamlParser::Scalar, [&]() {
cfg.esMinorVersion = yp.parseInt(0); } }
});
return cfg;
}
OpenGLConfiguration::OpenGLConfiguration(const QString &profile, int major, int minor)
: desktopProfile(profile), esMajorVersion(major), esMinorVersion(minor)
{ }
bool OpenGLConfiguration::operator==(const OpenGLConfiguration &other) const
{
return (desktopProfile == other.desktopProfile)
&& (esMajorVersion == other.esMajorVersion)
&& (esMinorVersion == other.esMinorVersion);
}
bool OpenGLConfiguration::operator!=(const OpenGLConfiguration &other) const
{
return !(*this == other);
}
QDataStream &operator<<(QDataStream &ds, const OpenGLConfiguration &cfg)
{
ds << cfg.desktopProfile << cfg.esMajorVersion << cfg.esMinorVersion;
return ds;
}
QDataStream &operator>>(QDataStream &ds, OpenGLConfiguration &cfg)
{
ds >> cfg.desktopProfile >> cfg.esMajorVersion >> cfg.esMinorVersion;
return ds;
}
QT_END_NAMESPACE_AM
|