diff options
Diffstat (limited to 'src/compositor')
6 files changed, 177 insertions, 24 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index fc53d3bc2..40a151c55 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -73,8 +73,9 @@ public: TouchExtension = 0x10, SubSurfaceExtension = 0x20, TextInputExtension = 0x40, + HardwareIntegrationExtension = 0x80, - DefaultExtensions = WindowManagerExtension | OutputExtension | SurfaceExtension | QtKeyExtension | TouchExtension + DefaultExtensions = WindowManagerExtension | OutputExtension | SurfaceExtension | QtKeyExtension | TouchExtension | HardwareIntegrationExtension }; Q_DECLARE_FLAGS(ExtensionFlags, ExtensionFlag) diff --git a/src/compositor/hardware_integration/hardware_integration.pri b/src/compositor/hardware_integration/hardware_integration.pri index 402a3f6bd..999434d93 100644 --- a/src/compositor/hardware_integration/hardware_integration.pri +++ b/src/compositor/hardware_integration/hardware_integration.pri @@ -1,11 +1,10 @@ -QT += core - isEmpty(QT_WAYLAND_GL_CONFIG):QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) !isEqual(QT_WAYLAND_GL_CONFIG,nogl) { CONFIG += wayland-scanner WAYLANDSERVERSOURCES += \ - ../extensions/server-buffer-extension.xml + ../extensions/server-buffer-extension.xml \ + ../extensions/hardware-integration.xml HEADERS += \ hardware_integration/qwaylandclientbufferintegration.h \ @@ -13,7 +12,8 @@ isEmpty(QT_WAYLAND_GL_CONFIG):QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) hardware_integration/qwaylandclientbufferintegrationplugin.h \ hardware_integration/qwaylandserverbufferintegration.h \ hardware_integration/qwaylandserverbufferintegrationfactory.h \ - hardware_integration/qwaylandserverbufferintegrationplugin.h + hardware_integration/qwaylandserverbufferintegrationplugin.h \ + hardware_integration/qwlhwintegration_p.h SOURCES += \ hardware_integration/qwaylandclientbufferintegration.cpp \ @@ -21,7 +21,8 @@ isEmpty(QT_WAYLAND_GL_CONFIG):QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) hardware_integration/qwaylandclientbufferintegrationplugin.cpp \ hardware_integration/qwaylandserverbufferintegration.cpp \ hardware_integration/qwaylandserverbufferintegrationfactory.cpp \ - hardware_integration/qwaylandserverbufferintegrationplugin.cpp + hardware_integration/qwaylandserverbufferintegrationplugin.cpp \ + hardware_integration/qwlhwintegration.cpp DEFINES += QT_COMPOSITOR_WAYLAND_GL } else { diff --git a/src/compositor/hardware_integration/qwlhwintegration.cpp b/src/compositor/hardware_integration/qwlhwintegration.cpp new file mode 100644 index 000000000..62614c4d4 --- /dev/null +++ b/src/compositor/hardware_integration/qwlhwintegration.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwlhwintegration_p.h" + +#include "qwlcompositor_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +HardwareIntegration::HardwareIntegration(Compositor *compositor) + : qt_hardware_integration(compositor->wl_display()) +{ +} +void HardwareIntegration::setClientBufferIntegration(const QString &name) +{ + m_client_buffer_integration = name; +} +void HardwareIntegration::setServerBufferIntegration(const QString &name) +{ + m_server_buffer_integration = name; +} + +void HardwareIntegration::hardware_integration_bind_resource(Resource *resource) +{ + if (m_client_buffer_integration.size()) + send_client_backend(resource->handle, m_client_buffer_integration); + if (m_server_buffer_integration.size()) + send_server_backend(resource->handle, m_server_buffer_integration); +} + +} + +QT_END_NAMESPACE diff --git a/src/compositor/hardware_integration/qwlhwintegration_p.h b/src/compositor/hardware_integration/qwlhwintegration_p.h new file mode 100644 index 000000000..70128eb0e --- /dev/null +++ b/src/compositor/hardware_integration/qwlhwintegration_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 QWLHWINTEGRATION_P_H +#define QWLHWINTEGRATION_P_H + +#include <QtCompositor/private/qwayland-server-hardware-integration.h> + +#include <QtCore/QString> + +QT_BEGIN_NAMESPACE + +namespace QtWayland { + +class Compositor; + +class HardwareIntegration : public QtWaylandServer::qt_hardware_integration +{ +public: + HardwareIntegration(Compositor *compositor); + + void setClientBufferIntegration(const QString &name); + void setServerBufferIntegration(const QString &name); + +protected: + void hardware_integration_bind_resource(Resource *resource); + +private: + QString m_client_buffer_integration; + QString m_server_buffer_integration; +}; + +} + +QT_END_NAMESPACE +#endif diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp index 206155a4a..3c606d217 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor.cpp +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -84,6 +84,7 @@ #include <wayland-server.h> +#include "hardware_integration/qwlhwintegration_p.h" #include "hardware_integration/qwaylandclientbufferintegration.h" #include "hardware_integration/qwaylandserverbufferintegration.h" #include "waylandwindowmanagerintegration.h" @@ -140,6 +141,7 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::Ex , m_directRenderContext(0) , m_directRenderActive(false) #if defined (QT_COMPOSITOR_WAYLAND_GL) + , m_hw_integration(0) , m_client_buffer_integration(0) , m_server_buffer_integration(0) #endif @@ -156,14 +158,6 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::Ex m_timer.start(); compositor = this; -#if defined (QT_COMPOSITOR_WAYLAND_GL) - QWindow *window = qt_compositor->window(); - if (window && window->surfaceType() != QWindow::RasterSurface) { - loadClientBufferIntegration(); - loadServerBufferIntegration(); - } -#endif - if (extensions & QWaylandCompositor::WindowManagerExtension) m_windowManagerIntegration = new WindowManagerServerIntegration(qt_compositor, this); @@ -178,6 +172,16 @@ Compositor::Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::Ex m_shell = new Shell(); wl_display_add_global(m_display->handle(), &wl_shell_interface, m_shell, Shell::bind_func); +#if defined (QT_COMPOSITOR_WAYLAND_GL) + if (extensions & QWaylandCompositor::HardwareIntegrationExtension) + m_hw_integration.reset(new HardwareIntegration(this)); + QWindow *window = qt_compositor->window(); + if (window && window->surfaceType() != QWindow::RasterSurface) { + loadClientBufferIntegration(); + loadServerBufferIntegration(); + } +#endif + if (extensions & QWaylandCompositor::OutputExtension) m_outputExtension = new OutputExtensionGlobal(this); if (extensions & QWaylandCompositor::SurfaceExtension) @@ -224,10 +228,6 @@ Compositor::~Compositor() delete m_default_wayland_input_device; delete m_data_device_manager; -#ifdef QT_COMPOSITOR_WAYLAND_GL - delete m_client_buffer_integration; - delete m_server_buffer_integration; -#endif delete m_output_global; delete m_display; } @@ -321,7 +321,7 @@ QWindow *Compositor::window() const QWaylandClientBufferIntegration * Compositor::clientBufferIntegration() const { #ifdef QT_COMPOSITOR_WAYLAND_GL - return m_client_buffer_integration; + return m_client_buffer_integration.data(); #else return 0; #endif @@ -330,7 +330,7 @@ QWaylandClientBufferIntegration * Compositor::clientBufferIntegration() const QWaylandServerBufferIntegration * Compositor::serverBufferIntegration() const { #ifdef QT_COMPOSITOR_WAYLAND_GL - return m_server_buffer_integration; + return m_server_buffer_integration.data(); #else return 0; #endif @@ -569,9 +569,11 @@ void Compositor::loadClientBufferIntegration() } if (!targetKey.isEmpty()) { - m_client_buffer_integration = QWaylandClientBufferIntegrationFactory::create(targetKey, QStringList()); + m_client_buffer_integration.reset(QWaylandClientBufferIntegrationFactory::create(targetKey, QStringList())); if (m_client_buffer_integration) { m_client_buffer_integration->setCompositor(m_qt_compositor); + if (m_hw_integration) + m_hw_integration->setClientBufferIntegration(targetKey); } } //BUG: if there is no client buffer integration, bad things will when opengl is used @@ -586,7 +588,9 @@ void Compositor::loadServerBufferIntegration() targetKey = QString::fromLocal8Bit(serverBufferIntegration.constData()); } if (!targetKey.isEmpty()) { - m_server_buffer_integration = QWaylandServerBufferIntegrationFactory::create(targetKey, QStringList()); + m_server_buffer_integration.reset(QWaylandServerBufferIntegrationFactory::create(targetKey, QStringList())); + if (m_hw_integration) + m_hw_integration->setServerBufferIntegration(targetKey); } } diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h index 0d7bf0246..e223b03fc 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor_p.h +++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h @@ -79,6 +79,7 @@ class TouchExtensionGlobal; class QtKeyExtensionGlobal; class TextInputManager; class InputPanel; +class HardwareIntegration; class Q_COMPOSITOR_EXPORT Compositor : public QObject { @@ -205,8 +206,9 @@ private: bool m_directRenderActive; #ifdef QT_COMPOSITOR_WAYLAND_GL - QWaylandClientBufferIntegration *m_client_buffer_integration; - QWaylandServerBufferIntegration *m_server_buffer_integration; + QScopedPointer<HardwareIntegration> m_hw_integration; + QScopedPointer<QWaylandClientBufferIntegration> m_client_buffer_integration; + QScopedPointer<QWaylandServerBufferIntegration> m_server_buffer_integration; #endif //extensions |