Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/qeglfshooks.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the qmake spec of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include "qeglfshooks.h" | - | ||||||||||||
35 | #include <QLoggingCategory> | - | ||||||||||||
36 | - | |||||||||||||
37 | QT_BEGIN_NAMESPACE | - | ||||||||||||
38 | - | |||||||||||||
39 | Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug) | - | ||||||||||||
40 | - | |||||||||||||
41 | #ifdef EGLFS_PLATFORM_HOOKS | - | ||||||||||||
42 | - | |||||||||||||
43 | QEGLDeviceIntegration *qt_egl_device_integration() | - | ||||||||||||
44 | { | - | ||||||||||||
45 | extern QEglFSHooks *platformHooks; | - | ||||||||||||
46 | return platformHooks; | - | ||||||||||||
47 | } | - | ||||||||||||
48 | - | |||||||||||||
49 | #else | - | ||||||||||||
50 | - | |||||||||||||
51 | class DeviceIntegration | - | ||||||||||||
52 | { | - | ||||||||||||
53 | public: | - | ||||||||||||
54 | DeviceIntegration(); | - | ||||||||||||
55 | ~DeviceIntegration() { delete m_integration; } never executed: end of block | 0 | ||||||||||||
56 | QEGLDeviceIntegration *integration() { return m_integration; } never executed: return m_integration; | 0 | ||||||||||||
57 | private: | - | ||||||||||||
58 | QEGLDeviceIntegration *m_integration; | - | ||||||||||||
59 | }; | - | ||||||||||||
60 | - | |||||||||||||
61 | Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration) never executed: end of block never executed: guard.store(QtGlobalStatic::Destroyed); never executed: return &holder.value;
| 0 | ||||||||||||
62 | - | |||||||||||||
63 | DeviceIntegration::DeviceIntegration() | - | ||||||||||||
64 | : m_integration(Q_NULLPTR) | - | ||||||||||||
65 | { | - | ||||||||||||
66 | QStringList pluginKeys = QEGLDeviceIntegrationFactory::keys(); | - | ||||||||||||
67 | if (!pluginKeys.isEmpty()) {
| 0 | ||||||||||||
68 | // Some built-in logic: Prioritize either X11 or KMS/DRM. | - | ||||||||||||
69 | if (qEnvironmentVariableIsSet("DISPLAY")) {
| 0 | ||||||||||||
70 | const QString x11key = QStringLiteral("eglfs_x11"); never executed: return qstring_literal_temp; | 0 | ||||||||||||
71 | if (pluginKeys.contains(x11key)) {
| 0 | ||||||||||||
72 | pluginKeys.removeOne(x11key); | - | ||||||||||||
73 | pluginKeys.prepend(x11key); | - | ||||||||||||
74 | } never executed: end of block | 0 | ||||||||||||
75 | } else { never executed: end of block | 0 | ||||||||||||
76 | const QString kmskey = QStringLiteral("eglfs_kms"); never executed: return qstring_literal_temp; | 0 | ||||||||||||
77 | if (pluginKeys.contains(kmskey)) {
| 0 | ||||||||||||
78 | pluginKeys.removeOne(kmskey); | - | ||||||||||||
79 | pluginKeys.prepend(kmskey); | - | ||||||||||||
80 | } never executed: end of block | 0 | ||||||||||||
81 | } never executed: end of block | 0 | ||||||||||||
82 | - | |||||||||||||
83 | QByteArray requested; | - | ||||||||||||
84 | - | |||||||||||||
85 | // The environment variable can override everything. | - | ||||||||||||
86 | if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_INTEGRATION")) {
| 0 | ||||||||||||
87 | requested = qgetenv("QT_QPA_EGLFS_INTEGRATION"); | - | ||||||||||||
88 | } else { never executed: end of block | 0 | ||||||||||||
89 | // Device-specific makespecs may define a preferred plugin. | - | ||||||||||||
90 | #ifdef EGLFS_PREFERRED_PLUGIN | - | ||||||||||||
91 | #define DEFAULT_PLUGIN EGLFS_PREFERRED_PLUGIN | - | ||||||||||||
92 | #define STR(s) #s | - | ||||||||||||
93 | #define STRQ(s) STR(s) | - | ||||||||||||
94 | requested = STRQ(DEFAULT_PLUGIN); | - | ||||||||||||
95 | #endif | - | ||||||||||||
96 | } never executed: end of block | 0 | ||||||||||||
97 | - | |||||||||||||
98 | // Treat "none" as special. There has to be a way to indicate | - | ||||||||||||
99 | // that plugins must be ignored when the device is known to be | - | ||||||||||||
100 | // functional with the default, non-specialized integration. | - | ||||||||||||
101 | if (requested != QByteArrayLiteral("none")) { never executed: return ba;
| 0 | ||||||||||||
102 | if (!requested.isEmpty()) {
| 0 | ||||||||||||
103 | QString reqStr = QString::fromLocal8Bit(requested); | - | ||||||||||||
104 | pluginKeys.removeOne(reqStr); | - | ||||||||||||
105 | pluginKeys.prepend(reqStr); | - | ||||||||||||
106 | } never executed: end of block | 0 | ||||||||||||
107 | qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys (sorted):" << pluginKeys; never executed: QMessageLogger(__FILE__, 107, __PRETTY_FUNCTION__, qLcEglDevDebug().categoryName()).debug() << "EGL device integration plugin keys (sorted):" << pluginKeys;
| 0 | ||||||||||||
108 | while (!m_integration && !pluginKeys.isEmpty()) {
| 0 | ||||||||||||
109 | QString key = pluginKeys.takeFirst(); | - | ||||||||||||
110 | qCDebug(qLcEglDevDebug) << "Trying to load device EGL integration" << key; never executed: QMessageLogger(__FILE__, 110, __PRETTY_FUNCTION__, qLcEglDevDebug().categoryName()).debug() << "Trying to load device EGL integration" << key;
| 0 | ||||||||||||
111 | m_integration = QEGLDeviceIntegrationFactory::create(key); | - | ||||||||||||
112 | } never executed: end of block | 0 | ||||||||||||
113 | } never executed: end of block | 0 | ||||||||||||
114 | } never executed: end of block | 0 | ||||||||||||
115 | - | |||||||||||||
116 | if (!m_integration) {
| 0 | ||||||||||||
117 | // Use a default, non-specialized device integration when no plugin is available. | - | ||||||||||||
118 | // For some systems this is sufficient. | - | ||||||||||||
119 | qCDebug(qLcEglDevDebug) << "Using base device integration"; never executed: QMessageLogger(__FILE__, 119, __PRETTY_FUNCTION__, qLcEglDevDebug().categoryName()).debug() << "Using base device integration";
| 0 | ||||||||||||
120 | m_integration = new QEGLDeviceIntegration; | - | ||||||||||||
121 | } never executed: end of block | 0 | ||||||||||||
122 | } never executed: end of block | 0 | ||||||||||||
123 | - | |||||||||||||
124 | QEGLDeviceIntegration *qt_egl_device_integration() | - | ||||||||||||
125 | { | - | ||||||||||||
126 | return deviceIntegration()->integration(); never executed: return deviceIntegration()->integration(); | 0 | ||||||||||||
127 | } | - | ||||||||||||
128 | - | |||||||||||||
129 | #endif // EGLFS_PLATFORM_HOOKS | - | ||||||||||||
130 | - | |||||||||||||
131 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |