From 3a49e96f29a7cde711f376f2417875d54dd9f17f Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Wed, 29 Jan 2014 14:30:21 +0200 Subject: Add a libhybris hardwareintegrations to share EGL server buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a hardwareintegration plugin to make Qt server side EGL buffers shareable from the compositor to the client, such as what the server-buffer example does. Change-Id: I24558324d51202ca449b47b0ee395c8e81c10698 Reviewed-by: Jørgen Lind --- .../libhybris_egl_server/libhybris_egl_server.pro | 14 ++ config.tests/libhybris_egl_server/main.cpp | 53 ++++++ qtwayland.pro | 1 + src/extensions/libhybris-egl-server-buffer.xml | 65 +++++++ .../libhybris-egl-server/libhybris-egl-server.pri | 17 ++ .../libhybriseglserverbufferintegration.cpp | 181 +++++++++++++++++++ .../libhybriseglserverbufferintegration.h | 158 +++++++++++++++++ .../libhybris-egl-server/libhybris-egl-server.pri | 18 ++ .../libhybriseglserverbufferintegration.cpp | 197 +++++++++++++++++++++ .../libhybriseglserverbufferintegration.h | 189 ++++++++++++++++++++ src/plugins/hardwareintegration/client/client.pro | 2 + .../libhybris-egl-server/libhybris-egl-server.json | 3 + .../libhybris-egl-server/libhybris-egl-server.pro | 14 ++ .../client/libhybris-egl-server/main.cpp | 64 +++++++ .../hardwareintegration/compositor/compositor.pro | 3 + .../libhybris-egl-server/libhybris-egl-server.json | 3 + .../libhybris-egl-server/libhybris-egl-server.pro | 12 ++ .../compositor/libhybris-egl-server/main.cpp | 65 +++++++ 18 files changed, 1059 insertions(+) create mode 100644 config.tests/libhybris_egl_server/libhybris_egl_server.pro create mode 100644 config.tests/libhybris_egl_server/main.cpp create mode 100644 src/extensions/libhybris-egl-server-buffer.xml create mode 100644 src/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri create mode 100644 src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp create mode 100644 src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h create mode 100644 src/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri create mode 100644 src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp create mode 100644 src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h create mode 100644 src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.json create mode 100644 src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pro create mode 100644 src/plugins/hardwareintegration/client/libhybris-egl-server/main.cpp create mode 100644 src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.json create mode 100644 src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro create mode 100644 src/plugins/hardwareintegration/compositor/libhybris-egl-server/main.cpp diff --git a/config.tests/libhybris_egl_server/libhybris_egl_server.pro b/config.tests/libhybris_egl_server/libhybris_egl_server.pro new file mode 100644 index 000000000..bc358d559 --- /dev/null +++ b/config.tests/libhybris_egl_server/libhybris_egl_server.pro @@ -0,0 +1,14 @@ +TARGET = libhybris_egl_server +QT = core + +!contains(QT_CONFIG, opengl): error("libhybris_egl_server support requires Qt configured with OpenGL") + +!contains(QT_CONFIG, no-pkg-config) { + CONFIG += link_pkgconfig + PKGCONFIG += egl +} else { + LIBS += -legl +} + +# Input +SOURCES += main.cpp diff --git a/config.tests/libhybris_egl_server/main.cpp b/config.tests/libhybris_egl_server/main.cpp new file mode 100644 index 000000000..214bc537b --- /dev/null +++ b/config.tests/libhybris_egl_server/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** 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 +#include +#include + +int main() +{ +#ifdef EGL_HYBRIS_native_buffer + return 0; +#else +#error Requires EGL_HYBRIS_native_buffer to be defined + return 1; +#endif +} diff --git a/qtwayland.pro b/qtwayland.pro index 497483bd3..a834a48a9 100644 --- a/qtwayland.pro +++ b/qtwayland.pro @@ -9,6 +9,7 @@ qtCompileTest(brcm_egl) qtCompileTest(glx) qtCompileTest(xcomposite) qtCompileTest(drm_egl_server) +qtCompileTest(libhybris_egl_server) load(qt_parts) diff --git a/src/extensions/libhybris-egl-server-buffer.xml b/src/extensions/libhybris-egl-server-buffer.xml new file mode 100644 index 000000000..597ca0d78 --- /dev/null +++ b/src/extensions/libhybris-egl-server-buffer.xml @@ -0,0 +1,65 @@ + + + + Copyright (C) 2014 Jolla Ltd + Contact: http://www.qt-project.org/legal + + This file is part of the plugins of the Qt Toolkit. + + $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$ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri b/src/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri new file mode 100644 index 000000000..55e0ffd2a --- /dev/null +++ b/src/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri @@ -0,0 +1,17 @@ +INCLUDEPATH += $$PWD + +contains(QT_CONFIG, no-pkg-config) { + LIBS += -lEGL -lwayland-client +} else { + CONFIG += link_pkgconfig + PKGCONFIG += egl wayland-client +} + +SOURCES += \ + $$PWD/libhybriseglserverbufferintegration.cpp + +HEADERS += \ + $$PWD/libhybriseglserverbufferintegration.h + +CONFIG += wayland-scanner +WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/libhybris-egl-server-buffer.xml diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp new file mode 100644 index 000000000..0fcfca434 --- /dev/null +++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "libhybriseglserverbufferintegration.h" +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +LibHybrisServerBuffer::LibHybrisServerBuffer(LibHybrisEglServerBufferIntegration *integration + , int32_t numFds + , wl_array *ints + , int32_t name + , int32_t width + , int32_t height + , int32_t stride + , int32_t format) + : QWaylandServerBuffer() + , m_integration(integration) + , m_stride(stride) + , m_hybrisFormat(format) +{ + m_numFds = numFds; + m_fds.reserve(numFds); + m_ints.resize(ints->size / sizeof(int32_t)); + memcpy(m_ints.data(), ints->data, ints->size); + m_image = 0; + + m_size = QSize(width, height); +} + +LibHybrisServerBuffer::~LibHybrisServerBuffer() +{ + m_integration->eglDestroyImageKHR(m_image); +} + +void LibHybrisServerBuffer::bindTextureToBuffer() +{ + if (!QOpenGLContext::currentContext()) { + qWarning("LibHybrisServerBuffer: creating texture with no current context"); + } + + m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +void LibHybrisServerBuffer::libhybris_buffer_add_fd(int32_t fd) +{ + m_fds << fd; + + if (m_fds.size() == m_numFds) { + EGLint egl_format; + switch (m_hybrisFormat) { + case QtWayland::qt_libhybris_egl_server_buffer::format_RGBA32: + m_format = QWaylandServerBuffer::RGBA32; + egl_format = HYBRIS_PIXEL_FORMAT_RGBA_8888; + break; + default: + qWarning("LibHybrisServerBuffer: unknown format"); + m_format = QWaylandServerBuffer::RGBA32; + egl_format = HYBRIS_PIXEL_FORMAT_RGBA_8888; + break; + } + + EGLClientBuffer buf; + m_integration->eglHybrisCreateRemoteBuffer(m_size.width(), m_size.height(), HYBRIS_USAGE_HW_TEXTURE, egl_format, m_stride, m_ints.size(), m_ints.data(), m_fds.size(), m_fds.data(), &buf); + m_image = m_integration->eglCreateImageKHR(EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, buf, 0); + } +} + +void LibHybrisEglServerBufferIntegration::initialize(QWaylandDisplay *display) +{ + m_egl_display = eglGetDisplay((EGLNativeDisplayType) display->wl_display()); + if (EGL_NO_DISPLAY) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not get egl display from wl_display."); + return; + } + + const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS); + if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) { + qWarning("Failed to initialize libhybris egl server buffer integration. There is no EGL_KHR_image extension.\n"); + return; + } + m_egl_create_image = reinterpret_cast(eglGetProcAddress("eglCreateImageKHR")); + m_egl_destroy_image = reinterpret_cast(eglGetProcAddress("eglDestroyImageKHR")); + if (!m_egl_create_image || !m_egl_destroy_image) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR"); + return; + } + + m_gl_egl_image_target_texture = reinterpret_cast(eglGetProcAddress("glEGLImageTargetTexture2DOES")); + if (!m_gl_egl_image_target_texture) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not resolve glEGLImageTargetTexture2DOES"); + return; + } + + m_egl_create_buffer = reinterpret_cast(eglGetProcAddress("eglHybrisCreateRemoteBuffer")); + if (!m_egl_create_buffer) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not resolve eglHybrisCreateRemoteBuffer"); + return; + } + + QtWayland::wl_registry::init(wl_display_get_registry(display->wl_display())); +} + +QWaylandServerBuffer *LibHybrisEglServerBufferIntegration::serverBuffer(struct qt_server_buffer *buffer) +{ + return static_cast(qt_server_buffer_get_user_data(buffer)); +} + +void LibHybrisEglServerBufferIntegration::registry_global(uint32_t name, const QString &interface, uint32_t version) +{ + Q_UNUSED(version); + if (interface == QStringLiteral("qt_libhybris_egl_server_buffer")) { + struct ::wl_registry *registry = QtWayland::wl_registry::object(); + QtWayland::qt_libhybris_egl_server_buffer::init(registry, name); + } +} + +void LibHybrisEglServerBufferIntegration::libhybris_egl_server_buffer_server_buffer_created(struct ::qt_libhybris_buffer *id + , struct ::qt_server_buffer *qid + , int32_t numFds + , wl_array *ints + , int32_t name + , int32_t width + , int32_t height + , int32_t stride + , int32_t format) +{ + LibHybrisServerBuffer *server_buffer = new LibHybrisServerBuffer(this, numFds, ints, name, width, height, stride, format); + server_buffer->QtWayland::qt_libhybris_buffer::init(id); + qt_server_buffer_set_user_data(qid, server_buffer); +} + +QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h new file mode 100644 index 000000000..dd334bd2f --- /dev/null +++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIBHYBRISEGLSERVERBUFFERINTEGRATION_H +#define LIBHYBRISEGLSERVERBUFFERINTEGRATION_H + +#include +#include "qwayland-libhybris-egl-server-buffer.h" +#include +#include +#include +#include + +#include +#include +#ifndef EGL_KHR_image +typedef void *EGLImageKHR; +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); +#endif + +#ifndef EGL_HYBRIS_native_buffer +typedef EGLBoolean (EGLAPIENTRYP PFNEGLHYBRISCREATEREMOTEBUFFERPROC)(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint stride, + int num_ints, int *ints, int num_fds, int *fds, EGLClientBuffer *buffer); +#endif + +QT_BEGIN_NAMESPACE + +class LibHybrisEglServerBufferIntegration; + +class LibHybrisServerBuffer : public QWaylandServerBuffer, public QtWayland::qt_libhybris_buffer +{ +public: + LibHybrisServerBuffer(LibHybrisEglServerBufferIntegration *integration, int32_t numFds, wl_array *ints, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format); + ~LibHybrisServerBuffer(); + void bindTextureToBuffer() Q_DECL_OVERRIDE; + +protected: + void libhybris_buffer_add_fd(int32_t fd) Q_DECL_OVERRIDE; + +private: + LibHybrisEglServerBufferIntegration *m_integration; + EGLImageKHR m_image; + int m_numFds; + QVector m_ints; + QVector m_fds; + int32_t m_stride; + int32_t m_hybrisFormat; +}; + +class LibHybrisEglServerBufferIntegration + : public QWaylandServerBufferIntegration + , public QtWayland::wl_registry + , public QtWayland::qt_libhybris_egl_server_buffer +{ +public: + void initialize(QWaylandDisplay *display) Q_DECL_OVERRIDE; + + virtual QWaylandServerBuffer *serverBuffer(struct qt_server_buffer *buffer) Q_DECL_OVERRIDE; + + inline EGLImageKHR eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); + inline EGLBoolean eglDestroyImageKHR (EGLImageKHR image); + inline void glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); + inline EGLBoolean eglHybrisCreateRemoteBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint stride, int num_ints, int *ints, int num_fds, int *fds, EGLClientBuffer *buffer); + +protected: + void registry_global(uint32_t name, const QString &interface, uint32_t version) Q_DECL_OVERRIDE; + void libhybris_egl_server_buffer_server_buffer_created(struct ::qt_libhybris_buffer *id, struct ::qt_server_buffer *qid, + int32_t numFds, wl_array *ints, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format) Q_DECL_OVERRIDE; +private: + PFNEGLCREATEIMAGEKHRPROC m_egl_create_image; + PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image; + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture; + PFNEGLHYBRISCREATEREMOTEBUFFERPROC m_egl_create_buffer; + EGLDisplay m_egl_display; +}; + +EGLImageKHR LibHybrisEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + if (!m_egl_create_image) { + qWarning("LibHybrisEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR"); + return EGL_NO_IMAGE_KHR; + } + return m_egl_create_image(m_egl_display, ctx, target, buffer,attrib_list); +} + +EGLBoolean LibHybrisEglServerBufferIntegration::eglDestroyImageKHR (EGLImageKHR image) +{ + if (!m_egl_destroy_image) { + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function eglDestroyImageKHR"); + return false; + } + return m_egl_destroy_image(m_egl_display, image); +} + +void LibHybrisEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) +{ + if (!m_gl_egl_image_target_texture) { + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function glEGLImageTargetRenderbufferStorageOES"); + return; + } + m_gl_egl_image_target_texture(target,image); +} + +EGLBoolean LibHybrisEglServerBufferIntegration::eglHybrisCreateRemoteBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint stride, + int num_ints, int *ints, int num_fds, int *fds, EGLClientBuffer *buffer) +{ + if (!m_egl_create_buffer) { + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function eglHybrisCreateRemoteBuffer"); + return false; + } + return m_egl_create_buffer(width, height, usage, format, stride, num_ints, ints, num_fds, fds, buffer); +} +QT_END_NAMESPACE + +#endif diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri b/src/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri new file mode 100644 index 000000000..84d901351 --- /dev/null +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri @@ -0,0 +1,18 @@ +INCLUDEPATH += $$PWD + +contains(QT_CONFIG, no-pkg-config) { + LIBS += -lwayland-server -lEGL +} else { + CONFIG += link_pkgconfig + PKGCONFIG += wayland-server egl +} + +SOURCES += \ + $$PWD/libhybriseglserverbufferintegration.cpp + + +HEADERS += \ + $$PWD/libhybriseglserverbufferintegration.h + +CONFIG += wayland-scanner +WAYLANDSERVERSOURCES += $$PWD/../../../extensions/libhybris-egl-server-buffer.xml diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp new file mode 100644 index 000000000..c15f3d154 --- /dev/null +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** 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 "libhybriseglserverbufferintegration.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +LibHybrisEglServerBuffer::LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QSize &size, QtWayland::ServerBuffer::Format format) + : QtWayland::ServerBuffer(size,format) + , m_integration(integration) +{ + m_format = format; + + EGLint egl_format; + switch (m_format) { + case RGBA32: + m_hybris_format = QtWaylandServer::qt_libhybris_egl_server_buffer::format_RGBA32; + egl_format = HYBRIS_PIXEL_FORMAT_RGBA_8888; + break; + default: + qWarning("LibHybrisEglServerBuffer: unsupported format"); + m_hybris_format = QtWaylandServer::qt_libhybris_egl_server_buffer::format_RGBA32; + egl_format = HYBRIS_PIXEL_FORMAT_RGBA_8888; + break; + } + + if (!m_integration->eglHybrisCreateNativeBuffer(size.width(), size.height(), HYBRIS_USAGE_HW_TEXTURE, egl_format, &m_stride, &m_buffer)) { + qWarning("LibHybrisEglServerBuffer: Failed to create egl buffer"); + return; + } + + int numInts; + int numFds; + m_integration->eglHybrisGetNativeBufferInfo(m_buffer, &numInts, &numFds); + m_ints.resize(numInts); + m_fds.resize(numFds); + m_integration->eglHybrisSerializeNativeBuffer(m_buffer, m_ints.data(), m_fds.data()); + + m_image = m_integration->eglCreateImageKHR(EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, m_buffer, 0); +} + +struct ::wl_resource *LibHybrisEglServerBuffer::resourceForClient(struct ::wl_client *client) +{ + QMultiMap::iterator it = resourceMap().find(client); + if (it == resourceMap().end()) { + QMultiMap::iterator egl_it = m_integration->resourceMap().find(client); + if (egl_it == m_integration->resourceMap().end()) { + qWarning("LibHybrisEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the libhybris_egl interface"); + return 0; + } + struct ::wl_resource *egl_resource = (*egl_it)->handle; + Resource *resource = add(client); + wl_resource *bufRes = wl_client_new_object(client, &qt_libhybris_buffer_interface, 0, 0); + + m_integration->send_server_buffer_created(egl_resource, resource->handle, bufRes, m_fds.size(), QByteArray((char *)m_ints.data(), m_ints.size() * sizeof(int32_t)), + m_name, m_size.width(), m_size.height(), m_stride, m_format); + + m_qtbuffers.insert(resource, bufRes); + + for (int i = 0; i < m_fds.size(); ++i) { + send_add_fd(resource->handle, m_fds.at(i)); + } + + return bufRes; + } + return m_qtbuffers.value(*it); +} + +void LibHybrisEglServerBuffer::bindTextureToBuffer() +{ + if (!QOpenGLContext::currentContext()) { + qWarning("LibHybrisEglServerBuffer: No current context when creating buffer. Texture loading will fail"); + return; + } + + m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +LibHybrisEglServerBufferIntegration::LibHybrisEglServerBufferIntegration() +{ +} + +LibHybrisEglServerBufferIntegration::~LibHybrisEglServerBufferIntegration() +{ +} + +void LibHybrisEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor) +{ + QWindow *window = compositor->window(); + Q_ASSERT(QGuiApplication::platformNativeInterface()); + + m_egl_display = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("egldisplay", window)); + if (!m_egl_display) { + qWarning("Cant initialize libhybris egl server buffer integration. Missing egl display from platformplugin"); + return; + } + + m_egl_create_buffer = reinterpret_cast(eglGetProcAddress("eglHybrisCreateNativeBuffer")); + if (!m_egl_create_buffer) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisCreateNativeBuffer.\n"); + return; + } + m_egl_get_buffer_info = reinterpret_cast(eglGetProcAddress("eglHybrisGetNativeBufferInfo")); + if (!m_egl_get_buffer_info) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisGetNativeBufferInfo.\n"); + return; + } + m_egl_serialize_buffer = reinterpret_cast(eglGetProcAddress("eglHybrisSerializeNativeBuffer")); + if (!m_egl_serialize_buffer) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisSerializeNativeBuffer.\n"); + return; + } + + const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS); + if (!extensionString || !strstr(extensionString, "EGL_KHR_image")) { + qWarning("Failed to initialize libhybris egl server buffer integration. There is no EGL_KHR_image extension.\n"); + return; + } + m_egl_create_image = reinterpret_cast(eglGetProcAddress("eglCreateImageKHR")); + m_egl_destroy_image = reinterpret_cast(eglGetProcAddress("eglDestroyImageKHR")); + if (!m_egl_create_image || !m_egl_destroy_image) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR"); + return; + } + + m_gl_egl_image_target_texture_2d = reinterpret_cast(eglGetProcAddress("glEGLImageTargetTexture2DOES")); + if (!m_gl_egl_image_target_texture_2d) { + qWarning("Failed to initialize libhybris egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n"); + return; + } + + QtWaylandServer::qt_libhybris_egl_server_buffer::init(compositor->waylandDisplay()); +} + +bool LibHybrisEglServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const +{ + switch (format) { + case QtWayland::ServerBuffer::RGBA32: + return true; + case QtWayland::ServerBuffer::A8: + return false; + default: + return false; + } +} + +QtWayland::ServerBuffer *LibHybrisEglServerBufferIntegration::createServerBuffer(const QSize &size, QtWayland::ServerBuffer::Format format) +{ + return new LibHybrisEglServerBuffer(this, size, format); +} + +QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h new file mode 100644 index 000000000..35a3e8007 --- /dev/null +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** 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 LIBHYBRISEGLSERVERBUFFERINTEGRATION_H +#define LIBHYBRISEGLSERVERBUFFERINTEGRATION_H + +#include + +#include "qwayland-server-libhybris-egl-server-buffer.h" + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#ifndef EGL_KHR_image +typedef void *EGLImageKHR; +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 EGL_HYBRIS_native_buffer +typedef EGLBoolean (EGLAPIENTRYP PFNEGLHYBRISCREATENATIVEBUFFERPROC)(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint *stride, EGLClientBuffer *buffer); +typedef void (EGLAPIENTRYP PFNEGLHYBRISGETNATIVEBUFFERINFOPROC)(EGLClientBuffer buffer, int *num_ints, int *num_fds); +typedef void (EGLAPIENTRYP PFNEGLHYBRISSERIALIZENATIVEBUFFERPROC)(EGLClientBuffer buffer, int *ints, int *fds); +#endif + +#ifndef GL_OES_EGL_image +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +#endif + +QT_BEGIN_NAMESPACE + +class LibHybrisEglServerBufferIntegration; + +class LibHybrisEglServerBuffer : public QtWayland::ServerBuffer, public QtWaylandServer::qt_libhybris_buffer +{ +public: + LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QSize &size, QtWayland::ServerBuffer::Format format); + + struct ::wl_resource *resourceForClient(struct ::wl_client *) Q_DECL_OVERRIDE; + void bindTextureToBuffer() Q_DECL_OVERRIDE; + +private: + LibHybrisEglServerBufferIntegration *m_integration; + + EGLImageKHR m_image; + EGLClientBuffer m_buffer; + + int32_t m_name; + int32_t m_stride; + QtWaylandServer::qt_libhybris_egl_server_buffer::format m_hybris_format; + QVector m_ints; + QVector m_fds; + QHash m_qtbuffers; +}; + +class LibHybrisEglServerBufferIntegration : + public QtWayland::ServerBufferIntegration, + public QtWaylandServer::qt_libhybris_egl_server_buffer +{ +public: + LibHybrisEglServerBufferIntegration(); + ~LibHybrisEglServerBufferIntegration(); + + void initializeHardware(QWaylandCompositor *); + + bool supportsFormat(QtWayland::ServerBuffer::Format format) const Q_DECL_OVERRIDE; + QtWayland::ServerBuffer *createServerBuffer(const QSize &size, QtWayland::ServerBuffer::Format format) Q_DECL_OVERRIDE; + + EGLDisplay display() const { return m_egl_display; } + + inline EGLImageKHR eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); + inline EGLBoolean eglDestroyImageKHR (EGLImageKHR image); + inline void glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); + + inline EGLBoolean eglHybrisCreateNativeBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint *stride, EGLClientBuffer *buffer); + inline void eglHybrisGetNativeBufferInfo(EGLClientBuffer buffer, int *num_ints, int *num_fds); + inline void eglHybrisSerializeNativeBuffer(EGLClientBuffer buffer, int *ints, int *fds); + +private: + EGLDisplay m_egl_display; + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture_2d; + + PFNEGLHYBRISCREATENATIVEBUFFERPROC m_egl_create_buffer; + PFNEGLHYBRISGETNATIVEBUFFERINFOPROC m_egl_get_buffer_info; + PFNEGLHYBRISSERIALIZENATIVEBUFFERPROC m_egl_serialize_buffer; + + PFNEGLCREATEIMAGEKHRPROC m_egl_create_image; + PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image; +}; + +EGLImageKHR LibHybrisEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + if (!m_egl_create_image) { + qWarning("LibHybrisEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR"); + return EGL_NO_IMAGE_KHR; + } + return m_egl_create_image(m_egl_display, ctx, target, buffer,attrib_list); +} + +EGLBoolean LibHybrisEglServerBufferIntegration::eglDestroyImageKHR (EGLImageKHR image) +{ + if (!m_egl_destroy_image) { + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function eglDestroyImageKHR"); + return false; + } + return m_egl_destroy_image(m_egl_display, image); +} + +void LibHybrisEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) +{ + if (m_gl_egl_image_target_texture_2d) + return m_gl_egl_image_target_texture_2d(target, image); + else + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function glEGLImageTargetTexture2DOES"); +} + +EGLBoolean LibHybrisEglServerBufferIntegration::eglHybrisCreateNativeBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint *stride, EGLClientBuffer *buffer) +{ + if (m_egl_create_buffer) + return m_egl_create_buffer(width, height, usage, format, stride, buffer); + else + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function eglHybrisCreateNativeBuffer"); + return EGL_FALSE; +} + +void LibHybrisEglServerBufferIntegration::eglHybrisGetNativeBufferInfo(EGLClientBuffer buffer, int *num_ints, int *num_fds) +{ + if (m_egl_get_buffer_info) + m_egl_get_buffer_info(buffer, num_ints, num_fds); + else + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function eglHybrisGetNativeBufferInfo"); +} + +void LibHybrisEglServerBufferIntegration::eglHybrisSerializeNativeBuffer(EGLClientBuffer buffer, int *ints, int *fds) +{ + if (m_egl_serialize_buffer) + m_egl_serialize_buffer(buffer, ints, fds); + else + qWarning("LibHybrisEglServerBufferIntegration: Trying to use unresolved function eglHybrisSerializeNativeBuffer"); +} + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/hardwareintegration/client/client.pro b/src/plugins/hardwareintegration/client/client.pro index 1d79b2634..b7a9b46ee 100644 --- a/src/plugins/hardwareintegration/client/client.pro +++ b/src/plugins/hardwareintegration/client/client.pro @@ -17,3 +17,5 @@ config_xcomposite { config_drm_egl_server: \ SUBDIRS += drm-egl-server +config_libhybris_egl_server: \ + SUBDIRS += libhybris-egl-server diff --git a/src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.json b/src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.json new file mode 100644 index 000000000..3a1f4c08a --- /dev/null +++ b/src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "libhybris-egl-server" ] +} diff --git a/src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pro b/src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pro new file mode 100644 index 000000000..4d7909701 --- /dev/null +++ b/src/plugins/hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pro @@ -0,0 +1,14 @@ +PLUGIN_TYPE = wayland-graphics-integration/client +load(qt_plugin) + +QT += waylandclient-private + +include(../../../../hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri) + +LIBS += -lEGL + +OTHER_FILES += \ + libhybris-egl-server.json + +SOURCES += main.cpp + diff --git a/src/plugins/hardwareintegration/client/libhybris-egl-server/main.cpp b/src/plugins/hardwareintegration/client/libhybris-egl-server/main.cpp new file mode 100644 index 000000000..9aee15790 --- /dev/null +++ b/src/plugins/hardwareintegration/client/libhybris-egl-server/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "libhybriseglserverbufferintegration.h" + +QT_BEGIN_NAMESPACE + +class LibHybrisEglServerBufferPlugin : public QWaylandServerBufferIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QWaylandServerBufferIntegrationFactoryInterface_iid FILE "libhybris-egl-server.json") +public: + QWaylandServerBufferIntegration *create(const QString&, const QStringList&); +}; + +QWaylandServerBufferIntegration *LibHybrisEglServerBufferPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + Q_UNUSED(system); + return new LibHybrisEglServerBufferIntegration(); +} + +QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/hardwareintegration/compositor/compositor.pro b/src/plugins/hardwareintegration/compositor/compositor.pro index 3c1ff5d73..215cd2571 100644 --- a/src/plugins/hardwareintegration/compositor/compositor.pro +++ b/src/plugins/hardwareintegration/compositor/compositor.pro @@ -15,3 +15,6 @@ config_xcomposite { config_drm_egl_server: \ SUBDIRS += drm-egl-server + +config_libhybris_egl_server: \ + SUBDIRS += libhybris-egl-server diff --git a/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.json b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.json new file mode 100644 index 000000000..3a1f4c08a --- /dev/null +++ b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "libhybris-egl-server" ] +} diff --git a/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro new file mode 100644 index 000000000..7a209724f --- /dev/null +++ b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pro @@ -0,0 +1,12 @@ +PLUGIN_TYPE = wayland-graphics-integration/server +load(qt_plugin) + +QT = compositor compositor-private core-private gui-private + +OTHER_FILES += libhybris-egl-server.json + +SOURCES += \ + main.cpp + +include($PWD/../../../../../hardwareintegration/compositor/libhybris-egl-server/libhybris-egl-server.pri) + diff --git a/src/plugins/hardwareintegration/compositor/libhybris-egl-server/main.cpp b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/main.cpp new file mode 100644 index 000000000..10751266c --- /dev/null +++ b/src/plugins/hardwareintegration/compositor/libhybris-egl-server/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "libhybriseglserverbufferintegration.h" + +QT_BEGIN_NAMESPACE + +class LibHybrisEglServerBufferIntegrationPlugin : public QtWayland::ServerBufferIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QtWaylandServerBufferIntegrationFactoryInterface_iid FILE "libhybris-egl-server.json") +public: + QtWayland::ServerBufferIntegration *create(const QString&, const QStringList&); +}; + +QtWayland::ServerBufferIntegration *LibHybrisEglServerBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + Q_UNUSED(system); + return new LibHybrisEglServerBufferIntegration(); +} + +QT_END_NAMESPACE + +#include "main.moc" -- cgit v1.2.3