Last active
February 17, 2016 08:49
-
-
Save ortogonal/c54e458e2fa856ec0923 to your computer and use it in GitHub Desktop.
First set of patches to get QtWaylandCompositor running on iMX6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From dac3e3b75f117dede7aa577d48fc10efb5a53dd1 Mon Sep 17 00:00:00 2001 | |
From: Erik Larsson <[email protected]> | |
Date: Thu, 30 Oct 2014 10:49:03 +0100 | |
Subject: [PATCH] Add fix to get QtWayland Compositor running on iMX6. | |
This patch is not really done yet, it's just some test. | |
Change-Id: If57be6d26b3d56a772db73d29cede6215f033a80 | |
Signed-off-by: Erik Larsson <[email protected]> | |
--- | |
src/compositor/wayland_wrapper/qwlcompositor.cpp | 14 +++++++++++++- | |
src/compositor/wayland_wrapper/qwldisplay_p.h | 4 ++++ | |
.../wayland-egl/qwaylandeglclientbufferintegration.cpp | 1 + | |
3 files changed, 18 insertions(+), 1 deletion(-) | |
diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp | |
index faf32dc..c3c4ad1 100644 | |
--- a/src/compositor/wayland_wrapper/qwlcompositor.cpp | |
+++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp | |
@@ -61,6 +61,8 @@ | |
#include "qwaylandglobalinterface.h" | |
#include "qwaylandsurfaceview.h" | |
+#include <qpa/qplatformnativeinterface.h> | |
+ | |
#include <QWindow> | |
#include <QSocketNotifier> | |
#include <QScreen> | |
@@ -106,7 +108,7 @@ Compositor *Compositor::instance() | |
Compositor::Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::ExtensionFlags extensions) | |
: m_extensions(extensions) | |
- , m_display(new Display) | |
+ , m_display(NULL) | |
, m_default_input_device(0) | |
, m_current_frame(0) | |
, m_last_queued_buf(-1) | |
@@ -127,6 +129,16 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::Ex | |
, m_inputPanel() | |
, m_retainSelection(false) | |
{ | |
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); | |
+ if (nativeInterface) { | |
+ struct wl_display* disp = (struct wl_display*)nativeInterface->nativeResourceForIntegration(QByteArrayLiteral("waylanddisplay")); | |
+ m_display = new Display(disp); | |
+ qDebug() << Q_FUNC_INFO << "Gettings wl_display" << disp; | |
+ } else { | |
+ qDebug() << Q_FUNC_INFO << "No wl_display"; | |
+ m_display = new Display(); | |
+ } | |
+ | |
m_timer.start(); | |
compositor = this; | |
} | |
diff --git a/src/compositor/wayland_wrapper/qwldisplay_p.h b/src/compositor/wayland_wrapper/qwldisplay_p.h | |
index f18cb1e..8a968cf 100644 | |
--- a/src/compositor/wayland_wrapper/qwldisplay_p.h | |
+++ b/src/compositor/wayland_wrapper/qwldisplay_p.h | |
@@ -52,6 +52,10 @@ class Display | |
{ | |
public: | |
Display(); | |
+ Display(struct wl_display* display) { | |
+ m_display = display; | |
+ } | |
+ | |
~Display(); | |
struct wl_display *handle() const { return m_display; } | |
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp | |
index 99a3201..df1948e 100644 | |
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp | |
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp | |
@@ -84,6 +84,7 @@ void QWaylandEglClientBufferIntegration::initialize(QWaylandDisplay *display) | |
qWarning("EGL not available"); | |
return; | |
} | |
+ qDebug() << Q_FUNC_INFO << "m_eglDisplay" << m_eglDisplay; | |
if (!eglInitialize(m_eglDisplay, &major, &minor)) { | |
qWarning("failed to initialize EGL display"); | |
-- | |
1.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From c3e70187e6ab774b6cf06d678dfa23a85474576f Mon Sep 17 00:00:00 2001 | |
From: Erik Larsson <[email protected]> | |
Date: Thu, 30 Oct 2014 10:52:10 +0100 | |
Subject: [PATCH] Fix to make QtWayland compositor work with the iMX6 CPU. | |
This is not a finished version, it's just the first test. | |
Change-Id: Icb6b55dddc7bd8b2871a7aca1279ef30e3b496d4 | |
Signed-off-by: Erik Larsson <[email protected]> | |
--- | |
.../devices/linux-imx6-g++/qeglfshooks_imx6.cpp | 7 +++++++ | |
.../eglconvenience/qeglplatformintegration.cpp | 13 +++++++++--- | |
.../eglconvenience/qeglplatformintegration_p.h | 3 +++ | |
src/plugins/platforms/eglfs/eglfs.pro | 2 +- | |
src/plugins/platforms/eglfs/qeglfshooks.h | 1 + | |
src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | 6 ++++++ | |
src/plugins/platforms/eglfs/qeglfsintegration.cpp | 24 +++++++++++++++++++++- | |
src/plugins/platforms/eglfs/qeglfsintegration.h | 4 ++++ | |
8 files changed, 55 insertions(+), 5 deletions(-) | |
diff --git a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp | |
index 719d851..62fe2fb 100644 | |
--- a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp | |
+++ b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp | |
@@ -45,6 +45,7 @@ public: | |
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format); | |
virtual void destroyNativeWindow(EGLNativeWindowType window); | |
virtual EGLNativeDisplayType platformDisplay() const; | |
+ virtual EGLNativeDisplayType waylandDisplay(void *) const; | |
private: | |
QSize mScreenSize; | |
@@ -80,6 +81,12 @@ EGLNativeDisplayType QEglFSImx6Hooks::platformDisplay() const | |
return mNativeDisplay; | |
} | |
+EGLNativeDisplayType QEglFSImx6Hooks::waylandDisplay(void *display) const | |
+{ | |
+ qDebug() << Q_FUNC_INFO << "fbGetDisplay with wl_display" << display; | |
+ return fbGetDisplay(display); | |
+} | |
+ | |
EGLNativeWindowType QEglFSImx6Hooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) | |
{ | |
Q_UNUSED(window) | |
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp | |
index 7d05b54..b00fd70 100644 | |
--- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp | |
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp | |
@@ -102,7 +102,10 @@ QEGLPlatformIntegration::~QEGLPlatformIntegration() | |
void QEGLPlatformIntegration::initialize() | |
{ | |
- m_display = eglGetDisplay(nativeDisplay()); | |
+ /* ERIK: byta ut native display mot wl_display kanske? Och i så fall hur? */ | |
+ // TODO: Make some argument to controll if we use Wayland or not | |
+ qDebug() << Q_FUNC_INFO << "waylandDisplay() returns" << waylandDisplay(); | |
+ m_display = eglGetDisplay(waylandDisplay()); | |
if (m_display == EGL_NO_DISPLAY) | |
qFatal("Could not open egl display"); | |
@@ -193,7 +196,8 @@ enum ResourceType { | |
EglContext, | |
EglConfig, | |
NativeDisplay, | |
- XlibDisplay | |
+ XlibDisplay, | |
+ WaylandDisplay | |
}; | |
static int resourceType(const QByteArray &key) | |
@@ -204,7 +208,8 @@ static int resourceType(const QByteArray &key) | |
QByteArrayLiteral("eglcontext"), | |
QByteArrayLiteral("eglconfig"), | |
QByteArrayLiteral("nativedisplay"), | |
- QByteArrayLiteral("display") | |
+ QByteArrayLiteral("display"), | |
+ QByteArrayLiteral("waylanddisplay") | |
}; | |
const QByteArray *end = names + sizeof(names) / sizeof(names[0]); | |
const QByteArray *result = std::find(names, end, key); | |
@@ -224,6 +229,8 @@ void *QEGLPlatformIntegration::nativeResourceForIntegration(const QByteArray &re | |
case NativeDisplay: | |
result = reinterpret_cast<void*>(nativeDisplay()); | |
break; | |
+ case WaylandDisplay: | |
+ result = reinterpret_cast<void*>(waylandCompositorDisplay()); | |
default: | |
break; | |
} | |
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h | |
index 4d7adce..0021afb 100644 | |
--- a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h | |
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h | |
@@ -49,6 +49,7 @@ | |
#include <qpa/qplatformnativeinterface.h> | |
#include <QtCore/QVariant> | |
#include <EGL/egl.h> | |
+#include <wayland-server.h> | |
QT_BEGIN_NAMESPACE | |
@@ -103,6 +104,8 @@ protected: | |
QOffscreenSurface *surface) const = 0; | |
virtual EGLNativeDisplayType nativeDisplay() const { return EGL_DEFAULT_DISPLAY; } | |
+ virtual EGLNativeDisplayType waylandDisplay() const { return EGL_DEFAULT_DISPLAY; } | |
+ virtual struct wl_display* waylandCompositorDisplay() const { return NULL; } | |
void createInputHandlers(); | |
diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro | |
index 3ebe05b..60bc7f8 100644 | |
--- a/src/plugins/platforms/eglfs/eglfs.pro | |
+++ b/src/plugins/platforms/eglfs/eglfs.pro | |
@@ -6,5 +6,5 @@ PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin | |
load(qt_plugin) | |
SOURCES += $$PWD/main.cpp | |
- | |
+LIBS+=-lwayland-server | |
include(eglfs.pri) | |
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h | |
index c51af17..468fdef 100644 | |
--- a/src/plugins/platforms/eglfs/qeglfshooks.h | |
+++ b/src/plugins/platforms/eglfs/qeglfshooks.h | |
@@ -52,6 +52,7 @@ public: | |
virtual void platformInit(); | |
virtual void platformDestroy(); | |
virtual EGLNativeDisplayType platformDisplay() const; | |
+ virtual EGLNativeDisplayType waylandDisplay(void *display) const; | |
virtual QSizeF physicalScreenSize() const; | |
virtual QSize screenSize() const; | |
virtual QDpi logicalDpi() const; | |
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | |
index b6b1be9..e6eefa1 100644 | |
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | |
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | |
@@ -94,6 +94,12 @@ EGLNativeDisplayType QEglFSHooks::platformDisplay() const | |
return EGL_DEFAULT_DISPLAY; | |
} | |
+EGLNativeDisplayType QEglFSHooks::waylandDisplay(void *display) const | |
+{ | |
+ Q_UNUSED(display) | |
+ return EGL_DEFAULT_DISPLAY; | |
+} | |
+ | |
QSizeF QEglFSHooks::physicalScreenSize() const | |
{ | |
return q_physicalScreenSizeFromFb(framebuffer, screenSize()); | |
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp | |
index 2a4eae3..b574332 100644 | |
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp | |
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp | |
@@ -52,6 +52,7 @@ | |
#include <qpa/qplatformcursor.h> | |
#include <EGL/egl.h> | |
+#include <QDebug> | |
static void initResources() | |
{ | |
@@ -63,7 +64,8 @@ QT_BEGIN_NAMESPACE | |
QEglFSIntegration::QEglFSIntegration() | |
{ | |
mDisableInputHandlers = qgetenv("QT_QPA_EGLFS_DISABLE_INPUT").toInt(); | |
- | |
+ mWlDisplay = NULL; | |
+ mCompositorDisplay = NULL; | |
initResources(); | |
} | |
@@ -96,6 +98,26 @@ EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const | |
return QEglFSHooks::hooks()->platformDisplay(); | |
} | |
+EGLNativeDisplayType QEglFSIntegration::waylandDisplay() const | |
+{ | |
+ if (!mCompositorDisplay) { | |
+ mCompositorDisplay = wl_display_create(); | |
+ qDebug() << Q_FUNC_INFO << "allocate wl_display" << mCompositorDisplay; | |
+ } | |
+ | |
+ if (!mWlDisplay) { | |
+ mWlDisplay = QEglFSHooks::hooks()->waylandDisplay(mCompositorDisplay); | |
+ } | |
+ | |
+ return (EGLNativeDisplayType)mWlDisplay; | |
+} | |
+ | |
+struct wl_display* QEglFSIntegration::waylandCompositorDisplay() const | |
+{ | |
+ // TODO: This function shall return a wl_display pointer | |
+ return mCompositorDisplay; | |
+} | |
+ | |
QEGLPlatformScreen *QEglFSIntegration::createScreen() const | |
{ | |
return new QEglFSScreen(display()); | |
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h | |
index d612a27..92f2671 100644 | |
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h | |
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h | |
@@ -64,9 +64,13 @@ protected: | |
const QSurfaceFormat &format, | |
QOffscreenSurface *surface) const Q_DECL_OVERRIDE; | |
EGLNativeDisplayType nativeDisplay() const Q_DECL_OVERRIDE; | |
+ EGLNativeDisplayType waylandDisplay() const Q_DECL_OVERRIDE; | |
+ struct wl_display* waylandCompositorDisplay() const Q_DECL_OVERRIDE; | |
private: | |
bool mDisableInputHandlers; | |
+ mutable void *mWlDisplay; | |
+ mutable struct wl_display *mCompositorDisplay; | |
}; | |
QT_END_NAMESPACE | |
-- | |
1.9.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment