Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglfshooks.cpp
Go to the documentation of this file.
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#include "qeglfshooks_p.h"
5#include <QLoggingCategory>
6
8
9Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug)
10
11#ifdef EGLFS_PLATFORM_HOOKS
12
14{
15 extern QEglFSHooks *platformHooks;
16 return platformHooks;
17}
18
19#else
20
21namespace {
23{
24public:
26 ~DeviceIntegration() { delete m_integration; }
27 QEglFSDeviceIntegration *integration() { return m_integration; }
28private:
29 QEglFSDeviceIntegration *m_integration;
30};
31}
32
33Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
34
36 : m_integration(nullptr)
37{
39 if (!pluginKeys.isEmpty()) {
40 // Some built-in logic: Prioritize either X11 or KMS/DRM.
41 if (qEnvironmentVariableIsSet("DISPLAY")) {
42 const QString x11key = QStringLiteral("eglfs_x11");
43 if (pluginKeys.contains(x11key)) {
44 pluginKeys.removeOne(x11key);
45 pluginKeys.prepend(x11key);
46 }
47 } else {
48 const QString kmskey = QStringLiteral("eglfs_kms");
49 if (pluginKeys.contains(kmskey)) {
50 pluginKeys.removeOne(kmskey);
51 pluginKeys.prepend(kmskey);
52 }
53 }
54
55 QByteArray requested;
56
57 // The environment variable can override everything.
58 if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_INTEGRATION")) {
59 requested = qgetenv("QT_QPA_EGLFS_INTEGRATION");
60 } else {
61 // Device-specific makespecs may define a preferred plugin.
62#ifdef EGLFS_PREFERRED_PLUGIN
63#define DEFAULT_PLUGIN EGLFS_PREFERRED_PLUGIN
64#define STR(s) #s
65#define STRQ(s) STR(s)
66 requested = STRQ(DEFAULT_PLUGIN);
67#endif
68 }
69
70 // Treat "none" as special. There has to be a way to indicate
71 // that plugins must be ignored when the device is known to be
72 // functional with the default, non-specialized integration.
73 if (requested != QByteArrayLiteral("none")) {
74 if (!requested.isEmpty()) {
75 QString reqStr = QString::fromLocal8Bit(requested);
76 pluginKeys.removeOne(reqStr);
77 pluginKeys.prepend(reqStr);
78 }
79 qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys (sorted):" << pluginKeys;
80 while (!m_integration && !pluginKeys.isEmpty()) {
81 QString key = pluginKeys.takeFirst();
82 qCDebug(qLcEglDevDebug) << "Trying to load device EGL integration" << key;
84 }
85 }
86 }
87
88 if (!m_integration) {
89 // Use a default, non-specialized device integration when no plugin is available.
90 // For some systems this is sufficient.
91 qCDebug(qLcEglDevDebug) << "Using base device integration";
92 m_integration = new QEglFSDeviceIntegration;
93 }
94}
95
97{
98 return deviceIntegration()->integration();
99}
100
101#endif // EGLFS_PLATFORM_HOOKS
102
\inmodule QtCore
Definition qbytearray.h:57
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:107
static QEglFSDeviceIntegration * create(const QString &name)
static QStringList keys()
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5949
QEglFSDeviceIntegration * integration()
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
QEglFSDeviceIntegration * qt_egl_device_integration()
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLuint64 key
#define QStringLiteral(str)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept