diff options
Diffstat (limited to 'src/gui/opengl/qopengl.cpp')
-rw-r--r-- | src/gui/opengl/qopengl.cpp | 86 |
1 files changed, 38 insertions, 48 deletions
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 3dedd7d7be..1a8fc599ce 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -132,22 +138,6 @@ QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g) enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan }; static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="}; -static inline QString valueKey() { return QStringLiteral("value"); } -static inline QString opKey() { return QStringLiteral("op"); } -static inline QString versionKey() { return QStringLiteral("version"); } -static inline QString releaseKey() { return QStringLiteral("release"); } -static inline QString typeKey() { return QStringLiteral("type"); } -static inline QString osKey() { return QStringLiteral("os"); } -static inline QString vendorIdKey() { return QStringLiteral("vendor_id"); } -static inline QString glVendorKey() { return QStringLiteral("gl_vendor"); } -static inline QString deviceIdKey() { return QStringLiteral("device_id"); } -static inline QString driverVersionKey() { return QStringLiteral("driver_version"); } -static inline QString driverDescriptionKey() { return QStringLiteral("driver_description"); } -static inline QString featuresKey() { return QStringLiteral("features"); } -static inline QString idKey() { return QStringLiteral("id"); } -static inline QString descriptionKey() { return QStringLiteral("description"); } -static inline QString exceptionsKey() { return QStringLiteral("exceptions"); } - typedef QJsonArray::ConstIterator JsonArrayConstIt; static inline bool contains(const QJsonArray &haystack, unsigned needle) @@ -210,8 +200,8 @@ VersionTerm VersionTerm::fromJson(const QJsonValue &v) if (!v.isObject()) return result; const QJsonObject o = v.toObject(); - result.number = QVersionNumber::fromString(o.value(valueKey()).toString()); - const QString opS = o.value(opKey()).toString(); + result.number = QVersionNumber::fromString(o.value(QLatin1String("value")).toString()); + const QString opS = o.value(QLatin1String("op")).toString(); for (size_t i = 0; i < sizeof(operators) / sizeof(operators[0]); ++i) { if (opS == QLatin1String(operators[i])) { result.op = static_cast<Operator>(i); @@ -286,9 +276,9 @@ OsTypeTerm OsTypeTerm::fromJson(const QJsonValue &v) if (!v.isObject()) return result; const QJsonObject o = v.toObject(); - result.type = o.value(typeKey()).toString(); - result.versionTerm = VersionTerm::fromJson(o.value(versionKey())); - result.release = o.value(releaseKey()).toArray(); + result.type = o.value(QLatin1String("type")).toString(); + result.versionTerm = VersionTerm::fromJson(o.value(QLatin1String("version"))); + result.release = o.value(QLatin1String("release")).toArray(); return result; } @@ -312,8 +302,8 @@ QString OsTypeTerm::hostOs() static QString msgSyntaxWarning(const QJsonObject &object, const QString &what) { QString result; - QTextStream(&result) << "Id " << object.value(idKey()).toInt() - << " (\"" << object.value(descriptionKey()).toString() + QTextStream(&result) << "Id " << object.value(QLatin1String("id")).toInt() + << " (\"" << object.value(QLatin1String("description")).toString() << "\"): " << what; return result; } @@ -327,11 +317,11 @@ static bool matches(const QJsonObject &object, const QString &osRelease, const QOpenGLConfig::Gpu &gpu) { - const OsTypeTerm os = OsTypeTerm::fromJson(object.value(osKey())); + const OsTypeTerm os = OsTypeTerm::fromJson(object.value(QLatin1String("os"))); if (!os.isNull() && !os.matches(osName, kernelVersion, osRelease)) return false; - const QJsonValue exceptionsV = object.value(exceptionsKey()); + const QJsonValue exceptionsV = object.value(QLatin1String("exceptions")); if (exceptionsV.isArray()) { const QJsonArray exceptionsA = exceptionsV.toArray(); for (JsonArrayConstIt it = exceptionsA.constBegin(), cend = exceptionsA.constEnd(); it != cend; ++it) { @@ -340,20 +330,20 @@ static bool matches(const QJsonObject &object, } } - const QJsonValue vendorV = object.value(vendorIdKey()); + const QJsonValue vendorV = object.value(QLatin1String("vendor_id")); if (vendorV.isString()) { if (gpu.vendorId != vendorV.toString().toUInt(Q_NULLPTR, /* base */ 0)) return false; } else { - if (object.contains(glVendorKey())) { - const QByteArray glVendorV = object.value(glVendorKey()).toString().toUtf8(); + if (object.contains(QLatin1String("gl_vendor"))) { + const QByteArray glVendorV = object.value(QLatin1String("gl_vendor")).toString().toUtf8(); if (!gpu.glVendor.contains(glVendorV)) return false; } } if (gpu.deviceId) { - const QJsonValue deviceIdV = object.value(deviceIdKey()); + const QJsonValue deviceIdV = object.value(QLatin1String("device_id")); switch (deviceIdV.type()) { case QJsonValue::Array: if (!contains(deviceIdV.toArray(), gpu.deviceId)) @@ -369,7 +359,7 @@ static bool matches(const QJsonObject &object, } } if (!gpu.driverVersion.isNull()) { - const QJsonValue driverVersionV = object.value(driverVersionKey()); + const QJsonValue driverVersionV = object.value(QLatin1String("driver_version")); switch (driverVersionV.type()) { case QJsonValue::Object: if (!VersionTerm::fromJson(driverVersionV).matches(gpu.driverVersion)) @@ -386,7 +376,7 @@ static bool matches(const QJsonObject &object, } if (!gpu.driverDescription.isEmpty()) { - const QJsonValue driverDescriptionV = object.value(driverDescriptionKey()); + const QJsonValue driverDescriptionV = object.value(QLatin1String("driver_description")); if (driverDescriptionV.isString()) { if (!gpu.driverDescription.contains(driverDescriptionV.toString().toUtf8())) return false; @@ -406,7 +396,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu, { result->clear(); errorMessage->clear(); - const QJsonValue entriesV = doc.object().value(QStringLiteral("entries")); + const QJsonValue entriesV = doc.object().value(QLatin1String("entries")); if (!entriesV.isArray()) { *errorMessage = QLatin1String("No entries read."); return false; @@ -417,7 +407,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu, if (eit->isObject()) { const QJsonObject object = eit->toObject(); if (matches(object, osName, kernelVersion, osRelease, gpu)) { - const QJsonValue featuresListV = object.value(featuresKey()); + const QJsonValue featuresListV = object.value(QLatin1String("features")); if (featuresListV.isArray()) { const QJsonArray featuresListA = featuresListV.toArray(); for (JsonArrayConstIt fit = featuresListA.constBegin(), fcend = featuresListA.constEnd(); fit != fcend; ++fit) @@ -542,7 +532,7 @@ Q_GUI_EXPORT std::set<QByteArray> *qgpu_features(const QString &filename) { const QSet<QString> features = QOpenGLConfig::gpuFeatures(QOpenGLConfig::Gpu::fromContext(), filename); std::set<QByteArray> *result = new std::set<QByteArray>; - foreach (const QString &feature, features) + for (const QString &feature : features) result->insert(feature.toUtf8()); return result; } |