Commit 2ce08ed0 authored by Volker Krause's avatar Volker Krause
Browse files

Add OpenGL information data source

Will probably need some more pre-processing of the data we get from the
GL driver, it contains some unstructured and/or too specific information
for our purpose.
parent d3e8e70b
......@@ -24,6 +24,7 @@
#include <provider/core/screeninfosource.h>
#include <provider/core/startcountsource.h>
#include <provider/core/usagetimesource.h>
#include <provider/core/openglinfosource.h>
#include <QDebug>
#include <QtTest/qtest.h>
......@@ -239,6 +240,26 @@ private slots:
QVERIFY(!m.value(QLatin1String("region")).toString().isEmpty());
}
void testOpenGLInfoSource()
{
OpenGLInfoSource src;
const auto m = src.data().toMap();
QVERIFY(m.contains(QLatin1String("type")));
const auto type = m.value(QLatin1String("type")).toString();
QVERIFY(!type.isEmpty());
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QVERIFY(type == QLatin1String("GL") || type == QLatin1String("GLES"));
QVERIFY(m.contains(QLatin1String("vendor")));
QVERIFY(!m.value(QLatin1String("vendor")).toString().isEmpty());
QVERIFY(m.contains(QLatin1String("renderer")));
QVERIFY(!m.value(QLatin1String("renderer")).toString().isEmpty());
QVERIFY(m.contains(QLatin1String("version")));
QVERIFY(!m.value(QLatin1String("version")).toString().isEmpty());
QVERIFY(m.contains(QLatin1String("glslVersion")));
QVERIFY(!m.value(QLatin1String("glslVersion")).toString().isEmpty());
#endif
}
};
QTEST_MAIN(DataSourceTest)
......
......@@ -130,6 +130,94 @@
],
"name": "Region Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "style",
"schemaEntryElement": "style",
"type": "value"
}
],
"name": "Widget Style Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "style",
"schemaEntryElement": "dark",
"type": "value"
}
],
"name": "Palette Color Scheme",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "opengl",
"schemaEntryElement": "type",
"type": "value"
}
],
"name": "OpenGL Stack Type",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "opengl",
"schemaEntryElement": "vendor",
"type": "value"
}
],
"name": "OpenGL Vendor Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "opengl",
"schemaEntryElement": "renderer",
"type": "value"
}
],
"name": "OpenGL Renderer Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "opengl",
"schemaEntryElement": "version",
"type": "value"
}
],
"name": "OpenGL Version Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "opengl",
"schemaEntryElement": "glslVersion",
"type": "value"
}
],
"name": "OpenGL GLSL Version Distribution",
"type": "category"
},
{
"elements": [
{
"schemaEntry": "opengl",
"schemaEntryElement": "profile",
"type": "value"
}
],
"name": "OpenGL Profile Distribution",
"type": "category"
}
],
"name": "org.kde.orwell",
......@@ -243,6 +331,50 @@
],
"name": "locale",
"type": "scalar"
},
{
"elements": [
{
"name": "style",
"type": "string"
},
{
"name": "dark",
"type": "bool"
}
],
"name": "style",
"type": "scalar"
},
{
"elements": [
{
"name": "type",
"type": "string"
},
{
"name": "vendor",
"type": "string"
},
{
"name": "renderer",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "glslVersion",
"type": "string"
},
{
"name": "profile",
"type": "string"
}
],
"name": "opengl",
"type": "scalar"
}
]
}
{
"name": "OpenGL Information",
"schema": [
{
"name": "opengl",
"type": "scalar",
"elements": [
{
"name": "type",
"type": "string"
},
{
"name": "vendor",
"type": "string"
},
{
"name": "renderer",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "glslVersion",
"type": "string"
},
{
"name": "profile",
"type": "string"
}
]
}
],
"aggregation": [
{
"type": "category",
"name": "OpenGL Stack Type",
"elements": [ { "type": "value", "schemaEntry": "opengl", "schemaEntryElement": "type" } ]
},
{
"type": "category",
"name": "OpenGL Vendor Distribution",
"elements": [ { "type": "value", "schemaEntry": "opengl", "schemaEntryElement": "vendor" } ]
},
{
"type": "category",
"name": "OpenGL Renderer Distribution",
"elements": [ { "type": "value", "schemaEntry": "opengl", "schemaEntryElement": "renderer" } ]
},
{
"type": "category",
"name": "OpenGL Version Distribution",
"elements": [ { "type": "value", "schemaEntry": "opengl", "schemaEntryElement": "version" } ]
},
{
"type": "category",
"name": "OpenGL GLSL Version Distribution",
"elements": [ { "type": "value", "schemaEntry": "opengl", "schemaEntryElement": "glslVersion" } ]
},
{
"type": "category",
"name": "OpenGL Profile Distribution",
"elements": [ { "type": "value", "schemaEntry": "opengl", "schemaEntryElement": "profile" } ]
}
]
}
......@@ -4,6 +4,7 @@
<file>applicationVersion.schema</file>
<file>cpu.schema</file>
<file>locale.schema</file>
<file>opengl.schema</file>
<file>platform.schema</file>
<file>propertyRatio.schema</file>
<file>qtVersion.schema</file>
......
......@@ -5,6 +5,7 @@ set(userfeedback_core_srcs
applicationversionsource.cpp
cpuinfosource.cpp
localeinfosource.cpp
openglinfosource.cpp
platforminfosource.cpp
propertyratiosource.cpp
provider.cpp
......@@ -42,6 +43,7 @@ ecm_generate_headers(UserFeedbackCore_HEADERS
ApplicationVersionSource
CpuInfoSource
LocaleInfoSource
OpenGLInfoSource
PlatformInfoSource
PropertyRatioSource
Provider
......
/*
Copyright (C) 2017 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "openglinfosource.h"
#include <QVariant>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QSurfaceFormat>
#include <QWindow>
#endif
using namespace UserFeedback;
OpenGLInfoSource::OpenGLInfoSource()
: AbstractDataSource(QStringLiteral("opengl"))
{
}
QString OpenGLInfoSource::description() const
{
return tr("Information about type, version and vendor of the OpenGL stack.");
}
QVariant OpenGLInfoSource::data()
{
QVariantMap m;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QOpenGLContext context;
if (context.create()) {
switch (context.openGLModuleType()) {
case QOpenGLContext::LibGL:
m.insert(QStringLiteral("type"), QStringLiteral("GL"));
break;
case QOpenGLContext::LibGLES:
m.insert(QStringLiteral("type"), QStringLiteral("GLES"));
break;
}
QWindow window;
window.setSurfaceType(QSurface::OpenGLSurface);
window.create();
context.makeCurrent(&window);
QOpenGLFunctions functions(&context);
m.insert(QStringLiteral("vendor"), QString::fromLocal8Bit(reinterpret_cast<const char*>(functions.glGetString(GL_VENDOR))));
m.insert(QStringLiteral("renderer"), QString::fromLocal8Bit(reinterpret_cast<const char*>(functions.glGetString(GL_RENDERER))));
m.insert(QStringLiteral("version"), QString::fromLocal8Bit(reinterpret_cast<const char*>(functions.glGetString(GL_VERSION))));
m.insert(QStringLiteral("glslVersion"), QString::fromLocal8Bit(reinterpret_cast<const char*>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION))));
switch (context.format().profile()) {
case QSurfaceFormat::NoProfile:
break;
case QSurfaceFormat::CoreProfile:
m.insert(QStringLiteral("profile"), QStringLiteral("core"));
break;
case QSurfaceFormat::CompatibilityProfile:
m.insert(QStringLiteral("profile"), QStringLiteral("compat"));
break;
}
return m;
}
#endif
m.insert(QStringLiteral("type"), QStringLiteral("none"));
return m;
}
/*
Copyright (C) 2017 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef USERFEEDBACK_OPENGLINFOSOURCE_H
#define USERFEEDBACK_OPENGLINFOSOURCE_H
#include "abstractdatasource.h"
namespace UserFeedback {
/*! Data source reporting type, version and vendor of the OpenGL stack. */
class USERFEEDBACKCORE_EXPORT OpenGLInfoSource : public AbstractDataSource
{
public:
Q_DECLARE_TR_FUNCTIONS(UserFeedback::LocaleInfoSource)
public:
OpenGLInfoSource();
QString description() const override;
QVariant data() override;
};
}
#endif // USERFEEDBACK_OPENGLINFOSOURCE_H
......@@ -24,6 +24,7 @@
#include <ApplicationVersionSource>
#include <CpuInfoSource>
#include <LocaleInfoSource>
#include <OpenGLInfoSource>
#include <PlatformInfoSource>
#include <PropertyRatioSource>
#include <QtVersionSource>
......@@ -116,6 +117,7 @@ int main(int argc, char** argv)
provider->addDataSource(new UserFeedback::ApplicationVersionSource, UserFeedback::Provider::BasicSystemInformation);
provider->addDataSource(new UserFeedback::CpuInfoSource, UserFeedback::Provider::DetailedSystemInformation);
provider->addDataSource(new UserFeedback::LocaleInfoSource, UserFeedback::Provider::DetailedSystemInformation);
provider->addDataSource(new UserFeedback::OpenGLInfoSource, UserFeedback::Provider::DetailedSystemInformation);
provider->addDataSource(new UserFeedback::PlatformInfoSource, UserFeedback::Provider::BasicSystemInformation);
provider->addDataSource(new UserFeedback::QtVersionSource, UserFeedback::Provider::BasicSystemInformation);
provider->addDataSource(new UserFeedback::ScreenInfoSource, UserFeedback::Provider::DetailedSystemInformation);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment