diff options
author | Andy Nichols <andy.nichols@digia.com> | 2013-02-01 00:40:44 +0100 |
---|---|---|
committer | Andy Nichols <andy.nichols@digia.com> | 2013-02-06 14:19:45 +0100 |
commit | 2e0efd201aa75121f4dd4049598f4d120811d784 (patch) | |
tree | a33026b8cc3b4f9add79b5a8ebd703fa3eeb6644 /src/compositor/hardware_integration | |
parent | 4cbc411f60d17a6d4f4e9d4156146537d5dc2f16 (diff) |
QtCompositor hardware integrations as plugins
Rather than defining which hardware integration should be used at
compile time, we should build each hardware integration as a plugin, and
load the one we want at runtime.
The default hardware integration is wayland-egl, but you are able to
override this using the environment variable
QT_WAYLAND_HARDWARE_INTEGRATION
Backends tested:
wayland-egl
xcomposite-egl
Backends untested:
xcomposite-glx
brcm-egl
Change-Id: Idee66574d232a9236898f68ca64145f471b1bb80
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@gmail.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/compositor/hardware_integration')
27 files changed, 283 insertions, 1694 deletions
diff --git a/src/compositor/hardware_integration/brcm_egl/brcm_egl.pri b/src/compositor/hardware_integration/brcm_egl/brcm_egl.pri deleted file mode 100644 index 1b753645d..000000000 --- a/src/compositor/hardware_integration/brcm_egl/brcm_egl.pri +++ /dev/null @@ -1,11 +0,0 @@ -LIBS += -lEGL - -SOURCES += \ - $$PWD/brcmeglintegration.cpp \ - $$PWD/brcmbuffer.cpp - -HEADERS += \ - $$PWD/brcmeglintegration.h \ - $$PWD/brcmbuffer.h - -WAYLANDSOURCES += $$PWD/../../../extensions/brcm.xml diff --git a/src/compositor/hardware_integration/brcm_egl/brcmbuffer.cpp b/src/compositor/hardware_integration/brcm_egl/brcmbuffer.cpp deleted file mode 100644 index c9a71172c..000000000 --- a/src/compositor/hardware_integration/brcm_egl/brcmbuffer.cpp +++ /dev/null @@ -1,79 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "brcmbuffer.h" - -#include <EGL/eglext.h> - -#define EGL_EGLEXT_PROTOTYPES -#include <EGL/eglext_brcm.h> - -BrcmBuffer::BrcmBuffer(Wayland::Compositor *compositor, const QSize &size, EGLint *data, size_t count) - : m_invertedY(false) - , m_handle(count) -{ - Q_UNUSED(compositor); - - base()->height = size.height(); - base()->width = size.width(); - - for (size_t i = 0; i < count; ++i) - m_handle[i] = data[i]; -} - -BrcmBuffer::~BrcmBuffer() -{ - eglDestroyGlobalImageBRCM(handle()); -} - -struct wl_buffer_interface BrcmBuffer::buffer_interface = { - BrcmBuffer::buffer_interface_destroy -}; - -void BrcmBuffer::buffer_interface_destroy(wl_client *client, wl_resource *buffer) -{ - Q_UNUSED(client); - Q_UNUSED(buffer); -} - -void BrcmBuffer::delete_resource(struct wl_resource *resource) -{ - delete reinterpret_cast<BrcmBuffer *>(resource); -} diff --git a/src/compositor/hardware_integration/brcm_egl/brcmbuffer.h b/src/compositor/hardware_integration/brcm_egl/brcmbuffer.h deleted file mode 100644 index 0f4098012..000000000 --- a/src/compositor/hardware_integration/brcm_egl/brcmbuffer.h +++ /dev/null @@ -1,74 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BRCMBUFFER_H -#define BRCMBUFFER_H - -#include "waylandobject.h" -#include "wayland_wrapper/wlcompositor.h" - -#include <QtCore/QSize> -#include <QtCore/QVector> - -#include <EGL/egl.h> - -class BrcmBuffer : public Wayland::Object<struct wl_buffer> -{ -public: - BrcmBuffer(Wayland::Compositor *compositor, const QSize &size, EGLint *data, size_t count); - ~BrcmBuffer(); - - static struct wl_buffer_interface buffer_interface; - static void delete_resource(struct wl_resource *resource); - - bool isYInverted() const { return m_invertedY; } - void setInvertedY(bool inverted) { m_invertedY = inverted; } - - EGLint *handle() { return m_handle.data(); } - - static void buffer_interface_destroy(struct wl_client *client, - struct wl_resource *buffer); - -private: - QVector<EGLint> m_handle; - bool m_invertedY; -}; - -#endif // BRCMBUFFER_H diff --git a/src/compositor/hardware_integration/brcm_egl/brcmeglintegration.cpp b/src/compositor/hardware_integration/brcm_egl/brcmeglintegration.cpp deleted file mode 100644 index 231794713..000000000 --- a/src/compositor/hardware_integration/brcm_egl/brcmeglintegration.cpp +++ /dev/null @@ -1,198 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "brcmeglintegration.h" -#include "brcmbuffer.h" -#include "wayland_wrapper/wlcompositor.h" -#include "wayland_wrapper/wlsurface.h" -#include "compositor_api/waylandsurface.h" -#include <qpa/qplatformnativeinterface.h> -#include <QtGui/QGuiApplication> -#include <QtGui/QOpenGLContext> -#include <qpa/qplatformscreen.h> -#include <QtGui/QWindow> - -#include <EGL/egl.h> -#include <EGL/eglext.h> - -#define EGL_EGLEXT_PROTOTYPES -#include <EGL/eglext_brcm.h> - -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> - -#include "wayland-brcm-server-protocol.h" - -GraphicsHardwareIntegration * GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) -{ - return new BrcmEglIntegration(compositor); -} - -class BrcmEglIntegrationPrivate -{ -public: - BrcmEglIntegrationPrivate() - : egl_display(EGL_NO_DISPLAY) - , valid(false) - { } - EGLDisplay egl_display; - bool valid; - PFNEGLQUERYGLOBALIMAGEBRCMPROC eglQueryGlobalImageBRCM; - PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; - PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; - PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; -}; - -BrcmEglIntegration::BrcmEglIntegration(WaylandCompositor *compositor) - : GraphicsHardwareIntegration(compositor) - , d_ptr(new BrcmEglIntegrationPrivate) -{ -} - -void BrcmEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) -{ - Q_D(BrcmEglIntegration); - - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - if (nativeInterface) { - d->egl_display = nativeInterface->nativeResourceForIntegration("EglDisplay"); - if (!d->egl_display) - qWarning("Failed to acquire EGL display from platform integration"); - - d->eglQueryGlobalImageBRCM = eglQueryGlobalImageBRCM; - - if (!d->eglQueryGlobalImageBRCM) { - qWarning("Failed to resolve eglQueryGlobalImageBRCM"); - return; - } - - d->glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); - - if (!d->glEGLImageTargetTexture2DOES) { - qWarning("Failed to resolve glEGLImageTargetTexture2DOES"); - return; - } - - d->eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); - - if (!d->eglCreateImageKHR) { - qWarning("Failed to resolve eglCreateImageKHR"); - return; - } - - d->eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - - if (!d->eglDestroyImageKHR) { - qWarning("Failed to resolve eglDestroyImageKHR"); - return; - } - d->valid = true; - } - - wl_display_add_global(waylandDisplay->handle(), &wl_brcm_interface, this, brcm_bind_func); -} - -GLuint BrcmEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context) -{ - Q_D(BrcmEglIntegration); - if (!d->valid) { - qWarning("createTextureFromBuffer() failed\n"); - return 0; - } - - BrcmBuffer *brcmBuffer = Wayland::wayland_cast<BrcmBuffer>(buffer); - - if (!d->eglQueryGlobalImageBRCM(brcmBuffer->handle(), brcmBuffer->handle() + 2)) { - qWarning("eglQueryGlobalImageBRCM failed!"); - return 0; - } - - EGLImageKHR image = d->eglCreateImageKHR(d->egl_display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)brcmBuffer->handle(), NULL); - if (image == EGL_NO_IMAGE_KHR) - qWarning("eglCreateImageKHR() failed: %x\n", eglGetError()); - - GLuint textureId; - glGenTextures(1, &textureId); - - glBindTexture(GL_TEXTURE_2D, textureId); - - d->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - d->eglDestroyImageKHR(d->egl_display, image); - - return textureId; -} - -void BrcmEglIntegration::create_buffer(struct wl_client *client, - struct wl_resource *brcm, - uint32_t id, - int32_t width, - int32_t height, - wl_array *data) -{ - BrcmEglIntegration *that = static_cast<BrcmEglIntegration *>(brcm->data); - BrcmBuffer *buffer = new BrcmBuffer(that->m_compositor->handle(), QSize(width, height), static_cast<EGLint *>(data->data), data->size / sizeof(EGLint)); - buffer->addClientResource(client, &buffer->base()->resource, - id, &wl_buffer_interface, - &BrcmBuffer::buffer_interface, - BrcmBuffer::delete_resource); -} - -static struct wl_brcm_interface brcm_interface = { - BrcmEglIntegration::create_buffer -}; - -void BrcmEglIntegration::brcm_bind_func(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - BrcmEglIntegration *integration = static_cast<BrcmEglIntegration *>(data); - wl_client_add_object(client, &wl_brcm_interface, &brcm_interface, id, integration); -} - -bool BrcmEglIntegration::isYInverted(struct wl_buffer *buffer) const -{ - Q_UNUSED(buffer); - return false; -} diff --git a/src/compositor/hardware_integration/brcm_egl/brcmeglintegration.h b/src/compositor/hardware_integration/brcm_egl/brcmeglintegration.h deleted file mode 100644 index adc64ec18..000000000 --- a/src/compositor/hardware_integration/brcm_egl/brcmeglintegration.h +++ /dev/null @@ -1,75 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BRCMEGLINTEGRATION_H -#define BRCMEGLINTEGRATION_H - -#include "hardware_integration/graphicshardwareintegration.h" -#include <QtCore/QScopedPointer> - -class BrcmEglIntegrationPrivate; - -class BrcmEglIntegration : public GraphicsHardwareIntegration -{ - Q_DECLARE_PRIVATE(BrcmEglIntegration) -public: - BrcmEglIntegration(WaylandCompositor *compositor); - - void initializeHardware(Wayland::Display *waylandDisplay); - - GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context); - bool isYInverted(struct wl_buffer *) const; - - static void create_buffer(struct wl_client *client, - struct wl_resource *brcm, - uint32_t id, - int32_t width, - int32_t height, - wl_array *data); - - static void brcm_bind_func(struct wl_client *client, void *data, uint32_t version, uint32_t id); - -private: - Q_DISABLE_COPY(BrcmEglIntegration) - QScopedPointer<BrcmEglIntegrationPrivate> d_ptr; -}; - -#endif // BRCMEGLINTEGRATION_H - diff --git a/src/compositor/hardware_integration/graphicshardwareintegration.cpp b/src/compositor/hardware_integration/graphicshardwareintegration.cpp index 6a5f1fb4e..13b460d71 100644 --- a/src/compositor/hardware_integration/graphicshardwareintegration.cpp +++ b/src/compositor/hardware_integration/graphicshardwareintegration.cpp @@ -40,7 +40,7 @@ #include "graphicshardwareintegration.h" -GraphicsHardwareIntegration::GraphicsHardwareIntegration(WaylandCompositor *compositor) - : m_compositor(compositor) +GraphicsHardwareIntegration::GraphicsHardwareIntegration() + : m_compositor(0) { } diff --git a/src/compositor/hardware_integration/graphicshardwareintegration.h b/src/compositor/hardware_integration/graphicshardwareintegration.h index ac4ec99d3..f6c46debf 100644 --- a/src/compositor/hardware_integration/graphicshardwareintegration.h +++ b/src/compositor/hardware_integration/graphicshardwareintegration.h @@ -45,15 +45,17 @@ #include <QtGui/QOpenGLContext> #include <wayland-server.h> -#include "waylandcompositor.h" -#include "wayland_wrapper/wldisplay.h" +#include <QtCompositor/waylandcompositor.h> +#include <QtCompositor/wldisplay.h> -class GraphicsHardwareIntegration +class Q_COMPOSITOR_EXPORT GraphicsHardwareIntegration { public: - GraphicsHardwareIntegration(WaylandCompositor *compositor); + GraphicsHardwareIntegration(); virtual ~GraphicsHardwareIntegration() { } + void setCompositor(WaylandCompositor *compositor) { m_compositor = compositor; } + virtual void initializeHardware(Wayland::Display *waylandDisplay) = 0; /** Bind the Wayland buffer to the textureId. The correct context is the current context, @@ -67,8 +69,6 @@ public: virtual void *lockNativeBuffer(struct wl_buffer *, QOpenGLContext *) const { return 0; } virtual void unlockNativeBuffer(void *, QOpenGLContext *) const { return; } - static GraphicsHardwareIntegration *createGraphicsHardwareIntegration(WaylandCompositor *compositor); - protected: WaylandCompositor *m_compositor; }; diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp b/src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp new file mode 100644 index 000000000..d8337c6e5 --- /dev/null +++ b/src/compositor/hardware_integration/graphicshardwareintegrationfactory.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module 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 "graphicshardwareintegrationfactory.h" +#include "graphicshardwareintegrationplugin.h" +#include "graphicshardwareintegration.h" +#include <QtCore/private/qfactoryloader_p.h> +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> + +#ifndef QT_NO_LIBRARY +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (GraphicsHardwareIntegrationFactoryInterface_iid, QLatin1String("/waylandcompositors"), Qt::CaseInsensitive)) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, + (GraphicsHardwareIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif + +QStringList GraphicsHardwareIntegrationFactory::keys(const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + QStringList list; + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + list = directLoader()->keyMap().values(); + if (!list.isEmpty()) { + const QString postFix = QStringLiteral(" (from ") + + QDir::toNativeSeparators(pluginPath) + + QLatin1Char(')'); + const QStringList::iterator end = list.end(); + for (QStringList::iterator it = list.begin(); it != end; ++it) + (*it).append(postFix); + } + } + list.append(loader()->keyMap().values()); + return list; +#else + return QStringList(); +#endif +} + +GraphicsHardwareIntegration *GraphicsHardwareIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + // Try loading the plugin from platformPluginPath first: + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + if (GraphicsHardwareIntegration *ret = qLoadPlugin1<GraphicsHardwareIntegration, GraphicsHardwareIntegrationPlugin>(directLoader(), name, args)) + return ret; + } + if (GraphicsHardwareIntegration *ret = qLoadPlugin1<GraphicsHardwareIntegration, GraphicsHardwareIntegrationPlugin>(loader(), name, args)) + return ret; +#endif + return 0; +} diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationfactory.h b/src/compositor/hardware_integration/graphicshardwareintegrationfactory.h new file mode 100644 index 000000000..22bcd09cf --- /dev/null +++ b/src/compositor/hardware_integration/graphicshardwareintegrationfactory.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module 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 GRAPHICSHARDWAREINTEGRATIONFACTORY_H +#define GRAPHICSHARDWAREINTEGRATIONFACTORY_H + +#include "waylandexport.h" +#include <QtCore/QStringList> + +class GraphicsHardwareIntegration; + +class Q_COMPOSITOR_EXPORT GraphicsHardwareIntegrationFactory +{ +public: + static QStringList keys(const QString &pluginPath = QString()); + static GraphicsHardwareIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString()); +}; + +#endif // GRAPHICSHARDWAREINTEGRATIONFACTORY_H diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp b/src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp new file mode 100644 index 000000000..3bde8e8ab --- /dev/null +++ b/src/compositor/hardware_integration/graphicshardwareintegrationplugin.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module 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 "graphicshardwareintegrationplugin.h" + +GraphicsHardwareIntegrationPlugin::GraphicsHardwareIntegrationPlugin(QObject *parent) : + QObject(parent) +{ +} + +GraphicsHardwareIntegrationPlugin::~GraphicsHardwareIntegrationPlugin() +{ +} + diff --git a/src/compositor/hardware_integration/graphicshardwareintegrationplugin.h b/src/compositor/hardware_integration/graphicshardwareintegrationplugin.h new file mode 100644 index 000000000..51f605164 --- /dev/null +++ b/src/compositor/hardware_integration/graphicshardwareintegrationplugin.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module 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 GRAPHICSHARDWAREINTEGRATIONPLUGIN_H +#define GRAPHICSHARDWAREINTEGRATIONPLUGIN_H + +#include "waylandexport.h" + +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +class GraphicsHardwareIntegration; + +#define GraphicsHardwareIntegrationFactoryInterface_iid "org.qt-project.Qt.Compositor.GraphicsHardwareIntegrationFactoryInterface.5.1" + +class Q_COMPOSITOR_EXPORT GraphicsHardwareIntegrationPlugin : public QObject +{ + Q_OBJECT +public: + explicit GraphicsHardwareIntegrationPlugin(QObject *parent = 0); + ~GraphicsHardwareIntegrationPlugin(); + + virtual GraphicsHardwareIntegration *create(const QString &key, const QStringList ¶mList) = 0; +}; + +#endif // GRAPHICSHARDWAREINTEGRATIONPLUGIN_H diff --git a/src/compositor/hardware_integration/hardware_integration.pri b/src/compositor/hardware_integration/hardware_integration.pri index c008521ac..352dbaee6 100644 --- a/src/compositor/hardware_integration/hardware_integration.pri +++ b/src/compositor/hardware_integration/hardware_integration.pri @@ -1,3 +1,5 @@ +QT += core + isEmpty(QT_WAYLAND_GL_CONFIG):QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) !isEqual(QT_WAYLAND_GL_CONFIG,nogl) { @@ -8,36 +10,15 @@ isEmpty(QT_WAYLAND_GL_CONFIG):QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) $$PWD/graphicshardwareintegration.cpp DEFINES += QT_COMPOSITOR_WAYLAND_GL - - isEqual(QT_WAYLAND_GL_CONFIG, custom) { - QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG - } else { - equals(QT_WAYLAND_GL_CONFIG, brcm_egl) { - CONFIG -= config_wayland_egl config_xcomposite - } - - equals(QT_WAYLAND_GL_CONFIG, xcomposite) { - CONFIG -= config_wayland_egl config_brcm_egl - } - - config_wayland_egl { - include (wayland_egl/wayland_egl.pri) - QT_WAYLAND_GL_INTEGRATION = wayland_egl - }else:config_brcm_egl { - include (brcm_egl/brcm_egl.pri) - QT_WAYLAND_GL_INTEGRATION = brcm_egl - }else:config_xcomposite{ - config_egl{ - include (xcomposite_egl/xcomposite_egl.pri) - QT_WAYLAND_GL_INTEGRATION = xcomposite_egl - }else:config_glx{ - include (xcomposite_glx/xcomposite_glx.pri) - QT_WAYLAND_GL_INTEGRATION = xcomposite_glx - } - } - } - system(echo "Qt-Compositor configured with openGL integration: $$QT_WAYLAND_GL_INTEGRATION") } else { system(echo "Qt-Compositor configured as raster only compositor") } +HEADERS += \ + hardware_integration/graphicshardwareintegrationplugin.h \ + hardware_integration/graphicshardwareintegrationfactory.h + +SOURCES += \ + hardware_integration/graphicshardwareintegrationplugin.cpp \ + hardware_integration/graphicshardwareintegrationfactory.cpp + diff --git a/src/compositor/hardware_integration/wayland_egl/wayland_egl.pri b/src/compositor/hardware_integration/wayland_egl/wayland_egl.pri deleted file mode 100644 index d1e389dac..000000000 --- a/src/compositor/hardware_integration/wayland_egl/wayland_egl.pri +++ /dev/null @@ -1,13 +0,0 @@ - -!contains(QT_CONFIG, no-pkg-config) { - CONFIG += link_pkgconfig - PKGCONFIG += wayland-egl egl -} else { - LIBS += -lwayland-egl -lEGL -} - -SOURCES += \ - $$PWD/waylandeglintegration.cpp - -HEADERS += \ - $$PWD/waylandeglintegration.h diff --git a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp b/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp deleted file mode 100644 index fdb64554f..000000000 --- a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp +++ /dev/null @@ -1,252 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandeglintegration.h" -#include "wayland_wrapper/wlcompositor.h" -#include "wayland_wrapper/wlsurface.h" -#include "compositor_api/waylandsurface.h" -#include <qpa/qplatformnativeinterface.h> -#include <QtGui/QGuiApplication> -#include <QtGui/QOpenGLContext> -#include <qpa/qplatformscreen.h> -#include <QtGui/QWindow> -#include <QtCore/QPointer> - -#include <QDebug> - -#include <EGL/egl.h> -#include <EGL/eglext.h> - -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> - - -GraphicsHardwareIntegration * GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) -{ - return new WaylandEglIntegration(compositor); -} - -#ifndef EGL_WL_bind_wayland_display -typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); -#endif - -#ifndef EGL_KHR_image -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); -#endif - -#ifndef GL_OES_EGL_image -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - -class WaylandEglIntegrationPrivate -{ -public: - WaylandEglIntegrationPrivate() - : egl_display(EGL_NO_DISPLAY) - , valid(false) - , flipperConnected(false) - , egl_bind_wayland_display(0) - , egl_unbind_wayland_display(0) - , egl_create_image(0) - , egl_destroy_image(0) - , gl_egl_image_target_texture_2d(0) - { } - EGLDisplay egl_display; - bool valid; - bool flipperConnected; -#ifdef EGL_WL_request_client_buffer_format - QPointer<WaylandSurface> directRenderSurface; -#endif - PFNEGLBINDWAYLANDDISPLAYWL egl_bind_wayland_display; - PFNEGLUNBINDWAYLANDDISPLAYWL egl_unbind_wayland_display; - - PFNEGLCREATEIMAGEKHRPROC egl_create_image; - PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image; - - PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_egl_image_target_texture_2d; - - QPlatformNativeInterface::NativeResourceForContextFunction get_egl_context; -}; - -WaylandEglIntegration::WaylandEglIntegration(WaylandCompositor *compositor) - : GraphicsHardwareIntegration(compositor) - , d_ptr(new WaylandEglIntegrationPrivate) -{ -} - -void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) -{ - Q_D(WaylandEglIntegration); - - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - if (nativeInterface) { - d->egl_display = nativeInterface->nativeResourceForWindow("EglDisplay", m_compositor->window()); - if (d->egl_display) { - const char *extensionString = eglQueryString(d->egl_display, EGL_EXTENSIONS); - if (extensionString && strstr(extensionString, "EGL_WL_bind_wayland_display")) - { - d->get_egl_context = nativeInterface->nativeResourceFunctionForContext("get_egl_context"); - if (!d->get_egl_context) { - qWarning("Failed to retrieve the get_egl_context function"); - } - d->egl_bind_wayland_display = - reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL")); - d->egl_unbind_wayland_display = - reinterpret_cast<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL")); - d->egl_create_image = - reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); - d->egl_destroy_image = - reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); - d->gl_egl_image_target_texture_2d = - reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES")); - - if (d->egl_bind_wayland_display - && d->get_egl_context - && d->egl_unbind_wayland_display - && d->egl_create_image - && d->egl_destroy_image - && d->gl_egl_image_target_texture_2d) { - if (d->egl_bind_wayland_display(d->egl_display, waylandDisplay->handle())) { - d->valid = true; - } - } - } - } - - if (!d->valid) - qWarning("Failed to initialize egl display\n"); - } -} - -GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context) -{ - Q_D(WaylandEglIntegration); - if (!d->valid) { - qWarning("createTextureFromBuffer() failed\n"); - return 0; - } - - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - EGLContext egl_context = d->get_egl_context(context); - - EGLImageKHR image = d->egl_create_image(d->egl_display, egl_context, - EGL_WAYLAND_BUFFER_WL, - buffer, NULL); - - GLuint textureId; - glGenTextures(1,&textureId); - - glBindTexture(GL_TEXTURE_2D, textureId); - - d->gl_egl_image_target_texture_2d(GL_TEXTURE_2D, image); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - d->egl_destroy_image(d->egl_display, image); - - return textureId; -} - -bool WaylandEglIntegration::isYInverted(struct wl_buffer *buffer) const -{ -#ifdef EGL_WL_request_client_buffer_format - return eglGetBufferYInvertedWL(buffer); -#else - return GraphicsHardwareIntegration::isYInverted(buffer); -#endif -} - - -bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *surface) -{ - Q_D(WaylandEglIntegration); - - QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(m_compositor->window()); - QPlatformScreenPageFlipper *flipper = screen ? screen->pageFlipper() : 0; - if (flipper && !d->flipperConnected) { - QObject::connect(flipper, SIGNAL(bufferReleased(void*)), m_compositor->handle(), SLOT(releaseBuffer(void*))); - d->flipperConnected = true; - } -#ifdef EGL_WL_request_client_buffer_format - int buffer_format = surface ? EGL_SCANOUT_FORMAT_WL : EGL_RENDER_FORMAT_WL; - struct wl_client *client = 0; - if (surface) { - client = surface->handle()->base()->resource.client; - } else { - WaylandSurface *oldSurface = d->directRenderSurface.data(); - if (oldSurface) - client = oldSurface->handle()->base()->resource.client; - } - if (client) - eglRequestClientBufferFormatWL(d->egl_display, client, buffer_format); - d->directRenderSurface = surface; -#else - Q_UNUSED(surface); -#endif - return flipper; -} - -void *WaylandEglIntegration::lockNativeBuffer(struct wl_buffer *buffer, QOpenGLContext *context) const -{ - Q_D(const WaylandEglIntegration); - - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - EGLContext egl_context = d->get_egl_context(context); - - EGLImageKHR image = d->egl_create_image(d->egl_display, egl_context, - EGL_WAYLAND_BUFFER_WL, - buffer, NULL); - return image; -} - -void WaylandEglIntegration::unlockNativeBuffer(void *native_buffer, QOpenGLContext *) const -{ - Q_D(const WaylandEglIntegration); - EGLImageKHR image = static_cast<EGLImageKHR>(native_buffer); - - d->egl_destroy_image(d->egl_display, image); -} - diff --git a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h b/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h deleted file mode 100644 index 552acb5c0..000000000 --- a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h +++ /dev/null @@ -1,71 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WAYLANDEGLINTEGRATION_H -#define WAYLANDEGLINTEGRATION_H - -#include "hardware_integration/graphicshardwareintegration.h" -#include <QtCore/QScopedPointer> - -class WaylandEglIntegrationPrivate; - -class WaylandEglIntegration : public GraphicsHardwareIntegration -{ - Q_DECLARE_PRIVATE(WaylandEglIntegration) -public: - WaylandEglIntegration(WaylandCompositor *compositor); - - void initializeHardware(Wayland::Display *waylandDisplay); - - GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context); - bool isYInverted(struct wl_buffer *) const; - - bool setDirectRenderSurface(WaylandSurface *); - - virtual void *lockNativeBuffer(struct wl_buffer *buffer, QOpenGLContext *context) const; - virtual void unlockNativeBuffer(void *native_buffer, QOpenGLContext *context) const; - -private: - Q_DISABLE_COPY(WaylandEglIntegration) - QScopedPointer<WaylandEglIntegrationPrivate> d_ptr; -}; - -#endif // WAYLANDEGLINTEGRATION_H - diff --git a/src/compositor/hardware_integration/xcomposite_egl/xcomposite_egl.pri b/src/compositor/hardware_integration/xcomposite_egl/xcomposite_egl.pri deleted file mode 100644 index 1004fe398..000000000 --- a/src/compositor/hardware_integration/xcomposite_egl/xcomposite_egl.pri +++ /dev/null @@ -1,14 +0,0 @@ -include (../xcomposite_share/xcomposite_share.pri) - -!contains(QT_CONFIG, no-pkg-config) { - CONFIG += link_pkgconfig - PKGCONFIG += xcomposite egl x11 -} else { - LIBS += -lXcomposite -lEGL -lX11 -} - -HEADERS += \ - $$PWD/xcompositeeglintegration.h - -SOURCES += \ - $$PWD/xcompositeeglintegration.cpp diff --git a/src/compositor/hardware_integration/xcomposite_egl/xcompositeeglintegration.cpp b/src/compositor/hardware_integration/xcomposite_egl/xcompositeeglintegration.cpp deleted file mode 100644 index 84905499a..000000000 --- a/src/compositor/hardware_integration/xcomposite_egl/xcompositeeglintegration.cpp +++ /dev/null @@ -1,150 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositeeglintegration.h" - -#include "waylandobject.h" -#include "wayland_wrapper/wlcompositor.h" -#include "wayland-xcomposite-server-protocol.h" - -#include <QtGui/QGuiApplication> -#include <qpa/qplatformnativeinterface.h> -#include <qpa/qplatformopenglcontext.h> - -#include "xcompositebuffer.h" -#include "xcompositehandler.h" -#include <X11/extensions/Xcomposite.h> - -#include <QtCore/QDebug> - -QVector<EGLint> eglbuildSpec() -{ - QVector<EGLint> spec; - - spec.append(EGL_SURFACE_TYPE); spec.append(EGL_WINDOW_BIT | EGL_PIXMAP_BIT); - spec.append(EGL_RENDERABLE_TYPE); spec.append(EGL_OPENGL_ES2_BIT); - spec.append(EGL_BIND_TO_TEXTURE_RGBA); spec.append(EGL_TRUE); - spec.append(EGL_ALPHA_SIZE); spec.append(8); - spec.append(EGL_NONE); - return spec; -} - - -struct wl_xcomposite_interface XCompositeHandler::xcomposite_interface = { - XCompositeHandler::create_buffer -}; - -GraphicsHardwareIntegration *GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) -{ - return new XCompositeEglIntegration(compositor); -} - -XCompositeEglIntegration::XCompositeEglIntegration(WaylandCompositor *compositor) - : GraphicsHardwareIntegration(compositor) - , mDisplay(0) -{ - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - if (nativeInterface) { - mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForWindow("Display",m_compositor->window())); - if (!mDisplay) - qFatal("could not retireve Display from platform integration"); - mEglDisplay = static_cast<EGLDisplay>(nativeInterface->nativeResourceForWindow("EGLDisplay",m_compositor->window())); - if (!mEglDisplay) - qFatal("could not retrieve EGLDisplay from plaform integration"); - } else { - qFatal("Platform integration doesn't have native interface"); - } - mScreen = XDefaultScreen(mDisplay); -} - -void XCompositeEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) -{ - XCompositeHandler *handler = new XCompositeHandler(m_compositor->handle(),mDisplay,m_compositor->window()); - wl_display_add_global(waylandDisplay->handle(),&wl_xcomposite_interface,handler,XCompositeHandler::xcomposite_bind_func); -} - -GLuint XCompositeEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *) -{ - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer>(buffer); - Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window()); - - QVector<EGLint> eglConfigSpec = eglbuildSpec(); - - EGLint matching = 0; - EGLConfig config; - bool matched = eglChooseConfig(mEglDisplay,eglConfigSpec.constData(),&config,1,&matching); - if (!matched || !matching) { - qWarning("Could not retrieve a suitable EGL config"); - return 0; - } - - QVector<EGLint> attribList; - - attribList.append(EGL_TEXTURE_FORMAT); - attribList.append(EGL_TEXTURE_RGBA); - attribList.append(EGL_TEXTURE_TARGET); - attribList.append(EGL_TEXTURE_2D); - attribList.append(EGL_NONE); - - EGLSurface surface = eglCreatePixmapSurface(mEglDisplay,config,pixmap,attribList.constData()); - if (surface == EGL_NO_SURFACE) { - qDebug() << "Failed to create eglsurface" << pixmap << compositorBuffer->window(); - } - - compositorBuffer->setInvertedY(false); - - GLuint textureId; - glGenTextures(1,&textureId); - glBindTexture(GL_TEXTURE_2D, textureId); - - if (!eglBindTexImage(mEglDisplay,surface,EGL_BACK_BUFFER)) { - qDebug() << "Failed to bind"; - } - - // eglDestroySurface(mEglDisplay,surface); - - return textureId; -} - -bool XCompositeEglIntegration::isYInverted(wl_buffer *buffer) const -{ - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer>(buffer); - return compositorBuffer->isYInverted(); -} diff --git a/src/compositor/hardware_integration/xcomposite_egl/xcompositeeglintegration.h b/src/compositor/hardware_integration/xcomposite_egl/xcompositeeglintegration.h deleted file mode 100644 index 61f21afba..000000000 --- a/src/compositor/hardware_integration/xcomposite_egl/xcompositeeglintegration.h +++ /dev/null @@ -1,66 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEEGLINTEGRATION_H -#define XCOMPOSITEEGLINTEGRATION_H - -#include "hardware_integration/graphicshardwareintegration.h" - -#include "xlibinclude.h" - -#include <EGL/egl.h> - -class XCompositeEglIntegration : public GraphicsHardwareIntegration -{ -public: - XCompositeEglIntegration(WaylandCompositor *compositor); - - void initializeHardware(Wayland::Display *waylandDisplay); - - GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context); - bool isYInverted(wl_buffer *) const; - -private: - Display *mDisplay; - EGLDisplay mEglDisplay; - int mScreen; -}; - -#endif // XCOMPOSITEEGLINTEGRATION_H diff --git a/src/compositor/hardware_integration/xcomposite_glx/xcomposite_glx.pri b/src/compositor/hardware_integration/xcomposite_glx/xcomposite_glx.pri deleted file mode 100644 index 26281cc60..000000000 --- a/src/compositor/hardware_integration/xcomposite_glx/xcomposite_glx.pri +++ /dev/null @@ -1,14 +0,0 @@ -include (../xcomposite_share/xcomposite_share.pri) - -!contains(QT_CONFIG, no-pkg-config) { - CONFIG += link_pkgconfig - PKGCONFIG += xcomposite gl x11 -} else { - LIBS += -lXcomposite -lGL -lX11 -} - -HEADERS += \ - $$PWD/xcompositeglxintegration.h - -SOURCES += \ - $$PWD/xcompositeglxintegration.cpp diff --git a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp b/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp deleted file mode 100644 index 1c4ad3943..000000000 --- a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.cpp +++ /dev/null @@ -1,160 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositeglxintegration.h" - -#include "waylandobject.h" -#include "wayland_wrapper/wlcompositor.h" -#include "wayland-xcomposite-server-protocol.h" - -#include <qpa/qplatformnativeinterface.h> -#include <qpa/qplatformintegration.h> -#include <QtGui/QOpenGLContext> - -#include "xcompositebuffer.h" -#include "xcompositehandler.h" -#include <X11/extensions/Xcomposite.h> - -#include <QtCore/QDebug> - -QVector<int> qglx_buildSpec() -{ - QVector<int> spec(48); - int i = 0; - - spec[i++] = GLX_LEVEL; - spec[i++] = 0; - spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_PIXMAP_BIT | GLX_WINDOW_BIT; - spec[i++] = GLX_BIND_TO_TEXTURE_TARGETS_EXT; spec[i++] = GLX_TEXTURE_2D_BIT_EXT; - spec[i++] = GLX_BIND_TO_TEXTURE_RGB_EXT; spec[i++] = TRUE; - - spec[i++] = 0; - return spec; -} - - -struct wl_xcomposite_interface XCompositeHandler::xcomposite_interface = { - XCompositeHandler::create_buffer -}; - -GraphicsHardwareIntegration *GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) -{ - return new XCompositeGLXIntegration(compositor); -} - -XCompositeGLXIntegration::XCompositeGLXIntegration(WaylandCompositor *compositor) - : GraphicsHardwareIntegration(compositor) - , mDisplay(0) - , mHandler(0) -{ - QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface(); - if (nativeInterface) { - mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForWindow("Display",m_compositor->window())); - if (!mDisplay) - qFatal("could not retireve Display from platform integration"); - } else { - qFatal("Platform integration doesn't have native interface"); - } - mScreen = XDefaultScreen(mDisplay); -} - -XCompositeGLXIntegration::~XCompositeGLXIntegration() -{ - delete mHandler; -} - -void XCompositeGLXIntegration::initializeHardware(Wayland::Display *waylandDisplay) -{ - mHandler = new XCompositeHandler(m_compositor->handle(),mDisplay,m_compositor->window()); - wl_display_add_global(waylandDisplay->handle(),&wl_xcomposite_interface,mHandler,XCompositeHandler::xcomposite_bind_func); - - QOpenGLContext *glContext = new QOpenGLContext(); - glContext->create(); - - m_glxBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT")); - if (!m_glxBindTexImageEXT) { - qDebug() << "Did not find glxBindTexImageExt, everything will FAIL!"; - } - m_glxReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT")); - if (!m_glxReleaseTexImageEXT) { - qDebug() << "Did not find glxReleaseTexImageExt"; - } - - delete glContext; -} - -GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *) -{ - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer>(buffer); - Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window()); - - QVector<int> glxConfigSpec = qglx_buildSpec(); - int numberOfConfigs; - GLXFBConfig *configs = glXChooseFBConfig(mDisplay,mScreen,glxConfigSpec.constData(),&numberOfConfigs); - - QVector<int> attribList; - attribList.append(GLX_TEXTURE_FORMAT_EXT); - attribList.append(GLX_TEXTURE_FORMAT_RGB_EXT); - attribList.append(GLX_TEXTURE_TARGET_EXT); - attribList.append(GLX_TEXTURE_2D_EXT); - attribList.append(0); - GLXPixmap glxPixmap = glXCreatePixmap(mDisplay,*configs,pixmap,attribList.constData()); - - uint inverted = 0; - glXQueryDrawable(mDisplay, glxPixmap, GLX_Y_INVERTED_EXT,&inverted); - compositorBuffer->setInvertedY(!inverted); - - XFree(configs); - - GLuint textureId; - glGenTextures(1,&textureId); - glBindTexture(GL_TEXTURE_2D, textureId); - m_glxBindTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT, 0); - //Do we need to change the api so that we do bind and release in the painevent? - //The specification states that when deleting the texture the color buffer is deleted -// m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT); - return textureId; -} - -bool XCompositeGLXIntegration::isYInverted(wl_buffer *buffer) const -{ - XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer>(buffer); - return compositorBuffer->isYInverted(); -} diff --git a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h b/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h deleted file mode 100644 index 308d6c884..000000000 --- a/src/compositor/hardware_integration/xcomposite_glx/xcompositeglxintegration.h +++ /dev/null @@ -1,74 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEGLXINTEGRATION_H -#define XCOMPOSITEGLXINTEGRATION_H - -#include "hardware_integration/graphicshardwareintegration.h" - -#include "xlibinclude.h" - -#define GLX_GLXEXT_PROTOTYPES -#include <GL/glx.h> -#include <GL/glxext.h> - -class XCompositeHandler; - -class XCompositeGLXIntegration : public GraphicsHardwareIntegration -{ -public: - XCompositeGLXIntegration(WaylandCompositor *compositor); - ~XCompositeGLXIntegration(); - - void initializeHardware(Wayland::Display *waylandDisplay); - - GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context); - bool isYInverted(wl_buffer *) const; - -private: - PFNGLXBINDTEXIMAGEEXTPROC m_glxBindTexImageEXT; - PFNGLXRELEASETEXIMAGEEXTPROC m_glxReleaseTexImageEXT; - - Display *mDisplay; - int mScreen; - XCompositeHandler *mHandler; -}; - -#endif // XCOMPOSITEGLXINTEGRATION_H diff --git a/src/compositor/hardware_integration/xcomposite_share/xcomposite_share.pri b/src/compositor/hardware_integration/xcomposite_share/xcomposite_share.pri deleted file mode 100644 index 631ddaf2e..000000000 --- a/src/compositor/hardware_integration/xcomposite_share/xcomposite_share.pri +++ /dev/null @@ -1,14 +0,0 @@ -INCLUDEPATH += $$PWD - -WAYLANDSOURCES += $$PWD/../../../extensions/xcomposite.xml - -HEADERS += \ - $$PWD/xcompositebuffer.h \ - $$PWD/xcompositehandler.h \ - $$PWD/xlibinclude.h - -SOURCES += \ - $$PWD/xcompositebuffer.cpp \ - $$PWD/xcompositehandler.cpp - -QT += gui-private diff --git a/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp b/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp deleted file mode 100644 index 9e6c4e64e..000000000 --- a/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.cpp +++ /dev/null @@ -1,70 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositebuffer.h" - -XCompositeBuffer::XCompositeBuffer(Wayland::Compositor *compositor, Window window, const QSize &size) - : mWindow(window) - , mInvertedY(false) -{ - Q_UNUSED(compositor); - base()->height = size.height(); - base()->width = size.width(); -} - -struct wl_buffer_interface XCompositeBuffer::buffer_interface = { - XCompositeBuffer::buffer_interface_destroy -}; - -void XCompositeBuffer::buffer_interface_destroy(wl_client *client, wl_resource *buffer) -{ - Q_UNUSED(client); - Q_UNUSED(buffer); -} - -void XCompositeBuffer::delete_resource(struct wl_resource *resource) -{ - delete reinterpret_cast<XCompositeBuffer *>(resource); -} - -Window XCompositeBuffer::window() -{ - return mWindow; -} diff --git a/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.h b/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.h deleted file mode 100644 index 7a815f0c4..000000000 --- a/src/compositor/hardware_integration/xcomposite_share/xcompositebuffer.h +++ /dev/null @@ -1,76 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEBUFFER_H -#define XCOMPOSITEBUFFER_H - -#include "waylandobject.h" -#include "wayland_wrapper/wlcompositor.h" - -#include <QtCore/QSize> - -#include <QtCore/QTextStream> -#include <QtCore/QDataStream> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> - -#include <X11/X.h> - -class XCompositeBuffer : public Wayland::Object<struct wl_buffer> -{ -public: - XCompositeBuffer(Wayland::Compositor *compositor, Window window, const QSize &size); - - Window window(); - - static struct wl_buffer_interface buffer_interface; - static void delete_resource(struct wl_resource *resource); - - bool isYInverted() const { return mInvertedY; } - void setInvertedY(bool inverted) { mInvertedY = inverted; } -private: - Window mWindow; - bool mInvertedY; - - static void buffer_interface_destroy(struct wl_client *client, - struct wl_resource *buffer); -}; - -#endif // XCOMPOSITORBUFFER_H diff --git a/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp b/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp deleted file mode 100644 index 7bb63e2b2..000000000 --- a/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.cpp +++ /dev/null @@ -1,95 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositehandler.h" - -#include "wayland-xcomposite-server-protocol.h" - -#include "xcompositebuffer.h" -#include <X11/extensions/Xcomposite.h> - -XCompositeHandler::XCompositeHandler(Wayland::Compositor *compositor, Display *display, QWindow *window) - : mCompositor(compositor) - , mwindow(window) - , mDisplay(display) -{ - mCompositor->window()->create(); - - mFakeRootWindow = new QWindow(mCompositor->window()); - mFakeRootWindow->setGeometry(QRect(-1,-1,1,1)); - mFakeRootWindow->create(); - mFakeRootWindow->show(); - int composite_event_base, composite_error_base; - if (XCompositeQueryExtension(mDisplay, &composite_event_base, &composite_error_base)) { - - } else { - qFatal("XComposite required"); - } -} - -void XCompositeHandler::createBuffer(struct wl_client *client, uint32_t id, Window window, const QSize &size) -{ - XCompositeBuffer *buffer = new XCompositeBuffer(mCompositor, window, size); - buffer->addClientResource(client, &buffer->base()->resource, - id,&wl_buffer_interface, - &XCompositeBuffer::buffer_interface, - XCompositeBuffer::delete_resource); -} - -void XCompositeHandler::xcomposite_bind_func(struct wl_client *client, void *data, uint32_t version, uint32_t id) -{ - Q_UNUSED(version); - XCompositeHandler *handler = static_cast<XCompositeHandler *>(data); - wl_resource *resource = wl_client_add_object(client,&wl_xcomposite_interface,&xcomposite_interface,id,handler); - const char *displayString = XDisplayString(handler->mDisplay); - wl_resource_post_event(resource, WL_XCOMPOSITE_ROOT, displayString, handler->mFakeRootWindow->winId()); -} - -void XCompositeHandler::create_buffer(struct wl_client *client, - struct wl_resource *xcomposite, - uint32_t id, - uint32_t x_window, - int32_t width, - int32_t height) -{ - Window window = (Window)x_window; - XCompositeHandler *that = reinterpret_cast<XCompositeHandler *>(xcomposite); - that->createBuffer(client, id, window, QSize(width,height)); -} diff --git a/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.h b/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.h deleted file mode 100644 index e2c85ef08..000000000 --- a/src/compositor/hardware_integration/xcomposite_share/xcompositehandler.h +++ /dev/null @@ -1,73 +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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEHANDLER_H -#define XCOMPOSITEHANDLER_H - -#include "wayland_wrapper/wlcompositor.h" -#include "waylandobject.h" - -#include "xlibinclude.h" - -class XCompositeHandler : public Wayland::Object<struct wl_object> -{ -public: - XCompositeHandler(Wayland::Compositor *compositor, Display *display, QWindow *window); - void createBuffer(struct wl_client *client, uint32_t id, Window window, const QSize &size); - - static void xcomposite_bind_func(struct wl_client *client, void *data, uint32_t version, uint32_t id); - static struct wl_xcomposite_interface xcomposite_interface; - -private: - Wayland::Compositor *mCompositor; - QWindow *mwindow; - QWindow *mFakeRootWindow; - Display *mDisplay; - - static void create_buffer(struct wl_client *client, - struct wl_resource *xcomposite, - uint32_t id, - uint32_t x_window, - int32_t width, - int32_t height); - -}; - -#endif // XCOMPOSITEHANDLER_H diff --git a/src/compositor/hardware_integration/xcomposite_share/xlibinclude.h b/src/compositor/hardware_integration/xcomposite_share/xlibinclude.h deleted file mode 100644 index 733fd6fd0..000000000 --- a/src/compositor/hardware_integration/xcomposite_share/xlibinclude.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 Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XLIBINCLUDE_H -#define XLIBINCLUDE_H - -#include <QtCore/QEvent> -#include <QtCore/QTextStream> -#include <QtCore/QDataStream> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> -#include <QtGui/QCursor> -#include <QtGui/private/qguiapplication_p.h> - -#include <X11/Xlib.h> -#include "X11/extensions/Xcomposite.h" - -enum { - XFocusOut = FocusOut, - XFocusIn = FocusIn, - XKeyPress = KeyPress, - XKeyRelease = KeyRelease, - XNone = None, - XRevertToParent = RevertToParent, - XGrayScale = GrayScale, - XCursorShape = CursorShape -}; -#undef FocusOut -#undef FocusIn -#undef KeyPress -#undef KeyRelease -#undef None -#undef RevertToParent -#undef GrayScale -#undef CursorShape - -#ifdef FontChange -#undef FontChange -#endif - -#endif //XLIBINCLUDE_H |