From 317b9e9c5fd4ba318658cce2bdef3ef82e1dd288 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 29 Oct 2015 14:11:29 +0100 Subject: Support for Wayland servers on i.MX6 A wayland compositor on i.MX6 needs to create the wl_display before creating the EGL display. This wl_display then needs to be exposed so that QWaylandCompositor can use it. Change-Id: Id60f6dd2fbba05140ca0671da6f17dbc2ecce3a3 Reviewed-by: Laszlo Agocs --- .../eglfs/deviceintegration/deviceintegration.pro | 1 + .../eglfs_viv_wl/eglfs_viv_wl.json | 3 + .../eglfs_viv_wl/eglfs_viv_wl.pro | 23 ++++++ .../eglfs_viv_wl/qeglfsvivwlintegration.cpp | 93 ++++++++++++++++++++++ .../eglfs_viv_wl/qeglfsvivwlintegration.h | 60 ++++++++++++++ .../eglfs_viv_wl/qeglfsvivwlmain.cpp | 50 ++++++++++++ .../platforms/eglfs/qeglfsdeviceintegration.cpp | 5 ++ .../platforms/eglfs/qeglfsdeviceintegration.h | 2 + src/plugins/platforms/eglfs/qeglfsintegration.cpp | 9 ++- 9 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.json create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp (limited to 'src/plugins/platforms/eglfs') diff --git a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro index cf367d930f..266a97dff5 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro @@ -6,3 +6,4 @@ contains(QT_CONFIG, eglfs_egldevice): SUBDIRS += eglfs_kms_egldevice contains(QT_CONFIG, eglfs_brcm): SUBDIRS += eglfs_brcm contains(QT_CONFIG, eglfs_mali): SUBDIRS += eglfs_mali contains(QT_CONFIG, eglfs_viv): SUBDIRS += eglfs_viv +contains(QT_CONFIG, eglfs_viv_wl): SUBDIRS += eglfs_viv_wl diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.json b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.json new file mode 100644 index 0000000000..ced5245fa0 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "eglfs_viv_wl" ] +} diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro new file mode 100644 index 0000000000..26b6a2e9ea --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro @@ -0,0 +1,23 @@ +TARGET = qeglfs-viv-wl-integration + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSVivWaylandIntegrationPlugin +load(qt_plugin) + +QT += core-private gui-private platformsupport-private eglfs_device_lib-private + +INCLUDEPATH += $$PWD/../.. +CONFIG += egl +DEFINES += LINUX=1 EGL_API_FB=1 +LIBS += -lGAL +QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF + +SOURCES += $$PWD/qeglfsvivwlmain.cpp \ + $$PWD/qeglfsvivwlintegration.cpp + +HEADERS += $$PWD/qeglfsvivwlintegration.h + +OTHER_FILES += $$PWD/eglfs_viv_wl.json + +CONFIG += link_pkgconfig +PKGCONFIG_PRIVATE += wayland-server diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp new file mode 100644 index 0000000000..9eebcc772a --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qeglfsvivwlintegration.h" +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +void QEglFSVivWaylandIntegration::platformInit() +{ + QEGLDeviceIntegration::platformInit(); + + int width, height; + + bool multiBufferNotEnabledYet = qEnvironmentVariableIsEmpty("FB_MULTI_BUFFER"); + bool multiBuffer = qEnvironmentVariableIsEmpty("QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER"); + if (multiBufferNotEnabledYet && multiBuffer) { + qWarning() << "QEglFSVivWaylandIntegration will set environment variable FB_MULTI_BUFFER=2 to enable double buffering and vsync.\n" + << "If this is not desired, you can override this via: export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1"; + qputenv("FB_MULTI_BUFFER", "2"); + } + + mWaylandDisplay = wl_display_create(); + mNativeDisplay = fbGetDisplay(mWaylandDisplay); + fbGetDisplayGeometry(mNativeDisplay, &width, &height); + mScreenSize.setHeight(height); + mScreenSize.setWidth(width); +} + +QSize QEglFSVivWaylandIntegration::screenSize() const +{ + return mScreenSize; +} + +EGLNativeDisplayType QEglFSVivWaylandIntegration::platformDisplay() const +{ + return mNativeDisplay; +} + +EGLNativeWindowType QEglFSVivWaylandIntegration::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) +{ + Q_UNUSED(window) + Q_UNUSED(format) + + EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height()); + return eglWindow; +} + +void QEglFSVivWaylandIntegration::destroyNativeWindow(EGLNativeWindowType window) +{ + fbDestroyWindow(window); +} + +void *QEglFSVivWaylandIntegration::wlDisplay() const +{ + return mWaylandDisplay; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h new file mode 100644 index 0000000000..677a1b6337 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLFSVIVINTEGRATION_H +#define QEGLFSVIVINTEGRATION_H + +#include "qeglfsdeviceintegration.h" +struct wl_display; + +QT_BEGIN_NAMESPACE + +class QEglFSVivWaylandIntegration : public QEGLDeviceIntegration +{ +public: + void platformInit() Q_DECL_OVERRIDE; + QSize screenSize() const Q_DECL_OVERRIDE; + EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) Q_DECL_OVERRIDE; + void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE; + EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE; + + void *wlDisplay() const Q_DECL_OVERRIDE; +private: + QSize mScreenSize; + EGLNativeDisplayType mNativeDisplay; + wl_display *mWaylandDisplay; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp new file mode 100644 index 0000000000..a48aa08e40 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qeglfsdeviceintegration.h" +#include "qeglfsvivwlintegration.h" + +QT_BEGIN_NAMESPACE + +class QEglFSVivWaylandIntegrationPlugin : public QEGLDeviceIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv_wl.json") + +public: + QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivWaylandIntegration; } +}; + +QT_END_NAMESPACE + +#include "qeglfsvivwlmain.moc" diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp index 0c2aa7ad61..10c8091815 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp @@ -334,4 +334,9 @@ bool QEGLDeviceIntegration::supportsSurfacelessContexts() const return true; } +void *QEGLDeviceIntegration::wlDisplay() const +{ + return Q_NULLPTR; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h index d91d67de16..97082df7f5 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h @@ -97,6 +97,8 @@ public: virtual int framebufferIndex() const; virtual bool supportsPBuffers() const; virtual bool supportsSurfacelessContexts() const; + + virtual void *wlDisplay() const; }; class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 2df06caa6b..ac6bb34ff1 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -251,7 +251,8 @@ enum ResourceType { EglContext, EglConfig, NativeDisplay, - XlibDisplay + XlibDisplay, + WaylandDisplay }; static int resourceType(const QByteArray &key) @@ -262,7 +263,8 @@ static int resourceType(const QByteArray &key) QByteArrayLiteral("eglcontext"), QByteArrayLiteral("eglconfig"), QByteArrayLiteral("nativedisplay"), - QByteArrayLiteral("display") + QByteArrayLiteral("display"), + QByteArrayLiteral("wl_display") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -282,6 +284,9 @@ void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource case NativeDisplay: result = reinterpret_cast(nativeDisplay()); break; + case WaylandDisplay: + result = qt_egl_device_integration()->wlDisplay(); + break; default: break; } -- cgit v1.2.3