diff options
author | Jorgen Lind <jorgen.lind@digia.com> | 2013-11-20 16:19:46 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-27 15:32:28 +0100 |
commit | 83791e4c0104d8b87ad2f198f9c07407c45603e3 (patch) | |
tree | 1e648ce8598c363c06796cd7cb599e1ffd68d875 /src/plugins | |
parent | 4e6e4783802c0a4483ab59a1bafbc2822eb5b725 (diff) |
Move to new hardware structure for the platform plugins
Change-Id: I0d383e4cdd59c4e4eae5506c814f0c80ecbf58ae
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src/plugins')
45 files changed, 200 insertions, 2961 deletions
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index ab8c9347e..0665511c5 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -1,11 +1,22 @@ TEMPLATE=subdirs CONFIG+=ordered -equals(QT_WAYLAND_GL_CONFIG, nogl) { - SUBDIRS += qwayland-nogl -} else { - config_wayland_egl { - SUBDIRS += qwayland-egl - } +SUBDIRS += qwayland-generic + +config_wayland_egl { + SUBDIRS += qwayland-egl +} +#The following integrations are only useful with QtCompositor +contains(CONFIG, wayland-compositor) { + config_brcm_egl: \ + SUBDIRS += qwayland-brcm-egl + + config_xcomposite { + config_egl: \ + SUBDIRS += qwayland-xcomposite-egl + !contains(QT_CONFIG, opengles2):config_glx: \ + SUBDIRS += qwayland-xcomposite-glx + } } + diff --git a/src/plugins/platforms/qwayland-brcm-egl/main.cpp b/src/plugins/platforms/qwayland-brcm-egl/main.cpp index 663d18b31..c8c4eef12 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/main.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <qpa/qplatformintegrationplugin.h> -#include "qwaylandintegration.h" +#include "qwaylandbrcmeglplatformintegration.h" QT_BEGIN_NAMESPACE @@ -64,7 +64,7 @@ QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, c { Q_UNUSED(paramList); if (system.toLower() == "wayland-brcm") - return new QWaylandIntegration(); + return new QWaylandBrcmEglPlatformIntegration(); return 0; } diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro b/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro index 070b7bce7..31bc718ff 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro +++ b/src/plugins/platforms/qwayland-brcm-egl/qwayland-brcm-egl.pro @@ -1,21 +1,14 @@ PLUGIN_TYPE = platforms load(qt_plugin) -include(../wayland_common/wayland_common.pri) +QT += waylandclient-private + +include(../../../hardwareintegration/client/brcm-egl/brcm-egl.pri) LIBS += -lEGL OTHER_FILES += \ qwayland-brcm-egl.json -SOURCES += qwaylandbrcmeglintegration.cpp \ - qwaylandbrcmglcontext.cpp \ - qwaylandbrcmeglwindow.cpp \ - main.cpp - -HEADERS += qwaylandbrcmeglintegration.h \ - qwaylandbrcmglcontext.h \ - qwaylandbrcmeglwindow.h +SOURCES += main.cpp -CONFIG += wayland-scanner -WAYLANDCLIENTSOURCES += ../../../extensions/brcm.xml diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp deleted file mode 100644 index f82ad6f97..000000000 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.cpp +++ /dev/null @@ -1,132 +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 "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; -} - -QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandBrcmEglIntegration(waylandDisplay); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h deleted file mode 100644 index f1100d8de..000000000 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglintegration.h +++ /dev/null @@ -1,94 +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 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/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglplatformintegration.h index c65ad4a1a..7dbe82fee 100644 --- a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglplatformintegration.h @@ -39,25 +39,31 @@ ** ****************************************************************************/ -#include "qwaylandxcompositebuffer.h" +#ifndef QWAYLANDBRCMEGLPLATFORMINTEGRATION_H +#define QWAYLANDBRCMEGLPLATFORMINTEGRATION_H -#include "wayland-client.h" -#include "wayland-xcomposite-client-protocol.h" +#include <QtWaylandClient/qwaylandintegration.h> +#include "qwaylandbrcmeglintegration.h" QT_BEGIN_NAMESPACE -QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(qt_xcomposite *xcomposite, uint32_t window, const QSize &size) - :mSize(size) +class QWaylandBrcmEglPlatformIntegration : public QWaylandIntegration { - mBuffer = qt_xcomposite_create_buffer(xcomposite, - window, - size.width(), - size.height()); -} +public: + QWaylandBrcmEglPlatformIntegration() + : QWaylandIntegration() + , m_gl_integration(new QWaylandBrcmEglIntegration(display()) + { + } -QSize QWaylandXCompositeBuffer::size() const -{ - return mSize; -} + QWaylandGLIntegration *glIntegration() const Q_DECL_OVERRIDE + { + return m_gl_integration; + } +private: + QWaylandGLIntegration *m_gl_integration; +}; QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp deleted file mode 100644 index c7073e149..000000000 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.cpp +++ /dev/null @@ -1,291 +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 "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-brcm-client-protocol.h" -#include "wayland-client.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/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h deleted file mode 100644 index 5a3fa0461..000000000 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmeglwindow.h +++ /dev/null @@ -1,103 +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 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/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp deleted file mode 100644 index dfb86e54c..000000000 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.cpp +++ /dev/null @@ -1,105 +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 "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/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h b/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h deleted file mode 100644 index 7beef166b..000000000 --- a/src/plugins/platforms/qwayland-brcm-egl/qwaylandbrcmglcontext.h +++ /dev/null @@ -1,83 +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 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/plugins/platforms/qwayland-egl/main.cpp b/src/plugins/platforms/qwayland-egl/main.cpp index e5a0a2c64..6f790a14a 100644 --- a/src/plugins/platforms/qwayland-egl/main.cpp +++ b/src/plugins/platforms/qwayland-egl/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <qpa/qplatformintegrationplugin.h> -#include "qwaylandintegration.h" +#include "qwaylandeglplatformintegration.h" QT_BEGIN_NAMESPACE @@ -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 7f8c7f3aa..279a7c382 100644 --- a/src/plugins/platforms/qwayland-egl/qwayland-egl.pro +++ b/src/plugins/platforms/qwayland-egl/qwayland-egl.pro @@ -3,23 +3,10 @@ load(qt_plugin) QT += waylandclient-private +include(../../../hardwareintegration/client/wayland-egl/wayland-egl.pri) + OTHER_FILES += \ qwayland-egl.json -DEFINES += QT_WAYLAND_GL_SUPPORT -!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/qwaylandeglintegration.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp deleted file mode 100644 index fd9c55859..000000000 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.cpp +++ /dev/null @@ -1,128 +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 <QtWaylandClient/qwaylandglintegration.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 -}; - -QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay) - : m_waylandDisplay(waylandDisplay), m_supportsThreading(false) -{ - 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; - } - } - - 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 QWaylandEglIntegration::supportsThreadedOpenGL() const -{ - return m_supportsThreading; -} - -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/qwaylandeglintegration.h deleted file mode 100644 index b26c43fe7..000000000 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglintegration.h +++ /dev/null @@ -1,77 +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 QWAYLANDEGLINTEGRATION_H -#define QWAYLANDEGLINTEGRATION_H - -#include <QtWaylandClient/qwaylandglintegration.h> - -#include "qwaylandeglinclude.h" - -QT_BEGIN_NAMESPACE - -class QWaylandWindow; -class QWindow; - -class QWaylandEglIntegration : public QWaylandGLIntegration -{ -public: - QWaylandEglIntegration(struct wl_display *waylandDisplay); - ~QWaylandEglIntegration(); - - void initialize(); - bool supportsThreadedOpenGL() const; - - QWaylandWindow *createEglWindow(QWindow *window); - QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; - - 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/plugins/platforms/qwayland-egl/qwaylandeglplatformintegration.h b/src/plugins/platforms/qwayland-egl/qwaylandeglplatformintegration.h new file mode 100644 index 000000000..c9c288feb --- /dev/null +++ b/src/plugins/platforms/qwayland-egl/qwaylandeglplatformintegration.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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. +** +** $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 QWAYLANDEGLPLATFORMINTEGRATION_H +#define QWAYLANDEGLPLATFORMINTEGRATION_H + +#include <QtWaylandClient/qwaylandintegration.h> + +#include "qwaylandeglintegration.h" + +QT_BEGIN_NAMESPACE + +class QWaylandEglPlatformIntegration : public QWaylandIntegration +{ +public: + QWaylandEglPlatformIntegration() + : QWaylandIntegration() + , m_gl_integration(new QWaylandEglIntegration(display())) + { + m_gl_integration->initialize(); + } + + QWaylandGLIntegration *glIntegration() const + { return m_gl_integration; } + +private: + QWaylandGLIntegration *m_gl_integration; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp deleted file mode 100644 index 1efc4a3f0..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) -{ - 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,¤t_width,¤t_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_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 b20e2ad01..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 <QtWaylandClient/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 92d79db36..000000000 --- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp +++ /dev/null @@ -1,261 +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) - , 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/plugins/platforms/qwayland-egl/qwaylandglcontext.h b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h deleted file mode 100644 index 1da849556..000000000 --- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h +++ /dev/null @@ -1,96 +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 <QtWaylandClient/qwaylanddisplay.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/plugins/platforms/qwayland-nogl/main.cpp b/src/plugins/platforms/qwayland-generic/main.cpp index d0bdf7f00..15a7a9f52 100644 --- a/src/plugins/platforms/qwayland-nogl/main.cpp +++ b/src/plugins/platforms/qwayland-generic/main.cpp @@ -40,14 +40,14 @@ ****************************************************************************/ #include <qpa/qplatformintegrationplugin.h> -#include "qwaylandintegration.h" +#include "qwaylandgenericplatformintegration.h" QT_BEGIN_NAMESPACE class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-nogl.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-generic.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-nogl"; + list << "wayland"; return list; } QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland" || system.toLower() == "wayland-nogl") - return new QWaylandIntegration(); + if (system.toLower() == "wayland") + return new QWaylandGenericPlatformIntegration(); return 0; } diff --git a/src/plugins/platforms/qwayland-generic/qwayland-generic.json b/src/plugins/platforms/qwayland-generic/qwayland-generic.json new file mode 100644 index 000000000..8e56c4fd8 --- /dev/null +++ b/src/plugins/platforms/qwayland-generic/qwayland-generic.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "wayland" ] +} diff --git a/src/plugins/platforms/qwayland-generic/qwayland-generic.pro b/src/plugins/platforms/qwayland-generic/qwayland-generic.pro new file mode 100644 index 000000000..cf42d1eb8 --- /dev/null +++ b/src/plugins/platforms/qwayland-generic/qwayland-generic.pro @@ -0,0 +1,10 @@ +PLUGIN_TYPE = platforms +load(qt_plugin) + +QT += waylandclient-private + +OTHER_FILES += \ + qwayland-generic.json + +SOURCES += main.cpp + diff --git a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/qwayland-generic/qwaylandgenericplatformintegration.h index e70012419..0d742e93a 100644 --- a/src/plugins/platforms/xcomposite_share/qwaylandxcompositebuffer.h +++ b/src/plugins/platforms/qwayland-generic/qwaylandgenericplatformintegration.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,29 +39,29 @@ ** ****************************************************************************/ -#ifndef QWAYLANDXCOMPOSITEBUFFER_H -#define QWAYLANDXCOMPOSITEBUFFER_H +#ifndef QWAYLANDEGLPLATFORMINTEGRATION_H +#define QWAYLANDEGLPLATFORMINTEGRATION_H -#include "qwaylandbuffer.h" -#include <stdint.h> - -struct qt_xcomposite; -struct wl_visual; +#include <QtWaylandClient/qwaylandintegration.h> QT_BEGIN_NAMESPACE -class QWaylandXCompositeBuffer : public QWaylandBuffer +class QWaylandGenericPlatformIntegration : public QWaylandIntegration { public: - QWaylandXCompositeBuffer(qt_xcomposite *xcomposite, - uint32_t window, - const QSize &size); + QWaylandGenericPlatformIntegration() + : QWaylandIntegration() + , m_gl_integration(0) + { + } + + QWaylandGLIntegration *glIntegration() const + { return m_gl_integration; } - QSize size() const; private: - QSize mSize; + QWaylandGLIntegration *m_gl_integration; }; QT_END_NAMESPACE -#endif // QWAYLANDXCOMPOSITEBUFFER_H +#endif diff --git a/src/plugins/platforms/qwayland-nogl/qwayland-nogl.json b/src/plugins/platforms/qwayland-nogl/qwayland-nogl.json deleted file mode 100644 index 8cbc863f9..000000000 --- a/src/plugins/platforms/qwayland-nogl/qwayland-nogl.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "wayland", "wayland-nogl" ] -} diff --git a/src/plugins/platforms/qwayland-nogl/qwayland-nogl.pro b/src/plugins/platforms/qwayland-nogl/qwayland-nogl.pro deleted file mode 100644 index cb3b86eb5..000000000 --- a/src/plugins/platforms/qwayland-nogl/qwayland-nogl.pro +++ /dev/null @@ -1,8 +0,0 @@ -PLUGIN_TYPE = platforms -load(qt_plugin) - -include(../wayland_common/wayland_common.pri) - -OTHER_FILES += qwayland-nogl.json - -SOURCES += main.cpp diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp index 0d6bcffe0..b065a4659 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <qpa/qplatformintegrationplugin.h> -#include "qwaylandintegration.h" +#include "qwaylandxcompositeeglplatformintegration.h" QT_BEGIN_NAMESPACE @@ -56,15 +56,15 @@ public: QStringList QWaylandIntegrationPlugin::keys() const { QStringList list; - list << "wayland-xcomposite"; + list << "wayland-xcomposite" << "wayland-xcomposite-egl"; return list; } QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite") - return new QWaylandIntegration(); + if (system.toLower() == "wayland-xcomposite" || system.toLower() == "wayland-xcomposite-egl") + return new QWaylandXCompositeEglPlatformIntegration(); return 0; } diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro b/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro index b691ec9dc..74a71a57a 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.pro @@ -1,25 +1,12 @@ PLUGIN_TYPE = platforms load(qt_plugin) -include(../wayland_common/wayland_common.pri) -include (../xcomposite_share/xcomposite_share.pri) +QT += waylandclient-private -OTHER_FILES += qwayland-xcomposite-egl.json +include(../../../hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri) -!contains(QT_CONFIG, no-pkg-config) { - CONFIG += link_pkgconfig - PKGCONFIG += xcomposite egl x11 -} else { - LIBS += -lXcomposite -lEGL -lX11 -} +OTHER_FILES += qwayland-xcomposite-egl.json SOURCES += \ - qwaylandxcompositeeglcontext.cpp \ - qwaylandxcompositeeglintegration.cpp \ - qwaylandxcompositeeglwindow.cpp \ main.cpp -HEADERS += \ - qwaylandxcompositeeglcontext.h \ - qwaylandxcompositeeglintegration.h \ - qwaylandxcompositeeglwindow.h diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp deleted file mode 100644 index 8d4a99b97..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.cpp +++ /dev/null @@ -1,77 +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 "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->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/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp deleted file mode 100644 index cd3a06ff8..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.cpp +++ /dev/null @@ -1,146 +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 "qwaylandxcompositeeglintegration.h" - -#include "qwaylandxcompositeeglwindow.h" - -#include <QtCore/QDebug> - -#include "wayland-xcomposite-client-protocol.h" - -QT_BEGIN_NAMESPACE - -QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandXCompositeEGLIntegration(waylandDisplay); -} - -QWaylandXCompositeEGLIntegration::QWaylandXCompositeEGLIntegration(QWaylandDisplay * waylandDisplay) - : QWaylandGLIntegration() - , mWaylandDisplay(waylandDisplay) -{ - qDebug() << "Using XComposite-EGL"; - waylandDisplay->addRegistryListener(&wlDisplayHandleGlobal, this); -} - -QWaylandXCompositeEGLIntegration::~QWaylandXCompositeEGLIntegration() -{ - XCloseDisplay(mDisplay); -} - -void QWaylandXCompositeEGLIntegration::initialize() -{ -} - -QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *window) -{ - return new QWaylandXCompositeEGLWindow(window,this); -} - -QPlatformOpenGLContext *QWaylandXCompositeEGLIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const -{ - return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay()); -} - -Display * QWaylandXCompositeEGLIntegration::xDisplay() const -{ - return mDisplay; -} - -EGLDisplay QWaylandXCompositeEGLIntegration::eglDisplay() const -{ - return mEglDisplay; -} - -int QWaylandXCompositeEGLIntegration::screen() const -{ - return mScreen; -} - -Window QWaylandXCompositeEGLIntegration::rootWindow() const -{ - return mRootWindow; -} - -QWaylandDisplay * QWaylandXCompositeEGLIntegration::waylandDisplay() const -{ - return mWaylandDisplay; -} -qt_xcomposite * QWaylandXCompositeEGLIntegration::waylandXComposite() const -{ - return mWaylandComposite; -} - -const struct qt_xcomposite_listener QWaylandXCompositeEGLIntegration::xcomposite_listener = { - QWaylandXCompositeEGLIntegration::rootInformation -}; - -void QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) -{ - Q_UNUSED(version); - if (interface == "qt_xcomposite") { - QWaylandXCompositeEGLIntegration *integration = static_cast<QWaylandXCompositeEGLIntegration *>(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 QWaylandXCompositeEGLIntegration::rootInformation(void *data, qt_xcomposite *xcomposite, const char *display_name, uint32_t root_window) -{ - Q_UNUSED(xcomposite); - QWaylandXCompositeEGLIntegration *integration = static_cast<QWaylandXCompositeEGLIntegration *>(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/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h deleted file mode 100644 index ba36fac3f..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglintegration.h +++ /dev/null @@ -1,114 +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 QWAYLANDXCOMPOSITEEGLINTEGRATION_H -#define QWAYLANDXCOMPOSITEEGLINTEGRATION_H - -#include "qwaylandglintegration.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 QWaylandXCompositeEGLIntegration : public QWaylandGLIntegration -{ -public: - QWaylandXCompositeEGLIntegration(QWaylandDisplay * waylandDispaly); - ~QWaylandXCompositeEGLIntegration(); - - 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; - 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 // QWAYLANDXCOMPOSITEEGLINTEGRATION_H diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglplatformintegration.h index 32cdb4322..0bcd128da 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglplatformintegration.h @@ -39,30 +39,30 @@ ** ****************************************************************************/ -#ifndef QWAYLANDXCOMPOSITEEGLCONTEXT_H -#define QWAYLANDXCOMPOSITEEGLCONTEXT_H +#ifndef QWAYLANDXCOMPOSITEEGLPLATFROMINTEGRATION_H +#define QWAYLANDXCOMPOSITEEGLPLATFROMINTEGRATION_H -#include <qpa/qplatformopenglcontext.h> +#include <QtWaylandClient/qwaylandintegration.h> #include "qwaylandxcompositeeglintegration.h" -#include <QtPlatformSupport/private/qeglplatformcontext_p.h> - QT_BEGIN_NAMESPACE -class QWaylandXCompositeEGLWindow; - -class QWaylandXCompositeEGLContext : public QEGLPlatformContext +class QWaylandXCompositeEglPlatformIntegration : public QWaylandIntegration { public: - QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display); + QWaylandXCompositeEglPlatformIntegration() + : QWaylandIntegration() + , m_gl_integration(new QWaylandXCompositeEGLIntegration(display())) + { } - void swapBuffers(QPlatformSurface *surface); + QWaylandGLIntegration *glIntegration() const Q_DECL_OVERRIDE + { return m_gl_integration; } private: - EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); + QWaylandGLIntegration *m_gl_integration; }; QT_END_NAMESPACE -#endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H +#endif diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp deleted file mode 100644 index f0df2bd2d..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.cpp +++ /dev/null @@ -1,137 +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 "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 "qwaylandxcompositeeglintegration.h" - -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *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); - attach(m_buffer, 0, 0); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h deleted file mode 100644 index 8fb631185..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwaylandxcompositeeglwindow.h +++ /dev/null @@ -1,77 +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 QWAYLANDXCOMPOSITEEGLWINDOW_H -#define QWAYLANDXCOMPOSITEEGLWINDOW_H - -#include "qwaylandwindow.h" -#include "qwaylandbuffer.h" - -#include "qwaylandxcompositeeglintegration.h" -#include "qwaylandxcompositeeglcontext.h" - -QT_BEGIN_NAMESPACE - -class QWaylandXCompositeEGLWindow : public QWaylandWindow -{ -public: - QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration); - WindowType windowType() const; - - void setGeometry(const QRect &rect); - - EGLSurface eglSurface() const; - -private: - void createEglSurface(); - - QWaylandXCompositeEGLIntegration *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/plugins/platforms/qwayland-xcomposite-glx/main.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp index 98ca13845..17b20f987 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp @@ -56,15 +56,15 @@ public: QStringList QWaylandIntegrationPlugin::keys() const { QStringList list; - list << "wayland-xcomposite"; + list << "wayland-xcomposite-glx"; return list; } QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite") - return new QWaylandIntegration(); + if (system.toLower() == "wayland-xcomposite-glx") + return new QWaylandXCompositeGlxPlatformIntegration(); return 0; } diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.json b/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.json index 8ccd5b46b..0f4a3bf69 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.json +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite" ] + "Keys": [ "wayland-xcomposite-glx" ] } diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro b/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro index 6d7041085..dcf2e1b67 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro @@ -1,25 +1,12 @@ PLUGIN_TYPE = platforms load(qt_plugin) -include(../wayland_common/wayland_common.pri) -include (../xcomposite_share/xcomposite_share.pri) +QT += waylandclient-private -OTHER_FILES += qwayland-xcomposite-glx.json +include(../../../hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri) -!contains(QT_CONFIG, no-pkg-config) { - CONFIG += link_pkgconfig - PKGCONFIG += xcomposite gl x11 -} else { - LIBS += -lXcomposite -lGL -lX11 -} +OTHER_FILES += qwayland-xcomposite-glx.json SOURCES += \ - qwaylandxcompositeglxcontext.cpp \ - qwaylandxcompositeglxintegration.cpp \ - qwaylandxcompositeglxwindow.cpp \ main.cpp -HEADERS += \ - qwaylandxcompositeglxcontext.h \ - qwaylandxcompositeglxintegration.h \ - qwaylandxcompositeglxwindow.h diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp deleted file mode 100644 index 6854dc3b2..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.cpp +++ /dev/null @@ -1,98 +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 <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) -{ - qDebug("creating XComposite-GLX context"); - GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0; - GLXFBConfig config = qglx_findConfig(display, screen, 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->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/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h deleted file mode 100644 index de0311262..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxcontext.h +++ /dev/null @@ -1,78 +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 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/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp deleted file mode 100644 index 2e8b444f9..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.cpp +++ /dev/null @@ -1,139 +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 "qwaylandxcompositeglxintegration.h" - -#include "qwaylandxcompositeglxwindow.h" - -#include <QtCore/QDebug> - -#include "wayland-xcomposite-client-protocol.h" - -QT_BEGIN_NAMESPACE - -QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandXCompositeGLXIntegration(waylandDisplay); -} - -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/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h deleted file mode 100644 index aeb7c66de..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxintegration.h +++ /dev/null @@ -1,107 +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 QWAYLANDXCOMPOSITEGLXINTEGRATION_H -#define QWAYLANDXCOMPOSITEGLXINTEGRATION_H - -#include "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 true; } - -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/plugins/platforms/qwayland-egl/qwaylandeglinclude.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxplatformintegration.h index 9b151a5e8..fe8c5b7c5 100644 --- a/src/plugins/platforms/qwayland-egl/qwaylandeglinclude.h +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxplatformintegration.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,16 +39,26 @@ ** ****************************************************************************/ -#ifndef QWAYLANDEGLINCLUDE_H -#define QWAYLANDEGLINCLUDE_H +#ifndef QWAYLANDXCOMPOSITEGLXPLATFORMINTEGRATION_H +#define QWAYLANDXCOMPOSITEGLXPLATFORMINTEGRATION_H -#include <string.h> -#include <wayland-client.h> +#include <QtWaylandClient/qwaylandintegration.h> -#include <wayland-egl.h> +#include "qwaylandxcompositeglxintegration.h" -#define EGL_EGLEXT_PROTOTYPES -#include <EGL/egl.h> -#include <EGL/eglext.h> +class QWaylandXCompositeGlxPlatformIntegration : public QWaylandIntegration +{ +public: + QWaylandXCompositeGlxPlatformIntegration() + : QWaylandIntegration() + , m_gl_integration(new QWaylandXCompositeGLXIntegration(display())) + { } -#endif // QWAYLANDEGLINCLUDE_H + QWaylandGLIntegration *glIntegration() const Q_DECL_OVERRIDE + { return m_gl_integration; } + +private: + QWaylandGLIntegration *m_gl_integration; +}; + +#endif diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp deleted file mode 100644 index 3a64961f1..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.cpp +++ /dev/null @@ -1,124 +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 "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); - attach(m_buffer, 0, 0); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h deleted file mode 100644 index b436cbbe6..000000000 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxwindow.h +++ /dev/null @@ -1,78 +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 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; - -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/plugins/platforms/xcomposite_share/xcomposite_share.pri b/src/plugins/platforms/xcomposite_share/xcomposite_share.pri deleted file mode 100644 index be3c9fc1b..000000000 --- a/src/plugins/platforms/xcomposite_share/xcomposite_share.pri +++ /dev/null @@ -1,10 +0,0 @@ -INCLUDEPATH += $$PWD - -CONFIG += wayland-scanner -WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/xcomposite.xml - -HEADERS += \ - $$PWD/qwaylandxcompositebuffer.h - -SOURCES += \ - $$PWD/qwaylandxcompositebuffer.cpp |