summaryrefslogtreecommitdiff
path: root/src/hardwareintegration
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2014-01-09 15:10:43 +0100
committerAndy Nichols <andy.nichols@digia.com>2014-01-09 16:10:23 +0100
commit1c70431808ca2d0797fda05bb9ee3640bff800bb (patch)
tree6bbf1333b7da5afea2e163263820d5c40dbc1ea3 /src/hardwareintegration
parent3e02c41cc43a20c8af41730934ae7bbac02ab861 (diff)
parentc9734e76ce03ebba63e34b60b16a9cca3efa3569 (diff)
downloadqtwayland-1c70431808ca2d0797fda05bb9ee3640bff800bb.tar.gz
Merge remote-tracking branch stable into dev
Conflicts: .qmake.conf src/compositor/hardware_integration/qwaylandclientbufferintegrationplugin.h src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp src/plugins/platforms/qwayland-brcm-egl/main.cpp src/plugins/platforms/qwayland-egl/main.cpp src/plugins/platforms/qwayland-generic/main.cpp src/plugins/platforms/qwayland-xcomposite-egl/main.cpp src/plugins/platforms/qwayland-xcomposite-glx/main.cpp Change-Id: I957c9bee893a9e19fc8c93f0e51292007fb3a4a8
Diffstat (limited to 'src/hardwareintegration')
-rw-r--r--src/hardwareintegration/client/brcm-egl/brcm-egl.pri13
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp127
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h94
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp291
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h103
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp105
-rw-r--r--src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h83
-rw-r--r--src/hardwareintegration/client/drm-egl-server/drm-egl-server.pri17
-rw-r--r--src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp168
-rw-r--r--src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h131
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp124
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h77
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h60
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h54
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp171
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h88
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp261
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h96
-rw-r--r--src/hardwareintegration/client/wayland-egl/wayland-egl.pri16
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp142
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h114
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp78
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h68
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp136
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h79
-rw-r--r--src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri19
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp109
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h78
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp134
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h107
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp123
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h80
-rw-r--r--src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri19
-rw-r--r--src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp63
-rw-r--r--src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h67
-rw-r--r--src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri10
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcm-egl.pri19
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp75
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h81
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp177
-rw-r--r--src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h78
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pri18
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp193
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h172
-rw-r--r--src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri14
-rw-r--r--src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp258
-rw-r--r--src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h77
-rw-r--r--src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri16
-rw-r--r--src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp144
-rw-r--r--src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h72
-rw-r--r--src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri16
-rw-r--r--src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp156
-rw-r--r--src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h80
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri15
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp69
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h85
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp78
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h71
-rw-r--r--src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h78
59 files changed, 5547 insertions, 0 deletions
diff --git a/src/hardwareintegration/client/brcm-egl/brcm-egl.pri b/src/hardwareintegration/client/brcm-egl/brcm-egl.pri
new file mode 100644
index 00000000..542c1c71
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/brcm-egl.pri
@@ -0,0 +1,13 @@
+INCLUDEPATH += $$PWD
+LIBS += -lEGL
+
+SOURCES += $$PWD/qwaylandbrcmeglintegration.cpp \
+ $$PWD/qwaylandbrcmglcontext.cpp \
+ $$PWD/qwaylandbrcmeglwindow.cpp
+
+HEADERS += $$PWD/qwaylandbrcmeglintegration.h \
+ $$PWD/qwaylandbrcmglcontext.h \
+ $$PWD/qwaylandbrcmeglwindow.h
+
+CONFIG += wayland-scanner
+WAYLANDCLIENTSOURCES += ../../../extensions/brcm.xml
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
new file mode 100644
index 00000000..197f4d2c
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandbrcmeglintegration.h"
+
+#include "qwaylandglintegration.h"
+
+#include "qwaylandbrcmeglwindow.h"
+#include "qwaylandbrcmglcontext.h"
+
+#include <QtCore/QDebug>
+
+#include "wayland-brcm-client-protocol.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandBrcmEglIntegration::QWaylandBrcmEglIntegration(QWaylandDisplay *waylandDisplay)
+ : m_waylandDisplay(waylandDisplay->wl_display())
+{
+ qDebug() << "Using Brcm-EGL";
+ waylandDisplay->addRegistryListener(wlDisplayHandleGlobal, this);
+}
+
+void QWaylandBrcmEglIntegration::wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
+{
+ Q_UNUSED(version);
+ if (interface == "qt_brcm") {
+ QWaylandBrcmEglIntegration *integration = static_cast<QWaylandBrcmEglIntegration *>(data);
+ integration->m_waylandBrcm = static_cast<struct qt_brcm *>(wl_registry_bind(registry, id, &qt_brcm_interface, 1));
+ }
+}
+
+qt_brcm *QWaylandBrcmEglIntegration::waylandBrcm() const
+{
+ return m_waylandBrcm;
+}
+
+QWaylandBrcmEglIntegration::~QWaylandBrcmEglIntegration()
+{
+ eglTerminate(m_eglDisplay);
+}
+
+void QWaylandBrcmEglIntegration::initialize()
+{
+ EGLint major,minor;
+ m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
+ if (m_eglDisplay == NULL) {
+ qWarning("EGL not available");
+ } else {
+ if (!eglInitialize(m_eglDisplay, &major, &minor)) {
+ qWarning("failed to initialize EGL display");
+ return;
+ }
+
+ eglFlushBRCM = (PFNEGLFLUSHBRCMPROC)eglGetProcAddress("eglFlushBRCM");
+ if (!eglFlushBRCM) {
+ qWarning("failed to resolve eglFlushBRCM, performance will suffer");
+ }
+
+ eglCreateGlobalImageBRCM = ::eglCreateGlobalImageBRCM;
+ if (!eglCreateGlobalImageBRCM) {
+ qWarning("failed to resolve eglCreateGlobalImageBRCM");
+ return;
+ }
+
+ eglDestroyGlobalImageBRCM = ::eglDestroyGlobalImageBRCM;
+ if (!eglDestroyGlobalImageBRCM) {
+ qWarning("failed to resolve eglDestroyGlobalImageBRCM");
+ return;
+ }
+ }
+}
+
+QWaylandWindow *QWaylandBrcmEglIntegration::createEglWindow(QWindow *window)
+{
+ return new QWaylandBrcmEglWindow(window);
+}
+
+QPlatformOpenGLContext *QWaylandBrcmEglIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const
+{
+ return new QWaylandBrcmGLContext(m_eglDisplay, glFormat, share);
+}
+
+EGLDisplay QWaylandBrcmEglIntegration::eglDisplay() const
+{
+ return m_eglDisplay;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
new file mode 100644
index 00000000..f1100d8d
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDBRCMEGLINTEGRATION_H
+#define QWAYLANDBRCMEGLINTEGRATION_H
+
+#include "qwaylandglintegration.h"
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext_brcm.h>
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandWindow;
+class QWindow;
+
+struct qt_brcm;
+
+class QWaylandBrcmEglIntegration : public QWaylandGLIntegration
+{
+public:
+ QWaylandBrcmEglIntegration(QWaylandDisplay *waylandDisplay);
+ ~QWaylandBrcmEglIntegration();
+
+ void initialize();
+
+ bool supportsThreadedOpenGL() const { return true; }
+
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const;
+
+ EGLDisplay eglDisplay() const;
+
+ struct qt_brcm *waylandBrcm() const;
+
+ PFNEGLFLUSHBRCMPROC eglFlushBRCM;
+ PFNEGLCREATEGLOBALIMAGEBRCMPROC eglCreateGlobalImageBRCM;
+ PFNEGLDESTROYGLOBALIMAGEBRCMPROC eglDestroyGlobalImageBRCM;
+
+private:
+ static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
+
+ struct wl_display *m_waylandDisplay;
+ struct qt_brcm *m_waylandBrcm;
+
+ EGLDisplay m_eglDisplay;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDBRCMEGLINTEGRATION_H
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp
new file mode 100644
index 00000000..5c67ba8e
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp
@@ -0,0 +1,291 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandbrcmeglwindow.h"
+
+#include "qwaylandbuffer.h"
+#include "qwaylandscreen.h"
+#include "qwaylandbrcmglcontext.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+
+#include <QtGui/QWindow>
+#include <qpa/qwindowsysteminterface.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext_brcm.h>
+
+#include <wayland-client.h>
+#include "wayland-brcm-client-protocol.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandBrcmBuffer : public QWaylandBuffer
+{
+public:
+ QWaylandBrcmBuffer(QWaylandDisplay *display,
+ struct qt_brcm *brcm,
+ const QSize &size,
+ EGLint *data,
+ int count,
+ struct wl_event_queue *eventQueue)
+ : m_size(size)
+ , m_released(true)
+ , m_display(display)
+ , m_eventQueue(eventQueue)
+ {
+ wl_array_init(&m_array);
+ m_data = static_cast<EGLint *>(wl_array_add(&m_array, count * sizeof(EGLint)));
+
+ for (int i = 0; i < count; ++i)
+ m_data[i] = data[i];
+
+ mBuffer = qt_brcm_create_buffer(brcm, size.width(), size.height(), &m_array);
+ wl_proxy_set_queue(reinterpret_cast<struct wl_proxy*>(mBuffer), m_eventQueue);
+
+ static const struct wl_buffer_listener buffer_listener = {
+ QWaylandBrcmBuffer::buffer_release
+ };
+
+ wl_buffer_add_listener(mBuffer, &buffer_listener, this);
+ }
+
+ ~QWaylandBrcmBuffer()
+ {
+ wl_array_release(&m_array);
+ }
+
+ QSize size() const { return m_size; }
+
+ void bind()
+ {
+ m_released = false;
+ }
+
+ void waitForRelease()
+ {
+ if (m_released)
+ return;
+ while (!m_released) {
+ wl_display_dispatch_queue(m_display->wl_display(), m_eventQueue);
+ }
+ }
+
+ static void buffer_release(void *data, wl_buffer *buffer)
+ {
+ Q_UNUSED(buffer);
+ static_cast<QWaylandBrcmBuffer *>(data)->m_released = true;
+ }
+
+private:
+
+ QSize m_size;
+ bool m_released;
+ wl_array m_array;
+ EGLint *m_data;
+ QWaylandDisplay *m_display;
+ struct wl_event_queue *m_eventQueue;
+};
+
+QWaylandBrcmEglWindow::QWaylandBrcmEglWindow(QWindow *window)
+ : QWaylandWindow(window)
+ , m_eglIntegration(static_cast<QWaylandBrcmEglIntegration *>(mDisplay->eglIntegration()))
+ , m_eglConfig(0)
+ , m_format(window->format())
+ , m_current(0)
+ , m_count(0)
+ , m_eventQueue(wl_display_create_queue(mDisplay->wl_display()))
+{
+}
+
+QWaylandBrcmEglWindow::~QWaylandBrcmEglWindow()
+{
+ destroyEglSurfaces();
+}
+
+QWaylandWindow::WindowType QWaylandBrcmEglWindow::windowType() const
+{
+ return QWaylandWindow::Egl;
+}
+
+void QWaylandBrcmEglWindow::setGeometry(const QRect &rect)
+{
+ destroyEglSurfaces();
+ QWaylandWindow::setGeometry(rect);
+}
+
+QSurfaceFormat QWaylandBrcmEglWindow::format() const
+{
+ return m_format;
+}
+
+void QWaylandBrcmEglWindow::destroyEglSurfaces()
+{
+ for (int i = 0; i < m_count; ++i) {
+ if (m_eglSurfaces[i]) {
+ eglDestroySurface(m_eglIntegration->eglDisplay(), m_eglSurfaces[i]);
+ m_eglSurfaces[i] = 0;
+ // the server does this
+ //m_eglIntegration->eglDestroyGlobalImageBRCM(&m_globalImages[5*i]);
+ delete m_buffers[i];
+ }
+ }
+
+ m_count = 0;
+ m_current = 0;
+}
+
+QSurfaceFormat brcmFixFormat(const QSurfaceFormat &f)
+{
+ QSurfaceFormat format = f;
+ format.setRedBufferSize(8);
+ format.setGreenBufferSize(8);
+ format.setBlueBufferSize(8);
+ format.setAlphaBufferSize(8);
+ return format;
+}
+
+void QWaylandBrcmEglWindow::createEglSurfaces()
+{
+ QSize size(geometry().size());
+
+ m_count = window()->format().swapBehavior() == QSurfaceFormat::TripleBuffer ? 3 : 2;
+
+ m_eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), brcmFixFormat(window()->format()), true, EGL_PIXMAP_BIT);
+
+ m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(), m_eglConfig);
+
+ EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM;
+
+ EGLint rt;
+ eglGetConfigAttrib(m_eglIntegration->eglDisplay(), m_eglConfig, EGL_RENDERABLE_TYPE, &rt);
+
+ if (rt & EGL_OPENGL_ES_BIT) {
+ pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM;
+ pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM;
+ }
+
+ if (rt & EGL_OPENGL_ES2_BIT) {
+ pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM;
+ pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM;
+ }
+
+ if (rt & EGL_OPENVG_BIT) {
+ pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM;
+ pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM;
+ }
+
+ if (rt & EGL_OPENGL_BIT) {
+ pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM;
+ }
+
+ memset(m_globalImages, 0, 5 * m_count * sizeof(EGLint));
+ for (int i = 0; i < m_count; ++i) {
+ m_eglIntegration->eglCreateGlobalImageBRCM(size.width(), size.height(), pixel_format,
+ 0, size.width() * 4, &m_globalImages[5*i]);
+
+ m_globalImages[5*i+2] = size.width();
+ m_globalImages[5*i+3] = size.height();
+ m_globalImages[5*i+4] = pixel_format;
+
+ EGLint attrs[] = {
+ EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
+ EGL_VG_ALPHA_FORMAT, pixel_format & EGL_PIXEL_FORMAT_ARGB_8888_PRE_BRCM ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE,
+ EGL_NONE
+ };
+
+ m_eglSurfaces[i] = eglCreatePixmapSurface(m_eglIntegration->eglDisplay(), m_eglConfig, (EGLNativePixmapType)&m_globalImages[5*i], attrs);
+ if (m_eglSurfaces[i] == EGL_NO_SURFACE)
+ qFatal("eglCreatePixmapSurface failed: %x, global image id: %d %d\n", eglGetError(), m_globalImages[5*i], m_globalImages[5*i+1]);
+ m_buffers[i] = new QWaylandBrcmBuffer(mDisplay, m_eglIntegration->waylandBrcm(), size, &m_globalImages[5*i], 5, m_eventQueue);
+ }
+}
+
+void QWaylandBrcmEglWindow::swapBuffers()
+{
+ if (m_eglIntegration->eglFlushBRCM) {
+ m_eglIntegration->eglFlushBRCM();
+ } else {
+ glFlush();
+ glFinish();
+ }
+
+ m_buffers[m_current]->bind();
+
+ m_mutex.lock();
+ m_pending << m_buffers[m_current];
+ m_mutex.unlock();
+
+ // can't use a direct call since swapBuffers might be called from a separate thread
+ QMetaObject::invokeMethod(this, "flushBuffers");
+
+ m_current = (m_current + 1) % m_count;
+
+ m_buffers[m_current]->waitForRelease();
+}
+
+void QWaylandBrcmEglWindow::flushBuffers()
+{
+ if (m_pending.isEmpty())
+ return;
+
+ QSize size = geometry().size();
+
+ m_mutex.lock();
+ while (!m_pending.isEmpty()) {
+ QWaylandBrcmBuffer *buffer = m_pending.takeFirst();
+ attach(buffer, 0, 0);
+ damage(QRect(QPoint(), size));
+ commit();
+ }
+ m_mutex.unlock();
+
+ mDisplay->flushRequests();
+}
+
+bool QWaylandBrcmEglWindow::makeCurrent(EGLContext context)
+{
+ if (!m_count)
+ const_cast<QWaylandBrcmEglWindow *>(this)->createEglSurfaces();
+ return eglMakeCurrent(m_eglIntegration->eglDisplay(), m_eglSurfaces[m_current], m_eglSurfaces[m_current], context);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h
new file mode 100644
index 00000000..5a3fa046
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDBRCMEGLWINDOW_H
+#define QWAYLANDBRCMEGLWINDOW_H
+
+#include "qwaylandwindow.h"
+#include "qwaylandbrcmeglintegration.h"
+
+#include <QMutex>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandGLContext;
+class QWaylandBrcmBuffer;
+
+class QWaylandBrcmEglWindow : public QWaylandWindow
+{
+ Q_OBJECT
+public:
+ QWaylandBrcmEglWindow(QWindow *window);
+ ~QWaylandBrcmEglWindow();
+ WindowType windowType() const;
+ void setGeometry(const QRect &rect);
+
+ QSurfaceFormat format() const;
+
+ bool makeCurrent(EGLContext context);
+ void swapBuffers();
+
+private slots:
+ void flushBuffers();
+
+private:
+ void createEglSurfaces();
+ void destroyEglSurfaces();
+
+ QWaylandBrcmEglIntegration *m_eglIntegration;
+ struct wl_egl_window *m_waylandEglWindow;
+
+ const QWaylandWindow *m_parentWindow;
+
+ EGLConfig m_eglConfig;
+
+ EGLint m_globalImages[3*5];
+ EGLSurface m_eglSurfaces[3];
+
+ QWaylandBrcmBuffer *m_buffers[3];
+ QSurfaceFormat m_format;
+
+ struct wl_event_queue *m_eventQueue;
+
+ int m_current;
+ int m_count;
+
+ QList<QWaylandBrcmBuffer *> m_pending;
+
+ QMutex m_mutex;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDBRCMEGLWINDOW_H
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp
new file mode 100644
index 00000000..dfb86e54
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandbrcmglcontext.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include "qwaylandbrcmeglwindow.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+
+#include <qpa/qplatformopenglcontext.h>
+#include <QtGui/QSurfaceFormat>
+
+QT_BEGIN_NAMESPACE
+
+extern QSurfaceFormat brcmFixFormat(const QSurfaceFormat &format);
+
+QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
+ : QPlatformOpenGLContext()
+ , m_eglDisplay(eglDisplay)
+ , m_config(q_configFromGLFormat(m_eglDisplay, brcmFixFormat(format), true))
+ , m_format(q_glFormatFromConfig(m_eglDisplay, m_config))
+{
+ EGLContext shareEGLContext = share ? static_cast<QWaylandBrcmGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2);
+ eglContextAttrs.append(EGL_NONE);
+
+ m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData());
+}
+
+QWaylandBrcmGLContext::~QWaylandBrcmGLContext()
+{
+ eglDestroyContext(m_eglDisplay, m_context);
+}
+
+bool QWaylandBrcmGLContext::makeCurrent(QPlatformSurface *surface)
+{
+ return static_cast<QWaylandBrcmEglWindow *>(surface)->makeCurrent(m_context);
+}
+
+void QWaylandBrcmGLContext::doneCurrent()
+{
+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+}
+
+void QWaylandBrcmGLContext::swapBuffers(QPlatformSurface *surface)
+{
+ static_cast<QWaylandBrcmEglWindow *>(surface)->swapBuffers();
+}
+
+void (*QWaylandBrcmGLContext::getProcAddress(const QByteArray &procName)) ()
+{
+ return eglGetProcAddress(procName.constData());
+}
+
+EGLConfig QWaylandBrcmGLContext::eglConfig() const
+{
+ return m_config;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h
new file mode 100644
index 00000000..7beef166
--- /dev/null
+++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDBRCMGLCONTEXT_H
+#define QWAYLANDBRCMGLCONTEXT_H
+
+#include "qwaylanddisplay.h"
+
+#include <qpa/qplatformopenglcontext.h>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandWindow;
+class QWaylandGLWindowSurface;
+
+class QWaylandBrcmGLContext : public QPlatformOpenGLContext {
+public:
+ QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share);
+ ~QWaylandBrcmGLContext();
+
+ void swapBuffers(QPlatformSurface *surface);
+
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
+
+ void (*getProcAddress(const QByteArray &procName)) ();
+
+ QSurfaceFormat format() const { return m_format; }
+
+ EGLConfig eglConfig() const;
+ EGLContext eglContext() const { return m_context; }
+
+private:
+ EGLDisplay m_eglDisplay;
+
+ EGLContext m_context;
+ EGLConfig m_config;
+ QSurfaceFormat m_format;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDBRCMGLCONTEXT_H
diff --git a/src/hardwareintegration/client/drm-egl-server/drm-egl-server.pri b/src/hardwareintegration/client/drm-egl-server/drm-egl-server.pri
new file mode 100644
index 00000000..dbc8dacf
--- /dev/null
+++ b/src/hardwareintegration/client/drm-egl-server/drm-egl-server.pri
@@ -0,0 +1,17 @@
+INCLUDEPATH += $$PWD
+
+contains(QT_CONFIG, no-pkg-config) {
+ LIBS += -lEGL -lwayland-client
+} else {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += egl wayland-client
+}
+
+SOURCES += \
+ $$PWD/drmeglserverbufferintegration.cpp
+
+HEADERS += \
+ $$PWD/drmeglserverbufferintegration.h
+
+CONFIG += wayland-scanner
+WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/drm-egl-server-buffer.xml
diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp
new file mode 100644
index 00000000..beb9106b
--- /dev/null
+++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "drmeglserverbufferintegration.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QDebug>
+#include <QtGui/QOpenGLContext>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+DrmServerBuffer::DrmServerBuffer(DrmEglServerBufferIntegration *integration
+ , int32_t name
+ , int32_t width
+ , int32_t height
+ , int32_t stride
+ , int32_t format)
+ : QWaylandServerBuffer()
+ , m_integration(integration)
+{
+ m_size = QSize(width, height);
+ EGLint egl_format;
+ int32_t format_stride;
+ switch (format) {
+ case QtWayland::qt_drm_egl_server_buffer::format_RGBA32:
+ m_format = QWaylandServerBuffer::RGBA32;
+ egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
+ format_stride = stride / 4;
+ break;
+#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
+ case QtWayland::qt_drm_egl_server_buffer::format_A8:
+ m_format = QWaylandServerBuffer::A8;
+ egl_format = EGL_DRM_BUFFER_FORMAT_A8_MESA;
+ format_stride = stride;
+ break;
+#endif
+ default:
+ qWarning("DrmServerBuffer: unknown format");
+ m_format = QWaylandServerBuffer::RGBA32;
+ egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
+ format_stride = stride / 4;
+ break;
+ }
+ EGLint attribs[] = {
+ EGL_WIDTH, width,
+ EGL_HEIGHT, height,
+ EGL_DRM_BUFFER_STRIDE_MESA, format_stride,
+ EGL_DRM_BUFFER_FORMAT_MESA, egl_format,
+ EGL_NONE
+ };
+
+ qintptr name_pointer = name;
+ m_image = integration->eglCreateImageKHR(EGL_NO_CONTEXT, EGL_DRM_BUFFER_MESA, (EGLClientBuffer) name_pointer, attribs);
+
+}
+
+DrmServerBuffer::~DrmServerBuffer()
+{
+ m_integration->eglDestroyImageKHR(m_image);
+}
+
+void DrmServerBuffer::bindTextureToBuffer()
+{
+ if (!QOpenGLContext::currentContext())
+ qWarning("DrmServerBuffer: creating texture with no current context");
+
+ m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+}
+
+void DrmEglServerBufferIntegration::initialize(QWaylandDisplay *display)
+{
+ m_egl_display = eglGetDisplay((EGLNativeDisplayType) display->wl_display());
+ if (EGL_NO_DISPLAY) {
+ qWarning("Failed to initialize drm egl server buffer integration. Could not get egl display from wl_display.");
+ return;
+ }
+
+ const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS);
+ if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) {
+ qWarning("Failed to initialize drm egl server buffer integration. There is no EGL_KHR_image extension.\n");
+ return;
+ }
+ m_egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ m_egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ if (!m_egl_create_image || !m_egl_destroy_image) {
+ qWarning("Failed to initialize drm egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR");
+ return;
+ }
+
+ m_gl_egl_image_target_texture = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
+ if (!m_gl_egl_image_target_texture) {
+ qWarning("Failed to initialize drm egl server buffer integration. Could not resolve glEGLImageTargetTexture2DOES");
+ return;
+ }
+
+ QtWayland::wl_registry::init(wl_display_get_registry(display->wl_display()));
+}
+
+QWaylandServerBuffer *DrmEglServerBufferIntegration::serverBuffer(struct qt_server_buffer *buffer)
+{
+ return static_cast<QWaylandServerBuffer *>(qt_server_buffer_get_user_data(buffer));
+}
+
+void DrmEglServerBufferIntegration::registry_global(uint32_t name, const QString &interface, uint32_t version)
+{
+ Q_UNUSED(version);
+ if (interface == QStringLiteral("qt_drm_egl_server_buffer")) {
+ struct ::wl_registry *registry = QtWayland::wl_registry::object();
+ QtWayland::qt_drm_egl_server_buffer::init(registry, name);
+ }
+}
+
+void DrmEglServerBufferIntegration::drm_egl_server_buffer_server_buffer_created(struct ::qt_server_buffer *id
+ , int32_t name
+ , int32_t width
+ , int32_t height
+ , int32_t stride
+ , int32_t format)
+{
+ DrmServerBuffer *server_buffer = new DrmServerBuffer(this, name, width, height, stride, format);
+ qt_server_buffer_set_user_data(id, server_buffer);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h
new file mode 100644
index 00000000..f74b8aca
--- /dev/null
+++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRMEGLSERVERBUFFERINTEGRATION_H
+#define DRMEGLSERVERBUFFERINTEGRATION_H
+
+#include <QtWaylandClient/private/qwayland-wayland.h>
+#include "qwayland-drm-egl-server-buffer.h"
+#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
+
+#include "drmeglserverbufferintegration.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtCore/QTextStream>
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#ifndef EGL_KHR_image
+typedef void *EGLImageKHR;
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
+#endif
+
+#ifndef GL_OES_EGL_image
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class DrmEglServerBufferIntegration;
+
+class DrmServerBuffer : public QWaylandServerBuffer
+{
+public:
+ DrmServerBuffer(DrmEglServerBufferIntegration *integration, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format);
+ ~DrmServerBuffer();
+ void bindTextureToBuffer() Q_DECL_OVERRIDE;
+private:
+ DrmEglServerBufferIntegration *m_integration;
+ EGLImageKHR m_image;
+};
+
+class DrmEglServerBufferIntegration
+ : public QWaylandServerBufferIntegration
+ , public QtWayland::wl_registry
+ , public QtWayland::qt_drm_egl_server_buffer
+{
+public:
+ void initialize(QWaylandDisplay *display) Q_DECL_OVERRIDE;
+
+ virtual QWaylandServerBuffer *serverBuffer(struct qt_server_buffer *buffer) Q_DECL_OVERRIDE;
+
+ inline EGLImageKHR eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+ inline EGLBoolean eglDestroyImageKHR (EGLImageKHR image);
+ inline void glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+protected:
+ void registry_global(uint32_t name, const QString &interface, uint32_t version) Q_DECL_OVERRIDE;
+ void drm_egl_server_buffer_server_buffer_created(struct ::qt_server_buffer *id, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format) Q_DECL_OVERRIDE;
+private:
+ PFNEGLCREATEIMAGEKHRPROC m_egl_create_image;
+ PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture;
+ EGLDisplay m_egl_display;
+};
+
+EGLImageKHR DrmEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+ if (!m_egl_create_image) {
+ qWarning("DrmEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR");
+ return EGL_NO_IMAGE_KHR;
+ }
+ return m_egl_create_image(m_egl_display, ctx, target, buffer,attrib_list);
+}
+
+EGLBoolean DrmEglServerBufferIntegration::eglDestroyImageKHR (EGLImageKHR image)
+{
+ if (!m_egl_destroy_image) {
+ qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglDestroyImageKHR");
+ return false;
+ }
+ return m_egl_destroy_image(m_egl_display, image);
+}
+
+void DrmEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
+{
+ if (!m_gl_egl_image_target_texture) {
+ qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function glEGLImageTargetRenderbufferStorageOES");
+ return;
+ }
+ m_gl_egl_image_target_texture(target,image);
+}
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
new file mode 100644
index 00000000..68d38c49
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandeglclientbufferintegration.h"
+
+#include "qwaylandeglwindow.h"
+#include "qwaylandglcontext.h"
+
+#include <wayland-client.h>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+static const char *qwaylandegl_threadedgl_blacklist_vendor[] = {
+ "Mesa Project",
+ 0
+};
+
+QWaylandEglClientBufferIntegration::QWaylandEglClientBufferIntegration()
+ : m_waylandDisplay(0)
+ , m_supportsThreading(false)
+{
+ qDebug() << "Using Wayland-EGL";
+}
+
+
+QWaylandEglClientBufferIntegration::~QWaylandEglClientBufferIntegration()
+{
+ eglTerminate(m_eglDisplay);
+}
+
+void QWaylandEglClientBufferIntegration::initialize(QWaylandDisplay *display)
+{
+ QByteArray eglPlatform = qgetenv("EGL_PLATFORM");
+ if (eglPlatform.isEmpty()) {
+ setenv("EGL_PLATFORM","wayland",true);
+ }
+
+ m_waylandDisplay = display->wl_display();
+
+ EGLint major,minor;
+ m_eglDisplay = eglGetDisplay((EGLNativeDisplayType) m_waylandDisplay);
+ if (m_eglDisplay == NULL) {
+ qWarning("EGL not available");
+ } else {
+ if (!eglInitialize(m_eglDisplay, &major, &minor)) {
+ qWarning("failed to initialize EGL display");
+ return;
+ }
+ }
+
+ m_supportsThreading = true;
+ if (qEnvironmentVariableIsSet("QT_OPENGL_NO_SANITY_CHECK"))
+ return;
+
+ const char *vendor = eglQueryString(m_eglDisplay, EGL_VENDOR);
+ for (int i = 0; qwaylandegl_threadedgl_blacklist_vendor[i]; ++i) {
+ if (strstr(vendor, qwaylandegl_threadedgl_blacklist_vendor[i]) != 0) {
+ m_supportsThreading = false;
+ break;
+ }
+ }
+}
+
+bool QWaylandEglClientBufferIntegration::supportsThreadedOpenGL() const
+{
+ return m_supportsThreading;
+}
+
+QWaylandWindow *QWaylandEglClientBufferIntegration::createEglWindow(QWindow *window)
+{
+ return new QWaylandEglWindow(window);
+}
+
+QPlatformOpenGLContext *QWaylandEglClientBufferIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const
+{
+ return new QWaylandGLContext(m_eglDisplay, glFormat, share);
+}
+
+EGLDisplay QWaylandEglClientBufferIntegration::eglDisplay() const
+{
+ return m_eglDisplay;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h
new file mode 100644
index 00000000..0c7d76cb
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDEGLINTEGRATION_H
+#define QWAYLANDEGLINTEGRATION_H
+
+#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
+
+#include "qwaylandeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandWindow;
+class QWindow;
+
+class QWaylandEglClientBufferIntegration : public QWaylandClientBufferIntegration
+{
+public:
+ QWaylandEglClientBufferIntegration();
+ ~QWaylandEglClientBufferIntegration();
+
+ void initialize(QWaylandDisplay *display) Q_DECL_OVERRIDE;
+ bool supportsThreadedOpenGL() const Q_DECL_OVERRIDE;
+
+ QWaylandWindow *createEglWindow(QWindow *window) Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const Q_DECL_OVERRIDE;
+
+ EGLDisplay eglDisplay() const;
+
+private:
+ struct wl_display *m_waylandDisplay;
+
+ EGLDisplay m_eglDisplay;
+ bool m_supportsThreading;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDEGLINTEGRATION_H
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h b/src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h
new file mode 100644
index 00000000..4eadacca
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDEGLWINDOW_H
+#define QWAYLANDEGLWINDOW_H
+
+#include <QtWaylandClient/qwaylanddisplay.h>
+
+#include "qwaylandeglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandEglDisplay : public QWaylandDisplay
+{
+public:
+
+ QWaylandEglDisplay()
+ : QWaylandDisplay()
+ { }
+};
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h
new file mode 100644
index 00000000..9b151a5e
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDEGLINCLUDE_H
+#define QWAYLANDEGLINCLUDE_H
+
+#include <string.h>
+#include <wayland-client.h>
+
+#include <wayland-egl.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#endif // QWAYLANDEGLINCLUDE_H
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
new file mode 100644
index 00000000..1e86bd31
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandeglwindow.h"
+
+#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include "qwaylandglcontext.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+
+#include <QDebug>
+#include <QtGui/QWindow>
+#include <qpa/qwindowsysteminterface.h>
+#include <QOpenGLFramebufferObject>
+#include <QOpenGLContext>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandEglWindow::QWaylandEglWindow(QWindow *window)
+ : QWaylandWindow(window)
+ , m_clientBufferIntegration(static_cast<QWaylandEglClientBufferIntegration *>(mDisplay->clientBufferIntegration()))
+ , m_waylandEglWindow(0)
+ , m_eglSurface(0)
+ , m_eglConfig(0)
+ , m_contentFBO(0)
+ , m_resize(false)
+ , m_format(window->requestedFormat())
+{
+ setGeometry(window->geometry());
+}
+
+QWaylandEglWindow::~QWaylandEglWindow()
+{
+ if (m_eglSurface) {
+ eglDestroySurface(m_clientBufferIntegration->eglDisplay(), m_eglSurface);
+ m_eglSurface = 0;
+ }
+
+ wl_egl_window_destroy(m_waylandEglWindow);
+
+ delete m_contentFBO;
+}
+
+QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
+{
+ return QWaylandWindow::Egl;
+}
+
+void QWaylandEglWindow::setGeometry(const QRect &rect)
+{
+ QWaylandWindow::setGeometry(rect);
+
+ createDecoration();
+ QMargins margins = frameMargins();
+ QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
+
+ if (m_waylandEglWindow) {
+ int current_width, current_height;
+ wl_egl_window_get_attached_size(m_waylandEglWindow,&current_width,&current_height);
+ if (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) {
+ wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
+ mOffset = QPoint();
+
+ m_resize = true;
+ }
+ } else {
+ m_waylandEglWindow = wl_egl_window_create(object(), sizeWithMargins.width(), sizeWithMargins.height());
+ }
+}
+
+QRect QWaylandEglWindow::contentsRect() const
+{
+ QRect r = geometry();
+ QMargins m = frameMargins();
+ return QRect(m.left(), m.bottom(), r.width(), r.height());
+}
+
+QSurfaceFormat QWaylandEglWindow::format() const
+{
+ return m_format;
+}
+
+EGLSurface QWaylandEglWindow::eglSurface() const
+{
+ if (!m_waylandEglWindow) {
+ QWaylandEglWindow *self = const_cast<QWaylandEglWindow *>(this);
+ self->createDecoration();
+ QMargins margins = frameMargins();
+ QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
+ m_waylandEglWindow = wl_egl_window_create(self->object(), sizeWithMargins.width(), sizeWithMargins.height());
+ }
+
+ if (!m_eglSurface) {
+ m_eglConfig = q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), window()->format(), true);
+ const_cast<QWaylandEglWindow *>(this)->m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(),m_eglConfig);
+
+ EGLNativeWindowType window = (EGLNativeWindowType) m_waylandEglWindow;
+ m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, window, 0);
+ }
+
+ return m_eglSurface;
+}
+
+GLuint QWaylandEglWindow::contentFBO() const
+{
+ if (!decoration())
+ return 0;
+
+ if (m_resize || !m_contentFBO) {
+ QOpenGLFramebufferObject *old = m_contentFBO;
+ m_contentFBO = new QOpenGLFramebufferObject(geometry().width(), geometry().height(), QOpenGLFramebufferObject::CombinedDepthStencil);
+
+ delete old;
+ m_resize = false;
+ }
+
+ return m_contentFBO->handle();
+}
+
+GLuint QWaylandEglWindow::contentTexture() const
+{
+ return m_contentFBO->texture();
+}
+
+void QWaylandEglWindow::bindContentFBO()
+{
+ if (decoration()) {
+ contentFBO();
+ m_contentFBO->bind();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
new file mode 100644
index 00000000..9f08559d
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDEGLWINDOW_H
+#define QWAYLANDEGLWINDOW_H
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include "qwaylandeglinclude.h"
+#include "qwaylandeglclientbufferintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandGLContext;
+class QOpenGLFramebufferObject;
+
+class QWaylandEglWindow : public QWaylandWindow
+{
+public:
+ QWaylandEglWindow(QWindow *window);
+ ~QWaylandEglWindow();
+ WindowType windowType() const;
+
+ virtual void setGeometry(const QRect &rect);
+ QRect contentsRect() const;
+
+ EGLSurface eglSurface() const;
+ GLuint contentFBO() const;
+ GLuint contentTexture() const;
+
+ QSurfaceFormat format() const;
+
+ void bindContentFBO();
+
+private:
+ QWaylandEglClientBufferIntegration *m_clientBufferIntegration;
+ mutable struct wl_egl_window *m_waylandEglWindow;
+
+ const QWaylandWindow *m_parentWindow;
+
+ mutable EGLSurface m_eglSurface;
+ mutable EGLConfig m_eglConfig;
+ mutable QOpenGLFramebufferObject *m_contentFBO;
+ mutable bool m_resize;
+
+ QSurfaceFormat m_format;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDEGLWINDOW_H
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
new file mode 100644
index 00000000..3bc1ff2b
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandglcontext.h"
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylanddecoration_p.h>
+#include "qwaylandeglwindow.h"
+
+#include <QDebug>
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtGui/private/qopenglcontext_p.h>
+#include <QtGui/private/qopengltexturecache_p.h>
+
+#include <qpa/qplatformopenglcontext.h>
+#include <QtGui/QSurfaceFormat>
+#include <QtGui/QOpenGLShaderProgram>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
+ : QPlatformOpenGLContext()
+ , m_eglDisplay(eglDisplay)
+ , m_config(q_configFromGLFormat(m_eglDisplay, format, true))
+ , m_format(q_glFormatFromConfig(m_eglDisplay, m_config))
+ , m_blitProgram(0)
+ , m_textureCache(0)
+ , mUseNativeDefaultFbo(false)
+{
+ m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
+
+ switch (m_format.renderableType()) {
+ case QSurfaceFormat::OpenVG:
+ eglBindAPI(EGL_OPENVG_API);
+ break;
+#ifdef EGL_VERSION_1_4
+# if !defined(QT_OPENGL_ES_2)
+ case QSurfaceFormat::DefaultRenderableType:
+# endif
+ case QSurfaceFormat::OpenGL:
+ eglBindAPI(EGL_OPENGL_API);
+ break;
+#endif
+ case QSurfaceFormat::OpenGLES:
+ default:
+ eglBindAPI(EGL_OPENGL_ES_API);
+ break;
+ }
+
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2);
+ eglContextAttrs.append(EGL_NONE);
+
+ m_context = eglCreateContext(m_eglDisplay, m_config, m_shareEGLContext, eglContextAttrs.constData());
+
+ if (m_context == EGL_NO_CONTEXT) {
+ m_context = eglCreateContext(m_eglDisplay, m_config, EGL_NO_CONTEXT, eglContextAttrs.constData());
+ m_shareEGLContext = EGL_NO_CONTEXT;
+ }
+}
+
+QWaylandGLContext::~QWaylandGLContext()
+{
+ delete m_blitProgram;
+ delete m_textureCache;
+ eglDestroyContext(m_eglDisplay, m_context);
+}
+
+bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
+{
+ QWaylandEglWindow *window = static_cast<QWaylandEglWindow *>(surface);
+
+ window->setCanResize(false);
+
+ EGLSurface eglSurface = window->eglSurface();
+ if (!eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_context)) {
+ qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this);
+ return false;
+ }
+
+ window->bindContentFBO();
+
+ return true;
+}
+
+void QWaylandGLContext::doneCurrent()
+{
+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+}
+
+void QWaylandGLContext::swapBuffers(QPlatformSurface *surface)
+{
+ QWaylandEglWindow *window = static_cast<QWaylandEglWindow *>(surface);
+
+ EGLSurface eglSurface = window->eglSurface();
+
+ if (window->decoration()) {
+ makeCurrent(surface);
+ if (!m_blitProgram) {
+ initializeOpenGLFunctions();
+ m_blitProgram = new QOpenGLShaderProgram();
+ m_blitProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, "attribute vec4 position;\n\
+ attribute vec4 texCoords;\n\
+ varying vec2 outTexCoords;\n\
+ void main()\n\
+ {\n\
+ gl_Position = position;\n\
+ outTexCoords = texCoords.xy;\n\
+ }");
+ m_blitProgram->addShaderFromSourceCode(QOpenGLShader::Fragment, "varying highp vec2 outTexCoords;\n\
+ uniform sampler2D texture;\n\
+ void main()\n\
+ {\n\
+ gl_FragColor = texture2D(texture, outTexCoords);\n\
+ }");
+
+ if (!m_blitProgram->link()) {
+ qDebug() << "Shader Program link failed.";
+ qDebug() << m_blitProgram->log();
+ }
+ }
+
+ if (!m_textureCache) {
+ m_textureCache = new QOpenGLTextureCache(this->context());
+ }
+
+ QRect windowRect = window->window()->frameGeometry();
+ glViewport(0, 0, windowRect.width(), windowRect.height());
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+ mUseNativeDefaultFbo = true;
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ mUseNativeDefaultFbo = false;
+
+ static const GLfloat squareVertices[] = {
+ -1.f, -1.f,
+ 1.0f, -1.f,
+ -1.f, 1.0f,
+ 1.0f, 1.0f
+ };
+
+ static const GLfloat inverseSquareVertices[] = {
+ -1.f, 1.f,
+ 1.f, 1.f,
+ -1.f, -1.f,
+ 1.f, -1.f
+ };
+
+ static const GLfloat textureVertices[] = {
+ 0.0f, 0.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ };
+
+ m_blitProgram->bind();
+
+ m_blitProgram->setUniformValue("texture", 0);
+
+ m_blitProgram->enableAttributeArray("position");
+ m_blitProgram->enableAttributeArray("texCoords");
+ m_blitProgram->setAttributeArray("texCoords", textureVertices, 2);
+
+ glActiveTexture(GL_TEXTURE0);
+
+ //Draw Decoration
+ m_blitProgram->setAttributeArray("position", inverseSquareVertices, 2);
+ QImage decorationImage = window->decoration()->contentImage();
+ m_textureCache->bindTexture(context(), decorationImage);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ //Draw Content
+ m_blitProgram->setAttributeArray("position", squareVertices, 2);
+ glBindTexture(GL_TEXTURE_2D, window->contentTexture());
+ QRect r = window->contentsRect();
+ glViewport(r.x(), r.y(), r.width(), r.height());
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ //Cleanup
+ m_blitProgram->disableAttributeArray("position");
+ m_blitProgram->disableAttributeArray("texCoords");
+ m_blitProgram->release();
+ }
+
+ eglSwapBuffers(m_eglDisplay, eglSurface);
+
+ window->setCanResize(true);
+}
+
+GLuint QWaylandGLContext::defaultFramebufferObject(QPlatformSurface *surface) const
+{
+ if (mUseNativeDefaultFbo)
+ return 0;
+
+ return static_cast<QWaylandEglWindow *>(surface)->contentFBO();
+}
+
+bool QWaylandGLContext::isSharing() const
+{
+ return m_shareEGLContext != EGL_NO_CONTEXT;
+}
+
+bool QWaylandGLContext::isValid() const
+{
+ return m_context != EGL_NO_CONTEXT;
+}
+
+void (*QWaylandGLContext::getProcAddress(const QByteArray &procName)) ()
+{
+ return eglGetProcAddress(procName.constData());
+}
+
+EGLConfig QWaylandGLContext::eglConfig() const
+{
+ return m_config;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
new file mode 100644
index 00000000..38548ac8
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDGLCONTEXT_H
+#define QWAYLANDGLCONTEXT_H
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+
+#include <qpa/qplatformopenglcontext.h>
+#include <QtGui/QOpenGLFunctions>
+
+#include "qwaylandeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandWindow;
+class QWaylandGLWindowSurface;
+class QOpenGLShaderProgram;
+class QOpenGLTextureCache;
+
+class QWaylandGLContext : public QPlatformOpenGLContext, protected QOpenGLFunctions
+{
+public:
+ QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share);
+ ~QWaylandGLContext();
+
+ void swapBuffers(QPlatformSurface *surface);
+
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
+
+ GLuint defaultFramebufferObject(QPlatformSurface *surface) const;
+
+ bool isSharing() const;
+ bool isValid() const;
+
+ void (*getProcAddress(const QByteArray &procName)) ();
+
+ QSurfaceFormat format() const { return m_format; }
+
+ EGLConfig eglConfig() const;
+ EGLContext eglContext() const { return m_context; }
+
+private:
+ EGLDisplay m_eglDisplay;
+
+ EGLContext m_context;
+ EGLContext m_shareEGLContext;
+ EGLConfig m_config;
+ QSurfaceFormat m_format;
+ QOpenGLShaderProgram *m_blitProgram;
+ QOpenGLTextureCache *m_textureCache;
+ bool mUseNativeDefaultFbo;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDGLCONTEXT_H
diff --git a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri
new file mode 100644
index 00000000..bf03a8c7
--- /dev/null
+++ b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri
@@ -0,0 +1,16 @@
+INCLUDEPATH += $$PWD
+!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += wayland-egl egl
+} else {
+ LIBS += -lwayland-egl -lEGL
+}
+
+SOURCES += $$PWD/qwaylandeglclientbufferintegration.cpp \
+ $$PWD/qwaylandglcontext.cpp \
+ $$PWD/qwaylandeglwindow.cpp
+
+HEADERS += $$PWD/qwaylandeglclientbufferintegration.h \
+ $$PWD/qwaylandglcontext.h \
+ $$PWD/qwaylandeglwindow.h \
+ $$PWD/qwaylandeglinclude.h
diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp
new file mode 100644
index 00000000..12ab0a47
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxcompositeeglclientbufferintegration.h"
+
+#include "qwaylandxcompositeeglwindow.h"
+
+#include <QtCore/QDebug>
+
+#include "wayland-xcomposite-client-protocol.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeEGLClientBufferIntegration::QWaylandXCompositeEGLClientBufferIntegration()
+ : QWaylandClientBufferIntegration()
+ , mWaylandDisplay(0)
+{
+ qDebug() << "Using XComposite-EGL";
+}
+
+QWaylandXCompositeEGLClientBufferIntegration::~QWaylandXCompositeEGLClientBufferIntegration()
+{
+ XCloseDisplay(mDisplay);
+}
+
+void QWaylandXCompositeEGLClientBufferIntegration::initialize(QWaylandDisplay *display)
+{
+ mWaylandDisplay = display;
+ mWaylandDisplay->addRegistryListener(&wlDisplayHandleGlobal, this);
+}
+
+QWaylandWindow * QWaylandXCompositeEGLClientBufferIntegration::createEglWindow(QWindow *window)
+{
+ return new QWaylandXCompositeEGLWindow(window,this);
+}
+
+QPlatformOpenGLContext *QWaylandXCompositeEGLClientBufferIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const
+{
+ return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay());
+}
+
+Display * QWaylandXCompositeEGLClientBufferIntegration::xDisplay() const
+{
+ return mDisplay;
+}
+
+EGLDisplay QWaylandXCompositeEGLClientBufferIntegration::eglDisplay() const
+{
+ return mEglDisplay;
+}
+
+int QWaylandXCompositeEGLClientBufferIntegration::screen() const
+{
+ return mScreen;
+}
+
+Window QWaylandXCompositeEGLClientBufferIntegration::rootWindow() const
+{
+ return mRootWindow;
+}
+
+QWaylandDisplay * QWaylandXCompositeEGLClientBufferIntegration::waylandDisplay() const
+{
+ return mWaylandDisplay;
+}
+qt_xcomposite * QWaylandXCompositeEGLClientBufferIntegration::waylandXComposite() const
+{
+ return mWaylandComposite;
+}
+
+const struct qt_xcomposite_listener QWaylandXCompositeEGLClientBufferIntegration::xcomposite_listener = {
+ QWaylandXCompositeEGLClientBufferIntegration::rootInformation
+};
+
+void QWaylandXCompositeEGLClientBufferIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
+{
+ Q_UNUSED(version);
+ if (interface == "qt_xcomposite") {
+ QWaylandXCompositeEGLClientBufferIntegration *integration = static_cast<QWaylandXCompositeEGLClientBufferIntegration *>(data);
+ integration->mWaylandComposite = static_cast<struct qt_xcomposite *>(wl_registry_bind(registry,id,&qt_xcomposite_interface,1));
+ qt_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
+ }
+
+}
+
+void QWaylandXCompositeEGLClientBufferIntegration::rootInformation(void *data, qt_xcomposite *xcomposite, const char *display_name, uint32_t root_window)
+{
+ Q_UNUSED(xcomposite);
+ QWaylandXCompositeEGLClientBufferIntegration *integration = static_cast<QWaylandXCompositeEGLClientBufferIntegration *>(data);
+
+ integration->mDisplay = XOpenDisplay(display_name);
+ integration->mRootWindow = (Window) root_window;
+ integration->mScreen = XDefaultScreen(integration->mDisplay);
+ integration->mEglDisplay = eglGetDisplay(integration->mDisplay);
+ eglBindAPI(EGL_OPENGL_ES_API);
+ EGLint minor,major;
+ if (!eglInitialize(integration->mEglDisplay,&major,&minor)) {
+ qFatal("Failed to initialize EGL");
+ }
+ eglSwapInterval(integration->eglDisplay(),0);
+ qDebug() << "ROOT INFORMATION" << integration->mDisplay << integration->mRootWindow << integration->mScreen;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h
new file mode 100644
index 00000000..9cf19e1c
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEEGLCLIENTBUFFERINTEGRATION_H
+#define QWAYLANDXCOMPOSITEEGLCLIENTBUFFERINTEGRATION_H
+
+#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
+#include <wayland-client.h>
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+#include <QtGui/QWindow>
+
+#include <qpa/qplatformopenglcontext.h>
+
+#include <QWaitCondition>
+
+#include <X11/Xlib.h>
+#include <EGL/egl.h>
+
+// avoid clashes with Qt::CursorShape
+#ifdef CursorShape
+# define X_CursorShape CursorShape
+# undef CursorShape
+#endif
+
+struct qt_xcomposite;
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeEGLClientBufferIntegration : public QWaylandClientBufferIntegration
+{
+public:
+ QWaylandXCompositeEGLClientBufferIntegration();
+ ~QWaylandXCompositeEGLClientBufferIntegration();
+
+ void initialize(QWaylandDisplay *dispaly) Q_DECL_OVERRIDE;
+ bool waitingForEvents() Q_DECL_OVERRIDE { return !mDisplay; }
+
+ QWaylandWindow *createEglWindow(QWindow *window) Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const Q_DECL_OVERRIDE;
+
+ QWaylandDisplay *waylandDisplay() const;
+ struct qt_xcomposite *waylandXComposite() const;
+
+ Display *xDisplay() const;
+ EGLDisplay eglDisplay() const;
+ int screen() const;
+ Window rootWindow() const;
+
+ bool supportsThreadedOpenGL() const { return true; }
+
+private:
+ QWaylandDisplay *mWaylandDisplay;
+ struct qt_xcomposite *mWaylandComposite;
+
+ Display *mDisplay;
+ EGLDisplay mEglDisplay;
+ int mScreen;
+ Window mRootWindow;
+
+ static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id,
+ const QString &interface, uint32_t version);
+
+ static const struct qt_xcomposite_listener xcomposite_listener;
+ static void rootInformation(void *data,
+ struct qt_xcomposite *xcomposite,
+ const char *display_name,
+ uint32_t root_window);
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEEGLCLIENTBUFFERINTEGRATION_H
diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp
new file mode 100644
index 00000000..1ebcdde1
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxcompositeeglcontext.h"
+
+#include "qwaylandxcompositeeglwindow.h"
+
+#include <QtCore/QDebug>
+#include <QtGui/QRegion>
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display)
+ : QEGLPlatformContext(format, share, display, q_configFromGLFormat(display, format, true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT), EGL_OPENGL_ES_API)
+{
+}
+
+void QWaylandXCompositeEGLContext::swapBuffers(QPlatformSurface *surface)
+{
+ QEGLPlatformContext::swapBuffers(surface);
+
+ QWaylandXCompositeEGLWindow *w =
+ static_cast<QWaylandXCompositeEGLWindow *>(surface);
+
+ QSize size = w->geometry().size();
+
+ w->attach(w->buffer(), 0, 0);
+ w->damage(QRect(QPoint(), size));
+ w->commit();
+ w->waitForFrameSync();
+}
+
+EGLSurface QWaylandXCompositeEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+{
+ return static_cast<QWaylandXCompositeEGLWindow *>(surface)->eglSurface();
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h
new file mode 100644
index 00000000..bc988480
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEEGLCONTEXT_H
+#define QWAYLANDXCOMPOSITEEGLCONTEXT_H
+
+#include <qpa/qplatformopenglcontext.h>
+
+#include "qwaylandxcompositeeglclientbufferintegration.h"
+
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeEGLWindow;
+
+class QWaylandXCompositeEGLContext : public QEGLPlatformContext
+{
+public:
+ QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display);
+
+ void swapBuffers(QPlatformSurface *surface);
+
+private:
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H
diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp
new file mode 100644
index 00000000..01d63241
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxcompositeeglwindow.h"
+#include "qwaylandxcompositebuffer.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
+
+#include "wayland-xcomposite-client-protocol.h"
+
+#include <X11/extensions/Xcomposite.h>
+#include "qwaylandxcompositeeglclientbufferintegration.h"
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLClientBufferIntegration *glxIntegration)
+ : QWaylandWindow(window)
+ , m_glxIntegration(glxIntegration)
+ , m_context(0)
+ , m_buffer(0)
+ , m_xWindow(0)
+ , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT))
+ , m_surface(0)
+{
+}
+
+QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const
+{
+ //yeah. this type needs a new name
+ return QWaylandWindow::Egl;
+}
+
+void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect)
+{
+ QWaylandWindow::setGeometry(rect);
+
+ if (m_surface) {
+ eglDestroySurface(m_glxIntegration->eglDisplay(), m_surface);
+ m_surface = 0;
+ }
+}
+
+EGLSurface QWaylandXCompositeEGLWindow::eglSurface() const
+{
+ if (!m_surface)
+ const_cast<QWaylandXCompositeEGLWindow *>(this)->createEglSurface();
+ return m_surface;
+}
+
+void QWaylandXCompositeEGLWindow::createEglSurface()
+{
+ QSize size(geometry().size());
+ if (size.isEmpty()) {
+ // QGLWidget wants a context for a window without geometry
+ size = QSize(1,1);
+ }
+
+ delete m_buffer;
+ //XFreePixmap deletes the glxPixmap as well
+ if (m_xWindow) {
+ XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
+ }
+
+ VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(m_glxIntegration->xDisplay(), m_glxIntegration->eglDisplay(), m_config);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = visualId;
+
+ int matchingCount = 0;
+ XVisualInfo *visualInfo = XGetVisualInfo(m_glxIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
+
+ Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(),m_glxIntegration->rootWindow(),visualInfo->visual,AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(),
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual);
+ XMapWindow(m_glxIntegration->xDisplay(), m_xWindow);
+
+ m_surface = eglCreateWindowSurface(m_glxIntegration->eglDisplay(), m_config, m_xWindow,0);
+ if (m_surface == EGL_NO_SURFACE) {
+ qFatal("Could not make eglsurface");
+ }
+
+ XSync(m_glxIntegration->xDisplay(),False);
+ m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
+ (uint32_t)m_xWindow,
+ size);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h
new file mode 100644
index 00000000..b45beaa2
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEEGLWINDOW_H
+#define QWAYLANDXCOMPOSITEEGLWINDOW_H
+
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
+#include <QtWaylandClient/private/qwaylandbuffer_p.h>
+
+#include "qwaylandxcompositeeglclientbufferintegration.h"
+#include "qwaylandxcompositeeglcontext.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeEGLWindow : public QWaylandWindow
+{
+public:
+ QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLClientBufferIntegration *glxIntegration);
+ WindowType windowType() const;
+
+ void setGeometry(const QRect &rect);
+
+ EGLSurface eglSurface() const;
+
+ QWaylandBuffer *buffer() { return m_buffer; }
+
+private:
+ void createEglSurface();
+
+ QWaylandXCompositeEGLClientBufferIntegration *m_glxIntegration;
+ QWaylandXCompositeEGLContext *m_context;
+ QWaylandBuffer *m_buffer;
+
+ Window m_xWindow;
+ EGLConfig m_config;
+ EGLSurface m_surface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEEGLWINDOW_H
diff --git a/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri b/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri
new file mode 100644
index 00000000..fa08daaf
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri
@@ -0,0 +1,19 @@
+INCLUDEPATH += $$PWD
+include($$PWD/../xcomposite_share/xcomposite_share.pri)
+
+!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += xcomposite egl x11
+} else {
+ LIBS += -lXcomposite -lEGL -lX11
+}
+
+SOURCES += \
+ $$PWD/qwaylandxcompositeeglcontext.cpp \
+ $$PWD/qwaylandxcompositeeglclientbufferintegration.cpp \
+ $$PWD/qwaylandxcompositeeglwindow.cpp
+
+HEADERS += \
+ $$PWD/qwaylandxcompositeeglcontext.h \
+ $$PWD/qwaylandxcompositeeglclientbufferintegration.h \
+ $$PWD/qwaylandxcompositeeglwindow.h
diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp
new file mode 100644
index 00000000..4ee02260
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QDebug>
+
+#include "qwaylandxcompositeglxcontext.h"
+
+#include "qwaylandxcompositeglxwindow.h"
+
+#include <QRegion>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen)
+ : m_display(display),
+ m_format(format)
+{
+ qDebug("creating XComposite-GLX context");
+
+ if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType)
+ m_format.setRenderableType(QSurfaceFormat::OpenGL);
+
+ if (m_format.renderableType() != QSurfaceFormat::OpenGL) {
+ qWarning("Unsupported renderable type");
+ return;
+ }
+
+ GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0;
+ GLXFBConfig config = qglx_findConfig(display, screen, m_format, GLX_WINDOW_BIT | GLX_PIXMAP_BIT);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config);
+ m_context = glXCreateContext(display, visualInfo, shareContext, true);
+ qglx_surfaceFormatFromGLXFBConfig(&m_format, display, config, m_context);
+}
+
+bool QWaylandXCompositeGLXContext::makeCurrent(QPlatformSurface *surface)
+{
+ Window xWindow = static_cast<QWaylandXCompositeGLXWindow *>(surface)->xWindow();
+
+ return glXMakeCurrent(m_display, xWindow, m_context);
+}
+
+void QWaylandXCompositeGLXContext::doneCurrent()
+{
+ glXMakeCurrent(m_display, 0, 0);
+}
+
+void QWaylandXCompositeGLXContext::swapBuffers(QPlatformSurface *surface)
+{
+ QWaylandXCompositeGLXWindow *w = static_cast<QWaylandXCompositeGLXWindow *>(surface);
+
+ QSize size = w->geometry().size();
+
+ glXSwapBuffers(m_display, w->xWindow());
+
+ w->attach(w->buffer(), 0, 0);
+ w->damage(QRect(QPoint(), size));
+ w->commit();
+ w->waitForFrameSync();
+}
+
+void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName)) ()
+{
+ return glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName.constData()));
+}
+
+QSurfaceFormat QWaylandXCompositeGLXContext::format() const
+{
+ return m_format;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h
new file mode 100644
index 00000000..de031126
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEGLXCONTEXT_H
+#define QWAYLANDXCOMPOSITEGLXCONTEXT_H
+
+#include <qpa/qplatformopenglcontext.h>
+
+#include "qwaylandxcompositeglxintegration.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeGLXWindow;
+class QWaylandShmBuffer;
+
+class QWaylandXCompositeGLXContext : public QPlatformOpenGLContext
+{
+public:
+ QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen);
+
+ QSurfaceFormat format() const;
+
+ void swapBuffers(QPlatformSurface *surface);
+
+ bool makeCurrent(QPlatformSurface *surface);
+ void doneCurrent();
+
+ void (*getProcAddress(const QByteArray &procName)) ();
+
+private:
+ GLXContext m_context;
+
+ Display *m_display;
+ QSurfaceFormat m_format;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H
diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp
new file mode 100644
index 00000000..62a9b0f3
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxcompositeglxintegration.h"
+
+#include "qwaylandxcompositeglxwindow.h"
+
+#include <QtCore/QDebug>
+
+#include "wayland-xcomposite-client-protocol.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay *waylandDisplay)
+ : mWaylandDisplay(waylandDisplay)
+ , mWaylandComposite(0)
+ , mDisplay(0)
+ , mScreen(0)
+ , mRootWindow(0)
+{
+ qDebug() << "Using XComposite-GLX";
+ waylandDisplay->addRegistryListener(QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, this);
+}
+
+QWaylandXCompositeGLXIntegration::~QWaylandXCompositeGLXIntegration()
+{
+ XCloseDisplay(mDisplay);
+}
+
+void QWaylandXCompositeGLXIntegration::initialize()
+{
+}
+
+QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window)
+{
+ return new QWaylandXCompositeGLXWindow(window, this);
+}
+
+QPlatformOpenGLContext *QWaylandXCompositeGLXIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const
+{
+ return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen);
+}
+
+Display * QWaylandXCompositeGLXIntegration::xDisplay() const
+{
+ return mDisplay;
+}
+
+int QWaylandXCompositeGLXIntegration::screen() const
+{
+ return mScreen;
+}
+
+Window QWaylandXCompositeGLXIntegration::rootWindow() const
+{
+ return mRootWindow;
+}
+
+QWaylandDisplay * QWaylandXCompositeGLXIntegration::waylandDisplay() const
+{
+ return mWaylandDisplay;
+}
+qt_xcomposite * QWaylandXCompositeGLXIntegration::waylandXComposite() const
+{
+ return mWaylandComposite;
+}
+
+const struct qt_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite_listener = {
+ QWaylandXCompositeGLXIntegration::rootInformation
+};
+
+void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
+{
+ Q_UNUSED(version);
+ if (interface == "qt_xcomposite") {
+ qDebug("XComposite-GLX: got qt_xcomposite global");
+ QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
+ integration->mWaylandComposite = static_cast<struct qt_xcomposite *>(wl_registry_bind(registry, id, &qt_xcomposite_interface, 1));
+ qt_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration);
+ }
+
+}
+
+void QWaylandXCompositeGLXIntegration::rootInformation(void *data, qt_xcomposite *xcomposite, const char *display_name, uint32_t root_window)
+{
+ Q_UNUSED(xcomposite);
+ QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data);
+
+ qDebug("XComposite-GLX: xcomposite listener callback");
+
+ integration->mDisplay = XOpenDisplay(display_name);
+ integration->mRootWindow = (Window) root_window;
+ integration->mScreen = XDefaultScreen(integration->mDisplay);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h
new file mode 100644
index 00000000..8e1d762d
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEGLXINTEGRATION_H
+#define QWAYLANDXCOMPOSITEGLXINTEGRATION_H
+
+#include <QtWaylandClient/qwaylandglintegration.h>
+#include <wayland-client.h>
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+#include <QtGui/QWindow>
+
+#include <X11/Xlib.h>
+
+// avoid clashes with Qt::CursorShape
+#ifdef CursorShape
+# define X_CursorShape CursorShape
+# undef CursorShape
+#endif
+
+struct qt_xcomposite;
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeGLXIntegration : public QWaylandGLIntegration
+{
+public:
+ QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly);
+ ~QWaylandXCompositeGLXIntegration();
+
+ void initialize();
+ bool waitingForEvents() { return !mDisplay; }
+
+ QWaylandWindow *createEglWindow(QWindow *window);
+ QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const;
+
+ QWaylandDisplay *waylandDisplay() const;
+ struct qt_xcomposite *waylandXComposite() const;
+
+ Display *xDisplay() const;
+ int screen() const;
+ Window rootWindow() const;
+
+ bool supportsThreadedOpenGL() const { return false; }
+
+private:
+ QWaylandDisplay *mWaylandDisplay;
+ struct qt_xcomposite *mWaylandComposite;
+
+ Display *mDisplay;
+ int mScreen;
+ Window mRootWindow;
+
+ static void wlDisplayHandleGlobal(void *data, struct wl_registry *registry, uint32_t id,
+ const QString &interface, uint32_t version);
+
+ static const struct qt_xcomposite_listener xcomposite_listener;
+ static void rootInformation(void *data,
+ struct qt_xcomposite *xcomposite,
+ const char *display_name,
+ uint32_t root_window);
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEGLXINTEGRATION_H
diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp
new file mode 100644
index 00000000..f33790f3
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxcompositeglxwindow.h"
+#include "qwaylandxcompositebuffer.h"
+
+#include <QtCore/QDebug>
+
+#include "wayland-xcomposite-client-protocol.h"
+#include <QtGui/QRegion>
+
+#include <X11/extensions/Xcomposite.h>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration)
+ : QWaylandWindow(window)
+ , m_glxIntegration(glxIntegration)
+ , m_xWindow(0)
+ , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format(), GLX_WINDOW_BIT | GLX_PIXMAP_BIT))
+ , m_buffer(0)
+{
+}
+
+QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const
+{
+ //yeah. this type needs a new name
+ return QWaylandWindow::Egl;
+}
+
+void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect)
+{
+ QWaylandWindow::setGeometry(rect);
+
+ if (m_xWindow) {
+ delete m_buffer;
+
+ XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
+ m_xWindow = 0;
+ }
+}
+
+Window QWaylandXCompositeGLXWindow::xWindow() const
+{
+ if (!m_xWindow)
+ const_cast<QWaylandXCompositeGLXWindow *>(this)->createSurface();
+
+ return m_xWindow;
+}
+
+void QWaylandXCompositeGLXWindow::createSurface()
+{
+ QSize size(geometry().size());
+ if (size.isEmpty()) {
+ //QGLWidget wants a context for a window without geometry
+ size = QSize(1,1);
+ }
+
+ if (!m_glxIntegration->xDisplay()) {
+ qWarning("XCompositeGLXWindow: X display still null?!");
+ return;
+ }
+
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config);
+ Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),
+ visualInfo->visual, AllocNone);
+
+ XSetWindowAttributes a;
+ a.background_pixel = WhitePixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen());
+ a.border_pixel = BlackPixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen());
+ a.colormap = cmap;
+ m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(),
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWBackPixel|CWBorderPixel|CWColormap, &a);
+
+ XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual);
+ XMapWindow(m_glxIntegration->xDisplay(), m_xWindow);
+
+ XSync(m_glxIntegration->xDisplay(), False);
+ m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
+ (uint32_t)m_xWindow,
+ size);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h
new file mode 100644
index 00000000..88f417f2
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEGLXWINDOW_H
+#define QWAYLANDXCOMPOSITEGLXWINDOW_H
+
+#include "qwaylandwindow.h"
+#include "qwaylandxcompositeglxintegration.h"
+#include "qwaylandxcompositeglxcontext.h"
+
+#include <QtCore/QWaitCondition>
+
+#include "qwaylandbuffer.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeGLXWindow : public QWaylandWindow
+{
+public:
+ QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration);
+ WindowType windowType() const;
+
+ void setGeometry(const QRect &rect);
+
+ Window xWindow() const;
+
+ QWaylandBuffer *buffer() { return m_buffer; }
+
+private:
+ void createSurface();
+
+ QWaylandXCompositeGLXIntegration *m_glxIntegration;
+
+ Window m_xWindow;
+ GLXFBConfig m_config;
+
+ QWaylandBuffer *m_buffer;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEGLXWINDOW_H
diff --git a/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri b/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri
new file mode 100644
index 00000000..cc41322b
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri
@@ -0,0 +1,19 @@
+INCLUDEPATH += $$PWD
+include ($$PWD/../xcomposite_share/xcomposite_share.pri)
+
+!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += xcomposite gl x11
+} else {
+ LIBS += -lXcomposite -lGL -lX11
+}
+
+SOURCES += \
+ $$PWD/qwaylandxcompositeglxcontext.cpp \
+ $$PWD/qwaylandxcompositeglxintegration.cpp \
+ $$PWD/qwaylandxcompositeglxwindow.cpp
+
+HEADERS += \
+ $$PWD/qwaylandxcompositeglxcontext.h \
+ $$PWD/qwaylandxcompositeglxintegration.h \
+ $$PWD/qwaylandxcompositeglxwindow.h
diff --git a/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp
new file mode 100644
index 00000000..94a9772a
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandxcompositebuffer.h"
+
+#include <wayland-client.h>
+#include "wayland-xcomposite-client-protocol.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(qt_xcomposite *xcomposite, uint32_t window, const QSize &size)
+ :mSize(size)
+{
+ mBuffer = qt_xcomposite_create_buffer(xcomposite,
+ window,
+ size.width(),
+ size.height());
+}
+
+QSize QWaylandXCompositeBuffer::size() const
+{
+ return mSize;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h b/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h
new file mode 100644
index 00000000..a2f42166
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDXCOMPOSITEBUFFER_H
+#define QWAYLANDXCOMPOSITEBUFFER_H
+
+#include <QtWaylandClient/private/qwaylandbuffer_p.h>
+#include <stdint.h>
+
+struct qt_xcomposite;
+struct wl_visual;
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandXCompositeBuffer : public QWaylandBuffer
+{
+public:
+ QWaylandXCompositeBuffer(qt_xcomposite *xcomposite,
+ uint32_t window,
+ const QSize &size);
+
+ QSize size() const;
+private:
+ QSize mSize;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDXCOMPOSITEBUFFER_H
diff --git a/src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri b/src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri
new file mode 100644
index 00000000..be3c9fc1
--- /dev/null
+++ b/src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri
@@ -0,0 +1,10 @@
+INCLUDEPATH += $$PWD
+
+CONFIG += wayland-scanner
+WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/xcomposite.xml
+
+HEADERS += \
+ $$PWD/qwaylandxcompositebuffer.h
+
+SOURCES += \
+ $$PWD/qwaylandxcompositebuffer.cpp
diff --git a/src/hardwareintegration/compositor/brcm-egl/brcm-egl.pri b/src/hardwareintegration/compositor/brcm-egl/brcm-egl.pri
new file mode 100644
index 00000000..c04b4abc
--- /dev/null
+++ b/src/hardwareintegration/compositor/brcm-egl/brcm-egl.pri
@@ -0,0 +1,19 @@
+PLUGIN_TYPE = waylandcompositors
+load(qt_plugin)
+
+QT = compositor compositor-private core-private gui-private
+
+INCLUDEPATH = $$PWD
+LIBS += -lwayland-server -lEGL
+
+SOURCES += \
+ brcmeglintegration.cpp \
+ brcmbuffer.cpp
+
+
+HEADERS += \
+ brcmeglintegration.h \
+ brcmbuffer.h
+
+CONFIG += wayland-scanner
+WAYLANDSERVERSOURCES += $$PWD/../../../extensions/brcm.xml
diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp
new file mode 100644
index 00000000..e4fbfb55
--- /dev/null
+++ b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "brcmbuffer.h"
+
+#include <EGL/eglext.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext_brcm.h>
+
+QT_BEGIN_NAMESPACE
+
+BrcmBuffer::BrcmBuffer(struct ::wl_client *client, uint32_t id, const QSize &size, EGLint *data, size_t count)
+ : QtWaylandServer::wl_buffer(client, id)
+ , m_handle(count)
+ , m_invertedY(false)
+ , m_size(size)
+{
+ for (size_t i = 0; i < count; ++i)
+ m_handle[i] = data[i];
+}
+
+BrcmBuffer::~BrcmBuffer()
+{
+ eglDestroyGlobalImageBRCM(handle());
+}
+
+void BrcmBuffer::buffer_destroy_resource(Resource *)
+{
+ delete this;
+}
+
+void BrcmBuffer::buffer_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h
new file mode 100644
index 00000000..6ec5868f
--- /dev/null
+++ b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BRCMBUFFER_H
+#define BRCMBUFFER_H
+
+#include <QtCompositor/private/qwlcompositor_p.h>
+#include <qwayland-server-wayland.h>
+
+#include <QtCore/QSize>
+#include <QtCore/QVector>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class BrcmBuffer : public QtWaylandServer::wl_buffer
+{
+public:
+ BrcmBuffer(struct ::wl_client *client, uint32_t id, const QSize &size, EGLint *data, size_t count);
+ ~BrcmBuffer();
+
+ bool isYInverted() const { return m_invertedY; }
+ void setInvertedY(bool inverted) { m_invertedY = inverted; }
+
+ EGLint *handle() { return m_handle.data(); }
+
+ QSize size() { return m_size; }
+
+ static BrcmBuffer *fromResource(struct ::wl_resource *resource) { return static_cast<BrcmBuffer*>(Resource::fromResource(resource)->buffer); }
+
+protected:
+ void buffer_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void buffer_destroy(Resource *resource) Q_DECL_OVERRIDE;
+
+private:
+ QVector<EGLint> m_handle;
+ bool m_invertedY;
+ QSize m_size;
+};
+
+QT_END_NAMESPACE
+
+#endif // BRCMBUFFER_H
diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp
new file mode 100644
index 00000000..a0be625d
--- /dev/null
+++ b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "brcmeglintegration.h"
+#include "brcmbuffer.h"
+#include <QtCompositor/private/qwlsurface_p.h>
+#include <QtCompositor/private/qwlcompositor_p.h>
+#include <QtCompositor/qwaylandsurface.h>
+#include <qpa/qplatformnativeinterface.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QOpenGLContext>
+#include <qpa/qplatformscreen.h>
+#include <QtGui/QWindow>
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/eglext_brcm.h>
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+QT_BEGIN_NAMESPACE
+
+class BrcmEglIntegrationPrivate
+{
+public:
+ BrcmEglIntegrationPrivate()
+ : egl_display(EGL_NO_DISPLAY)
+ , valid(false)
+ { }
+ EGLDisplay egl_display;
+ bool valid;
+ PFNEGLQUERYGLOBALIMAGEBRCMPROC eglQueryGlobalImageBRCM;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
+ PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
+ PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
+};
+
+BrcmEglIntegration::BrcmEglIntegration()
+ : QWaylandClientBufferIntegration()
+ , QtWaylandServer::qt_brcm()
+ , d_ptr(new BrcmEglIntegrationPrivate)
+{
+}
+
+void BrcmEglIntegration::initializeHardware(QtWayland::Display *waylandDisplay)
+{
+ Q_D(BrcmEglIntegration);
+
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ if (nativeInterface) {
+ d->egl_display = nativeInterface->nativeResourceForIntegration("EglDisplay");
+ if (!d->egl_display)
+ qWarning("Failed to acquire EGL display from platform integration");
+
+ d->eglQueryGlobalImageBRCM = eglQueryGlobalImageBRCM;
+
+ if (!d->eglQueryGlobalImageBRCM) {
+ qWarning("Failed to resolve eglQueryGlobalImageBRCM");
+ return;
+ }
+
+ d->glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+
+ if (!d->glEGLImageTargetTexture2DOES) {
+ qWarning("Failed to resolve glEGLImageTargetTexture2DOES");
+ return;
+ }
+
+ d->eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
+
+ if (!d->eglCreateImageKHR) {
+ qWarning("Failed to resolve eglCreateImageKHR");
+ return;
+ }
+
+ d->eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
+
+ if (!d->eglDestroyImageKHR) {
+ qWarning("Failed to resolve eglDestroyImageKHR");
+ return;
+ }
+ d->valid = true;
+ init(waylandDisplay->handle());
+ }
+}
+
+void BrcmEglIntegration::bindTextureToBuffer(struct ::wl_resource *buffer)
+{
+ Q_D(BrcmEglIntegration);
+ if (!d->valid) {
+ qWarning("bindTextureToBuffer failed!");
+ return;
+ }
+
+ BrcmBuffer *brcmBuffer = BrcmBuffer::fromResource(buffer);
+
+ if (!d->eglQueryGlobalImageBRCM(brcmBuffer->handle(), brcmBuffer->handle() + 2)) {
+ qWarning("eglQueryGlobalImageBRCM failed!");
+ return;
+ }
+
+ EGLImageKHR image = d->eglCreateImageKHR(d->egl_display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)brcmBuffer->handle(), NULL);
+ if (image == EGL_NO_IMAGE_KHR)
+ qWarning("eglCreateImageKHR() failed: %x\n", eglGetError());
+
+ d->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ d->eglDestroyImageKHR(d->egl_display, image);
+}
+
+bool BrcmEglIntegration::isYInverted(struct ::wl_resource *) const
+{
+ return false;
+}
+
+void BrcmEglIntegration::brcm_bind_resource(Resource *)
+{
+}
+
+void BrcmEglIntegration::brcm_create_buffer(Resource *resource, uint32_t id, int32_t width, int32_t height, wl_array *data)
+{
+ new BrcmBuffer(resource->client(), id, QSize(width, height), static_cast<EGLint *>(data->data), data->size / sizeof(EGLint));
+}
+
+QSize BrcmEglIntegration::bufferSize(struct ::wl_resource *buffer) const
+{
+ BrcmBuffer *brcmBuffer = BrcmBuffer::fromResource(buffer);
+
+ return brcmBuffer->size();
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h
new file mode 100644
index 00000000..f6486ed4
--- /dev/null
+++ b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BRCMEGLINTEGRATION_H
+#define BRCMEGLINTEGRATION_H
+
+#include <QtCompositor/qwaylandclientbufferintegration.h>
+#include "qwayland-server-brcm.h"
+
+#include <QtCore/QScopedPointer>
+
+QT_BEGIN_NAMESPACE
+
+class BrcmEglIntegrationPrivate;
+
+class BrcmEglIntegration : public QWaylandClientBufferIntegration, public QtWaylandServer::qt_brcm
+{
+ Q_DECLARE_PRIVATE(BrcmEglIntegration)
+public:
+ BrcmEglIntegration();
+
+ void initializeHardware(QtWayland::Display *waylandDisplay) Q_DECL_OVERRIDE;
+
+ void udpateTextureFromBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE;
+ bool isYInverted(struct ::wl_resource *) const Q_DECL_OVERRIDE;
+
+ QSize bufferSize(struct ::wl_resource *buffer) const Q_DECL_OVERRIDE;
+
+protected:
+ void brcm_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void brcm_create_buffer(Resource *resource, uint32_t id, int32_t width, int32_t height, wl_array *data) Q_DECL_OVERRIDE;
+
+private:
+ Q_DISABLE_COPY(BrcmEglIntegration)
+ QScopedPointer<BrcmEglIntegrationPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // BRCMEGLINTEGRATION_H
+
diff --git a/src/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pri b/src/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pri
new file mode 100644
index 00000000..cd2e2471
--- /dev/null
+++ b/src/hardwareintegration/compositor/drm-egl-server/drm-egl-server.pri
@@ -0,0 +1,18 @@
+INCLUDEPATH += $$PWD
+
+contains(QT_CONFIG, no-pkg-config) {
+ LIBS += -lwayland-server -lEGL
+} else {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += wayland-server egl
+}
+
+SOURCES += \
+ $$PWD/drmeglserverbufferintegration.cpp
+
+
+HEADERS += \
+ $$PWD/drmeglserverbufferintegration.h
+
+CONFIG += wayland-scanner
+WAYLANDSERVERSOURCES += $$PWD/../../../extensions/drm-egl-server-buffer.xml
diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp
new file mode 100644
index 00000000..9c7440dc
--- /dev/null
+++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "drmeglserverbufferintegration.h"
+
+#include <QtGui/QOpenGLContext>
+
+QT_BEGIN_NAMESPACE
+
+DrmEglServerBuffer::DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QSize &size, QWaylandServerBuffer::Format format)
+ : QWaylandServerBuffer(size,format)
+ , m_integration(integration)
+{
+ m_format = format;
+
+ EGLint egl_format;
+ switch (m_format) {
+ case RGBA32:
+ m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
+ egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
+ break;
+#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
+ case A8:
+ m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_A8;
+ egl_format = EGL_DRM_BUFFER_FORMAT_A8_MESA;
+ break;
+#endif
+ default:
+ qWarning("DrmEglServerBuffer: unsupported format");
+ m_drm_format = QtWaylandServer::qt_drm_egl_server_buffer::format_RGBA32;
+ egl_format = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
+ break;
+ }
+ EGLint imageAttribs[] = {
+ EGL_WIDTH, m_size.width(),
+ EGL_HEIGHT, m_size.height(),
+ EGL_DRM_BUFFER_FORMAT_MESA, egl_format,
+ EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA,
+ EGL_NONE
+ };
+
+ m_image = m_integration->eglCreateDRMImageMESA(imageAttribs);
+
+ EGLint handle;
+ if (!m_integration->eglExportDRMImageMESA(m_image, &m_name, &handle, &m_stride)) {
+ qWarning("DrmEglServerBuffer: Failed to export egl image");
+ }
+
+}
+
+struct ::wl_resource *DrmEglServerBuffer::resourceForClient(struct ::wl_client *client)
+{
+ QMultiMap<struct ::wl_client *, Resource *>::iterator it = resourceMap().find(client);
+ if (it == resourceMap().end()) {
+ QMultiMap<struct ::wl_client *, QtWaylandServer::qt_drm_egl_server_buffer::Resource *>::iterator drm_egl_it = m_integration->resourceMap().find(client);
+ if (drm_egl_it == m_integration->resourceMap().end()) {
+ qWarning("DrmEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the drm_egl interface");
+ return 0;
+ }
+ struct ::wl_resource *drm_egl_resource = (*drm_egl_it)->handle;
+ Resource *resource = add(client);
+ m_integration->send_server_buffer_created(drm_egl_resource, resource->handle, m_name, m_size.width(), m_size.height(), m_stride, m_drm_format);
+ return resource->handle;
+ }
+ return (*it)->handle;
+}
+
+void DrmEglServerBuffer::bindTextureToBuffer()
+{
+ if (!QOpenGLContext::currentContext()) {
+ qWarning("DrmEglServerBuffer: No current context when creating buffer. Texture loading will fail");
+ return;
+ }
+
+ m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+}
+
+DrmEglServerBufferIntegration::DrmEglServerBufferIntegration()
+{
+}
+
+DrmEglServerBufferIntegration::~DrmEglServerBufferIntegration()
+{
+}
+
+void DrmEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor)
+{
+ QWindow *window = compositor->window();
+ Q_ASSERT(QGuiApplication::platformNativeInterface());
+
+ m_egl_display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("egldisplay", window));
+ if (!m_egl_display) {
+ qWarning("Cant initialize drm egl server buffer integration. Missing egl display from platformplugin");
+ return;
+ }
+
+ const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS);
+ if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) {
+ qWarning("Failed to initialize drm egl server buffer integration. There is no EGL_KHR_image extension.\n");
+ return;
+ }
+ m_egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ m_egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ if (!m_egl_create_image || !m_egl_destroy_image) {
+ qWarning("Failed to initialize drm egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR");
+ return;
+ }
+
+ if (!extensionString || !strstr(extensionString, "EGL_MESA_drm_image")) {
+ qWarning("Failed to initialize drm egl server buffer integration. There is no EGL_MESA_drm_image extension.\n");
+ return;
+ }
+
+ m_egl_create_drm_image = reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC>(eglGetProcAddress("eglCreateDRMImageMESA"));
+ m_egl_export_drm_image = reinterpret_cast<PFNEGLEXPORTDRMIMAGEMESAPROC>(eglGetProcAddress("eglExportDRMImageMESA"));
+ if (!m_egl_create_drm_image || !m_egl_export_drm_image) {
+ qWarning("Failed to initialize drm egl server buffer integration. Could not find eglCreateDRMImageMESA or eglExportDRMImageMESA.\n");
+ return;
+ }
+
+ m_gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
+ if (!m_gl_egl_image_target_texture_2d) {
+ qWarning("Failed to initialize drm egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n");
+ return;
+ }
+
+ QtWaylandServer::qt_drm_egl_server_buffer::init(compositor->waylandDisplay());
+}
+
+bool DrmEglServerBufferIntegration::supportsFormat(QWaylandServerBuffer::Format format) const
+{
+ switch (format) {
+ case QWaylandServerBuffer::RGBA32:
+ return true;
+ case QWaylandServerBuffer::A8:
+#ifdef EGL_DRM_BUFFER_FORMAT_A8_MESA
+ return true;
+#else
+ return false;
+#endif
+ default:
+ return false;
+ }
+}
+
+QWaylandServerBuffer *DrmEglServerBufferIntegration::createServerBuffer(const QSize &size, QWaylandServerBuffer::Format format)
+{
+ return new DrmEglServerBuffer(this, size, format);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h
new file mode 100644
index 00000000..659b261e
--- /dev/null
+++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRMEGLSERVERBUFFERINTEGRATION_H
+#define DRMEGLSERVERBUFFERINTEGRATION_H
+
+#include <QtCompositor/qwaylandserverbufferintegration.h>
+
+#include "qwayland-server-drm-egl-server-buffer.h"
+
+#include <QtGui/QWindow>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+#include <QtGui/QGuiApplication>
+
+#include <QtCompositor/qwaylandcompositor.h>
+#include <QtCompositor/private/qwayland-server-server-buffer-extension.h>
+
+#include <QtCore/QDebug>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#ifndef EGL_KHR_image
+typedef void *EGLImageKHR;
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
+#endif
+
+#ifndef GL_OES_EGL_image
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+#ifndef EGL_MESA_drm_image
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class DrmEglServerBufferIntegration;
+
+class DrmEglServerBuffer : public QWaylandServerBuffer, public QtWaylandServer::qt_server_buffer
+{
+public:
+ DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QSize &size, QWaylandServerBuffer::Format format);
+
+ struct ::wl_resource *resourceForClient(struct ::wl_client *) Q_DECL_OVERRIDE;
+ void bindTextureToBuffer() Q_DECL_OVERRIDE;
+
+private:
+ DrmEglServerBufferIntegration *m_integration;
+
+ EGLImageKHR m_image;
+
+ int32_t m_name;
+ int32_t m_stride;
+ QtWaylandServer::qt_drm_egl_server_buffer::format m_drm_format;
+};
+
+class DrmEglServerBufferIntegration :
+ public QWaylandServerBufferIntegration,
+ public QtWaylandServer::qt_drm_egl_server_buffer
+{
+public:
+ DrmEglServerBufferIntegration();
+ ~DrmEglServerBufferIntegration();
+
+ void initializeHardware(QWaylandCompositor *);
+
+ bool supportsFormat(QWaylandServerBuffer::Format format) const Q_DECL_OVERRIDE;
+ QWaylandServerBuffer *createServerBuffer(const QSize &size, QWaylandServerBuffer::Format format) Q_DECL_OVERRIDE;
+
+ EGLDisplay display() const { return m_egl_display; }
+
+ inline EGLImageKHR eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+ inline EGLBoolean eglDestroyImageKHR (EGLImageKHR image);
+ inline EGLImageKHR eglCreateDRMImageMESA (const EGLint *attrib_list);
+ inline EGLBoolean eglExportDRMImageMESA (EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+ inline void glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+
+private:
+ EGLDisplay m_egl_display;
+ PFNEGLCREATEDRMIMAGEMESAPROC m_egl_create_drm_image;
+ PFNEGLEXPORTDRMIMAGEMESAPROC m_egl_export_drm_image;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture_2d;
+
+ PFNEGLCREATEIMAGEKHRPROC m_egl_create_image;
+ PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image;
+};
+
+EGLImageKHR DrmEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+ if (!m_egl_create_image) {
+ qWarning("DrmEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR");
+ return EGL_NO_IMAGE_KHR;
+ }
+ return m_egl_create_image(m_egl_display, ctx, target, buffer,attrib_list);
+}
+
+EGLBoolean DrmEglServerBufferIntegration::eglDestroyImageKHR (EGLImageKHR image)
+{
+ if (!m_egl_destroy_image) {
+ qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglDestroyImageKHR");
+ return false;
+ }
+ return m_egl_destroy_image(m_egl_display, image);
+}
+
+EGLImageKHR DrmEglServerBufferIntegration::eglCreateDRMImageMESA (const EGLint *attrib_list)
+{
+ if (m_egl_create_drm_image)
+ return m_egl_create_drm_image(m_egl_display, attrib_list);
+ else
+ qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglCreateDRMImageMESA");
+ return EGL_NO_IMAGE_KHR;
+
+}
+
+EGLBoolean DrmEglServerBufferIntegration::eglExportDRMImageMESA (EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride)
+{
+ if (m_egl_export_drm_image)
+ return m_egl_export_drm_image(m_egl_display, image, name, handle, stride);
+ else
+ qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function eglExportDRMImageMESA");
+ return 0;
+}
+
+void DrmEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
+{
+ if (m_gl_egl_image_target_texture_2d)
+ return m_gl_egl_image_target_texture_2d(target, image);
+ else
+ qWarning("DrmEglServerBufferIntegration: Trying to use unresolved function glEGLImageTargetTexture2DOES");
+}
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri b/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri
new file mode 100644
index 00000000..2d4771a2
--- /dev/null
+++ b/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri
@@ -0,0 +1,14 @@
+INCLUDEPATH += $$PWD
+
+!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += wayland-server wayland-egl egl
+} else {
+ LIBS += -lwayland-egl -lwayland-server -lEGL
+}
+
+SOURCES += \
+ $$PWD/waylandeglclientbufferintegration.cpp
+
+HEADERS += \
+ $$PWD/waylandeglclientbufferintegration.h
diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
new file mode 100644
index 00000000..a127b7bd
--- /dev/null
+++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "waylandeglclientbufferintegration.h"
+
+#include <QtCompositor/private/qwlcompositor_p.h>
+#include <QtCompositor/private/qwlsurface_p.h>
+#include <qpa/qplatformnativeinterface.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QOpenGLContext>
+#include <qpa/qplatformscreen.h>
+#include <QtGui/QWindow>
+#include <QtCore/QPointer>
+
+#include <QDebug>
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#ifndef EGL_WL_bind_wayland_display
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, struct wl_buffer *buffer, EGLint attribute, EGLint *value);
+#endif
+
+#ifndef EGL_KHR_image
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
+#endif
+
+#ifndef GL_OES_EGL_image
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class WaylandEglClientBufferIntegrationPrivate
+{
+public:
+ WaylandEglClientBufferIntegrationPrivate()
+ : egl_display(EGL_NO_DISPLAY)
+ , valid(false)
+ , display_bound(false)
+ , flipperConnected(false)
+ , egl_bind_wayland_display(0)
+ , egl_unbind_wayland_display(0)
+ , egl_query_wayland_buffer(0)
+ , egl_create_image(0)
+ , egl_destroy_image(0)
+ , gl_egl_image_target_texture_2d(0)
+ { }
+ EGLDisplay egl_display;
+ bool valid;
+ bool display_bound;
+ bool flipperConnected;
+ PFNEGLBINDWAYLANDDISPLAYWL egl_bind_wayland_display;
+ PFNEGLUNBINDWAYLANDDISPLAYWL egl_unbind_wayland_display;
+ PFNEGLQUERYWAYLANDBUFFERWL egl_query_wayland_buffer;
+
+ PFNEGLCREATEIMAGEKHRPROC egl_create_image;
+ PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image;
+
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_egl_image_target_texture_2d;
+};
+
+WaylandEglClientBufferIntegration::WaylandEglClientBufferIntegration()
+ : QWaylandClientBufferIntegration()
+ , d_ptr(new WaylandEglClientBufferIntegrationPrivate)
+{
+}
+
+void WaylandEglClientBufferIntegration::initializeHardware(QtWayland::Display *waylandDisplay)
+{
+ Q_D(WaylandEglClientBufferIntegration);
+
+ const bool ignoreBindDisplay = !qgetenv("QT_WAYLAND_IGNORE_BIND_DISPLAY").isEmpty();
+
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ if (!nativeInterface) {
+ qWarning("Failed to initialize egl display. No native platform interface available.\n");
+ return;
+ }
+
+ d->egl_display = nativeInterface->nativeResourceForWindow("EglDisplay", m_compositor->window());
+ if (!d->egl_display) {
+ qWarning("Failed to initialize egl display. Could not get EglDisplay for window.\n");
+ return;
+ }
+
+ const char *extensionString = eglQueryString(d->egl_display, EGL_EXTENSIONS);
+ if ((!extensionString || !strstr(extensionString, "EGL_WL_bind_wayland_display")) && !ignoreBindDisplay) {
+ qWarning("Failed to initialize egl display. There is no EGL_WL_bind_wayland_display extension.\n");
+ return;
+ }
+
+ d->egl_bind_wayland_display = reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
+ d->egl_unbind_wayland_display = reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL"));
+ if ((!d->egl_bind_wayland_display || !d->egl_unbind_wayland_display) && !ignoreBindDisplay) {
+ qWarning("Failed to initialize egl display. Could not find eglBindWaylandDisplayWL and eglUnbindWaylandDisplayWL.\n");
+ return;
+ }
+
+ d->egl_query_wayland_buffer = reinterpret_cast<PFNEGLQUERYWAYLANDBUFFERWL>(eglGetProcAddress("eglQueryWaylandBufferWL"));
+ if (!d->egl_query_wayland_buffer) {
+ qWarning("Failed to initialize egl display. Could not find eglQueryWaylandBufferWL.\n");
+ return;
+ }
+
+ d->egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ d->egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ if (!d->egl_create_image || !d->egl_destroy_image) {
+ qWarning("Failed to initialize egl display. Could not find eglCreateImageKHR and eglDestroyImageKHR.\n");
+ return;
+ }
+
+ d->gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
+ if (!d->gl_egl_image_target_texture_2d) {
+ qWarning("Failed to initialize egl display. Could not find glEGLImageTargetTexture2DOES.\n");
+ return;
+ }
+
+ if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) {
+ d->display_bound = d->egl_bind_wayland_display(d->egl_display, waylandDisplay->handle());
+ if (!d->display_bound && !ignoreBindDisplay) {
+ qWarning("Failed to initialize egl display. Could not bind Wayland display.\n");
+ return;
+ }
+ }
+
+ d->valid = true;
+
+ qWarning("EGL Wayland extension successfully initialized.%s\n", !d->display_bound ? " eglBindWaylandDisplayWL ignored" : "");
+}
+
+void WaylandEglClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer)
+{
+ Q_D(WaylandEglClientBufferIntegration);
+ if (!d->valid) {
+ qWarning("bindTextureToBuffer() failed");
+ return;
+ }
+
+ EGLImageKHR image = d->egl_create_image(d->egl_display, EGL_NO_CONTEXT,
+ EGL_WAYLAND_BUFFER_WL,
+ buffer, NULL);
+
+ d->gl_egl_image_target_texture_2d(GL_TEXTURE_2D, image);
+
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ d->egl_destroy_image(d->egl_display, image);
+}
+
+bool WaylandEglClientBufferIntegration::isYInverted(struct ::wl_resource *buffer) const
+{
+#if defined(EGL_WAYLAND_Y_INVERTED_WL)
+ Q_D(const WaylandEglClientBufferIntegration);
+
+ EGLint isYInverted;
+ EGLBoolean ret;
+ ret = d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_WAYLAND_Y_INVERTED_WL, &isYInverted);
+
+ // Yes, this looks strange, but the specification says that EGL_FALSE return
+ // value (not supported) should be treated the same as EGL_TRUE return value
+ // and EGL_TRUE in value.
+ if (ret == EGL_FALSE || isYInverted == EGL_TRUE)
+ return true;
+#endif
+
+ return QWaylandClientBufferIntegration::isYInverted(buffer);
+}
+
+
+bool WaylandEglClientBufferIntegration::setDirectRenderSurface(QWaylandSurface *surface)
+{
+ Q_D(WaylandEglClientBufferIntegration);
+
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(m_compositor->window());
+ QPlatformScreenPageFlipper *flipper = screen ? screen->pageFlipper() : 0;
+ if (flipper && !d->flipperConnected) {
+ QObject::connect(flipper, SIGNAL(bufferReleased(QPlatformScreenBuffer*)), m_compositor->handle(), SLOT(releaseBuffer(QPlatformScreenBuffer*)));
+ d->flipperConnected = true;
+ }
+ Q_UNUSED(surface);
+ return flipper;
+}
+
+void *WaylandEglClientBufferIntegration::lockNativeBuffer(struct ::wl_resource *buffer, QOpenGLContext *) const
+{
+ Q_D(const WaylandEglClientBufferIntegration);
+
+ EGLImageKHR image = d->egl_create_image(d->egl_display, EGL_NO_CONTEXT,
+ EGL_WAYLAND_BUFFER_WL,
+ buffer, NULL);
+ return image;
+}
+
+void WaylandEglClientBufferIntegration::unlockNativeBuffer(void *native_buffer, QOpenGLContext *) const
+{
+ Q_D(const WaylandEglClientBufferIntegration);
+ EGLImageKHR image = static_cast<EGLImageKHR>(native_buffer);
+
+ d->egl_destroy_image(d->egl_display, image);
+}
+
+QSize WaylandEglClientBufferIntegration::bufferSize(struct ::wl_resource *buffer) const
+{
+ Q_D(const WaylandEglClientBufferIntegration);
+
+ int width, height;
+ d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_WIDTH, &width);
+ d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_HEIGHT, &height);
+
+ return QSize(width, height);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h
new file mode 100644
index 00000000..a289baa0
--- /dev/null
+++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WAYLANDEGLINTEGRATION_H
+#define WAYLANDEGLINTEGRATION_H
+
+#include <QtCompositor/qwaylandclientbufferintegration.h>
+#include <QtCore/QScopedPointer>
+
+QT_BEGIN_NAMESPACE
+
+class WaylandEglClientBufferIntegrationPrivate;
+
+class WaylandEglClientBufferIntegration : public QWaylandClientBufferIntegration
+{
+ Q_DECLARE_PRIVATE(WaylandEglClientBufferIntegration)
+public:
+ WaylandEglClientBufferIntegration();
+
+ void initializeHardware(QtWayland::Display *waylandDisplay) Q_DECL_OVERRIDE;
+
+ void bindTextureToBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE;
+ bool isYInverted(struct ::wl_resource *) const Q_DECL_OVERRIDE;
+
+ bool setDirectRenderSurface(QWaylandSurface *) Q_DECL_OVERRIDE;
+
+ void *lockNativeBuffer(struct ::wl_resource *buffer, QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ void unlockNativeBuffer(void *native_buffer, QOpenGLContext *context) const Q_DECL_OVERRIDE;
+
+ QSize bufferSize(struct ::wl_resource *buffer) const Q_DECL_OVERRIDE;
+
+private:
+ Q_DISABLE_COPY(WaylandEglClientBufferIntegration)
+ QScopedPointer<WaylandEglClientBufferIntegrationPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // WAYLANDEGLINTEGRATION_H
+
diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri b/src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri
new file mode 100644
index 00000000..cde790bd
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri
@@ -0,0 +1,16 @@
+include($$PWD/../xcomposite_share/xcomposite_share.pri)
+
+!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += xcomposite egl x11 wayland-server
+} else {
+ LIBS += -lXcomposite -lEGL -lX11
+}
+
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/xcompositeeglintegration.h
+
+SOURCES += \
+ $$PWD/xcompositeeglintegration.cpp
diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp
new file mode 100644
index 00000000..c645b997
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "xcompositeeglintegration.h"
+
+#include "wayland-xcomposite-server-protocol.h"
+
+#include <QtCompositor/private/qwlcompositor_p.h>
+#include <QtGui/QGuiApplication>
+#include <qpa/qplatformnativeinterface.h>
+#include <qpa/qplatformopenglcontext.h>
+
+#include "xcompositebuffer.h"
+#include "xcompositehandler.h"
+#include <X11/extensions/Xcomposite.h>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QVector<EGLint> eglbuildSpec()
+{
+ QVector<EGLint> spec;
+
+ spec.append(EGL_SURFACE_TYPE); spec.append(EGL_WINDOW_BIT | EGL_PIXMAP_BIT);
+ spec.append(EGL_RENDERABLE_TYPE); spec.append(EGL_OPENGL_ES2_BIT);
+ spec.append(EGL_BIND_TO_TEXTURE_RGBA); spec.append(EGL_TRUE);
+ spec.append(EGL_ALPHA_SIZE); spec.append(8);
+ spec.append(EGL_NONE);
+ return spec;
+}
+
+XCompositeEglClientBufferIntegration::XCompositeEglClientBufferIntegration()
+ : QWaylandClientBufferIntegration()
+ , mDisplay(0)
+{
+
+}
+
+void XCompositeEglClientBufferIntegration::initializeHardware(QtWayland::Display *)
+{
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ if (nativeInterface) {
+ mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForWindow("Display",m_compositor->window()));
+ if (!mDisplay)
+ qFatal("could not retireve Display from platform integration");
+ mEglDisplay = static_cast<EGLDisplay>(nativeInterface->nativeResourceForWindow("EGLDisplay",m_compositor->window()));
+ if (!mEglDisplay)
+ qFatal("could not retrieve EGLDisplay from platform integration");
+ } else {
+ qFatal("Platform integration doesn't have native interface");
+ }
+ mScreen = XDefaultScreen(mDisplay);
+ new XCompositeHandler(m_compositor->handle(), mDisplay);
+}
+
+void XCompositeEglClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer)
+{
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
+ Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window());
+
+ QVector<EGLint> eglConfigSpec = eglbuildSpec();
+
+ EGLint matching = 0;
+ EGLConfig config;
+ bool matched = eglChooseConfig(mEglDisplay,eglConfigSpec.constData(),&config,1,&matching);
+ if (!matched || !matching) {
+ qWarning("Could not retrieve a suitable EGL config");
+ return;
+ }
+
+ QVector<EGLint> attribList;
+
+ attribList.append(EGL_TEXTURE_FORMAT);
+ attribList.append(EGL_TEXTURE_RGBA);
+ attribList.append(EGL_TEXTURE_TARGET);
+ attribList.append(EGL_TEXTURE_2D);
+ attribList.append(EGL_NONE);
+
+ EGLSurface surface = eglCreatePixmapSurface(mEglDisplay,config,pixmap,attribList.constData());
+ if (surface == EGL_NO_SURFACE) {
+ qDebug() << "Failed to create eglsurface" << pixmap << compositorBuffer->window();
+ }
+
+ compositorBuffer->setInvertedY(true);
+
+ if (!eglBindTexImage(mEglDisplay,surface,EGL_BACK_BUFFER)) {
+ qDebug() << "Failed to bind";
+ }
+
+ // eglDestroySurface(mEglDisplay,surface);
+}
+
+bool XCompositeEglClientBufferIntegration::isYInverted(struct ::wl_resource *buffer) const
+{
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
+ return compositorBuffer->isYInverted();
+}
+
+QSize XCompositeEglClientBufferIntegration::bufferSize(struct ::wl_resource *buffer) const
+{
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
+
+ return compositorBuffer->size();
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h
new file mode 100644
index 00000000..5497daed
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XCOMPOSITEEGLINTEGRATION_H
+#define XCOMPOSITEEGLINTEGRATION_H
+
+#include <QtCompositor/qwaylandclientbufferintegration.h>
+
+#include "xlibinclude.h"
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class XCompositeEglClientBufferIntegration : public QWaylandClientBufferIntegration
+{
+public:
+ XCompositeEglClientBufferIntegration();
+
+ void initializeHardware(QtWayland::Display *waylandDisplay) Q_DECL_OVERRIDE;
+
+ void bindTextureToBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE;
+ bool isYInverted(struct ::wl_resource *) const Q_DECL_OVERRIDE;
+
+ QSize bufferSize(struct ::wl_resource *buffer) const Q_DECL_OVERRIDE;
+
+private:
+ Display *mDisplay;
+ EGLDisplay mEglDisplay;
+ int mScreen;
+};
+
+QT_END_NAMESPACE
+
+#endif // XCOMPOSITEEGLINTEGRATION_H
diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri b/src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri
new file mode 100644
index 00000000..ccbbe46a
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri
@@ -0,0 +1,16 @@
+include($$PWD/../xcomposite_share/xcomposite_share.pri)
+
+!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += xcomposite gl x11 wayland-server
+} else {
+ LIBS += -lXcomposite -lGL -lX11
+}
+
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/xcompositeglxintegration.h
+
+SOURCES += \
+ $$PWD/xcompositeglxintegration.cpp
diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
new file mode 100644
index 00000000..a58827ce
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "xcompositeglxintegration.h"
+
+#include <QtCompositor/private/qwlcompositor_p.h>
+#include "wayland-xcomposite-server-protocol.h"
+
+#include <qpa/qplatformnativeinterface.h>
+#include <qpa/qplatformintegration.h>
+#include <QtGui/QOpenGLContext>
+
+#include "xcompositebuffer.h"
+#include "xcompositehandler.h"
+#include <X11/extensions/Xcomposite.h>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QVector<int> qglx_buildSpec()
+{
+ QVector<int> spec(48);
+ int i = 0;
+
+ spec[i++] = GLX_LEVEL;
+ spec[i++] = 0;
+ spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_PIXMAP_BIT | GLX_WINDOW_BIT;
+ spec[i++] = GLX_BIND_TO_TEXTURE_TARGETS_EXT; spec[i++] = GLX_TEXTURE_2D_BIT_EXT;
+ spec[i++] = GLX_BIND_TO_TEXTURE_RGB_EXT; spec[i++] = true;
+
+ spec[i++] = 0;
+ return spec;
+}
+
+
+XCompositeGLXClientBufferIntegration::XCompositeGLXClientBufferIntegration()
+ : QWaylandClientBufferIntegration()
+ , mDisplay(0)
+ , mHandler(0)
+{
+}
+
+XCompositeGLXClientBufferIntegration::~XCompositeGLXClientBufferIntegration()
+{
+ delete mHandler;
+}
+
+void XCompositeGLXClientBufferIntegration::initializeHardware(QtWayland::Display *)
+{
+ QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface();
+ if (nativeInterface) {
+ mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForWindow("Display",m_compositor->window()));
+ if (!mDisplay)
+ qFatal("could not retireve Display from platform integration");
+ } else {
+ qFatal("Platform integration doesn't have native interface");
+ }
+ mScreen = XDefaultScreen(mDisplay);
+
+ mHandler = new XCompositeHandler(m_compositor->handle(), mDisplay);
+
+ QOpenGLContext *glContext = new QOpenGLContext();
+ glContext->create();
+
+ m_glxBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT"));
+ if (!m_glxBindTexImageEXT) {
+ qDebug() << "Did not find glxBindTexImageExt, everything will FAIL!";
+ }
+ m_glxReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT"));
+ if (!m_glxReleaseTexImageEXT) {
+ qDebug() << "Did not find glxReleaseTexImageExt";
+ }
+
+ delete glContext;
+}
+
+void XCompositeGLXClientBufferIntegration::updateTextureFromBuffer(struct ::wl_resource *buffer)
+{
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
+ Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window());
+
+ QVector<int> glxConfigSpec = qglx_buildSpec();
+ int numberOfConfigs;
+ GLXFBConfig *configs = glXChooseFBConfig(mDisplay,mScreen,glxConfigSpec.constData(),&numberOfConfigs);
+
+ QVector<int> attribList;
+ attribList.append(GLX_TEXTURE_FORMAT_EXT);
+ attribList.append(GLX_TEXTURE_FORMAT_RGB_EXT);
+ attribList.append(GLX_TEXTURE_TARGET_EXT);
+ attribList.append(GLX_TEXTURE_2D_EXT);
+ attribList.append(0);
+ GLXPixmap glxPixmap = glXCreatePixmap(mDisplay,*configs,pixmap,attribList.constData());
+
+ uint inverted = 0;
+ glXQueryDrawable(mDisplay, glxPixmap, GLX_Y_INVERTED_EXT,&inverted);
+ compositorBuffer->setInvertedY(!inverted);
+
+ XFree(configs);
+
+ m_glxBindTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT, 0);
+ //Do we need to change the api so that we do bind and release in the painevent?
+ //The specification states that when deleting the texture the color buffer is deleted
+// m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT);
+}
+
+bool XCompositeGLXClientBufferIntegration::isYInverted(struct ::wl_resource *buffer) const
+{
+ return XCompositeBuffer::fromResource(buffer)->isYInverted();
+}
+
+QSize XCompositeGLXClientBufferIntegration::bufferSize(struct ::wl_resource *buffer) const
+{
+ XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
+
+ return compositorBuffer->size();
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h
new file mode 100644
index 00000000..5a724eed
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XCOMPOSITEGLXINTEGRATION_H
+#define XCOMPOSITEGLXINTEGRATION_H
+
+#include <QtCompositor/qwaylandclientbufferintegration.h>
+
+#include "xlibinclude.h"
+
+#define GLX_GLXEXT_PROTOTYPES
+#include <GL/glx.h>
+#include <GL/glxext.h>
+
+QT_BEGIN_NAMESPACE
+
+class XCompositeHandler;
+
+class XCompositeGLXClientBufferIntegration : public QWaylandClientBufferIntegration
+{
+public:
+ XCompositeGLXClientBufferIntegration();
+ ~XCompositeGLXClientBufferIntegration();
+
+ void initializeHardware(QtWayland::Display *waylandDisplay) Q_DECL_OVERRIDE;
+
+ void bindTextureToBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE;
+ bool isYInverted(struct ::wl_resource *) const Q_DECL_OVERRIDE;
+
+ QSize bufferSize(struct ::wl_resource *buffer) const Q_DECL_OVERRIDE;
+
+private:
+ PFNGLXBINDTEXIMAGEEXTPROC m_glxBindTexImageEXT;
+ PFNGLXRELEASETEXIMAGEEXTPROC m_glxReleaseTexImageEXT;
+
+ Display *mDisplay;
+ int mScreen;
+ XCompositeHandler *mHandler;
+};
+
+QT_END_NAMESPACE
+
+#endif // XCOMPOSITEGLXINTEGRATION_H
diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri b/src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri
new file mode 100644
index 00000000..06937c41
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri
@@ -0,0 +1,15 @@
+INCLUDEPATH += $$PWD
+
+CONFIG += wayland-scanner
+WAYLANDSERVERSOURCES += $$PWD/../../../extensions/xcomposite.xml $$PWD/../../../3rdparty/protocol/wayland.xml
+
+HEADERS += \
+ $$PWD/xcompositebuffer.h \
+ $$PWD/xcompositehandler.h \
+ $$PWD/xlibinclude.h
+
+SOURCES += \
+ $$PWD/xcompositebuffer.cpp \
+ $$PWD/xcompositehandler.cpp
+
+QT += gui-private
diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp
new file mode 100644
index 00000000..0457214b
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "xcompositebuffer.h"
+
+QT_BEGIN_NAMESPACE
+
+XCompositeBuffer::XCompositeBuffer(Window window, const QSize &size,
+ struct ::wl_client *client, uint32_t id)
+ : QtWaylandServer::wl_buffer(client, id)
+ , mWindow(window)
+ , mInvertedY(false)
+ , mSize(size)
+{
+}
+
+void XCompositeBuffer::buffer_destroy_resource(Resource *)
+{
+ delete this;
+}
+
+void XCompositeBuffer::buffer_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+Window XCompositeBuffer::window()
+{
+ return mWindow;
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h
new file mode 100644
index 00000000..20cf399b
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XCOMPOSITEBUFFER_H
+#define XCOMPOSITEBUFFER_H
+
+#include <private/qwlcompositor_p.h>
+#include <qwayland-server-wayland.h>
+
+#include <QtCore/QSize>
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+
+#include <X11/X.h>
+
+QT_BEGIN_NAMESPACE
+
+class XCompositeBuffer : public QtWaylandServer::wl_buffer
+{
+public:
+ XCompositeBuffer(Window window, const QSize &size,
+ struct ::wl_client *client, uint32_t id);
+
+ Window window();
+
+ bool isYInverted() const { return mInvertedY; }
+ void setInvertedY(bool inverted) { mInvertedY = inverted; }
+
+ QSize size() const { return mSize; }
+
+ static XCompositeBuffer *fromResource(struct ::wl_resource *resource) { return static_cast<XCompositeBuffer*>(Resource::fromResource(resource)->buffer); }
+
+protected:
+ void buffer_destroy_resource(Resource *) Q_DECL_OVERRIDE;
+ void buffer_destroy(Resource *) Q_DECL_OVERRIDE;
+
+private:
+ Window mWindow;
+ bool mInvertedY;
+ QSize mSize;
+};
+
+QT_END_NAMESPACE
+
+#endif // XCOMPOSITORBUFFER_H
diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp
new file mode 100644
index 00000000..0f10d38d
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "xcompositehandler.h"
+
+#include "wayland-xcomposite-server-protocol.h"
+
+#include "xcompositebuffer.h"
+#include <X11/extensions/Xcomposite.h>
+
+QT_BEGIN_NAMESPACE
+
+XCompositeHandler::XCompositeHandler(QtWayland::Compositor *compositor, Display *display)
+ : QtWaylandServer::qt_xcomposite(compositor->wl_display())
+{
+ compositor->window()->create();
+
+ mFakeRootWindow = new QWindow(compositor->window());
+ mFakeRootWindow->setGeometry(QRect(-1,-1,1,1));
+ mFakeRootWindow->create();
+ mFakeRootWindow->show();
+
+ int composite_event_base, composite_error_base;
+ if (!XCompositeQueryExtension(display, &composite_event_base, &composite_error_base))
+ qFatal("XComposite required");
+
+ mDisplayString = QString::fromLocal8Bit(XDisplayString(display));
+}
+
+void XCompositeHandler::xcomposite_bind_resource(Resource *resource)
+{
+ send_root(resource->handle, mDisplayString, mFakeRootWindow->winId());
+}
+
+void XCompositeHandler::xcomposite_create_buffer(Resource *resource, uint32_t id, uint32_t window,
+ int32_t width, int32_t height)
+{
+ new XCompositeBuffer(Window(window), QSize(width, height), resource->client(), id);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h
new file mode 100644
index 00000000..678ad446
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XCOMPOSITEHANDLER_H
+#define XCOMPOSITEHANDLER_H
+
+#include <QtCompositor/private/qwlcompositor_p.h>
+
+#include "xlibinclude.h"
+
+#include "qwayland-server-xcomposite.h"
+#include <wayland-server.h>
+
+QT_BEGIN_NAMESPACE
+
+class XCompositeHandler : public QtWaylandServer::qt_xcomposite
+{
+public:
+ XCompositeHandler(QtWayland::Compositor *compositor, Display *display);
+
+private:
+ QWindow *mFakeRootWindow;
+
+ QString mDisplayString;
+
+ void xcomposite_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void xcomposite_create_buffer(Resource *resource, uint32_t id, uint32_t x_window,
+ int32_t width, int32_t height) Q_DECL_OVERRIDE;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // XCOMPOSITEHANDLER_H
diff --git a/src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h b/src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h
new file mode 100644
index 00000000..733fd6fd
--- /dev/null
+++ b/src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XLIBINCLUDE_H
+#define XLIBINCLUDE_H
+
+#include <QtCore/QEvent>
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+#include <QtGui/QCursor>
+#include <QtGui/private/qguiapplication_p.h>
+
+#include <X11/Xlib.h>
+#include "X11/extensions/Xcomposite.h"
+
+enum {
+ XFocusOut = FocusOut,
+ XFocusIn = FocusIn,
+ XKeyPress = KeyPress,
+ XKeyRelease = KeyRelease,
+ XNone = None,
+ XRevertToParent = RevertToParent,
+ XGrayScale = GrayScale,
+ XCursorShape = CursorShape
+};
+#undef FocusOut
+#undef FocusIn
+#undef KeyPress
+#undef KeyRelease
+#undef None
+#undef RevertToParent
+#undef GrayScale
+#undef CursorShape
+
+#ifdef FontChange
+#undef FontChange
+#endif
+
+#endif //XLIBINCLUDE_H