qeglfsdeviceintegration.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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 plugins 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 "qeglfsdeviceintegration.h"-
35#include "qeglfsintegration.h"-
36#include "qeglfscursor.h"-
37#include "qeglfswindow.h"-
38#include <QtPlatformSupport/private/qeglconvenience_p.h>-
39#include <QGuiApplication>-
40#include <private/qguiapplication_p.h>-
41#include <QScreen>-
42#include <QDir>-
43#include <QRegularExpression>-
44#include <QLoggingCategory>-
45-
46#if defined(Q_OS_LINUX)-
47#include <fcntl.h>-
48#include <unistd.h>-
49#include <linux/fb.h>-
50#include <sys/ioctl.h>-
51#endif-
52-
53#include <private/qfactoryloader_p.h>-
54#include <private/qcore_unix_p.h>-
55-
56QT_BEGIN_NAMESPACE-
57-
58Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration")
never executed: return category;
0
59-
60#ifndef QT_NO_LIBRARY-
61-
62Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
63 (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))-
64-
65Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
66 (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))-
67-
68static inline QEGLDeviceIntegration *loadIntegration(QFactoryLoader *loader, const QString &key)-
69{-
70 const int index = loader->indexOf(key);-
71 if (index != -1) {
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
72 QObject *plugin = loader->instance(index);-
73 if (QEGLDeviceIntegrationPlugin *factory = qobject_cast<QEGLDeviceIntegrationPlugin *>(plugin)) {
QEGLDeviceInte...gin *>(plugin)Description
TRUEnever evaluated
FALSEnever evaluated
0
74 if (QEGLDeviceIntegration *result = factory->create())
QEGLDeviceInte...tory->create()Description
TRUEnever evaluated
FALSEnever evaluated
0
75 return result;
never executed: return result;
0
76 }
never executed: end of block
0
77 }
never executed: end of block
0
78 return Q_NULLPTR;
never executed: return nullptr;
0
79}-
80-
81#endif // QT_NO_LIBRARY-
82-
83QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)-
84{-
85#ifndef QT_NO_LIBRARY-
86 QStringList list;-
87 if (!pluginPath.isEmpty()) {
!pluginPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
88 QCoreApplication::addLibraryPath(pluginPath);-
89 list = directLoader()->keyMap().values();-
90 if (!list.isEmpty()) {
!list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
91 const QString postFix = QStringLiteral(" (from ")
never executed: return qstring_literal_temp;
0
92 + QDir::toNativeSeparators(pluginPath)-
93 + QLatin1Char(')');-
94 const QStringList::iterator end = list.end();-
95 for (QStringList::iterator it = list.begin(); it != end; ++it)
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
96 (*it).append(postFix);
never executed: (*it).append(postFix);
0
97 }
never executed: end of block
0
98 }
never executed: end of block
0
99 list.append(loader()->keyMap().values());-
100 qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys:" << list;
never executed: QMessageLogger(__FILE__, 100, __PRETTY_FUNCTION__, qLcEglDevDebug().categoryName()).debug() << "EGL device integration plugin keys:" << list;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
101 return list;
never executed: return list;
0
102#else-
103 Q_UNUSED(pluginPath);-
104 return QStringList();-
105#endif-
106}-
107-
108QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)-
109{-
110 QEGLDeviceIntegration *integration = Q_NULLPTR;-
111#ifndef QT_NO_LIBRARY-
112 if (!pluginPath.isEmpty()) {
!pluginPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
113 QCoreApplication::addLibraryPath(pluginPath);-
114 integration = loadIntegration(directLoader(), key);-
115 }
never executed: end of block
0
116 if (!integration)
!integrationDescription
TRUEnever evaluated
FALSEnever evaluated
0
117 integration = loadIntegration(loader(), key);
never executed: integration = loadIntegration(loader(), key);
0
118 if (integration)
integrationDescription
TRUEnever evaluated
FALSEnever evaluated
0
119 qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
never executed: QMessageLogger(__FILE__, 119, __PRETTY_FUNCTION__, qLcEglDevDebug().categoryName()).debug() << "Using EGL device integration" << key;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 else-
121 qCWarning(qLcEglDevDebug) << "Failed to load EGL device integration" << key;
never executed: QMessageLogger(__FILE__, 121, __PRETTY_FUNCTION__, qLcEglDevDebug().categoryName()).warning() << "Failed to load EGL device integration" << key;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
122#else-
123 Q_UNUSED(key);-
124 Q_UNUSED(pluginPath);-
125#endif-
126 return integration;
never executed: return integration;
0
127}-
128-
129static int framebuffer = -1;-
130-
131QByteArray QEGLDeviceIntegration::fbDeviceName() const-
132{-
133 QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB");-
134 if (fbDev.isEmpty())
fbDev.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
135 fbDev = QByteArrayLiteral("/dev/fb0");
never executed: fbDev = ([]() -> QByteArray { enum { Size = sizeof("/dev/fb0") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "/dev/fb0" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());
never executed: return ba;
0
136-
137 return fbDev;
never executed: return fbDev;
0
138}-
139-
140int QEGLDeviceIntegration::framebufferIndex() const-
141{-
142 int fbIndex = 0;-
143#ifndef QT_NO_REGULAREXPRESSION-
144 QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));-
145 QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName()));-
146 if (match.hasMatch())
match.hasMatch()Description
TRUEnever evaluated
FALSEnever evaluated
0
147 fbIndex = match.captured(1).toInt();
never executed: fbIndex = match.captured(1).toInt();
0
148#endif-
149 return fbIndex;
never executed: return fbIndex;
0
150}-
151-
152void QEGLDeviceIntegration::platformInit()-
153{-
154 QByteArray fbDev = fbDeviceName();-
155-
156 framebuffer = qt_safe_open(fbDev, O_RDONLY);-
157-
158 if (framebuffer == -1) {
framebuffer == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
159 qWarning("EGLFS: Failed to open %s", fbDev.constData());-
160 qFatal("EGLFS: Can't continue without a display");-
161 }
never executed: end of block
0
162-
163#ifdef FBIOBLANK-
164 ioctl(framebuffer, FBIOBLANK, VESA_NO_BLANKING);-
165#endif-
166}
never executed: end of block
0
167-
168void QEGLDeviceIntegration::platformDestroy()-
169{-
170 if (framebuffer != -1)
framebuffer != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
171 close(framebuffer);
never executed: close(framebuffer);
0
172}
never executed: end of block
0
173-
174EGLNativeDisplayType QEGLDeviceIntegration::platformDisplay() const-
175{-
176 return EGL_DEFAULT_DISPLAY;
never executed: return ((EGLNativeDisplayType)0);
0
177}-
178-
179EGLDisplay QEGLDeviceIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)-
180{-
181 return eglGetDisplay(nativeDisplay);
never executed: return eglGetDisplay(nativeDisplay);
0
182}-
183-
184bool QEGLDeviceIntegration::usesDefaultScreen()-
185{-
186 return true;
never executed: return true;
0
187}-
188-
189void QEGLDeviceIntegration::screenInit()-
190{-
191 // Nothing to do here. Called only when usesDefaultScreen is false.-
192}-
193-
194void QEGLDeviceIntegration::screenDestroy()-
195{-
196 QGuiApplication *app = qGuiApp;-
197 QEglFSIntegration *platformIntegration = static_cast<QEglFSIntegration *>(-
198 QGuiApplicationPrivate::platformIntegration());-
199 while (!app->screens().isEmpty())
!app->screens().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
200 platformIntegration->removeScreen(app->screens().last()->handle());
never executed: platformIntegration->removeScreen(app->screens().last()->handle());
0
201}
never executed: end of block
0
202-
203QSizeF QEGLDeviceIntegration::physicalScreenSize() const-
204{-
205 return q_physicalScreenSizeFromFb(framebuffer, screenSize());
never executed: return q_physicalScreenSizeFromFb(framebuffer, screenSize());
0
206}-
207-
208QSize QEGLDeviceIntegration::screenSize() const-
209{-
210 return q_screenSizeFromFb(framebuffer);
never executed: return q_screenSizeFromFb(framebuffer);
0
211}-
212-
213QDpi QEGLDeviceIntegration::logicalDpi() const-
214{-
215 const QSizeF ps = physicalScreenSize();-
216 const QSize s = screenSize();-
217-
218 if (!ps.isEmpty() && !s.isEmpty())
!ps.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!s.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
219 return QDpi(25.4 * s.width() / ps.width(),
never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height());
0
220 25.4 * s.height() / ps.height());
never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height());
0
221 else-
222 return QDpi(100, 100);
never executed: return QDpi(100, 100);
0
223}-
224-
225qreal QEGLDeviceIntegration::pixelDensity() const-
226{-
227 return qRound(logicalDpi().first / qreal(100));
never executed: return qRound(logicalDpi().first / qreal(100));
0
228}-
229-
230Qt::ScreenOrientation QEGLDeviceIntegration::nativeOrientation() const-
231{-
232 return Qt::PrimaryOrientation;
never executed: return Qt::PrimaryOrientation;
0
233}-
234-
235Qt::ScreenOrientation QEGLDeviceIntegration::orientation() const-
236{-
237 return Qt::PrimaryOrientation;
never executed: return Qt::PrimaryOrientation;
0
238}-
239-
240int QEGLDeviceIntegration::screenDepth() const-
241{-
242 return q_screenDepthFromFb(framebuffer);
never executed: return q_screenDepthFromFb(framebuffer);
0
243}-
244-
245QImage::Format QEGLDeviceIntegration::screenFormat() const-
246{-
247 return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
never executed: return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
screenDepth() == 16Description
TRUEnever evaluated
FALSEnever evaluated
0
248}-
249-
250qreal QEGLDeviceIntegration::refreshRate() const-
251{-
252 return q_refreshRateFromFb(framebuffer);
never executed: return q_refreshRateFromFb(framebuffer);
0
253}-
254-
255EGLint QEGLDeviceIntegration::surfaceType() const-
256{-
257 return EGL_WINDOW_BIT;
never executed: return 0x0004;
0
258}-
259-
260QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const-
261{-
262 QSurfaceFormat format = inputFormat;-
263-
264 static const bool force888 = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCE888");-
265 if (force888) {
force888Description
TRUEnever evaluated
FALSEnever evaluated
0
266 format.setRedBufferSize(8);-
267 format.setGreenBufferSize(8);-
268 format.setBlueBufferSize(8);-
269 }
never executed: end of block
0
270-
271 return format;
never executed: return format;
0
272}-
273-
274bool QEGLDeviceIntegration::filterConfig(EGLDisplay, EGLConfig) const-
275{-
276 return true;
never executed: return true;
0
277}-
278-
279QEglFSWindow *QEGLDeviceIntegration::createWindow(QWindow *window) const-
280{-
281 return new QEglFSWindow(window);
never executed: return new QEglFSWindow(window);
0
282}-
283-
284EGLNativeWindowType QEGLDeviceIntegration::createNativeWindow(QPlatformWindow *platformWindow,-
285 const QSize &size,-
286 const QSurfaceFormat &format)-
287{-
288 Q_UNUSED(platformWindow);-
289 Q_UNUSED(size);-
290 Q_UNUSED(format);-
291 return 0;
never executed: return 0;
0
292}-
293-
294EGLNativeWindowType QEGLDeviceIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)-
295{-
296 Q_UNUSED(format);-
297 return 0;
never executed: return 0;
0
298}-
299-
300void QEGLDeviceIntegration::destroyNativeWindow(EGLNativeWindowType window)-
301{-
302 Q_UNUSED(window);-
303}
never executed: end of block
0
304-
305bool QEGLDeviceIntegration::hasCapability(QPlatformIntegration::Capability cap) const-
306{-
307 Q_UNUSED(cap);-
308 return false;
never executed: return false;
0
309}-
310-
311QPlatformCursor *QEGLDeviceIntegration::createCursor(QPlatformScreen *screen) const-
312{-
313 return new QEglFSCursor(screen);
never executed: return new QEglFSCursor(screen);
0
314}-
315-
316void QEGLDeviceIntegration::waitForVSync(QPlatformSurface *surface) const-
317{-
318 Q_UNUSED(surface);-
319-
320#if defined(FBIO_WAITFORVSYNC)-
321 static const bool forceSync = qEnvironmentVariableIntValue("QT_QPA_EGLFS_FORCEVSYNC");-
322 if (forceSync && framebuffer != -1) {
forceSyncDescription
TRUEnever evaluated
FALSEnever evaluated
framebuffer != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
323 int arg = 0;-
324 if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1)
ioctl(framebuf...), &arg) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
325 qWarning("Could not wait for vsync.");
never executed: QMessageLogger(__FILE__, 325, __PRETTY_FUNCTION__).warning("Could not wait for vsync.");
0
326 }
never executed: end of block
0
327#endif-
328}
never executed: end of block
0
329-
330void QEGLDeviceIntegration::presentBuffer(QPlatformSurface *surface)-
331{-
332 Q_UNUSED(surface);-
333}
never executed: end of block
0
334-
335bool QEGLDeviceIntegration::supportsPBuffers() const-
336{-
337 return true;
never executed: return true;
0
338}-
339-
340bool QEGLDeviceIntegration::supportsSurfacelessContexts() const-
341{-
342 return true;
never executed: return true;
0
343}-
344-
345void *QEGLDeviceIntegration::wlDisplay() const-
346{-
347 return Q_NULLPTR;
never executed: return nullptr;
0
348}-
349-
350QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9