summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/gl_integrations/xcb_egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/xcb/gl_integrations/xcb_egl')
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h96
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h49
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp107
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h77
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp54
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp132
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h64
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp88
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h67
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json3
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro24
11 files changed, 761 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
new file mode 100644
index 0000000000..9b903d8212
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLCONTEXT_H
+#define QXCBEGLCONTEXT_H
+
+#include "qxcbeglwindow.h"
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtPlatformHeaders/QEGLNativeContext>
+
+QT_BEGIN_NAMESPACE
+
+//####todo remove the noops (looks like their where there in the initial commit)
+class QXcbEglContext : public QEGLPlatformContext
+{
+public:
+ QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share,
+ EGLDisplay display, QXcbConnection *c, const QVariant &nativeHandle)
+ : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle)
+ , m_connection(c)
+ {
+ Q_XCB_NOOP(m_connection);
+ }
+
+ void swapBuffers(QPlatformSurface *surface)
+ {
+ Q_XCB_NOOP(m_connection);
+ QEGLPlatformContext::swapBuffers(surface);
+ Q_XCB_NOOP(m_connection);
+ }
+
+ bool makeCurrent(QPlatformSurface *surface)
+ {
+ Q_XCB_NOOP(m_connection);
+ bool ret = QEGLPlatformContext::makeCurrent(surface);
+ Q_XCB_NOOP(m_connection);
+ return ret;
+ }
+
+ void doneCurrent()
+ {
+ Q_XCB_NOOP(m_connection);
+ QEGLPlatformContext::doneCurrent();
+ Q_XCB_NOOP(m_connection);
+ }
+
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ {
+ if (surface->surface()->surfaceClass() == QSurface::Window)
+ return static_cast<QXcbEglWindow *>(surface)->eglSurface();
+ else
+ return static_cast<QEGLPbuffer *>(surface)->pbuffer();
+ }
+
+ QVariant nativeHandle() const {
+ return QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(eglContext(), eglDisplay()));
+ }
+
+private:
+ QXcbConnection *m_connection;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLCONTEXT_H
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
new file mode 100644
index 0000000000..ec59cbc7c9
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBINCLUDE_H
+#define QXCBINCLUDE_H
+
+#include <QtGui/QPalette>
+#include <QtCore/QTextStream>
+#include <QtGui/private/qmath_p.h>
+#include <QtGui/private/qcssparser_p.h>
+#include <QtGui/private/qtextengine_p.h>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+#endif //QXCBINCLUDE_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
new file mode 100644
index 0000000000..a456317801
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglintegration.h"
+
+#include "qxcbeglcontext.h"
+
+#include <QtGui/QOffscreenSurface>
+
+#include "qxcbeglnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+QXcbEglIntegration::QXcbEglIntegration()
+ : m_connection(Q_NULLPTR)
+ , m_egl_display(EGL_NO_DISPLAY)
+{
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration created";
+}
+
+QXcbEglIntegration::~QXcbEglIntegration()
+{
+ if (m_egl_display != EGL_NO_DISPLAY)
+ eglTerminate(m_egl_display);
+}
+
+bool QXcbEglIntegration::initialize(QXcbConnection *connection)
+{
+ m_connection = connection;
+ m_egl_display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(xlib_display()));
+
+ EGLint major, minor;
+ bool success = eglInitialize(m_egl_display, &major, &minor);
+ if (!success) {
+ m_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration retrying with display" << m_egl_display;
+ success = eglInitialize(m_egl_display, &major, &minor);
+ }
+
+ m_native_interface_handler.reset(new QXcbEglNativeInterfaceHandler(connection->nativeInterface()));
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration successfully initialized";
+ return success;
+}
+
+QXcbWindow *QXcbEglIntegration::createWindow(QWindow *window) const
+{
+ return new QXcbEglWindow(window, const_cast<QXcbEglIntegration *>(this));
+}
+
+QPlatformOpenGLContext *QXcbEglIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+ QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+ QXcbEglContext *platformContext = new QXcbEglContext(context->format(),
+ context->shareHandle(),
+ eglDisplay(),
+ screen->connection(),
+ context->nativeHandle());
+ context->setNativeHandle(platformContext->nativeHandle());
+ return platformContext;
+}
+
+QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ return new QEGLPbuffer(eglDisplay(), surface->requestedFormat(), surface);
+}
+
+void *QXcbEglIntegration::xlib_display() const
+{
+#ifdef XCB_USE_XLIB
+ return m_connection->xlib_display();
+#else
+ return EGL_DEFAULT_DISPLAY;
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h
new file mode 100644
index 0000000000..3f7134c1a1
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLINTEGRATION_H
+#define QXCBEGLINTEGRATION_H
+
+#include "qxcbglintegration.h"
+
+#include "qxcbeglwindow.h"
+
+#include <QtGui/QOpenGLContext>
+#include <QtGui/qpa/qplatformscreen.h>
+#include <QtGui/QScreen>
+
+#include "qxcbscreen.h"
+
+#include "qxcbeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglNativeInterfaceHandler;
+
+class QXcbEglIntegration : public QXcbGlIntegration
+{
+public:
+ QXcbEglIntegration();
+ ~QXcbEglIntegration();
+
+ bool initialize(QXcbConnection *connection) Q_DECL_OVERRIDE;
+
+ QXcbWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
+
+ bool supportsThreadedOpenGL() const Q_DECL_OVERRIDE { return true; }
+
+ EGLDisplay eglDisplay() const { return m_egl_display; }
+ void *xlib_display() const;
+private:
+ QXcbConnection *m_connection;
+ EGLDisplay m_egl_display;
+
+ QScopedPointer<QXcbEglNativeInterfaceHandler> m_native_interface_handler;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp
new file mode 100644
index 0000000000..72b471be67
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbeglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglIntegrationPlugin : public QXcbGlIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QXcbGlIntegrationFactoryInterface_iid FILE "xcb_egl.json")
+public:
+ QXcbGlIntegration *create()
+ {
+ return new QXcbEglIntegration();
+ }
+
+};
+
+QT_END_NAMESPACE
+
+#include "qxcbeglmain.moc"
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..562b5c154f
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglnativeinterfacehandler.h"
+
+#include <QtGui/private/qguiapplication_p.h>
+#include "qxcbeglwindow.h"
+#include "qxcbintegration.h"
+#include "qxcbeglintegration.h"
+#include "qxcbeglcontext.h"
+
+QT_BEGIN_NAMESPACE
+
+static int resourceType(const QByteArray &key)
+{
+ static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
+ QByteArrayLiteral("egldisplay"),
+ QByteArrayLiteral("eglcontext"),
+ QByteArrayLiteral("eglconfig")
+ };
+ for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+ if (key == names[i])
+ return i;
+ }
+
+ if (key == QByteArrayLiteral("get_egl_context"))
+ return QXcbEglNativeInterfaceHandler::EglContext;
+
+ return sizeof(names) / sizeof(names[0]);
+}
+
+QXcbEglNativeInterfaceHandler::QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+ : QXcbNativeInterfaceHandler(nativeInterface)
+{
+}
+
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForIntegration(const QByteArray &resource) const{
+ switch (resourceType(resource)) {
+ case EglDisplay:
+ return eglDisplay;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case EglContext:
+ return eglContextForContext;
+ case EglConfig:
+ return eglConfigForContext;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case EglDisplay:
+ return eglDisplayForWindow;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbEglNativeInterfaceHandler::eglDisplay()
+{
+ QXcbIntegration *integration = QXcbIntegration::instance();
+ QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->defaultConnection()->glIntegration());
+ return eglIntegration->eglDisplay();
+}
+
+void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
+{
+ Q_ASSERT(window);
+ if (window->supportsOpenGL() && window->handle() == Q_NULLPTR)
+ return eglDisplay();
+ else if (window->supportsOpenGL())
+ return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
+ return Q_NULLPTR;
+}
+
+void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ Q_ASSERT(context->handle());
+ return static_cast<QXcbEglContext *>(context->handle())->eglContext();
+}
+
+void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ Q_ASSERT(context->handle());
+ return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h
new file mode 100644
index 0000000000..92a48fc144
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLNATIVEINTERFACEHANDLER_H
+#define QXCBEGLNATIVEINTERFACEHANDLER_H
+
+#include "qxcbnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglNativeInterfaceHandler : public QXcbNativeInterfaceHandler
+{
+public:
+ enum ResourceType {
+ EglDisplay,
+ EglContext,
+ EglConfig
+ };
+
+ QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+
+ QPlatformNativeInterface::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const Q_DECL_OVERRIDE;
+ QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE;
+ QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const Q_DECL_OVERRIDE;
+private:
+ static void *eglDisplay();
+ static void *eglDisplayForWindow(QWindow *window);
+ static void *eglContextForContext(QOpenGLContext *context);
+ static void *eglConfigForContext(QOpenGLContext *context);
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBEGLNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
new file mode 100644
index 0000000000..a26280b399
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglwindow.h"
+
+#include "qxcbeglintegration.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QXcbEglWindow::QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration)
+ : QXcbWindow(window)
+ , m_glIntegration(glIntegration)
+ , m_config(Q_NULLPTR)
+ , m_surface(EGL_NO_SURFACE)
+{
+}
+
+QXcbEglWindow::~QXcbEglWindow()
+{
+ eglDestroySurface(m_glIntegration->eglDisplay(), m_surface);
+}
+
+void QXcbEglWindow::resolveFormat()
+{
+ m_config = q_configFromGLFormat(m_glIntegration->eglDisplay(), window()->requestedFormat(), true);
+ m_format = q_glFormatFromConfig(m_glIntegration->eglDisplay(), m_config, m_format);
+}
+
+void *QXcbEglWindow::createVisual()
+{
+#ifdef XCB_USE_XLIB
+ Display *xdpy = static_cast<Display *>(m_glIntegration->xlib_display());
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(xdpy, m_glIntegration->eglDisplay(), m_config);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(xdpy, VisualIDMask, &visualInfoTemplate, &matchingCount);
+ return visualInfo;
+#else
+ return QXcbWindow::createVisual();
+#endif
+}
+
+void QXcbEglWindow::create()
+{
+ QXcbWindow::create();
+
+ m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, 0);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h
new file mode 100644
index 0000000000..dfb32332bc
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLWINDOW_H
+#define QXCBEGLWINDOW_H
+
+#include "qxcbwindow.h"
+
+#include "qxcbeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglIntegration;
+
+class QXcbEglWindow : public QXcbWindow
+{
+public:
+ QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration);
+ ~QXcbEglWindow();
+
+ EGLSurface eglSurface() const { return m_surface; }
+
+ QXcbEglIntegration *glIntegration() const { return m_glIntegration; }
+
+protected:
+ void create() Q_DECL_OVERRIDE;
+ void resolveFormat() Q_DECL_OVERRIDE;
+ void *createVisual() Q_DECL_OVERRIDE;
+
+private:
+ QXcbEglIntegration *m_glIntegration;
+ EGLConfig m_config;
+ EGLSurface m_surface;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLWINDOW_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json
new file mode 100644
index 0000000000..6d6785691d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "xcb_egl" ]
+}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
new file mode 100644
index 0000000000..28a572a2c9
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
@@ -0,0 +1,24 @@
+TARGET = qxcb-egl-integration
+
+PLUGIN_CLASS_NAME = QXcbEglIntegrationPlugin
+PLUGIN_TYPE = xcbglintegrations
+
+load(qt_plugin)
+
+include(../gl_integrations_plugin_base.pri)
+
+CONFIG += egl
+
+contains(QT_CONFIG, xcb-xlib): DEFINES += XCB_USE_XLIB
+
+HEADERS += \
+ qxcbeglcontext.h \
+ qxcbeglintegration.h \
+ qxcbeglwindow.h \
+ qxcbeglnativeinterfacehandler.h
+
+SOURCES += \
+ qxcbeglintegration.cpp \
+ qxcbeglwindow.cpp \
+ qxcbeglmain.cpp \
+ qxcbeglnativeinterfacehandler.cpp