summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qwayland-egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/qwayland-egl')
-rw-r--r--src/plugins/platforms/qwayland-egl/main.cpp10
-rw-r--r--src/plugins/platforms/qwayland-egl/qwayland-egl.json2
-rw-r--r--src/plugins/platforms/qwayland-egl/qwayland-egl.pro20
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglinclude.h58
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp111
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglplatformintegration.h (renamed from src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h)38
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp171
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h88
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp236
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandglcontext.h93
10 files changed, 26 insertions, 801 deletions
diff --git a/src/plugins/platforms/qwayland-egl/main.cpp b/src/plugins/platforms/qwayland-egl/main.cpp
index 6cf6fec28..6f790a14a 100644
--- a/src/plugins/platforms/qwayland-egl/main.cpp
+++ b/src/plugins/platforms/qwayland-egl/main.cpp
@@ -40,14 +40,14 @@
****************************************************************************/
#include <qpa/qplatformintegrationplugin.h>
-#include "qwaylandintegration.h"
+#include "qwaylandeglplatformintegration.h"
QT_BEGIN_NAMESPACE
class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3" FILE "qwayland-egl.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-egl.json")
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
@@ -56,15 +56,15 @@ public:
QStringList QWaylandIntegrationPlugin::keys() const
{
QStringList list;
- list << "wayland" << "wayland-egl";
+ list << "wayland-egl";
return list;
}
QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
- if (system.toLower() == "wayland" || system.toLower() == "wayland-egl")
- return new QWaylandIntegration();
+ if (system.toLower() == "wayland-egl")
+ return new QWaylandEglPlatformIntegration();
return 0;
}
diff --git a/src/plugins/platforms/qwayland-egl/qwayland-egl.json b/src/plugins/platforms/qwayland-egl/qwayland-egl.json
index 3ab70d3c3..4ea5bab90 100644
--- a/src/plugins/platforms/qwayland-egl/qwayland-egl.json
+++ b/src/plugins/platforms/qwayland-egl/qwayland-egl.json
@@ -1,3 +1,3 @@
{
- "Keys": [ "wayland", "wayland-egl" ]
+ "Keys": [ "wayland-egl" ]
}
diff --git a/src/plugins/platforms/qwayland-egl/qwayland-egl.pro b/src/plugins/platforms/qwayland-egl/qwayland-egl.pro
index 339f94616..279a7c382 100644
--- a/src/plugins/platforms/qwayland-egl/qwayland-egl.pro
+++ b/src/plugins/platforms/qwayland-egl/qwayland-egl.pro
@@ -1,24 +1,12 @@
PLUGIN_TYPE = platforms
load(qt_plugin)
-include(../wayland_common/wayland_common.pri)
+QT += waylandclient-private
+
+include(../../../hardwareintegration/client/wayland-egl/wayland-egl.pri)
OTHER_FILES += \
qwayland-egl.json
-!contains(QT_CONFIG, no-pkg-config) {
- CONFIG += link_pkgconfig
- PKGCONFIG += wayland-egl egl
-} else {
- LIBS += -lwayland-egl -lEGL
-}
-
-SOURCES += qwaylandeglintegration.cpp \
- qwaylandglcontext.cpp \
- qwaylandeglwindow.cpp \
- main.cpp
+SOURCES += main.cpp
-HEADERS += qwaylandeglintegration.h \
- qwaylandglcontext.h \
- qwaylandeglwindow.h \
- qwaylandeglinclude.h
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglinclude.h b/src/plugins/platforms/qwayland-egl/qwaylandeglinclude.h
deleted file mode 100644
index fb42d43c1..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglinclude.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** 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 GL_GLEXT_PROTOTYPES
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-#define EGL_EGLEXT_PROTOTYPES
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#endif // QWAYLANDEGLINCLUDE_H
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp
deleted file mode 100644
index 07f6d586e..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** 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 "qwaylandeglintegration.h"
-
-#include "qwaylandglintegration.h"
-
-#include "qwaylandeglwindow.h"
-#include "qwaylandglcontext.h"
-
-#include <wayland-client.h>
-
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-
-QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay)
- : m_waylandDisplay(waylandDisplay)
-{
- qDebug() << "Using Wayland-EGL";
-}
-
-
-QWaylandEglIntegration::~QWaylandEglIntegration()
-{
- eglTerminate(m_eglDisplay);
-}
-
-void QWaylandEglIntegration::initialize()
-{
- QByteArray eglPlatform = qgetenv("EGL_PLATFORM");
- if (eglPlatform.isEmpty()) {
- setenv("EGL_PLATFORM","wayland",true);
- }
-
- 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;
- }
- }
-}
-
-bool QWaylandEglIntegration::supportsThreadedOpenGL() const
-{
- return true;
-}
-
-QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window)
-{
- return new QWaylandEglWindow(window);
-}
-
-QPlatformOpenGLContext *QWaylandEglIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const
-{
- return new QWaylandGLContext(m_eglDisplay, glFormat, share);
-}
-
-EGLDisplay QWaylandEglIntegration::eglDisplay() const
-{
- return m_eglDisplay;
-}
-
-QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
-{
- return new QWaylandEglIntegration(waylandDisplay->wl_display());
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h b/src/plugins/platforms/qwayland-egl/qwaylandeglplatformintegration.h
index 64e7d97de..5f23f68de 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h
+++ b/src/plugins/platforms/qwayland-egl/qwaylandeglplatformintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 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.
@@ -39,38 +39,32 @@
**
****************************************************************************/
-#ifndef QWAYLANDEGLINTEGRATION_H
-#define QWAYLANDEGLINTEGRATION_H
+#ifndef QWAYLANDEGLPLATFORMINTEGRATION_H
+#define QWAYLANDEGLPLATFORMINTEGRATION_H
-#include "qwaylandglintegration.h"
+#include <QtWaylandClient/private/qwaylandintegration_p.h>
-#include "qwaylandeglinclude.h"
+#include "qwaylandeglclientbufferintegration.h"
QT_BEGIN_NAMESPACE
-class QWaylandWindow;
-class QWindow;
-
-class QWaylandEglIntegration : public QWaylandGLIntegration
+class QWaylandEglPlatformIntegration : public QWaylandIntegration
{
public:
- QWaylandEglIntegration(struct wl_display *waylandDisplay);
- ~QWaylandEglIntegration();
-
- void initialize();
- bool supportsThreadedOpenGL() const;
+ QWaylandEglPlatformIntegration()
+ : QWaylandIntegration()
+ , m_client_buffer_integration(new QWaylandEglClientBufferIntegration())
+ {
+ m_client_buffer_integration->initialize(display());
+ }
- QWaylandWindow *createEglWindow(QWindow *window);
- QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const;
-
- EGLDisplay eglDisplay() const;
+ QWaylandEglClientBufferIntegration *clientBufferIntegration() const
+ { return m_client_buffer_integration; }
private:
- struct wl_display *m_waylandDisplay;
-
- EGLDisplay m_eglDisplay;
+ QWaylandEglClientBufferIntegration *m_client_buffer_integration;
};
QT_END_NAMESPACE
-#endif // QWAYLANDEGLINTEGRATION_H
+#endif
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp
deleted file mode 100644
index 7829f381a..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** 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 "qwaylandscreen.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_eglIntegration(static_cast<QWaylandEglIntegration *>(mDisplay->eglIntegration()))
- , 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_eglIntegration->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)
-{
- createDecoration();
- QMargins margins = frameMargins();
- QSize sizeWithMargins = rect.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());
- }
-
- QWaylandWindow::setGeometry(rect);
-}
-
-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_eglIntegration->eglDisplay(), window()->format(), true);
- const_cast<QWaylandEglWindow *>(this)->m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(),m_eglConfig);
-
- EGLNativeWindowType window = (EGLNativeWindowType) m_waylandEglWindow;
- m_eglSurface = eglCreateWindowSurface(m_eglIntegration->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/plugins/platforms/qwayland-egl/qwaylandeglwindow.h b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h
deleted file mode 100644
index f973547a7..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** 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 "qwaylandwindow.h"
-#include "qwaylandeglinclude.h"
-#include "qwaylandeglintegration.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:
- QWaylandEglIntegration *m_eglIntegration;
- 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/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
deleted file mode 100644
index 303e59f76..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/****************************************************************************
-**
-** 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 "qwaylanddisplay.h"
-#include "qwaylandwindow.h"
-#include "qwaylandeglwindow.h"
-#include "qwaylanddecoration.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)
-{
- m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(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, 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) {
- 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());
- }
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- 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->setUniformValue("texture", 0);
-
- m_blitProgram->enableAttributeArray("position");
- m_blitProgram->enableAttributeArray("texCoords");
- m_blitProgram->setAttributeArray("texCoords", textureVertices, 2);
-
- m_blitProgram->bind();
- 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);
- QRect windowRect = window->window()->frameGeometry();
- glViewport(0, 0, windowRect.width(), windowRect.height());
- 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
-{
- 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/plugins/platforms/qwayland-egl/qwaylandglcontext.h b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
deleted file mode 100644
index bc231e82d..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** 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 "qwaylanddisplay.h"
-
-#include <qpa/qplatformopenglcontext.h>
-
-#include "qwaylandeglinclude.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandWindow;
-class QWaylandGLWindowSurface;
-class QOpenGLShaderProgram;
-class QOpenGLTextureCache;
-
-class QWaylandGLContext : public QPlatformOpenGLContext {
-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;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWAYLANDGLCONTEXT_H