diff options
Diffstat (limited to 'src/hardwareintegration')
92 files changed, 905 insertions, 4470 deletions
diff --git a/src/hardwareintegration/CMakeLists.txt b/src/hardwareintegration/CMakeLists.txt new file mode 100644 index 000000000..bc75a2088 --- /dev/null +++ b/src/hardwareintegration/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if(TARGET Qt::WaylandClient) + add_subdirectory(client) +endif() +if(TARGET Qt::WaylandCompositor) + add_subdirectory(compositor) +endif() diff --git a/src/hardwareintegration/client/CMakeLists.txt b/src/hardwareintegration/client/CMakeLists.txt new file mode 100644 index 000000000..f63592c84 --- /dev/null +++ b/src/hardwareintegration/client/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if(QT_FEATURE_wayland_egl) + add_subdirectory(wayland-egl) +endif() diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp index 4c310b96e..8f9047993 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwaylandbrcmeglintegration.h" diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h index 9db8e1612..ac164ab9d 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWAYLANDBRCMEGLINTEGRATION_H #define QWAYLANDBRCMEGLINTEGRATION_H diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp index 87ae8c02c..117e57807 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwaylandbrcmeglwindow.h" @@ -185,14 +149,14 @@ void QWaylandBrcmEglWindow::createEglSurfaces() m_count = window()->format().swapBehavior() == QSurfaceFormat::TripleBuffer ? 3 : 2; - m_eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), brcmFixFormat(window()->format()), true, EGL_PIXMAP_BIT); + EGLConfig eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), brcmFixFormat(window()->format()), true, EGL_PIXMAP_BIT); - m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(), m_eglConfig); + m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(), eglConfig); EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM; EGLint rt; - eglGetConfigAttrib(m_eglIntegration->eglDisplay(), m_eglConfig, EGL_RENDERABLE_TYPE, &rt); + eglGetConfigAttrib(m_eglIntegration->eglDisplay(), eglConfig, EGL_RENDERABLE_TYPE, &rt); if (rt & EGL_OPENGL_ES_BIT) { pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM; @@ -228,7 +192,7 @@ void QWaylandBrcmEglWindow::createEglSurfaces() EGL_NONE }; - m_eglSurfaces[i] = eglCreatePixmapSurface(m_eglIntegration->eglDisplay(), m_eglConfig, (EGLNativePixmapType)&m_globalImages[5*i], attrs); + m_eglSurfaces[i] = eglCreatePixmapSurface(m_eglIntegration->eglDisplay(), eglConfig, (EGLNativePixmapType)&m_globalImages[5*i], attrs); if (m_eglSurfaces[i] == EGL_NO_SURFACE) qFatal("eglCreatePixmapSurface failed: %x, global image id: %d %d\n", eglGetError(), m_globalImages[5*i], m_globalImages[5*i+1]); m_buffers[i] = new QWaylandBrcmBuffer(mDisplay, m_eglIntegration->waylandBrcm(), size, &m_globalImages[5*i], 5, m_eventQueue); diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h index 0c809e1ad..3b9026f9c 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmeglwindow.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWAYLANDBRCMEGLWINDOW_H #define QWAYLANDBRCMEGLWINDOW_H @@ -76,8 +40,6 @@ private: const QWaylandWindow *m_parentWindow = nullptr; - EGLConfig m_eglConfig = 0; - EGLint m_globalImages[3*5]; EGLSurface m_eglSurfaces[3]; diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp index f6029f040..66135a7cc 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwaylandbrcmglcontext.h" diff --git a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h index d95ea9410..e64a20d9b 100644 --- a/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h +++ b/src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWAYLANDBRCMGLCONTEXT_H #define QWAYLANDBRCMGLCONTEXT_H @@ -51,7 +15,6 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { class QWaylandWindow; -class QWaylandGLWindowSurface; class QWaylandBrcmGLContext : public QPlatformOpenGLContext { public: diff --git a/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.cpp b/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.cpp index 8637d4435..54df2badd 100644 --- a/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.cpp +++ b/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "dmabufserverbufferintegration.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> diff --git a/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.h b/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.h index 1ce2ad991..13dbdfbfb 100644 --- a/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.h +++ b/src/hardwareintegration/client/dmabuf-server/dmabufserverbufferintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef DMABUFSERVERBUFFERINTEGRATION_H #define DMABUFSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp index b55f35368..16a3aa4cf 100644 --- a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp +++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "drmeglserverbufferintegration.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h index dc6ec1364..a06bc96b8 100644 --- a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h +++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef DRMEGLSERVERBUFFERINTEGRATION_H #define DRMEGLSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp index 252ceb698..54081de97 100644 --- a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp +++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "libhybriseglserverbufferintegration.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h index e57a40339..7fd4a2abb 100644 --- a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h +++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef LIBHYBRISEGLSERVERBUFFERINTEGRATION_H #define LIBHYBRISEGLSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp index ad7bc5b70..38065dbde 100644 --- a/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp +++ b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "shmserverbufferintegration.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> @@ -49,7 +13,7 @@ QT_BEGIN_NAMESPACE static QOpenGLTexture *createTextureFromShm(const QString &key, int w, int h, int bpl, int format) { - QSharedMemory shm(key); + QT_IGNORE_DEPRECATIONS(QSharedMemory shm(key);) bool ok; ok = shm.attach(QSharedMemory::ReadOnly); if (!ok) { diff --git a/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h index b162d6924..344046ae1 100644 --- a/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h +++ b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SHMSERVERBUFFERINTEGRATION_H #define SHMSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.cpp b/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.cpp index 90e9a3217..8f1ff9a46 100644 --- a/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.cpp +++ b/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "vulkanserverbufferintegration.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> @@ -50,7 +14,7 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -static constexpr bool extraDebug = +static constexpr bool sbiExtraDebug = #ifdef VULKAN_SERVER_BUFFER_EXTRA_DEBUG true; #else @@ -124,7 +88,7 @@ VulkanServerBuffer::~VulkanServerBuffer() if (m_texture) { //only do gl cleanup if import has been called m_integration->deleteGLTextureWhenPossible(m_texture); - if (extraDebug) qDebug() << "glDeleteMemoryObjectsEXT" << m_memoryObject; + if (sbiExtraDebug) qDebug() << "glDeleteMemoryObjectsEXT" << m_memoryObject; funcs->glDeleteMemoryObjectsEXT(1, &m_memoryObject); } qt_server_buffer_release(m_server_buffer); @@ -136,7 +100,7 @@ void VulkanServerBuffer::import() if (m_texture) return; - if (extraDebug) qDebug() << "importing" << m_fd << Qt::hex << glGetError(); + if (sbiExtraDebug) qDebug() << "importing" << m_fd << Qt::hex << glGetError(); auto *glContext = QOpenGLContext::currentContext(); if (!glContext) @@ -146,21 +110,21 @@ void VulkanServerBuffer::import() return; funcs->glCreateMemoryObjectsEXT(1, &m_memoryObject); - if (extraDebug) qDebug() << "glCreateMemoryObjectsEXT" << Qt::hex << glGetError(); + if (sbiExtraDebug) qDebug() << "glCreateMemoryObjectsEXT" << Qt::hex << glGetError(); funcs->glImportMemoryFdEXT(m_memoryObject, m_memorySize, GL_HANDLE_TYPE_OPAQUE_FD_EXT, m_fd); - if (extraDebug) qDebug() << "glImportMemoryFdEXT" << Qt::hex << glGetError(); + if (sbiExtraDebug) qDebug() << "glImportMemoryFdEXT" << Qt::hex << glGetError(); m_texture = new QOpenGLTexture(QOpenGLTexture::Target2D); m_texture->create(); - if (extraDebug) qDebug() << "created texture" << m_texture->textureId() << Qt::hex << glGetError(); + if (sbiExtraDebug) qDebug() << "created texture" << m_texture->textureId() << Qt::hex << glGetError(); m_texture->bind(); - if (extraDebug) qDebug() << "bound texture" << Qt::hex << glGetError(); + if (sbiExtraDebug) qDebug() << "bound texture" << Qt::hex << glGetError(); funcs->glTexStorageMem2DEXT(GL_TEXTURE_2D, 1, m_internalFormat, m_size.width(), m_size.height(), m_memoryObject, 0 ); - if (extraDebug) qDebug() << "glTexStorageMem2DEXT" << Qt::hex << glGetError(); - if (extraDebug) qDebug() << "format" << Qt::hex << m_internalFormat << GL_RGBA8; + if (sbiExtraDebug) qDebug() << "glTexStorageMem2DEXT" << Qt::hex << glGetError(); + if (sbiExtraDebug) qDebug() << "format" << Qt::hex << m_internalFormat << GL_RGBA8; } QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture() @@ -193,7 +157,7 @@ void VulkanServerBufferIntegration::wlDisplayHandleGlobal(void *data, ::wl_regis void VulkanServerBufferIntegration::zqt_vulkan_server_buffer_v1_server_buffer_created(qt_server_buffer *id, int32_t fd, uint32_t width, uint32_t height, uint32_t memory_size, uint32_t format) { - if (extraDebug) qDebug() << "vulkan_server_buffer_server_buffer_created" << fd; + if (sbiExtraDebug) qDebug() << "vulkan_server_buffer_server_buffer_created" << fd; auto *server_buffer = new VulkanServerBuffer(this, id, fd, width, height, memory_size, format); qt_server_buffer_set_user_data(id, server_buffer); } diff --git a/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.h b/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.h index 44fd69973..2f0867a81 100644 --- a/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.h +++ b/src/hardwareintegration/client/vulkan-server/vulkanserverbufferintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef VULKANSERVERBUFFERINTEGRATION_H #define VULKANSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/client/wayland-egl/CMakeLists.txt b/src/hardwareintegration/client/wayland-egl/CMakeLists.txt new file mode 100644 index 000000000..967dd3cab --- /dev/null +++ b/src/hardwareintegration/client/wayland-egl/CMakeLists.txt @@ -0,0 +1,34 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from wayland-egl.pro. + +##################################################################### +## WaylandEglClientHwIntegrationPrivate Module: +##################################################################### +qt_find_package(EGL) # special case + +qt_internal_add_module(WaylandEglClientHwIntegrationPrivate + CONFIG_MODULE_NAME wayland_egl_client_hw_integration + INTERNAL_MODULE + SOURCES + qwaylandeglclientbufferintegration.cpp qwaylandeglclientbufferintegration_p.h + qwaylandeglinclude_p.h + qwaylandeglwindow.cpp qwaylandeglwindow_p.h + qwaylandglcontext.cpp qwaylandglcontext_p.h + INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC_LIBRARIES + ${CMAKE_DL_LIBS} + EGL::EGL + Qt::Core + Qt::Gui + Qt::OpenGLPrivate + Qt::WaylandClientPrivate + Wayland::Client + Wayland::Egl + NO_GENERATE_CPP_EXPORTS +) + +#### Keys ignored in scope 1:.:.:wayland-egl.pro:<TRUE>: +# MODULE = "wayland_egl_client_hw_integration" diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp index dcdc9c90b..3b97aef20 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp @@ -1,46 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandeglclientbufferintegration.h" - -#include "qwaylandeglwindow.h" -#include "qwaylandglcontext.h" +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qwaylandeglclientbufferintegration_p.h" + +#include "qwaylandeglwindow_p.h" +#include "qwaylandglcontext_p.h" #include <wayland-client-core.h> @@ -128,6 +92,13 @@ void QWaylandEglClientBufferIntegration::initialize(QWaylandDisplay *display) break; } } + + // On desktop NVIDIA resizing QtQuick freezes them when using threaded rendering QTBUG-95817 + // In order to support threaded rendering on embedded platforms where resizing is not needed + // we check if XDG_CURRENT_DESKTOP is set which desktop environments should set + if (qstrcmp(vendor, "NVIDIA") == 0 && qEnvironmentVariableIsSet("XDG_CURRENT_DESKTOP")) { + m_supportsThreading = false; + } } bool QWaylandEglClientBufferIntegration::isValid() const diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h deleted file mode 100644 index 0c5326230..000000000 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEGLINTEGRATION_H -#define QWAYLANDEGLINTEGRATION_H - -#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> - -#include "qwaylandeglinclude.h" - -QT_BEGIN_NAMESPACE - -class QWindow; - -namespace QtWaylandClient { - -class QWaylandWindow; - -class QWaylandEglClientBufferIntegration : public QWaylandClientBufferIntegration -{ -public: - QWaylandEglClientBufferIntegration(); - ~QWaylandEglClientBufferIntegration() override; - - void initialize(QWaylandDisplay *display) override; - bool isValid() const override; - bool supportsThreadedOpenGL() const override; - bool supportsWindowDecoration() const override; - - QWaylandWindow *createEglWindow(QWindow *window) override; - QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override; - - void *nativeResource(NativeResource resource) override; - void *nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override; - - EGLDisplay eglDisplay() const; - -private: - QWaylandDisplay *m_display = nullptr; - - EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; - bool m_supportsThreading = false; -}; - -QT_END_NAMESPACE - -} - -#endif // QWAYLANDEGLINTEGRATION_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration_p.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration_p.h new file mode 100644 index 000000000..ed8fdec2d --- /dev/null +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QWAYLANDEGLINTEGRATION_H +#define QWAYLANDEGLINTEGRATION_H + +#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> + +#include "qwaylandeglinclude_p.h" + +QT_BEGIN_NAMESPACE + +class QWindow; + +namespace QtWaylandClient { + +class QWaylandWindow; + +class Q_WAYLANDCLIENT_EXPORT QWaylandEglClientBufferIntegration : public QWaylandClientBufferIntegration +{ +public: + QWaylandEglClientBufferIntegration(); + ~QWaylandEglClientBufferIntegration() override; + + void initialize(QWaylandDisplay *display) override; + bool isValid() const override; + bool supportsThreadedOpenGL() const override; + bool supportsWindowDecoration() const override; + + QWaylandWindow *createEglWindow(QWindow *window) override; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override; + + void *nativeResource(NativeResource resource) override; + void *nativeResourceForContext(NativeResource resource, QPlatformOpenGLContext *context) override; + + EGLDisplay eglDisplay() const; + +private: + QWaylandDisplay *m_display = nullptr; + + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; + bool m_supportsThreading = false; +}; + +QT_END_NAMESPACE + +} + +#endif // QWAYLANDEGLINTEGRATION_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h b/src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h deleted file mode 100644 index ac0d96791..000000000 --- a/src/hardwareintegration/client/wayland-egl/qwaylandegldisplay.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEGLWINDOW_H -#define QWAYLANDEGLWINDOW_H - -#include <QtWaylandClient/qwaylanddisplay.h> - -#include "qwaylandeglintegration.h" - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandEglDisplay : public QWaylandDisplay -{ -public: - - QWaylandEglDisplay() - : QWaylandDisplay() - { } -}; - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h deleted file mode 100644 index 0f3b505a3..000000000 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEGLINCLUDE_H -#define QWAYLANDEGLINCLUDE_H - -#include <string.h> -#include <wayland-client-core.h> - -#include <wayland-egl.h> - -#define EGL_EGLEXT_PROTOTYPES -#include <QtGui/private/qt_egl_p.h> - -#endif // QWAYLANDEGLINCLUDE_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude_p.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude_p.h new file mode 100644 index 000000000..eb52ce8ee --- /dev/null +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglinclude_p.h @@ -0,0 +1,27 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QWAYLANDEGLINCLUDE_H +#define QWAYLANDEGLINCLUDE_H + +#include <string.h> +#include <wayland-client-core.h> + +#include <wayland-egl.h> + +#define EGL_EGLEXT_PROTOTYPES +#include <QtGui/private/qt_egl_p.h> + +#endif // QWAYLANDEGLINCLUDE_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp index 1e8dc06f7..0b014cd5c 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp @@ -1,46 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandeglwindow.h" +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qwaylandeglwindow_p.h" #include <QtWaylandClient/private/qwaylandscreen_p.h> -#include "qwaylandglcontext.h" +#include <QtWaylandClient/private/qwaylandsurface_p.h> +#include "qwaylandglcontext_p.h" #include <QtGui/private/qeglconvenience_p.h> @@ -57,17 +22,12 @@ namespace QtWaylandClient { QWaylandEglWindow::QWaylandEglWindow(QWindow *window, QWaylandDisplay *display) : QWaylandWindow(window, display) , m_clientBufferIntegration(static_cast<QWaylandEglClientBufferIntegration *>(mDisplay->clientBufferIntegration())) + , m_format(window->requestedFormat()) { - QSurfaceFormat fmt = window->requestedFormat(); - if (mDisplay->supportsWindowDecoration()) - fmt.setAlphaBufferSize(8); - m_eglConfig = q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), fmt); - m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig, fmt); - - // Do not create anything from here. This platform window may belong to a - // RasterGLSurface window which may have pure raster content. In this case, where the - // window is never actually made current, creating a wl_egl_window and EGL surface - // should be avoided. + connect(display, &QWaylandDisplay::connected, this, [this] { + m_clientBufferIntegration = static_cast<QWaylandEglClientBufferIntegration *>( + mDisplay->clientBufferIntegration()); + }); } QWaylandEglWindow::~QWaylandEglWindow() @@ -105,7 +65,7 @@ void QWaylandEglWindow::setGeometry(const QRect &rect) void QWaylandEglWindow::updateSurface(bool create) { - QMargins margins = frameMargins(); + QMargins margins = clientSideMargins(); QRect rect = geometry(); QSize sizeWithMargins = (rect.size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom())) * scale(); @@ -124,6 +84,7 @@ void QWaylandEglWindow::updateSurface(bool create) } mOffset = QPoint(); } else { + QReadLocker locker(&mSurfaceLock); if (m_waylandEglWindow) { int current_width, current_height; static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt(); @@ -131,19 +92,26 @@ void QWaylandEglWindow::updateSurface(bool create) if (!disableResizeCheck) { wl_egl_window_get_attached_size(m_waylandEglWindow, ¤t_width, ¤t_height); } - if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) { + if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) { wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y()); + m_requestedSize = sizeWithMargins; mOffset = QPoint(); m_resize = true; } - } else if (create && wlSurface()) { - m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height()); + } else if (create && mSurface) { + m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height()); + m_requestedSize = sizeWithMargins; } if (!m_eglSurface && m_waylandEglWindow && create) { EGLNativeWindowType eglw = (EGLNativeWindowType) m_waylandEglWindow; - m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, eglw, 0); + QSurfaceFormat fmt = window()->requestedFormat(); + if (mDisplay->supportsWindowDecoration()) + fmt.setAlphaBufferSize(8); + EGLConfig eglConfig = q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), fmt); + m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), eglConfig, fmt); + m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), eglConfig, eglw, 0); if (Q_UNLIKELY(m_eglSurface == EGL_NO_SURFACE)) qCWarning(lcQpaWayland, "Could not create EGL surface (EGL error 0x%x)\n", eglGetError()); } @@ -153,7 +121,7 @@ void QWaylandEglWindow::updateSurface(bool create) QRect QWaylandEglWindow::contentsRect() const { QRect r = geometry(); - QMargins m = frameMargins(); + QMargins m = clientSideMargins(); return QRect(m.left(), m.bottom(), r.width(), r.height()); } @@ -172,6 +140,8 @@ void QWaylandEglWindow::invalidateSurface() wl_egl_window_destroy(m_waylandEglWindow); m_waylandEglWindow = nullptr; } + delete m_contentFBO; + m_contentFBO = nullptr; } EGLSurface QWaylandEglWindow::eglSurface() const @@ -212,3 +182,5 @@ void QWaylandEglWindow::bindContentFBO() } QT_END_NAMESPACE + +#include "moc_qwaylandeglwindow_p.cpp" diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h deleted file mode 100644 index 5b1f4d56f..000000000 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEGLWINDOW_H -#define QWAYLANDEGLWINDOW_H - -#include <QtWaylandClient/private/qwaylandwindow_p.h> -#include "qwaylandeglinclude.h" -#include "qwaylandeglclientbufferintegration.h" - -QT_BEGIN_NAMESPACE - -class QOpenGLFramebufferObject; - -namespace QtWaylandClient { - -class QWaylandGLContext; - -class QWaylandEglWindow : public QWaylandWindow -{ - Q_OBJECT -public: - QWaylandEglWindow(QWindow *window, QWaylandDisplay *display); - ~QWaylandEglWindow(); - WindowType windowType() const override; - void ensureSize() override; - - void updateSurface(bool create); - void setGeometry(const QRect &rect) override; - QRect contentsRect() const; - - EGLSurface eglSurface() const; - GLuint contentFBO() const; - GLuint contentTexture() const; - bool needToUpdateContentFBO() const { return decoration() && (m_resize || !m_contentFBO); } - - QSurfaceFormat format() const override; - - void bindContentFBO(); - - void invalidateSurface() override; - -private: - QWaylandEglClientBufferIntegration *m_clientBufferIntegration = nullptr; - struct wl_egl_window *m_waylandEglWindow = nullptr; - - const QWaylandWindow *m_parentWindow = nullptr; - - EGLSurface m_eglSurface = EGL_NO_SURFACE; - EGLConfig m_eglConfig; - mutable bool m_resize = false; - mutable QOpenGLFramebufferObject *m_contentFBO = nullptr; - - QSurfaceFormat m_format; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDEGLWINDOW_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h new file mode 100644 index 000000000..5b9aa9874 --- /dev/null +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h @@ -0,0 +1,70 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QWAYLANDEGLWINDOW_H +#define QWAYLANDEGLWINDOW_H + +#include <QtWaylandClient/private/qwaylandwindow_p.h> +#include "qwaylandeglinclude_p.h" +#include "qwaylandeglclientbufferintegration_p.h" + +QT_BEGIN_NAMESPACE + +class QOpenGLFramebufferObject; + +namespace QtWaylandClient { + +class QWaylandGLContext; + +class Q_WAYLANDCLIENT_EXPORT QWaylandEglWindow : public QWaylandWindow +{ + Q_OBJECT +public: + QWaylandEglWindow(QWindow *window, QWaylandDisplay *display); + ~QWaylandEglWindow(); + WindowType windowType() const override; + void ensureSize() override; + + void updateSurface(bool create); + void setGeometry(const QRect &rect) override; + QRect contentsRect() const; + + EGLSurface eglSurface() const; + GLuint contentFBO() const; + GLuint contentTexture() const; + bool needToUpdateContentFBO() const { return decoration() && (m_resize || !m_contentFBO); } + + QSurfaceFormat format() const override; + + void bindContentFBO(); + + void invalidateSurface() override; + +private: + QWaylandEglClientBufferIntegration *m_clientBufferIntegration = nullptr; + struct wl_egl_window *m_waylandEglWindow = nullptr; + + EGLSurface m_eglSurface = EGL_NO_SURFACE; + mutable bool m_resize = false; + mutable QOpenGLFramebufferObject *m_contentFBO = nullptr; + + QSurfaceFormat m_format; + QSize m_requestedSize; +}; + +} + +QT_END_NAMESPACE + +#endif // QWAYLANDEGLWINDOW_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index c0c86a6dd..02789b305 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -1,50 +1,14 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandglcontext.h" +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qwaylandglcontext_p.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> #include <QtWaylandClient/private/qwaylandwindow_p.h> #include <QtWaylandClient/private/qwaylandsubsurface_p.h> #include <QtWaylandClient/private/qwaylandabstractdecoration_p.h> #include <QtWaylandClient/private/qwaylandintegration_p.h> -#include "qwaylandeglwindow.h" +#include "qwaylandeglwindow_p.h" #include <QDebug> #include <QtGui/private/qeglconvenience_p.h> @@ -192,22 +156,23 @@ public: } void blit(QWaylandEglWindow *window) { - Q_ASSERT(window->wlSurface()); QOpenGLTextureCache *cache = QOpenGLTextureCache::cacheForContext(m_context->context()); QSize surfaceSize = window->surfaceSize(); - int scale = window->scale() ; + qreal scale = window->scale() ; glViewport(0, 0, surfaceSize.width() * scale, surfaceSize.height() * scale); //Draw Decoration - m_blitProgram->setAttributeBuffer(0, GL_FLOAT, m_inverseSquareVerticesOffset, 2); - QImage decorationImage = window->decoration()->contentImage(); - cache->bindTexture(m_context->context(), decorationImage); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_textureWrap); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_textureWrap); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + if (auto *decoration = window->decoration()) { + m_blitProgram->setAttributeBuffer(0, GL_FLOAT, m_inverseSquareVerticesOffset, 2); + QImage decorationImage = decoration->contentImage(); + cache->bindTexture(m_context->context(), decorationImage); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_textureWrap); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_textureWrap); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } //Draw Content m_blitProgram->setAttributeBuffer(0, GL_FLOAT, m_squareVerticesOffset, 2); @@ -230,6 +195,9 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis const QSurfaceFormat &fmt, QPlatformOpenGLContext *share) : QEGLPlatformContext(fmt, share, eglDisplay), m_display(display) { + m_reconnectionWatcher = QObject::connect(m_display, &QWaylandDisplay::connected, + m_display, [this] { invalidateContext(); }); + switch (format().renderableType()) { case QSurfaceFormat::OpenVG: m_api = EGL_OPENVG_API; @@ -295,12 +263,33 @@ void QWaylandGLContext::destroyTemporaryOffscreenSurface(EGLSurface eglSurface) QWaylandGLContext::~QWaylandGLContext() { + QObject::disconnect(m_reconnectionWatcher); delete m_blitter; m_blitter = nullptr; + if (m_decorationsContext != EGL_NO_CONTEXT) + eglDestroyContext(eglDisplay(), m_decorationsContext); +} + +void QWaylandGLContext::beginFrame() +{ + Q_ASSERT(m_currentWindow != nullptr); + if (m_supportNonBlockingSwap) + m_currentWindow->beginFrame(); +} + +void QWaylandGLContext::endFrame() +{ + Q_ASSERT(m_currentWindow != nullptr); + if (m_supportNonBlockingSwap) + m_currentWindow->endFrame(); } bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface) { + if (!isValid()) { + return false; + } + // in QWaylandGLContext() we called eglBindAPI with the correct value. However, // eglBindAPI's documentation says: // "eglBindAPI defines the current rendering API for EGL in the thread it is called from" @@ -310,37 +299,35 @@ bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface) eglBindAPI(m_api); } - QWaylandEglWindow *window = static_cast<QWaylandEglWindow *>(surface); - EGLSurface eglSurface = window->eglSurface(); + m_currentWindow = static_cast<QWaylandEglWindow *>(surface); + EGLSurface eglSurface = m_currentWindow->eglSurface(); - if (!window->needToUpdateContentFBO() && (eglSurface != EGL_NO_SURFACE)) { + if (!m_currentWindow->needToUpdateContentFBO() && (eglSurface != EGL_NO_SURFACE)) { if (!eglMakeCurrent(eglDisplay(), eglSurface, eglSurface, eglContext())) { - qWarning("QWaylandGLContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); + qWarning("QWaylandGLContext::makeCurrent: eglError: %#x, this: %p \n", eglGetError(), this); return false; } return true; } - if (window->isExposed()) - window->setCanResize(false); - if (m_decorationsContext != EGL_NO_CONTEXT && !window->decoration()) - window->createDecoration(); + if (m_currentWindow->isExposed()) + m_currentWindow->setCanResize(false); if (eglSurface == EGL_NO_SURFACE) { - window->updateSurface(true); - eglSurface = window->eglSurface(); + m_currentWindow->updateSurface(true); + eglSurface = m_currentWindow->eglSurface(); } if (!eglMakeCurrent(eglDisplay(), eglSurface, eglSurface, eglContext())) { - qWarning("QWaylandGLContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); - window->setCanResize(true); + qWarning("QWaylandGLContext::makeCurrent: eglError: %#x, this: %p \n", eglGetError(), this); + m_currentWindow->setCanResize(true); return false; } //### setCurrentContext will be called in QOpenGLContext::makeCurrent after this function // returns, but that's too late, as we need a current context in order to bind the content FBO. QOpenGLContextPrivate::setCurrentContext(context()); - window->bindContentFBO(); + m_currentWindow->bindContentFBO(); return true; } @@ -384,7 +371,8 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) window->waitForFrameSync(100); } window->handleUpdate(); - eglSwapBuffers(eglDisplay(), eglSurface); + if (!eglSwapBuffers(eglDisplay(), eglSurface)) + qCWarning(lcQpaWayland, "eglSwapBuffers failed with %#x, surface: %p", eglGetError(), eglSurface); window->setCanResize(true); } diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h deleted file mode 100644 index 21dc64619..000000000 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDGLCONTEXT_H -#define QWAYLANDGLCONTEXT_H - -#include "qwaylandeglinclude.h" //must be first - -#include <QtWaylandClient/private/qwaylanddisplay_p.h> -#include <QtGui/private/qeglplatformcontext_p.h> -#include <qpa/qplatformopenglcontext.h> - -QT_BEGIN_NAMESPACE - -class QOpenGLShaderProgram; -class QOpenGLTextureCache; - -namespace QtWaylandClient { - -class QWaylandWindow; -class QWaylandGLWindowSurface; -class DecorationsBlitter; - -class QWaylandGLContext : public QEGLPlatformContext -{ -public: - QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *display, const QSurfaceFormat &format, QPlatformOpenGLContext *share); - ~QWaylandGLContext(); - void swapBuffers(QPlatformSurface *surface) override; - - bool makeCurrent(QPlatformSurface *surface) override; - void doneCurrent() override; - - GLuint defaultFramebufferObject(QPlatformSurface *surface) const override; - - QFunctionPointer getProcAddress(const char *procName) override; - -protected: - EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; - EGLSurface createTemporaryOffscreenSurface() override; - void destroyTemporaryOffscreenSurface(EGLSurface surface) override; - -private: - QWaylandDisplay *m_display = nullptr; - EGLContext m_decorationsContext; - DecorationsBlitter *m_blitter = nullptr; - bool m_supportNonBlockingSwap = true; - EGLenum m_api; - wl_surface *m_wlSurface = nullptr; - wl_egl_window *m_eglWindow = nullptr; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDGLCONTEXT_H diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext_p.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext_p.h new file mode 100644 index 000000000..b985c6675 --- /dev/null +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext_p.h @@ -0,0 +1,72 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QWAYLANDGLCONTEXT_H +#define QWAYLANDGLCONTEXT_H + +#include "qwaylandeglinclude_p.h" //must be first + +#include <QtWaylandClient/private/qwaylanddisplay_p.h> +#include <QtGui/private/qeglplatformcontext_p.h> +#include <qpa/qplatformopenglcontext.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLShaderProgram; +class QOpenGLTextureCache; + +namespace QtWaylandClient { + +class QWaylandEglWindow; +class DecorationsBlitter; + +class Q_WAYLANDCLIENT_EXPORT QWaylandGLContext : public QEGLPlatformContext +{ +public: + QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *display, const QSurfaceFormat &format, QPlatformOpenGLContext *share); + ~QWaylandGLContext(); + void swapBuffers(QPlatformSurface *surface) override; + + bool makeCurrent(QPlatformSurface *surface) override; + void doneCurrent() override; + + void beginFrame() override; + void endFrame() override; + + GLuint defaultFramebufferObject(QPlatformSurface *surface) const override; + + QFunctionPointer getProcAddress(const char *procName) override; + +protected: + EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; + EGLSurface createTemporaryOffscreenSurface() override; + void destroyTemporaryOffscreenSurface(EGLSurface surface) override; + +private: + QWaylandDisplay *m_display = nullptr; + EGLContext m_decorationsContext; + DecorationsBlitter *m_blitter = nullptr; + bool m_supportNonBlockingSwap = true; + EGLenum m_api; + wl_surface *m_wlSurface = nullptr; + wl_egl_window *m_eglWindow = nullptr; + QWaylandEglWindow *m_currentWindow = nullptr; + QMetaObject::Connection m_reconnectionWatcher; +}; + +} + +QT_END_NAMESPACE + +#endif // QWAYLANDGLCONTEXT_H diff --git a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri index 0de56607d..5d0d0204b 100644 --- a/src/hardwareintegration/client/wayland-egl/wayland-egl.pri +++ b/src/hardwareintegration/client/wayland-egl/wayland-egl.pri @@ -8,7 +8,7 @@ SOURCES += $$PWD/qwaylandeglclientbufferintegration.cpp \ $$PWD/qwaylandglcontext.cpp \ $$PWD/qwaylandeglwindow.cpp -HEADERS += $$PWD/qwaylandeglclientbufferintegration.h \ - $$PWD/qwaylandglcontext.h \ - $$PWD/qwaylandeglwindow.h \ - $$PWD/qwaylandeglinclude.h +HEADERS += $$PWD/qwaylandeglclientbufferintegration_p.h \ + $$PWD/qwaylandglcontext_p.h \ + $$PWD/qwaylandeglwindow_p.h \ + $$PWD/qwaylandeglinclude_p.h diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp deleted file mode 100644 index 1809aa21e..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxcompositeeglclientbufferintegration.h" - -#include "qwaylandxcompositeeglwindow.h" - -#include <QtCore/QDebug> -#include <QtGui/private/qeglconvenience_p.h> - -#include <QtWaylandClient/private/qwaylanddisplay_p.h> - -#include "wayland-xcomposite-client-protocol.h" - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeEGLClientBufferIntegration::QWaylandXCompositeEGLClientBufferIntegration() - : QWaylandClientBufferIntegration() -{ - qDebug() << "Using XComposite-EGL"; -} - -QWaylandXCompositeEGLClientBufferIntegration::~QWaylandXCompositeEGLClientBufferIntegration() -{ - XCloseDisplay(mDisplay); -} - -void QWaylandXCompositeEGLClientBufferIntegration::initialize(QWaylandDisplay *display) -{ - mWaylandDisplay = display; - mWaylandDisplay->addRegistryListener(&wlDisplayHandleGlobal, this); - while (!mDisplay) { - display->flushRequests(); - display->blockingReadEvents(); - } -} - -QWaylandWindow * QWaylandXCompositeEGLClientBufferIntegration::createEglWindow(QWindow *window) -{ - return new QWaylandXCompositeEGLWindow(window,this); -} - -QPlatformOpenGLContext *QWaylandXCompositeEGLClientBufferIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const -{ - EGLDisplay display = eglDisplay(); - EGLConfig config = q_configFromGLFormat(display, glFormat, true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT); - return new QWaylandXCompositeEGLContext(glFormat, share, display, config); -} - -Display * QWaylandXCompositeEGLClientBufferIntegration::xDisplay() const -{ - return mDisplay; -} - -EGLDisplay QWaylandXCompositeEGLClientBufferIntegration::eglDisplay() const -{ - return mEglDisplay; -} - -int QWaylandXCompositeEGLClientBufferIntegration::screen() const -{ - return mScreen; -} - -Window QWaylandXCompositeEGLClientBufferIntegration::rootWindow() const -{ - return mRootWindow; -} - -QWaylandDisplay * QWaylandXCompositeEGLClientBufferIntegration::waylandDisplay() const -{ - return mWaylandDisplay; -} -qt_xcomposite * QWaylandXCompositeEGLClientBufferIntegration::waylandXComposite() const -{ - return mWaylandComposite; -} - -const struct qt_xcomposite_listener QWaylandXCompositeEGLClientBufferIntegration::xcomposite_listener = { - QWaylandXCompositeEGLClientBufferIntegration::rootInformation -}; - -void QWaylandXCompositeEGLClientBufferIntegration::wlDisplayHandleGlobal(void *data, ::wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) -{ - Q_UNUSED(version); - if (interface == "qt_xcomposite") { - QWaylandXCompositeEGLClientBufferIntegration *integration = static_cast<QWaylandXCompositeEGLClientBufferIntegration *>(data); - integration->mWaylandComposite = static_cast<struct qt_xcomposite *>(wl_registry_bind(registry,id,&qt_xcomposite_interface,1)); - qt_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); - } - -} - -void QWaylandXCompositeEGLClientBufferIntegration::rootInformation(void *data, qt_xcomposite *xcomposite, const char *display_name, uint32_t root_window) -{ - Q_UNUSED(xcomposite); - QWaylandXCompositeEGLClientBufferIntegration *integration = static_cast<QWaylandXCompositeEGLClientBufferIntegration *>(data); - - integration->mDisplay = XOpenDisplay(display_name); - integration->mRootWindow = (Window) root_window; - integration->mScreen = XDefaultScreen(integration->mDisplay); - integration->mEglDisplay = eglGetDisplay(integration->mDisplay); - eglBindAPI(EGL_OPENGL_ES_API); - EGLint minor,major; - if (!eglInitialize(integration->mEglDisplay,&major,&minor)) { - qFatal("Failed to initialize EGL"); - } - eglSwapInterval(integration->eglDisplay(),0); - qDebug() << "ROOT INFORMATION" << integration->mDisplay << integration->mRootWindow << integration->mScreen; -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h deleted file mode 100644 index 5fe21d7b7..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEEGLCLIENTBUFFERINTEGRATION_H -#define QWAYLANDXCOMPOSITEEGLCLIENTBUFFERINTEGRATION_H - -#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> -#include <wayland-client-core.h> - -#include <QtCore/QTextStream> -#include <QtCore/QDataStream> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> -#include <QtGui/QWindow> - -#include <qpa/qplatformopenglcontext.h> - -#include <QWaitCondition> - -#include <X11/Xlib.h> -#include <EGL/egl.h> - -// avoid clashes with Qt::CursorShape -#ifdef CursorShape -# define X_CursorShape CursorShape -# undef CursorShape -#endif - -struct qt_xcomposite; -struct qt_xcomposite_listener; -struct wl_registry; - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeEGLClientBufferIntegration : public QWaylandClientBufferIntegration -{ -public: - QWaylandXCompositeEGLClientBufferIntegration(); - ~QWaylandXCompositeEGLClientBufferIntegration() override; - - void initialize(QWaylandDisplay *dispaly) override; - - QWaylandWindow *createEglWindow(QWindow *window) override; - QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override; - - QWaylandDisplay *waylandDisplay() const; - struct qt_xcomposite *waylandXComposite() const; - - Display *xDisplay() const; - EGLDisplay eglDisplay() const; - int screen() const; - Window rootWindow() const; - - bool supportsThreadedOpenGL() const override { return true; } - bool supportsWindowDecoration() const override { return false; } - -private: - QWaylandDisplay *mWaylandDisplay = nullptr; - struct qt_xcomposite *mWaylandComposite = nullptr; - - Display *mDisplay = nullptr; - EGLDisplay mEglDisplay = EGL_NO_DISPLAY; - int mScreen = 0; - Window mRootWindow = -1; - - static void wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id, - const QString &interface, uint32_t version); - - static const struct ::qt_xcomposite_listener xcomposite_listener; - static void rootInformation(void *data, - struct qt_xcomposite *xcomposite, - const char *display_name, - uint32_t root_window); -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEEGLCLIENTBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp deleted file mode 100644 index ed739f81a..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxcompositeeglcontext.h" - -#include "qwaylandxcompositeeglwindow.h" - -#include <QtCore/QDebug> -#include <QtGui/QRegion> - -#include <QtGui/private/qeglconvenience_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig config) - : QEGLPlatformContext(format, share, display, &config) -{ -} - -void QWaylandXCompositeEGLContext::swapBuffers(QPlatformSurface *surface) -{ - QEGLPlatformContext::swapBuffers(surface); - - QWaylandXCompositeEGLWindow *w = - static_cast<QWaylandXCompositeEGLWindow *>(surface); - - QSize size = w->geometry().size(); - - w->commit(w->buffer(), QRegion(0, 0, size.width(), size.height())); - w->waitForFrameSync(100); -} - -EGLSurface QWaylandXCompositeEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) -{ - return static_cast<QWaylandXCompositeEGLWindow *>(surface)->eglSurface(); -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h deleted file mode 100644 index 266c9816a..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEEGLCONTEXT_H -#define QWAYLANDXCOMPOSITEEGLCONTEXT_H - -#include <qpa/qplatformopenglcontext.h> - -#include "qwaylandxcompositeeglclientbufferintegration.h" - -#include <QtGui/private/qeglplatformcontext_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeEGLWindow; - -class QWaylandXCompositeEGLContext : public QEGLPlatformContext -{ -public: - QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig config); - - void swapBuffers(QPlatformSurface *surface) override; - -private: - EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp deleted file mode 100644 index 4c6bc7b95..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxcompositeeglwindow.h" -#include "qwaylandxcompositebuffer.h" - -#include <QtGui/private/qeglconvenience_p.h> -#include <QtGui/private/qxlibeglintegration_p.h> - -#include "wayland-xcomposite-client-protocol.h" - -#include <X11/extensions/Xcomposite.h> -#include "qwaylandxcompositeeglclientbufferintegration.h" - -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLClientBufferIntegration *glxIntegration) - : QWaylandWindow(window, glxIntegration->waylandDisplay()) - , m_glxIntegration(glxIntegration) - , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT)) -{ -} - -QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const -{ - //yeah. this type needs a new name - return QWaylandWindow::Egl; -} - -void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect) -{ - QWaylandWindow::setGeometry(rect); - - if (m_surface) { - eglDestroySurface(m_glxIntegration->eglDisplay(), m_surface); - m_surface = 0; - } -} - -EGLSurface QWaylandXCompositeEGLWindow::eglSurface() const -{ - if (!m_surface) - const_cast<QWaylandXCompositeEGLWindow *>(this)->createEglSurface(); - return m_surface; -} - -void QWaylandXCompositeEGLWindow::createEglSurface() -{ - QSize size(geometry().size()); - if (size.isEmpty()) { - // QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - delete m_buffer; - //XFreePixmap deletes the glxPixmap as well - if (m_xWindow) { - XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow); - } - - VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(m_glxIntegration->xDisplay(), m_glxIntegration->eglDisplay(), m_config); - - XVisualInfo visualInfoTemplate; - memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - visualInfoTemplate.visualid = visualId; - - int matchingCount = 0; - XVisualInfo *visualInfo = XGetVisualInfo(m_glxIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount); - - Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(),m_glxIntegration->rootWindow(),visualInfo->visual,AllocNone); - - XSetWindowAttributes a; - a.colormap = cmap; - m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual); - XMapWindow(m_glxIntegration->xDisplay(), m_xWindow); - - m_surface = eglCreateWindowSurface(m_glxIntegration->eglDisplay(), m_config, reinterpret_cast<EGLNativeWindowType>(m_xWindow), nullptr); - if (m_surface == EGL_NO_SURFACE) { - qFatal("Could not make eglsurface"); - } - - XSync(m_glxIntegration->xDisplay(),False); - m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(), - (uint32_t)m_xWindow, - size); -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h deleted file mode 100644 index 0c8bcf441..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglwindow.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEEGLWINDOW_H -#define QWAYLANDXCOMPOSITEEGLWINDOW_H - -#include <QtWaylandClient/private/qwaylandwindow_p.h> -#include <QtWaylandClient/private/qwaylandbuffer_p.h> - -#include "qwaylandxcompositeeglclientbufferintegration.h" -#include "qwaylandxcompositeeglcontext.h" - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeEGLWindow : public QWaylandWindow -{ -public: - QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLClientBufferIntegration *glxIntegration); - WindowType windowType() const override; - - void setGeometry(const QRect &rect) override; - - EGLSurface eglSurface() const; - - QWaylandBuffer *buffer() { return m_buffer; } - -private: - void createEglSurface(); - - QWaylandXCompositeEGLClientBufferIntegration *m_glxIntegration = nullptr; - QWaylandBuffer *m_buffer = nullptr; - - Window m_xWindow = 0; - EGLConfig m_config; - EGLSurface m_surface = EGL_NO_SURFACE; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEEGLWINDOW_H diff --git a/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri b/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri deleted file mode 100644 index ecbaae648..000000000 --- a/src/hardwareintegration/client/xcomposite-egl/xcomposite-egl.pri +++ /dev/null @@ -1,14 +0,0 @@ -INCLUDEPATH += $$PWD -include($$PWD/../xcomposite_share/xcomposite_share.pri) - -QMAKE_USE += egl wayland-client - -SOURCES += \ - $$PWD/qwaylandxcompositeeglcontext.cpp \ - $$PWD/qwaylandxcompositeeglclientbufferintegration.cpp \ - $$PWD/qwaylandxcompositeeglwindow.cpp - -HEADERS += \ - $$PWD/qwaylandxcompositeeglcontext.h \ - $$PWD/qwaylandxcompositeeglclientbufferintegration.h \ - $$PWD/qwaylandxcompositeeglwindow.h diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp deleted file mode 100644 index 351887416..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/QDebug> - -#include "qwaylandxcompositeglxcontext.h" - -#include "qwaylandxcompositeglxwindow.h" - -#include <QRegion> - -#include <dlfcn.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen) - : m_display(display), - m_format(format) -{ - qDebug("creating XComposite-GLX context"); - - if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType) - m_format.setRenderableType(QSurfaceFormat::OpenGL); - - if (m_format.renderableType() != QSurfaceFormat::OpenGL) { - qWarning("Unsupported renderable type"); - return; - } - - GLXContext shareContext = share ? static_cast<QWaylandXCompositeGLXContext *>(share)->m_context : 0; - GLXFBConfig config = qglx_findConfig(display, screen, m_format, GLX_WINDOW_BIT | GLX_PIXMAP_BIT); - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); - m_context = glXCreateContext(display, visualInfo, shareContext, true); - qglx_surfaceFormatFromGLXFBConfig(&m_format, display, config); -} - -bool QWaylandXCompositeGLXContext::makeCurrent(QPlatformSurface *surface) -{ - Window xWindow = static_cast<QWaylandXCompositeGLXWindow *>(surface)->xWindow(); - - return glXMakeCurrent(m_display, xWindow, m_context); -} - -void QWaylandXCompositeGLXContext::doneCurrent() -{ - glXMakeCurrent(m_display, 0, 0); -} - -void QWaylandXCompositeGLXContext::swapBuffers(QPlatformSurface *surface) -{ - QWaylandXCompositeGLXWindow *w = static_cast<QWaylandXCompositeGLXWindow *>(surface); - - QSize size = w->geometry().size(); - - glXSwapBuffers(m_display, w->xWindow()); - - w->commit(w->buffer(), QRegion(0, 0, size.width(), size.height())); - w->waitForFrameSync(100); -} - -QFunctionPointer QWaylandXCompositeGLXContext::getProcAddress(const char *procName) -{ - QFunctionPointer proc = glXGetProcAddress(reinterpret_cast<const GLubyte *>(procName)); - if (!proc) - proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName); - return proc; -} - -QSurfaceFormat QWaylandXCompositeGLXContext::format() const -{ - return m_format; -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h deleted file mode 100644 index edb74a89a..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEGLXCONTEXT_H -#define QWAYLANDXCOMPOSITEGLXCONTEXT_H - -#include <qpa/qplatformopenglcontext.h> - -#include "qwaylandxcompositeglxintegration.h" -#include <QtGui/private/qglxconvenience_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeGLXWindow; -class QWaylandShmBuffer; - -class QWaylandXCompositeGLXContext : public QPlatformOpenGLContext -{ -public: - QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen); - - QSurfaceFormat format() const override; - - void swapBuffers(QPlatformSurface *surface) override; - - bool makeCurrent(QPlatformSurface *surface) override; - void doneCurrent() override; - - QFunctionPointer getProcAddress(const char *procName) override; - -private: - GLXContext m_context; - - Display *m_display = nullptr; - QSurfaceFormat m_format; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp deleted file mode 100644 index 8be47fa2e..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxcompositeglxintegration.h" - -#include "qwaylandxcompositeglxwindow.h" - -#include <QtCore/QDebug> - -#include "wayland-xcomposite-client-protocol.h" - -#include <QtWaylandClient/private/qwaylanddisplay_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration() -{ - qDebug() << "Using XComposite-GLX"; -} - -QWaylandXCompositeGLXIntegration::~QWaylandXCompositeGLXIntegration() -{ - XCloseDisplay(mDisplay); -} - -void QWaylandXCompositeGLXIntegration::initialize(QWaylandDisplay *display) -{ - mWaylandDisplay = display; - mWaylandDisplay->addRegistryListener(QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, this); - while (!mDisplay) { - display->flushRequests(); - display->blockingReadEvents(); - } -} - -QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window) -{ - return new QWaylandXCompositeGLXWindow(window, this); -} - -QPlatformOpenGLContext *QWaylandXCompositeGLXIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const -{ - return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen); -} - -Display * QWaylandXCompositeGLXIntegration::xDisplay() const -{ - return mDisplay; -} - -int QWaylandXCompositeGLXIntegration::screen() const -{ - return mScreen; -} - -Window QWaylandXCompositeGLXIntegration::rootWindow() const -{ - return mRootWindow; -} - -QWaylandDisplay * QWaylandXCompositeGLXIntegration::waylandDisplay() const -{ - return mWaylandDisplay; -} -qt_xcomposite * QWaylandXCompositeGLXIntegration::waylandXComposite() const -{ - return mWaylandComposite; -} - -const struct qt_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite_listener = { - QWaylandXCompositeGLXIntegration::rootInformation -}; - -void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(void *data, ::wl_registry *registry, uint32_t id, const QString &interface, uint32_t version) -{ - Q_UNUSED(version); - if (interface == "qt_xcomposite") { - qDebug("XComposite-GLX: got qt_xcomposite global"); - QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data); - integration->mWaylandComposite = static_cast<struct qt_xcomposite *>(wl_registry_bind(registry, id, &qt_xcomposite_interface, 1)); - qt_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); - } - -} - -void QWaylandXCompositeGLXIntegration::rootInformation(void *data, qt_xcomposite *xcomposite, const char *display_name, uint32_t root_window) -{ - Q_UNUSED(xcomposite); - QWaylandXCompositeGLXIntegration *integration = static_cast<QWaylandXCompositeGLXIntegration *>(data); - - qDebug("XComposite-GLX: xcomposite listener callback"); - - integration->mDisplay = XOpenDisplay(display_name); - integration->mRootWindow = (Window) root_window; - integration->mScreen = XDefaultScreen(integration->mDisplay); -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h deleted file mode 100644 index 809690816..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEGLXINTEGRATION_H -#define QWAYLANDXCOMPOSITEGLXINTEGRATION_H - -#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> -#include <wayland-client-core.h> - -#include <QtCore/QTextStream> -#include <QtCore/QDataStream> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> -#include <QtGui/QWindow> - -#include <X11/Xlib.h> - -// avoid clashes with Qt::CursorShape -#ifdef CursorShape -# define X_CursorShape CursorShape -# undef CursorShape -#endif - -struct qt_xcomposite; -struct qt_xcomposite_listener; -struct wl_registry; - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeGLXIntegration : public QWaylandClientBufferIntegration -{ -public: - QWaylandXCompositeGLXIntegration(); - ~QWaylandXCompositeGLXIntegration() override; - - void initialize(QWaylandDisplay *display) override; - - QWaylandWindow *createEglWindow(QWindow *window) override; - QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const override; - - QWaylandDisplay *waylandDisplay() const; - struct qt_xcomposite *waylandXComposite() const; - - Display *xDisplay() const; - int screen() const; - Window rootWindow() const; - - bool supportsThreadedOpenGL() const override { return false; } - bool supportsWindowDecoration() const override { return false; } - -private: - QWaylandDisplay *mWaylandDisplay = nullptr; - struct qt_xcomposite *mWaylandComposite = nullptr; - - Display *mDisplay = nullptr; - int mScreen = 0; - Window mRootWindow = 0; - - static void wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id, - const QString &interface, uint32_t version); - - static const struct qt_xcomposite_listener xcomposite_listener; - static void rootInformation(void *data, - struct qt_xcomposite *xcomposite, - const char *display_name, - uint32_t root_window); -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEGLXINTEGRATION_H diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp deleted file mode 100644 index b0c78b631..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxcompositeglxwindow.h" -#include "qwaylandxcompositebuffer.h" - -#include <QtCore/QDebug> - -#include "wayland-xcomposite-client-protocol.h" -#include <QtGui/QRegion> - -#include <X11/extensions/Xcomposite.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) - : QWaylandWindow(window, glxIntegration->waylandDisplay()) - , m_glxIntegration(glxIntegration) - , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format(), GLX_WINDOW_BIT | GLX_PIXMAP_BIT)) -{ -} - -QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const -{ - //yeah. this type needs a new name - return QWaylandWindow::Egl; -} - -void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect) -{ - QWaylandWindow::setGeometry(rect); - - if (m_xWindow) { - XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow); - m_xWindow = 0; - } -} - -Window QWaylandXCompositeGLXWindow::xWindow() const -{ - if (!m_xWindow) - const_cast<QWaylandXCompositeGLXWindow *>(this)->createSurface(); - - return m_xWindow; -} - -void QWaylandXCompositeGLXWindow::createSurface() -{ - QSize size(geometry().size()); - if (size.isEmpty()) { - //QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - if (!m_glxIntegration->xDisplay()) { - qWarning("XCompositeGLXWindow: X display still null?!"); - return; - } - - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config); - Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), - visualInfo->visual, AllocNone); - - XSetWindowAttributes a; - a.background_pixel = WhitePixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen()); - a.border_pixel = BlackPixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen()); - a.colormap = cmap; - m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWBackPixel|CWBorderPixel|CWColormap, &a); - - XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual); - XMapWindow(m_glxIntegration->xDisplay(), m_xWindow); - - XSync(m_glxIntegration->xDisplay(), False); - mBuffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(), - (uint32_t)m_xWindow, - size); -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h deleted file mode 100644 index 45a77a299..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEGLXWINDOW_H -#define QWAYLANDXCOMPOSITEGLXWINDOW_H - -#include <QtWaylandClient/private/qwaylandwindow_p.h> -#include "qwaylandxcompositeglxintegration.h" -#include "qwaylandxcompositeglxcontext.h" - -#include <QtCore/QWaitCondition> - -#include <QtWaylandClient/private/qwaylandbuffer_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeGLXWindow : public QWaylandWindow -{ -public: - QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration); - WindowType windowType() const override; - - void setGeometry(const QRect &rect) override; - - Window xWindow() const; - - QWaylandBuffer *buffer() { return mBuffer; } - -private: - void createSurface(); - - QWaylandXCompositeGLXIntegration *m_glxIntegration = nullptr; - - Window m_xWindow = 0; - GLXFBConfig m_config; - QWaylandBuffer *mBuffer = nullptr; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEGLXWINDOW_H diff --git a/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri b/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri deleted file mode 100644 index b836724fa..000000000 --- a/src/hardwareintegration/client/xcomposite-glx/xcomposite-glx.pri +++ /dev/null @@ -1,14 +0,0 @@ -INCLUDEPATH += $$PWD -include ($$PWD/../xcomposite_share/xcomposite_share.pri) - -QMAKE_USE += wayland-client libdl - -SOURCES += \ - $$PWD/qwaylandxcompositeglxcontext.cpp \ - $$PWD/qwaylandxcompositeglxintegration.cpp \ - $$PWD/qwaylandxcompositeglxwindow.cpp - -HEADERS += \ - $$PWD/qwaylandxcompositeglxcontext.h \ - $$PWD/qwaylandxcompositeglxintegration.h \ - $$PWD/qwaylandxcompositeglxwindow.h diff --git a/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp deleted file mode 100644 index 33d9a6038..000000000 --- a/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxcompositebuffer.h" - -#include "wayland-xcomposite-client-protocol.h" - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(qt_xcomposite *xcomposite, uint32_t window, const QSize &size) - :mSize(size) -{ - mBuffer = qt_xcomposite_create_buffer(xcomposite, - window, - size.width(), - size.height()); -} - -QSize QWaylandXCompositeBuffer::size() const -{ - return mSize; -} - -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h b/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h deleted file mode 100644 index 2c11fd52a..000000000 --- a/src/hardwareintegration/client/xcomposite_share/qwaylandxcompositebuffer.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXCOMPOSITEBUFFER_H -#define QWAYLANDXCOMPOSITEBUFFER_H - -#include <QtWaylandClient/private/qwaylandbuffer_p.h> -#include <stdint.h> - -struct qt_xcomposite; -struct wl_visual; - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandXCompositeBuffer : public QWaylandBuffer -{ -public: - QWaylandXCompositeBuffer(qt_xcomposite *xcomposite, - uint32_t window, - const QSize &size); - - QSize size() const override; -private: - QSize mSize; -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDXCOMPOSITEBUFFER_H diff --git a/src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri b/src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri deleted file mode 100644 index d2b129d03..000000000 --- a/src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri +++ /dev/null @@ -1,11 +0,0 @@ -INCLUDEPATH += $$PWD - -QMAKE_USE += xcomposite x11 -CONFIG += wayland-scanner-client-wayland-protocol-include -WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/xcomposite.xml - -HEADERS += \ - $$PWD/qwaylandxcompositebuffer.h - -SOURCES += \ - $$PWD/qwaylandxcompositebuffer.cpp diff --git a/src/hardwareintegration/compositor/CMakeLists.txt b/src/hardwareintegration/compositor/CMakeLists.txt new file mode 100644 index 000000000..8da6b3ce1 --- /dev/null +++ b/src/hardwareintegration/compositor/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from compositor.pro. + +if(QT_FEATURE_wayland_egl) + add_subdirectory(wayland-egl) +endif() diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp index 760762572..1380bd5b8 100644 --- a/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp +++ b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "brcmbuffer.h" diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h index fe453bae0..6a21c3f5c 100644 --- a/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h +++ b/src/hardwareintegration/compositor/brcm-egl/brcmbuffer.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef BRCMBUFFER_H #define BRCMBUFFER_H diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp index de39ff1d2..178a2e30a 100644 --- a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp +++ b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "brcmeglintegration.h" #include "brcmbuffer.h" diff --git a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h index 3728da7bc..4ee5d404e 100644 --- a/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h +++ b/src/hardwareintegration/compositor/brcm-egl/brcmeglintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef BRCMEGLINTEGRATION_H #define BRCMEGLINTEGRATION_H diff --git a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp index d66eb1d66..a217c1c89 100644 --- a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "dmabufserverbufferintegration.h" @@ -126,7 +100,7 @@ QOpenGLTexture *DmaBufServerBuffer::toOpenGlTexture() bool DmaBufServerBuffer::bufferInUse() { - return resourceMap().count() > 0; + return resourceMap().size() > 0; } DmaBufServerBufferIntegration::DmaBufServerBufferIntegration() diff --git a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h index a66a37b90..eb559686c 100644 --- a/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h +++ b/src/hardwareintegration/compositor/dmabuf-server/dmabufserverbufferintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef DMABUFSERVERBUFFERINTEGRATION_H #define DMABUFSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp index 2dbad2288..3c49f30a4 100644 --- a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "drmeglserverbufferintegration.h" @@ -113,7 +87,7 @@ QOpenGLTexture *DrmEglServerBuffer::toOpenGlTexture() bool DrmEglServerBuffer::bufferInUse() { - return resourceMap().count() > 0; + return resourceMap().size() > 0; } DrmEglServerBufferIntegration::DrmEglServerBufferIntegration() diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h index 2108632e4..e99a62542 100644 --- a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h +++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef DRMEGLSERVERBUFFERINTEGRATION_H #define DRMEGLSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.cpp b/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.cpp index e527e1a07..c30bf5ae3 100644 --- a/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.cpp +++ b/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "vsp2hardwarelayerintegration.h" @@ -68,7 +42,7 @@ Vsp2Layer::Vsp2Layer(QWaylandQuickHardwareLayer *hwLayer, Vsp2HardwareLayerInteg connect(hwLayer->waylandItem(), &QWaylandQuickItem::surfaceChanged, this, &Vsp2Layer::handleSurfaceChanged); connect(hwLayer->waylandItem(), &QQuickItem::opacityChanged, this, &Vsp2Layer::updateOpacity); connect(hwLayer->waylandItem()->window(), &QQuickWindow::afterSynchronizing, this, &Vsp2Layer::updatePosition); - hwLayer->disableSceneGraphPainting(); + hwLayer->setSceneGraphPainting(false); QWaylandViewPrivate::get(hwLayer->waylandItem()->view())->independentFrameCallback = true; handleSurfaceChanged(); } @@ -188,7 +162,7 @@ wl_kms_buffer *Vsp2Layer::nextKmsBuffer() void Vsp2HardwareLayerIntegration::enableVspLayers() { - for (auto &layer : qAsConst(m_layers)) { + for (auto &layer : std::as_const(m_layers)) { Q_ASSERT(!layer->isEnabled()); layer->enableVspLayer(); } @@ -251,7 +225,7 @@ void Vsp2HardwareLayerIntegration::remove(QWaylandQuickHardwareLayer *hwLayer) void Vsp2HardwareLayerIntegration::sendFrameCallbacks() { - for (auto &layer : qAsConst(m_layers)) { + for (auto &layer : std::as_const(m_layers)) { if (auto *surface = layer->hwLayer()->waylandItem()->surface()) surface->sendFrameCallbacks(); } diff --git a/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.h b/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.h index 982c96cba..3ec77957f 100644 --- a/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.h +++ b/src/hardwareintegration/compositor/hardwarelayer/vsp2/vsp2hardwarelayerintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef VSP2HARDWARELAYERINTEGRATION_H #define VSP2HARDWARELAYERINTEGRATION_H @@ -90,7 +64,7 @@ public: bool isEnabled() { return m_layerIndex != -1; } QWaylandQuickHardwareLayer *hwLayer() const { return m_hwLayer; } -public slots: +public Q_SLOTS: void handleBufferCommitted(); void handleSurfaceChanged(); void updatePosition(); diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp index f9ef5635d..f28c6df6d 100644 --- a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "libhybriseglserverbufferintegration.h" diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h index 0867cded7..3759a3329 100644 --- a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h +++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef LIBHYBRISEGLSERVERBUFFERINTEGRATION_H #define LIBHYBRISEGLSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.cpp b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.cpp index 777f7eea1..a608b9c4d 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.cpp +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.cpp @@ -1,36 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "linuxdmabuf.h" #include "linuxdmabufclientbufferintegration.h" #include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/private/qwltextureorphanage_p.h> #include <drm_fourcc.h> #include <drm_mode.h> @@ -58,7 +33,7 @@ void LinuxDmabuf::zwp_linux_dmabuf_v1_bind_resource(Resource *resource) // send DRM_FORMAT_MOD_INVALID when no modifiers are supported for a format if (modifiers.isEmpty()) modifiers << DRM_FORMAT_MOD_INVALID; - for (const auto &modifier : qAsConst(modifiers)) { + for (const auto &modifier : std::as_const(modifiers)) { if (resource->version() >= ZWP_LINUX_DMABUF_V1_MODIFIER_SINCE_VERSION) { const uint32_t modifier_lo = modifier & 0xFFFFFFFF; const uint32_t modifier_hi = modifier >> 32; @@ -118,7 +93,7 @@ bool LinuxDmabufParams::handleCreateParams(Resource *resource, int width, int he // check for holes in plane sequence auto planeIds = m_planes.keys(); std::sort(planeIds.begin(), planeIds.end()); - for (int i = 0; i < planeIds.count(); ++i) { + for (int i = 0; i < planeIds.size(); ++i) { if (uint(i) != planeIds[i]) { wl_resource_post_error(resource->handle, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, @@ -283,10 +258,17 @@ LinuxDmabufWlBuffer::~LinuxDmabufWlBuffer() void LinuxDmabufWlBuffer::buffer_destroy(Resource *resource) { Q_UNUSED(resource); + + QMutexLocker locker(&m_texturesLock); + for (uint32_t i = 0; i < m_planesNumber; ++i) { if (m_textures[i] != nullptr) { - m_clientBufferIntegration->deleteGLTextureWhenPossible(m_textures[i]); + QtWayland::QWaylandTextureOrphanage::instance()->admitTexture(m_textures[i], + m_texturesContext[i]); m_textures[i] = nullptr; + m_texturesContext[i] = nullptr; + QObject::disconnect(m_texturesAboutToBeDestroyedConnection[i]); + m_texturesAboutToBeDestroyedConnection[i] = QMetaObject::Connection(); } if (m_eglImages[i] != EGL_NO_IMAGE_KHR) { m_clientBufferIntegration->deleteImage(m_eglImages[i]); @@ -308,9 +290,40 @@ void LinuxDmabufWlBuffer::initImage(uint32_t plane, EGLImageKHR image) void LinuxDmabufWlBuffer::initTexture(uint32_t plane, QOpenGLTexture *texture) { + QMutexLocker locker(&m_texturesLock); + Q_ASSERT(plane < m_planesNumber); Q_ASSERT(m_textures.at(plane) == nullptr); + Q_ASSERT(QOpenGLContext::currentContext()); m_textures[plane] = texture; + m_texturesContext[plane] = QOpenGLContext::currentContext(); + + m_texturesAboutToBeDestroyedConnection[plane] = + QObject::connect(m_texturesContext[plane], &QOpenGLContext::aboutToBeDestroyed, + m_texturesContext[plane], [this, plane]() { + + QMutexLocker locker(&this->m_texturesLock); + + // See above lock - there is a chance that this has already been removed from m_textures[plane]! + // Furthermore, we can trust that all the rest (e.g. disconnect) has also been properly executed! + if (this->m_textures[plane] == nullptr) + return; + + delete this->m_textures[plane]; + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO + << "texture deleted due to QOpenGLContext::aboutToBeDestroyed!" + << "Pointer (now dead) was:" << (void*)(this->m_textures[plane]) + << " Associated context (about to die too) is: " << (void*)(this->m_texturesContext[plane]); + + this->m_textures[plane] = nullptr; + this->m_texturesContext[plane] = nullptr; + + QObject::disconnect(this->m_texturesAboutToBeDestroyedConnection[plane]); + this->m_texturesAboutToBeDestroyedConnection[plane] = QMetaObject::Connection(); + + }, Qt::DirectConnection); } void LinuxDmabufWlBuffer::buffer_destroy_resource(Resource *resource) diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h index aaf803148..dba4e3980 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef LINUXDMABUF_H #define LINUXDMABUF_H @@ -41,6 +15,10 @@ #include <QtCore/QSize> #include <QtCore/QTextStream> +#include <array> +#include <QtGui/QOpenGLContext> +#include <QtCore/QMutex> + #include <EGL/egl.h> #include <EGL/eglext.h> @@ -147,6 +125,10 @@ private: LinuxDmabufClientBufferIntegration *m_clientBufferIntegration = nullptr; std::array<EGLImageKHR, MaxDmabufPlanes> m_eglImages = { {EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR, EGL_NO_IMAGE_KHR} }; std::array<QOpenGLTexture *, MaxDmabufPlanes> m_textures = { {nullptr, nullptr, nullptr, nullptr} }; + std::array<QOpenGLContext *, MaxDmabufPlanes> m_texturesContext = { {nullptr, nullptr, nullptr, nullptr} }; + std::array<QMetaObject::Connection, MaxDmabufPlanes> m_texturesAboutToBeDestroyedConnection = { {QMetaObject::Connection(), QMetaObject::Connection(), QMetaObject::Connection(), QMetaObject::Connection()} }; + QMutex m_texturesLock; + void freeResources(); void buffer_destroy(Resource *resource) override; diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp index a4fbc6b50..205f25d1f 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp @@ -1,39 +1,15 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "linuxdmabufclientbufferintegration.h" #include "linuxdmabuf.h" #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtWaylandCompositor/private/qwltextureorphanage_p.h> #include <qpa/qplatformnativeinterface.h> #include <QtOpenGL/QOpenGLTexture> +#include <QtCore/QVarLengthArray> #include <QtGui/QGuiApplication> #include <QtGui/QOpenGLContext> @@ -105,6 +81,11 @@ static QOpenGLTexture::TextureFormat openGLFormatFromBufferFormat(QWaylandBuffer } } +// Initialize the EGLImage for a dmabuf buffer which conceptually consists of a +// single plane. Note that depending on the modifiers, the buffer may be actually +// transported as multiple dmabuf planes which must be combined into a single +// EGLImage. For formats where the buffer needs to be represented as multiple +// EGLImages (e.g., various YUV formats) a different approach is required. bool LinuxDmabufClientBufferIntegration::initSimpleTexture(LinuxDmabufWlBuffer *dmabufBuffer) { bool success = true; @@ -118,79 +99,67 @@ bool LinuxDmabufClientBufferIntegration::initSimpleTexture(LinuxDmabufWlBuffer * success = false; } - for (uint32_t i = 0; i < dmabufBuffer->planesNumber(); ++i) { - QVarLengthArray<EGLint, 17> attribs; - switch (i) { - case 0: - attribs = { - EGL_WIDTH, dmabufBuffer->size().width(), - EGL_HEIGHT, dmabufBuffer->size().height(), - EGL_LINUX_DRM_FOURCC_EXT, EGLint(dmabufBuffer->drmFormat()), - EGL_DMA_BUF_PLANE0_FD_EXT, dmabufBuffer->plane(i).fd, - EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGLint(dmabufBuffer->plane(i).offset), - EGL_DMA_BUF_PLANE0_PITCH_EXT, EGLint(dmabufBuffer->plane(i).stride), - EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, EGLint(dmabufBuffer->plane(i).modifiers & 0xffffffff), - EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, EGLint(dmabufBuffer->plane(i).modifiers >> 32), - EGL_NONE - }; - break; - case 1: - attribs = { - EGL_WIDTH, dmabufBuffer->size().width(), - EGL_HEIGHT, dmabufBuffer->size().height(), - EGL_LINUX_DRM_FOURCC_EXT, EGLint(dmabufBuffer->drmFormat()), - EGL_DMA_BUF_PLANE1_FD_EXT, dmabufBuffer->plane(i).fd, - EGL_DMA_BUF_PLANE1_OFFSET_EXT, EGLint(dmabufBuffer->plane(i).offset), - EGL_DMA_BUF_PLANE1_PITCH_EXT, EGLint(dmabufBuffer->plane(i).stride), - EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, EGLint(dmabufBuffer->plane(i).modifiers & 0xffffffff), - EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT, EGLint(dmabufBuffer->plane(i).modifiers >> 32), - EGL_NONE - }; - break; - case 2: - attribs = { - EGL_WIDTH, dmabufBuffer->size().width(), - EGL_HEIGHT, dmabufBuffer->size().height(), - EGL_LINUX_DRM_FOURCC_EXT, EGLint(dmabufBuffer->drmFormat()), - EGL_DMA_BUF_PLANE2_FD_EXT, dmabufBuffer->plane(i).fd, - EGL_DMA_BUF_PLANE2_OFFSET_EXT, EGLint(dmabufBuffer->plane(i).offset), - EGL_DMA_BUF_PLANE2_PITCH_EXT, EGLint(dmabufBuffer->plane(i).stride), - EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, EGLint(dmabufBuffer->plane(i).modifiers & 0xffffffff), - EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT, EGLint(dmabufBuffer->plane(i).modifiers >> 32), - EGL_NONE - }; - break; - case 3: - attribs = { - EGL_WIDTH, dmabufBuffer->size().width(), - EGL_HEIGHT, dmabufBuffer->size().height(), - EGL_LINUX_DRM_FOURCC_EXT, EGLint(dmabufBuffer->drmFormat()), - EGL_DMA_BUF_PLANE3_FD_EXT, dmabufBuffer->plane(i).fd, - EGL_DMA_BUF_PLANE3_OFFSET_EXT, EGLint(dmabufBuffer->plane(i).offset), - EGL_DMA_BUF_PLANE3_PITCH_EXT, EGLint(dmabufBuffer->plane(i).stride), - EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, EGLint(dmabufBuffer->plane(i).modifiers & 0xffffffff), - EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT, EGLint(dmabufBuffer->plane(i).modifiers >> 32), - EGL_NONE - }; + // 6 entries for the common attribs plus 10 per possible plane, plus 1 for + // the final EGL_NONE sentinel. + QVarLengthArray<EGLint, 6 + 10 * 4 + 1> attribs; + + attribs.append(EGL_WIDTH); + attribs.append(dmabufBuffer->size().width()); + attribs.append(EGL_HEIGHT); + attribs.append(dmabufBuffer->size().height()); + attribs.append(EGL_LINUX_DRM_FOURCC_EXT); + attribs.append(EGLint(dmabufBuffer->drmFormat())); + +#define ADD_PLANE_ATTRIBS(plane_idx) { \ + attribs.append(EGL_DMA_BUF_PLANE ## plane_idx ## _FD_EXT); \ + attribs.append(dmabufBuffer->plane(plane_idx).fd); \ + attribs.append(EGL_DMA_BUF_PLANE ## plane_idx ## _OFFSET_EXT); \ + attribs.append(EGLint(dmabufBuffer->plane(plane_idx).offset)); \ + attribs.append(EGL_DMA_BUF_PLANE ## plane_idx ## _PITCH_EXT); \ + attribs.append(EGLint(dmabufBuffer->plane(plane_idx).stride)); \ + if (dmabufBuffer->plane(plane_idx).modifiers != DRM_FORMAT_MOD_INVALID) { \ + attribs.append(EGL_DMA_BUF_PLANE ## plane_idx ## _MODIFIER_LO_EXT); \ + attribs.append(EGLint(dmabufBuffer->plane(plane_idx).modifiers & 0xffffffff)); \ + attribs.append(EGL_DMA_BUF_PLANE ## plane_idx ## _MODIFIER_HI_EXT); \ + attribs.append(EGLint(dmabufBuffer->plane(plane_idx).modifiers >> 32)); \ + } \ +} + + switch (dmabufBuffer->planesNumber()) { + case 4: + ADD_PLANE_ATTRIBS(3); + Q_FALLTHROUGH(); + case 3: + ADD_PLANE_ATTRIBS(2); + Q_FALLTHROUGH(); + case 2: + ADD_PLANE_ATTRIBS(1); + Q_FALLTHROUGH(); + case 1: + ADD_PLANE_ATTRIBS(0); break; - default: - return false; - } + default: + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Buffer uses invalid number of planes:" << dmabufBuffer->planesNumber(); + return false; + } - // note: EGLImageKHR does NOT take ownership of the file descriptors - EGLImageKHR image = egl_create_image(m_eglDisplay, - EGL_NO_CONTEXT, - EGL_LINUX_DMA_BUF_EXT, - (EGLClientBuffer) nullptr, - attribs.constData()); + attribs.append(EGL_NONE); - if (image == EGL_NO_IMAGE_KHR) { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "failed to create EGL image for plane" << i; - success = false; - } + // note: EGLImageKHR does NOT take ownership of the file descriptors + EGLImageKHR image = egl_create_image(m_eglDisplay, + EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + (EGLClientBuffer) nullptr, + attribs.constData()); - dmabufBuffer->initImage(i, image); + if (image == EGL_NO_IMAGE_KHR) { + qCWarning(qLcWaylandCompositorHardwareIntegration) << "failed to create EGL image from" << + dmabufBuffer->planesNumber() << "plane(s)"; + success = false; } + + dmabufBuffer->initImage(0, image); + return success; } @@ -273,6 +242,12 @@ LinuxDmabufClientBufferIntegration::LinuxDmabufClientBufferIntegration() LinuxDmabufClientBufferIntegration::~LinuxDmabufClientBufferIntegration() { m_importedBuffers.clear(); + + if (egl_unbind_wayland_display != nullptr && m_displayBound) { + Q_ASSERT(m_wlDisplay != nullptr); + if (!egl_unbind_wayland_display(m_eglDisplay, m_wlDisplay)) + qCWarning(qLcWaylandCompositorHardwareIntegration) << "eglUnbindWaylandDisplayWL failed"; + } } void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display *display) @@ -326,14 +301,9 @@ void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display if (egl_bind_wayland_display && egl_unbind_wayland_display) { m_displayBound = egl_bind_wayland_display(m_eglDisplay, display); - if (!m_displayBound) { - if (ignoreBindDisplay) { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not bind Wayland display. Ignoring."; - } else { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not bind Wayland display."; - return; - } - } + if (!m_displayBound) + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Wayland display already bound by other client buffer integration."; + m_wlDisplay = display; } // request and sent formats/modifiers only after egl_display is bound @@ -381,13 +351,6 @@ QList<uint64_t> LinuxDmabufClientBufferIntegration::supportedDrmModifiers(uint32 return QList<uint64_t>(); } -void LinuxDmabufClientBufferIntegration::deleteOrphanedTextures() -{ - Q_ASSERT(QOpenGLContext::currentContext()); - qDeleteAll(m_orphanedTextures); - m_orphanedTextures.clear(); -} - void LinuxDmabufClientBufferIntegration::deleteImage(EGLImageKHR image) { egl_destroy_image(m_eglDisplay, image); @@ -434,7 +397,7 @@ LinuxDmabufClientBuffer::LinuxDmabufClientBuffer(LinuxDmabufClientBufferIntegrat QOpenGLTexture *LinuxDmabufClientBuffer::toOpenGlTexture(int plane) { // At this point we should have a valid OpenGL context, so it's safe to destroy textures - m_integration->deleteOrphanedTextures(); + QtWayland::QWaylandTextureOrphanage::instance()->deleteTextures(); if (!m_buffer) return nullptr; @@ -452,6 +415,7 @@ QOpenGLTexture *LinuxDmabufClientBuffer::toOpenGlTexture(int plane) } if (m_textureDirty) { + m_textureDirty = false; texture->bind(); glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); m_integration->gl_egl_image_target_texture_2d(target, d->image(plane)); diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h index 35417d796..b72a24d5d 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef LINUXDMABUFCLIENTBUFFERINTEGRATION_H #define LINUXDMABUFCLIENTBUFFERINTEGRATION_H @@ -35,6 +9,7 @@ #include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h> #include <QtWaylandCompositor/private/qwlclientbuffer_p.h> #include <QtWaylandCompositor/private/qwayland-server-wayland.h> +#include <QtCore/QMutex> #include <drm_fourcc.h> @@ -71,9 +46,7 @@ public: QtWayland::ClientBuffer *createBufferFor(wl_resource *resource) override; bool importBuffer(wl_resource *resource, LinuxDmabufWlBuffer *linuxDmabufBuffer); void removeBuffer(wl_resource *resource); - void deleteOrphanedTextures(); void deleteImage(EGLImageKHR image); - void deleteGLTextureWhenPossible(QOpenGLTexture *texture) { m_orphanedTextures << texture; } PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_egl_image_target_texture_2d = nullptr; private: @@ -92,8 +65,9 @@ private: QList<uint64_t> supportedDrmModifiers(uint32_t format); EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; + ::wl_display *m_wlDisplay = nullptr; bool m_displayBound = false; - QList<QOpenGLTexture *> m_orphanedTextures; + QHash<EGLint, YuvFormatConversion> m_yuvFormats; bool m_supportsDmabufModifiers = false; QHash<struct ::wl_resource *, LinuxDmabufWlBuffer *> m_importedBuffers; diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp index 5c2aa82c3..6dc99e193 100644 --- a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "shmserverbufferintegration.h" @@ -59,7 +33,8 @@ ShmServerBuffer::ShmServerBuffer(ShmServerBufferIntegration *integration, const } QString key = "qt_shm_emulation_" + QString::number(qimage.cacheKey()); - m_shm = new QSharedMemory(key); + // ### Use proper native keys the next time we can break protocol compatibility + QT_IGNORE_DEPRECATIONS(m_shm = new QSharedMemory(key);) qsizetype shm_size = qimage.sizeInBytes(); bool ok = m_shm->create(shm_size) && m_shm->lock(); if (ok) { @@ -86,7 +61,8 @@ struct ::wl_resource *ShmServerBuffer::resourceForClient(struct ::wl_client *cli } struct ::wl_resource *shm_integration_resource = integrationResource->handle; Resource *resource = add(client, 1); - m_integration->send_server_buffer_created(shm_integration_resource, resource->handle, m_shm->key(), m_width, m_height, m_bpl, m_shm_format); + QT_IGNORE_DEPRECATIONS(const QString shmKey = m_shm->key();) + m_integration->send_server_buffer_created(shm_integration_resource, resource->handle, shmKey, m_width, m_height, m_bpl, m_shm_format); return resource->handle; } return bufferResource->handle; @@ -94,7 +70,7 @@ struct ::wl_resource *ShmServerBuffer::resourceForClient(struct ::wl_client *cli bool ShmServerBuffer::bufferInUse() { - return resourceMap().count() > 0; + return resourceMap().size() > 0; } QOpenGLTexture *ShmServerBuffer::toOpenGlTexture() diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h index 95439f080..527e65cb7 100644 --- a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h +++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SHMSERVERBUFFERINTEGRATION_H #define SHMSERVERBUFFERINTEGRATION_H diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp index 4f8830ef7..1b5aea29a 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "vulkanserverbufferintegration.h" @@ -42,7 +16,7 @@ #include <QtCore/QDebug> QT_BEGIN_NAMESPACE -static constexpr bool extraDebug = false; +static constexpr bool vsbiExtraDebug = false; #define DECL_GL_FUNCTION(name, type) \ type name @@ -205,7 +179,7 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture() return nullptr; funcs->glCreateMemoryObjectsEXT(1, &m_memoryObject); - if (extraDebug) qDebug() << "glCreateMemoryObjectsEXT" << Qt::hex << glGetError(); + if (vsbiExtraDebug) qDebug() << "glCreateMemoryObjectsEXT" << Qt::hex << glGetError(); int dupfd = fcntl(m_fd, F_DUPFD_CLOEXEC, 0); @@ -215,7 +189,7 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture() } funcs->glImportMemoryFdEXT(m_memoryObject, m_memorySize, GL_HANDLE_TYPE_OPAQUE_FD_EXT, dupfd); - if (extraDebug) qDebug() << "glImportMemoryFdEXT" << Qt::hex << glGetError(); + if (vsbiExtraDebug) qDebug() << "glImportMemoryFdEXT" << Qt::hex << glGetError(); if (!m_texture) @@ -223,13 +197,13 @@ QOpenGLTexture *VulkanServerBuffer::toOpenGlTexture() m_texture->create(); GLuint texId = m_texture->textureId(); - if (extraDebug) qDebug() << "created texture" << texId << Qt::hex << glGetError(); + if (vsbiExtraDebug) qDebug() << "created texture" << texId << Qt::hex << glGetError(); m_texture->bind(); - if (extraDebug) qDebug() << "bound texture" << texId << Qt::hex << glGetError(); + if (vsbiExtraDebug) qDebug() << "bound texture" << texId << Qt::hex << glGetError(); funcs->glTexStorageMem2DEXT(GL_TEXTURE_2D, 1, m_glInternalFormat, m_size.width(), m_size.height(), m_memoryObject, 0 ); - if (extraDebug) qDebug() << "glTexStorageMem2DEXT" << Qt::hex << glGetError(); - if (extraDebug) qDebug() << "format" << Qt::hex << m_glInternalFormat << GL_RGBA8; + if (vsbiExtraDebug) qDebug() << "glTexStorageMem2DEXT" << Qt::hex << glGetError(); + if (vsbiExtraDebug) qDebug() << "format" << Qt::hex << m_glInternalFormat << GL_RGBA8; return m_texture; @@ -248,7 +222,7 @@ void VulkanServerBuffer::releaseOpenGlTexture() bool VulkanServerBuffer::bufferInUse() { - return (m_texture && m_texture->isCreated()) || resourceMap().count() > 0; + return (m_texture && m_texture->isCreated()) || resourceMap().size() > 0; } void VulkanServerBuffer::server_buffer_release(Resource *resource) @@ -294,14 +268,17 @@ QtWayland::ServerBuffer *VulkanServerBufferIntegration::createServerBufferFromIm return new VulkanServerBuffer(this, qimage, format); } -QtWayland::ServerBuffer *VulkanServerBufferIntegration::createServerBufferFromData(const QByteArray &data, const QSize &size, uint glInternalFormat) +QtWayland::ServerBuffer * +VulkanServerBufferIntegration::createServerBufferFromData(QByteArrayView view, const QSize &size, + uint glInternalFormat) { if (!m_vulkanWrapper) { CurrentContext current; m_vulkanWrapper = new VulkanWrapper(current.context()); } - auto *vImage = m_vulkanWrapper->createTextureImageFromData(reinterpret_cast<const uchar*>(data.constData()), data.size(), size, glInternalFormat); + auto *vImage = m_vulkanWrapper->createTextureImageFromData( + reinterpret_cast<const uchar *>(view.constData()), view.size(), size, glInternalFormat); if (vImage) return new VulkanServerBuffer(this, vImage, glInternalFormat, size); diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h index 6e2c51dd4..ab1899fb2 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanserverbufferintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef VULKANSERVERBUFFERINTEGRATION_H #define VULKANSERVERBUFFERINTEGRATION_H @@ -90,7 +64,8 @@ public: bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; - QtWayland::ServerBuffer *createServerBufferFromData(const QByteArray &data, const QSize &size, uint glInternalFormat) override; + QtWayland::ServerBuffer *createServerBufferFromData(QByteArrayView view, const QSize &size, + uint glInternalFormat) override; private: VulkanWrapper *m_vulkanWrapper = nullptr; diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.cpp b/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.cpp index 6ab970f78..bf3700aec 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.cpp +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // NOTE: Some of the code below is adapted from the public domain code at https://vulkan-tutorial.com/ @@ -34,6 +8,7 @@ #include "vulkanwrapper.h" #include <QImage> +#include <QVarLengthArray> #include <QOpenGLContext> #include <QtGui/qopengl.h> #include <QtOpenGL/private/qvkconvenience_p.h> @@ -46,7 +21,7 @@ QT_BEGIN_NAMESPACE -static constexpr bool extraDebug = false; +static constexpr bool vwExtraDebug = false; #define DECL_VK_FUNCTION(name) \ PFN_ ## name name = nullptr; @@ -225,7 +200,7 @@ VulkanImageWrapper *VulkanWrapperPrivate::createImage(VkFormat format, VkImageTi return nullptr; } - QScopedPointer<VulkanImageWrapper> imageWrapper(new VulkanImageWrapper); + std::unique_ptr imageWrapper = std::make_unique<VulkanImageWrapper>(); imageWrapper->textureImage = image; imageWrapper->imgMemSize = memSize; imageWrapper->imgSize = size; @@ -253,7 +228,7 @@ VulkanImageWrapper *VulkanWrapperPrivate::createImage(VkFormat format, VkImageTi int res = vkBindImageMemory(m_device, image, imageWrapper->textureImageMemory, 0); Q_UNUSED(res); - if (extraDebug) qDebug() << "vkBindImageMemory res" << res; + if (vwExtraDebug) qDebug() << "vkBindImageMemory res" << res; VkMemoryGetFdInfoKHR memoryFdInfo = {}; memoryFdInfo.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR; @@ -261,9 +236,9 @@ VulkanImageWrapper *VulkanWrapperPrivate::createImage(VkFormat format, VkImageTi memoryFdInfo.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR; res = vkGetMemoryFdKHR(m_device, &memoryFdInfo, &imageWrapper->imgFd); - if (extraDebug) qDebug() << "vkGetMemoryFdKHR res" << res << "fd" << imageWrapper->imgFd; + if (vwExtraDebug) qDebug() << "vkGetMemoryFdKHR res" << res << "fd" << imageWrapper->imgFd; - return imageWrapper.take(); + return imageWrapper.release(); } @@ -356,19 +331,19 @@ VkCommandBuffer VulkanWrapperPrivate::beginSingleTimeCommands() allocInfo.commandPool = m_commandPool; allocInfo.commandBufferCount = 1; - if (extraDebug) qDebug() << "allocating..."; + if (vwExtraDebug) qDebug() << "allocating..."; VkCommandBuffer commandBuffer; int res = vkAllocateCommandBuffers(m_device, &allocInfo, &commandBuffer); Q_UNUSED(res); - if (extraDebug) qDebug() << "vkAllocateCommandBuffers res" << res; + if (vwExtraDebug) qDebug() << "vkAllocateCommandBuffers res" << res; VkCommandBufferBeginInfo beginInfo = {}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; res = vkBeginCommandBuffer(commandBuffer, &beginInfo); - if (extraDebug) qDebug() << "BEGIN res" << res; + if (vwExtraDebug) qDebug() << "BEGIN res" << res; return commandBuffer; } @@ -377,7 +352,7 @@ void VulkanWrapperPrivate::endSingleTimeCommands(VkCommandBuffer commandBuffer) { int res = vkEndCommandBuffer(commandBuffer); Q_UNUSED(res); - if (extraDebug) qDebug() << "END res" << res; + if (vwExtraDebug) qDebug() << "END res" << res; VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; @@ -434,7 +409,7 @@ QueueFamilyIndices VulkanWrapperPrivate::findQueueFamilies(VkPhysicalDevice devi uint32_t queueFamilyCount = 0; vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, nullptr); - if (extraDebug) qDebug() << "queueFamilyCount" << queueFamilyCount; + if (vwExtraDebug) qDebug() << "queueFamilyCount" << queueFamilyCount; std::vector<VkQueueFamilyProperties> queueFamilies(queueFamilyCount); @@ -507,7 +482,7 @@ VulkanImageWrapper *VulkanWrapperPrivate::createTextureImageFromData(const uchar int texWidth = size.width(); int texHeight = size.height(); bool ok; - if (extraDebug) qDebug("image load %p %dx%d", pixels, texWidth, texHeight); + if (vwExtraDebug) qDebug("image load %p %dx%d", pixels, texWidth, texHeight); if (!pixels) { qCritical("VulkanWrapper: failed to load texture image!"); return nullptr; @@ -522,17 +497,17 @@ VulkanImageWrapper *VulkanWrapperPrivate::createTextureImageFromData(const uchar void* data; vkMapMemory(m_device, stagingBufferMemory, 0, bufferSize, 0, &data); - if (extraDebug) qDebug() << "mapped" << data << bufferSize; + if (vwExtraDebug) qDebug() << "mapped" << data << bufferSize; memcpy(data, pixels, static_cast<size_t>(bufferSize)); vkUnmapMemory(m_device, stagingBufferMemory); - if (extraDebug) qDebug() << "creating image..."; + if (vwExtraDebug) qDebug() << "creating image..."; - QScopedPointer<VulkanImageWrapper> imageWrapper(createImage(vkFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, size, bufferSize)); - if (imageWrapper.isNull()) + std::unique_ptr<VulkanImageWrapper> imageWrapper(createImage(vkFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, size, bufferSize)); + if (!imageWrapper) return nullptr; - if (extraDebug) qDebug() << "transition..."; + if (vwExtraDebug) qDebug() << "transition..."; const VkImage textureImage = imageWrapper->textureImage; @@ -541,14 +516,14 @@ VulkanImageWrapper *VulkanWrapperPrivate::createTextureImageFromData(const uchar if (!ok) return nullptr; - if (extraDebug) qDebug() << "copyBufferToImage..."; + if (vwExtraDebug) qDebug() << "copyBufferToImage..."; copyBufferToImage(stagingBuffer, textureImage, static_cast<uint32_t>(texWidth), static_cast<uint32_t>(texHeight)); transitionImageLayout(textureImage, vkFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); vkDestroyBuffer(m_device, stagingBuffer, nullptr); vkFreeMemory(m_device, stagingBufferMemory, nullptr); - return imageWrapper.take(); + return imageWrapper.release(); } void VulkanWrapperPrivate::freeTextureImage(VulkanImageWrapper *imageWrapper) @@ -566,7 +541,7 @@ void VulkanWrapperPrivate::freeTextureImage(VulkanImageWrapper *imageWrapper) VulkanWrapperPrivate::VulkanWrapperPrivate(QOpenGLContext *glContext) { - if (extraDebug) qDebug("Creating Vulkan instance"); + if (vwExtraDebug) qDebug("Creating Vulkan instance"); VkApplicationInfo applicationInfo = {}; applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; applicationInfo.pNext = nullptr; @@ -598,7 +573,7 @@ VulkanWrapperPrivate::VulkanWrapperPrivate(QOpenGLContext *glContext) VkResult instanceCreationResult = vkCreateInstance(&instanceCreateInfo, nullptr, &m_instance); - if (extraDebug) qDebug() << "result" << instanceCreationResult; + if (vwExtraDebug) qDebug() << "result" << instanceCreationResult; if (instanceCreationResult != VK_SUCCESS) { qCritical() << "VulkanWrapper: Failed to create Vulkan instance: Error " @@ -610,12 +585,12 @@ VulkanWrapperPrivate::VulkanWrapperPrivate(QOpenGLContext *glContext) uint32_t devCount; auto res = vkEnumeratePhysicalDevices(m_instance, &devCount, nullptr); - if (extraDebug) qDebug() << "vkEnumeratePhysicalDevices res =" << res << "count =" << devCount; + if (vwExtraDebug) qDebug() << "vkEnumeratePhysicalDevices res =" << res << "count =" << devCount; QVarLengthArray<VkPhysicalDevice, 5> dev(devCount); res = vkEnumeratePhysicalDevices(m_instance, &devCount, dev.data()); - if (extraDebug) qDebug() << "...devs res =" << res << "count =" << devCount; + if (vwExtraDebug) qDebug() << "...devs res =" << res << "count =" << devCount; #ifdef VULKAN_SERVER_BUFFER_EXTRA_DEBUG VkPhysicalDeviceProperties props; diff --git a/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.h b/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.h index 159e3ac84..a2f55fd75 100644 --- a/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.h +++ b/src/hardwareintegration/compositor/vulkan-server/vulkanwrapper.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef VULKANWRAPPER_H #define VULKANWRAPPER_H diff --git a/src/hardwareintegration/compositor/wayland-egl/CMakeLists.txt b/src/hardwareintegration/compositor/wayland-egl/CMakeLists.txt new file mode 100644 index 000000000..f31928550 --- /dev/null +++ b/src/hardwareintegration/compositor/wayland-egl/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## WaylandEglCompositorHwIntegrationPrivate Module: +##################################################################### +qt_find_package(EGL) # special case + +qt_internal_add_module(WaylandEglCompositorHwIntegrationPrivate + CONFIG_MODULE_NAME wayland_egl_compositor_hw_integration + INTERNAL_MODULE + SOURCES + waylandeglclientbufferintegration.cpp waylandeglclientbufferintegration_p.h + INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR} + LIBRARIES + EGL::EGL + Wayland::Egl + Wayland::Server + PUBLIC_LIBRARIES + Qt::Core + Qt::Gui + Qt::WaylandCompositorPrivate + NO_GENERATE_CPP_EXPORTS +) + +qt_internal_extend_target(WaylandEglCompositorHwIntegrationPrivate CONDITION NOT QT_FEATURE_egl_x11 + DEFINES + QT_EGL_NO_X11 +) diff --git a/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri b/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri index 0a90583be..23615f316 100644 --- a/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri +++ b/src/hardwareintegration/compositor/wayland-egl/wayland-egl.pri @@ -6,4 +6,4 @@ SOURCES += \ $$PWD/waylandeglclientbufferintegration.cpp HEADERS += \ - $$PWD/waylandeglclientbufferintegration.h + $$PWD/waylandeglclientbufferintegration_p.h diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index a826c5fca..c8819ba1f 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -1,35 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "waylandeglclientbufferintegration.h" +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "waylandeglclientbufferintegration_p.h" #include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/private/qwltextureorphanage_p.h> #include <qpa/qplatformnativeinterface.h> #include <QtOpenGL/QOpenGLTexture> #include <QtGui/QGuiApplication> @@ -42,6 +17,7 @@ #include <QMutex> #include <QMutexLocker> +#include <QVarLengthArray> #include <QtCore/private/qcore_unix_p.h> #include <QtGui/private/qeglstreamconvenience_p.h> @@ -151,7 +127,11 @@ struct BufferState EGLint egl_format = EGL_TEXTURE_RGBA; QVarLengthArray<EGLImageKHR, 3> egl_images; - QOpenGLTexture *textures[3] = {}; + QOpenGLTexture *textures[3] = {nullptr, nullptr, nullptr}; + QOpenGLContext *texturesContext[3] = {nullptr, nullptr, nullptr}; + QMetaObject::Connection texturesAboutToBeDestroyedConnection[3] = {QMetaObject::Connection(), QMetaObject::Connection(), QMetaObject::Connection()}; + QMutex texturesLock; + EGLStreamKHR egl_stream = EGL_NO_STREAM_KHR; bool isYInverted = true; @@ -168,17 +148,15 @@ public: void initEglTexture(WaylandEglClientBuffer *buffer, EGLint format); bool ensureContext(); bool initEglStream(WaylandEglClientBuffer *buffer, struct ::wl_resource *bufferHandle); + void setupBufferAndCleanup(BufferState *bs, QOpenGLTexture *texture, int plane); void handleEglstreamTexture(WaylandEglClientBuffer *buffer, wl_resource *bufferHandle); void registerBuffer(struct ::wl_resource *buffer, BufferState state); - void deleteGLTextureWhenPossible(QOpenGLTexture *texture) { orphanedTextures << texture; } - void deleteOrphanedTextures(); EGLDisplay egl_display = EGL_NO_DISPLAY; bool display_bound = false; ::wl_display *wlDisplay = nullptr; QOffscreenSurface *offscreenSurface = nullptr; QOpenGLContext *localContext = nullptr; - QList<QOpenGLTexture *> orphanedTextures; PFNEGLBINDWAYLANDDISPLAYWL egl_bind_wayland_display = nullptr; PFNEGLUNBINDWAYLANDDISPLAYWL egl_unbind_wayland_display = nullptr; @@ -259,7 +237,14 @@ void WaylandEglClientBufferIntegrationPrivate::initEglTexture(WaylandEglClientBu } for (int i = 0; i < planes; i++) { - const EGLint attribs[] = { EGL_WAYLAND_PLANE_WL, i, EGL_NONE }; + EGLint attribs[5] = { EGL_WAYLAND_PLANE_WL, i, EGL_NONE }; +#ifdef EGL_EXT_protected_content + if (buffer->isProtected()) { + attribs[2] = EGL_PROTECTED_CONTENT_EXT; + attribs[3] = EGL_TRUE; + attribs[4] = EGL_NONE; + } +#endif EGLImageKHR image = egl_create_image(egl_display, EGL_NO_CONTEXT, EGL_WAYLAND_BUFFER_WL, @@ -272,6 +257,8 @@ void WaylandEglClientBufferIntegrationPrivate::initEglTexture(WaylandEglClientBu } state.egl_images << image; + + QMutexLocker locker(&state.texturesLock); state.textures[i] = nullptr; } } @@ -298,6 +285,50 @@ bool WaylandEglClientBufferIntegrationPrivate::ensureContext() return localContextNeeded; } + +void WaylandEglClientBufferIntegrationPrivate::setupBufferAndCleanup(BufferState *bs, QOpenGLTexture *texture, int plane) +{ + QMutexLocker locker(&bs->texturesLock); + + bs->textures[plane] = texture; + bs->texturesContext[plane] = QOpenGLContext::currentContext(); + + Q_ASSERT(bs->texturesContext[plane] != nullptr); + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO + << "(egl) creating a cleanup-lambda for QOpenGLContext::aboutToBeDestroyed!" + << ", texture: " << bs->textures[plane] + << ", ctx: " << (void*)bs->texturesContext[plane]; + + bs->texturesAboutToBeDestroyedConnection[plane] = + QObject::connect(bs->texturesContext[plane], &QOpenGLContext::aboutToBeDestroyed, + bs->texturesContext[plane], [bs, plane]() { + + QMutexLocker locker(&bs->texturesLock); + + // See above lock - there is a chance that this has already been removed from textures[plane]! + // Furthermore, we can trust that all the rest (e.g. disconnect) has also been properly executed! + if (bs->textures[plane] == nullptr) + return; + + delete bs->textures[plane]; + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO + << "texture deleted due to QOpenGLContext::aboutToBeDestroyed!" + << "Pointer (now dead) was:" << (void*)(bs->textures[plane]) + << " Associated context (about to die too) is: " << (void*)(bs->texturesContext[plane]); + + bs->textures[plane] = nullptr; + bs->texturesContext[plane] = nullptr; + + QObject::disconnect(bs->texturesAboutToBeDestroyedConnection[plane]); + bs->texturesAboutToBeDestroyedConnection[plane] = QMetaObject::Connection(); + + }, Qt::DirectConnection); +} + bool WaylandEglClientBufferIntegrationPrivate::initEglStream(WaylandEglClientBuffer *buffer, wl_resource *bufferHandle) { BufferState &state = *buffer->d; @@ -331,7 +362,11 @@ bool WaylandEglClientBufferIntegrationPrivate::initEglStream(WaylandEglClientBuf auto texture = new QOpenGLTexture(static_cast<QOpenGLTexture::Target>(GL_TEXTURE_EXTERNAL_OES)); texture->create(); - state.textures[0] = texture; // TODO: support multiple planes for the streaming case + setupBufferAndCleanup(buffer->d, texture, 0); + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << " NEW texture! It's pointer and ctx pointer: " + << (void*)state.textures[0] << "; " << (void*)state.texturesContext[0]; texture->bind(); @@ -375,13 +410,6 @@ void WaylandEglClientBufferIntegrationPrivate::handleEglstreamTexture(WaylandEgl localContext->doneCurrent(); } -void WaylandEglClientBufferIntegrationPrivate::deleteOrphanedTextures() -{ - Q_ASSERT(QOpenGLContext::currentContext()); - qDeleteAll(orphanedTextures); - orphanedTextures.clear(); -} - WaylandEglClientBufferIntegration::WaylandEglClientBufferIntegration() : d_ptr(new WaylandEglClientBufferIntegrationPrivate) { @@ -450,15 +478,8 @@ void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *di if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) { d->display_bound = d->egl_bind_wayland_display(d->egl_display, display); - if (!d->display_bound) { - if (!ignoreBindDisplay) { - qCWarning(qLcWaylandCompositorHardwareIntegration) - << "Failed to initialize EGL display. Could not bind Wayland display."; - return; - } else { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not bind Wayland display. Ignoring."; - } - } + if (!d->display_bound) + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Wayland display already bound by other client buffer integration."; d->wlDisplay = display; } @@ -504,9 +525,29 @@ WaylandEglClientBuffer::~WaylandEglClientBuffer() if (d->egl_stream) p->funcs->destroy_stream(p->egl_display, d->egl_stream); - for (auto *texture : d->textures) - p->deleteGLTextureWhenPossible(texture); } + + { + QMutexLocker locker(&d->texturesLock); + + for (int i=0; i<3; i++) { + if (d->textures[i] != nullptr) { + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO << " handing over texture!" + << (void*)d->textures[i] << "; " << (void*)d->texturesContext[i] + << " ... current context might be the same: " << QOpenGLContext::currentContext(); + + QtWayland::QWaylandTextureOrphanage::instance()->admitTexture( + d->textures[i], d->texturesContext[i]); + d->textures[i] = nullptr; // in case the aboutToBeDestroyed lambda is called while we where here + d->texturesContext[i] = nullptr; + QObject::disconnect(d->texturesAboutToBeDestroyedConnection[i]); + d->texturesAboutToBeDestroyedConnection[i] = QMetaObject::Connection(); + } + } + } + delete d; } @@ -549,7 +590,7 @@ QOpenGLTexture *WaylandEglClientBuffer::toOpenGlTexture(int plane) { auto *p = WaylandEglClientBufferIntegrationPrivate::get(m_integration); // At this point we should have a valid OpenGL context, so it's safe to destroy textures - p->deleteOrphanedTextures(); + QtWayland::QWaylandTextureOrphanage::instance()->deleteTextures(); if (!m_buffer) return nullptr; @@ -565,13 +606,18 @@ QOpenGLTexture *WaylandEglClientBuffer::toOpenGlTexture(int plane) texture->setFormat(openGLFormatFromEglFormat(d->egl_format)); texture->setSize(d->size.width(), d->size.height()); texture->create(); - d->textures[plane] = texture; + p->setupBufferAndCleanup(this->d, texture, plane); } if (m_textureDirty) { + m_textureDirty = false; texture->bind(); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); p->gl_egl_image_target_texture_2d(target, d->egl_images[plane]); +#ifdef GL_EXT_protected_textures + if (isProtected()) + glTexParameteri(target, GL_TEXTURE_PROTECTED_EXT, GL_TRUE); +#endif } return texture; } @@ -585,6 +631,15 @@ void WaylandEglClientBuffer::setCommitted(QRegion &damage) } } +bool WaylandEglClientBuffer::isProtected() +{ + if (m_integration && m_buffer) + return m_integration->isProtected(m_buffer); + + return false; +} + + QWaylandSurface::Origin WaylandEglClientBuffer::origin() const { return d->isYInverted ? QWaylandSurface::OriginTopLeft : QWaylandSurface::OriginBottomLeft; diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration_p.h index bbc0eafef..ca4dd3736 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration_p.h @@ -1,31 +1,16 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// #ifndef WAYLANDEGLINTEGRATION_H #define WAYLANDEGLINTEGRATION_H @@ -38,7 +23,7 @@ QT_BEGIN_NAMESPACE class WaylandEglClientBufferIntegrationPrivate; -class WaylandEglClientBufferIntegration : public QtWayland::ClientBufferIntegration +class Q_WAYLANDCOMPOSITOR_EXPORT WaylandEglClientBufferIntegration : public QtWayland::ClientBufferIntegration { Q_DECLARE_PRIVATE(WaylandEglClientBufferIntegration) public: @@ -56,9 +41,10 @@ private: struct BufferState; -class WaylandEglClientBuffer : public QtWayland::ClientBuffer +class Q_WAYLANDCOMPOSITOR_EXPORT WaylandEglClientBuffer : public QtWayland::ClientBuffer { public: + WaylandEglClientBuffer(WaylandEglClientBufferIntegration* integration, wl_resource *bufferResource); ~WaylandEglClientBuffer() override; QWaylandBufferRef::BufferFormatEgl bufferFormatEgl() const override; @@ -68,13 +54,12 @@ public: void unlockNativeBuffer(quintptr native_buffer) const override; QOpenGLTexture *toOpenGlTexture(int plane) override; void setCommitted(QRegion &damage) override; + bool isProtected() override; private: friend class WaylandEglClientBufferIntegration; friend class WaylandEglClientBufferIntegrationPrivate; - WaylandEglClientBuffer(WaylandEglClientBufferIntegration* integration, wl_resource *bufferResource); - BufferState *d = nullptr; WaylandEglClientBufferIntegration *m_integration = nullptr; }; diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.cpp b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.cpp index d2e0d52e7..c2689b2b2 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.cpp +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "waylandeglstreamcontroller.h" #include "waylandeglstreamintegration.h" diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.h b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.h index c4a1fa869..54db28250 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.h +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamcontroller.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WAYLANDEGLSTREAMCONTROLLER_H #define WAYLANDEGLSTREAMCONTROLLER_H diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp index 9bdf8eb5c..0924f0fd7 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "waylandeglstreamintegration.h" #include "waylandeglstreamcontroller.h" @@ -35,12 +9,14 @@ #include <QtGui/QGuiApplication> #include <QtGui/QOpenGLContext> #include <QtGui/QOffscreenSurface> +#include <QtCore/QMutexLocker> #include <QtGui/private/qeglstreamconvenience_p.h> #include <qpa/qplatformnativeinterface.h> #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> #include <QtWaylandCompositor/private/qwlbuffermanager_p.h> +#include <QtWaylandCompositor/private/qwltextureorphanage_p.h> #include <EGL/egl.h> #include <EGL/eglext.h> @@ -135,7 +111,11 @@ struct BufferState BufferState() = default; EGLint egl_format = EGL_TEXTURE_EXTERNAL_WL; - QOpenGLTexture *textures[3] = {}; + QOpenGLTexture *textures[3] = {nullptr, nullptr, nullptr}; + QOpenGLContext *texturesContext[3] = {nullptr, nullptr, nullptr}; + QMetaObject::Connection texturesAboutToBeDestroyedConnection[3] = {QMetaObject::Connection(), QMetaObject::Connection(), QMetaObject::Connection()}; + QMutex texturesLock; + EGLStreamKHR egl_stream = EGL_NO_STREAM_KHR; bool isYInverted = false; @@ -149,15 +129,14 @@ public: bool ensureContext(); bool initEglStream(WaylandEglStreamClientBuffer *buffer, struct ::wl_resource *bufferHandle); + void setupBufferAndCleanup(BufferState *bs, QOpenGLTexture *texture, int plane); void handleEglstreamTexture(WaylandEglStreamClientBuffer *buffer); - void deleteGLTextureWhenPossible(QOpenGLTexture *texture) { orphanedTextures << texture; } - void deleteOrphanedTextures(); EGLDisplay egl_display = EGL_NO_DISPLAY; bool display_bound = false; + ::wl_display *wlDisplay = nullptr; QOffscreenSurface *offscreenSurface = nullptr; QOpenGLContext *localContext = nullptr; - QList<QOpenGLTexture *> orphanedTextures; WaylandEglStreamController *eglStreamController = nullptr; @@ -175,13 +154,6 @@ public: bool WaylandEglStreamClientBufferIntegrationPrivate::shuttingDown = false; -void WaylandEglStreamClientBufferIntegrationPrivate::deleteOrphanedTextures() -{ - Q_ASSERT(QOpenGLContext::currentContext()); - qDeleteAll(orphanedTextures); - orphanedTextures.clear(); -} - bool WaylandEglStreamClientBufferIntegrationPrivate::ensureContext() { bool localContextNeeded = false; @@ -205,6 +177,49 @@ bool WaylandEglStreamClientBufferIntegrationPrivate::ensureContext() } +void WaylandEglStreamClientBufferIntegrationPrivate::setupBufferAndCleanup(BufferState *bs, QOpenGLTexture *texture, int plane) +{ + QMutexLocker locker(&bs->texturesLock); + + bs->textures[plane] = texture; + bs->texturesContext[plane] = QOpenGLContext::currentContext(); + + Q_ASSERT(bs->texturesContext[plane] != nullptr); + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO + << "(eglstream) creating a cleanup-lambda for QOpenGLContext::aboutToBeDestroyed!" + << ", texture: " << bs->textures[plane] + << ", ctx: " << (void*)bs->texturesContext[plane]; + + bs->texturesAboutToBeDestroyedConnection[plane] = + QObject::connect(bs->texturesContext[plane], &QOpenGLContext::aboutToBeDestroyed, + bs->texturesContext[plane], [bs, plane]() { + + QMutexLocker locker(&bs->texturesLock); + + // See above lock - there is a chance that this has already been removed from textures[plane]! + // Furthermore, we can trust that all the rest (e.g. disconnect) has also been properly executed! + if (bs->textures[plane] == nullptr) + return; + + delete bs->textures[plane]; + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO + << "texture deleted due to QOpenGLContext::aboutToBeDestroyed!" + << "Pointer (now dead) was:" << (void*)(bs->textures[plane]) + << " Associated context (about to die too) is: " << (void*)(bs->texturesContext[plane]); + + bs->textures[plane] = nullptr; + bs->texturesContext[plane] = nullptr; + + QObject::disconnect(bs->texturesAboutToBeDestroyedConnection[plane]); + bs->texturesAboutToBeDestroyedConnection[plane] = QMetaObject::Connection(); + + }, Qt::DirectConnection); +} + bool WaylandEglStreamClientBufferIntegrationPrivate::initEglStream(WaylandEglStreamClientBuffer *buffer, wl_resource *bufferHandle) { BufferState &state = *buffer->d; @@ -235,7 +250,7 @@ bool WaylandEglStreamClientBufferIntegrationPrivate::initEglStream(WaylandEglStr auto texture = new QOpenGLTexture(static_cast<QOpenGLTexture::Target>(GL_TEXTURE_EXTERNAL_OES)); texture->create(); - state.textures[0] = texture; // TODO: support multiple planes + setupBufferAndCleanup(buffer->d, texture, 0); texture->bind(); @@ -282,7 +297,13 @@ WaylandEglStreamClientBufferIntegration::WaylandEglStreamClientBufferIntegration WaylandEglStreamClientBufferIntegration::~WaylandEglStreamClientBufferIntegration() { + Q_D(WaylandEglStreamClientBufferIntegration); WaylandEglStreamClientBufferIntegrationPrivate::shuttingDown = true; + if (d->egl_unbind_wayland_display != nullptr && d->display_bound) { + Q_ASSERT(d->wlDisplay != nullptr); + if (!d->egl_unbind_wayland_display(d->egl_display, d->wlDisplay)) + qCWarning(qLcWaylandCompositorHardwareIntegration) << "eglUnbindWaylandDisplayWL failed"; + } } void WaylandEglStreamClientBufferIntegration::attachEglStreamConsumer(struct ::wl_resource *wl_surface, struct ::wl_resource *wl_buffer) @@ -336,14 +357,10 @@ void WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_displ if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) { d->display_bound = d->egl_bind_wayland_display(d->egl_display, display); - if (!d->display_bound) { - if (!ignoreBindDisplay) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not bind Wayland display."); - return; - } else { - qWarning("QtCompositor: Could not bind Wayland display. Ignoring."); - } - } + if (!d->display_bound) + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Wayland display already bound by other client buffer integration."; + + d->wlDisplay = display; } d->eglStreamController = new WaylandEglStreamController(display, this); @@ -382,10 +399,29 @@ WaylandEglStreamClientBuffer::~WaylandEglStreamClientBuffer() if (p) { if (d->egl_stream) p->funcs->destroy_stream(p->egl_display, d->egl_stream); + } + + { + QMutexLocker locker(&d->texturesLock); + + for (int i=0; i<3; i++) { + if (d->textures[i] != nullptr) { + + qCDebug(qLcWaylandCompositorHardwareIntegration) + << Q_FUNC_INFO << " handing over texture!" + << (void*)d->textures[i] << "; " << (void*)d->texturesContext[i] + << " ... current context might be the same: " << QOpenGLContext::currentContext(); - for (auto *texture : d->textures) - p->deleteGLTextureWhenPossible(texture); + QtWayland::QWaylandTextureOrphanage::instance()->admitTexture( + d->textures[i], d->texturesContext[i]); + d->textures[i] = nullptr; // in case the aboutToBeDestroyed lambda is called while we where here + d->texturesContext[i] = nullptr; + QObject::disconnect(d->texturesAboutToBeDestroyedConnection[i]); + d->texturesAboutToBeDestroyedConnection[i] = QMetaObject::Connection(); + } + } } + delete d; } @@ -408,9 +444,8 @@ QWaylandSurface::Origin WaylandEglStreamClientBuffer::origin() const QOpenGLTexture *WaylandEglStreamClientBuffer::toOpenGlTexture(int plane) { - auto *p = WaylandEglStreamClientBufferIntegrationPrivate::get(m_integration); // At this point we should have a valid OpenGL context, so it's safe to destroy textures - p->deleteOrphanedTextures(); + QtWayland::QWaylandTextureOrphanage::instance()->deleteTextures(); if (!m_buffer) return nullptr; diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h index 4c4cce257..3f4f7f27a 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.h @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WAYLANDEGLSTREAMINTEGRATION_H #define WAYLANDEGLSTREAMINTEGRATION_H diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri b/src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri deleted file mode 100644 index 6d0f81659..000000000 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.pri +++ /dev/null @@ -1,11 +0,0 @@ -include($$PWD/../xcomposite_share/xcomposite_share.pri) - -QMAKE_USE_PRIVATE += egl wayland-server x11 - -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/xcompositeeglintegration.h - -SOURCES += \ - $$PWD/xcompositeeglintegration.cpp diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp deleted file mode 100644 index 770656c23..000000000 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositeeglintegration.h" - -#include "wayland-xcomposite-server-protocol.h" - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtOpenGL/QOpenGLTexture> -#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> - -QT_BEGIN_NAMESPACE - -QList<EGLint> eglbuildSpec() -{ - QList<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; -} - -XCompositeEglClientBufferIntegration::XCompositeEglClientBufferIntegration() -{ - -} - -void XCompositeEglClientBufferIntegration::initializeHardware(struct ::wl_display *) -{ - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - if (nativeInterface) { - mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForIntegration("Display")); - if (!mDisplay) - qFatal("could not retrieve Display from platform integration"); - mEglDisplay = static_cast<EGLDisplay>(nativeInterface->nativeResourceForIntegration("EGLDisplay")); - if (!mEglDisplay) - qFatal("could not retrieve EGLDisplay from platform integration"); - } else { - qFatal("Platform integration doesn't have native interface"); - } - mHandler = new XCompositeHandler(m_compositor, mDisplay); -} - -QtWayland::ClientBuffer *XCompositeEglClientBufferIntegration::createBufferFor(wl_resource *buffer) -{ - if (!mHandler->isXCompositeBuffer(buffer)) - return nullptr; - return new XCompositeEglClientBuffer(this, buffer); -} - - -XCompositeEglClientBuffer::XCompositeEglClientBuffer(XCompositeEglClientBufferIntegration *integration, wl_resource *bufferResource) - : QtWayland::ClientBuffer(bufferResource) - , m_integration(integration) -{ -} - -QOpenGLTexture *XCompositeEglClientBuffer::toOpenGlTexture(int plane) -{ - Q_UNUSED(plane); - XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer); - Pixmap pixmap = XCompositeNameWindowPixmap(m_integration->xDisplay(), compositorBuffer->window()); - - QList<EGLint> eglConfigSpec = eglbuildSpec(); - - EGLint matching = 0; - EGLConfig config; - bool matched = eglChooseConfig(m_integration->eglDisplay(),eglConfigSpec.constData(),&config,1,&matching); - if (!matched || !matching) { - qWarning("Could not retrieve a suitable EGL config"); - return nullptr; - } - - QList<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(m_integration->eglDisplay(), config, reinterpret_cast<EGLNativePixmapType>(pixmap), attribList.constData()); - if (surface == EGL_NO_SURFACE) { - qDebug() << "Failed to create eglsurface" << pixmap << compositorBuffer->window(); - } - - compositorBuffer->setOrigin(QWaylandSurface::OriginTopLeft); - - if (!m_texture) { - m_texture = new QOpenGLTexture(QOpenGLTexture::Target2D); - m_texture->create(); - } - m_texture->bind(); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - if (!eglBindTexImage(m_integration->eglDisplay(),surface,EGL_BACK_BUFFER)) { - qWarning() << "Failed to bind"; - } - - // eglDestroySurface(mEglDisplay,surface); - return m_texture; -} - - -QWaylandSurface::Origin XCompositeEglClientBuffer::origin() const -{ - XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer); - return compositorBuffer->origin(); -} - -QSize XCompositeEglClientBuffer::size() const -{ - XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer); - - return compositorBuffer->size(); -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h deleted file mode 100644 index ae7354f8a..000000000 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEEGLINTEGRATION_H -#define XCOMPOSITEEGLINTEGRATION_H - -#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h> - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/private/qwlclientbuffer_p.h> -#include "xlibinclude.h" - -#include <EGL/egl.h> - -QT_BEGIN_NAMESPACE - -class XCompositeHandler; - -class XCompositeEglClientBufferIntegration : public QtWayland::ClientBufferIntegration -{ -public: - XCompositeEglClientBufferIntegration(); - - void initializeHardware(struct ::wl_display *display) override; - QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; - inline Display *xDisplay() const { return mDisplay; } - inline EGLDisplay eglDisplay() const { return mEglDisplay; } - -private: - Display *mDisplay = nullptr; - EGLDisplay mEglDisplay = EGL_NO_DISPLAY; - XCompositeHandler *mHandler = nullptr; -}; - -class XCompositeEglClientBuffer : public QtWayland::ClientBuffer -{ -public: - XCompositeEglClientBuffer(XCompositeEglClientBufferIntegration *integration, wl_resource *bufferResource); - - QSize size() const override; - QWaylandSurface::Origin origin() const override; - QOpenGLTexture *toOpenGlTexture(int plane) override; - QWaylandBufferRef::BufferFormatEgl bufferFormatEgl() const override { - return QWaylandBufferRef::BufferFormatEgl_RGBA; - } - -private: - QOpenGLTexture *m_texture = nullptr; - XCompositeEglClientBufferIntegration *m_integration = nullptr; -}; - -QT_END_NAMESPACE - -#endif // XCOMPOSITEEGLINTEGRATION_H diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri b/src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri deleted file mode 100644 index c02c873a6..000000000 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.pri +++ /dev/null @@ -1,11 +0,0 @@ -include($$PWD/../xcomposite_share/xcomposite_share.pri) - -QMAKE_USE_PRIVATE += wayland-server xlib - -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/xcompositeglxintegration.h - -SOURCES += \ - $$PWD/xcompositeglxintegration.cpp diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp deleted file mode 100644 index b8415e88f..000000000 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositeglxintegration.h" - -#include "wayland-xcomposite-server-protocol.h" - -#include <qpa/qplatformnativeinterface.h> -#include <qpa/qplatformintegration.h> -#include <QtOpenGL/QOpenGLTexture> -#include <QtGui/QOpenGLContext> - -#include "xcompositebuffer.h" -#include "xcompositehandler.h" -#include <X11/extensions/Xcomposite.h> - -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -QList<int> qglx_buildSpec() -{ - QList<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; -} - - -XCompositeGLXClientBufferIntegration::XCompositeGLXClientBufferIntegration() -{ - qDebug() << "Loading GLX integration"; -} - -XCompositeGLXClientBufferIntegration::~XCompositeGLXClientBufferIntegration() -{ - delete mHandler; -} - -void XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_display *) -{ - qDebug() << "Initializing GLX integration"; - QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface(); - if (nativeInterface) { - mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForIntegration("Display")); - if (!mDisplay) - qFatal("could not retrieve Display from platform integration"); - } else { - qFatal("Platform integration doesn't have native interface"); - } - mScreen = XDefaultScreen(mDisplay); - - mHandler = new XCompositeHandler(m_compositor, mDisplay); - - 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; -} - -QtWayland::ClientBuffer *XCompositeGLXClientBufferIntegration::createBufferFor(wl_resource *buffer) -{ - if (!mHandler->isXCompositeBuffer(buffer)) - return nullptr; - return new XCompositeGLXClientBuffer(this, buffer); -} - -XCompositeGLXClientBuffer::XCompositeGLXClientBuffer(XCompositeGLXClientBufferIntegration *integration, wl_resource *bufferResource) - : QtWayland::ClientBuffer(bufferResource) - , m_integration(integration) -{ -} - - -QOpenGLTexture *XCompositeGLXClientBuffer::toOpenGlTexture(int plane) -{ - Q_UNUSED(plane); - XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer); - Pixmap pixmap = XCompositeNameWindowPixmap(m_integration->xDisplay(), compositorBuffer->window()); - - QList<int> glxConfigSpec = qglx_buildSpec(); - int numberOfConfigs; - GLXFBConfig *configs = glXChooseFBConfig(m_integration->xDisplay(),m_integration->xScreen(),glxConfigSpec.constData(),&numberOfConfigs); - - QList<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); - - if (!m_glxPixmap) - m_glxPixmap = glXCreatePixmap(m_integration->xDisplay(), *configs, pixmap, attribList.constData()); - - uint inverted = 0; - glXQueryDrawable(m_integration->xDisplay(), m_glxPixmap, GLX_Y_INVERTED_EXT,&inverted); - compositorBuffer->setOrigin(inverted ? QWaylandSurface::OriginBottomLeft : QWaylandSurface::OriginTopLeft); - - XFree(configs); - auto tex = m_texture; - if (!m_texture) { - tex = new QOpenGLTexture(QOpenGLTexture::Target2D); - tex->create(); - m_texture = tex; - } - tex->bind(); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - m_integration->m_glxBindTexImageEXT(m_integration->xDisplay(),m_glxPixmap,GLX_FRONT_EXT, nullptr); - - // TODO: release in the destructor? - // m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT); - return tex; -} - - -QWaylandSurface::Origin XCompositeGLXClientBuffer::origin() const -{ - XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer); - return compositorBuffer->origin(); -} - -QSize XCompositeGLXClientBuffer::size() const -{ - XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(m_buffer); - - return compositorBuffer->size(); -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h deleted file mode 100644 index e783d41bf..000000000 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEGLXINTEGRATION_H -#define XCOMPOSITEGLXINTEGRATION_H - -#include <QtWaylandCompositor/private/qwlclientbufferintegration_p.h> -#include <QtWaylandCompositor/private/qwlclientbuffer_p.h> -#include "xlibinclude.h" - -#define GLX_GLXEXT_PROTOTYPES -#include <GL/glx.h> -#include <GL/glxext.h> - -QT_BEGIN_NAMESPACE - -class XCompositeHandler; - -class XCompositeGLXClientBufferIntegration : public QtWayland::ClientBufferIntegration -{ -public: - XCompositeGLXClientBufferIntegration(); - ~XCompositeGLXClientBufferIntegration() override; - - void initializeHardware(struct ::wl_display *display) override; - QtWayland::ClientBuffer *createBufferFor(wl_resource *buffer) override; - - inline Display *xDisplay() const { return mDisplay; } - inline int xScreen() const { return mScreen; } - - PFNGLXBINDTEXIMAGEEXTPROC m_glxBindTexImageEXT; - PFNGLXRELEASETEXIMAGEEXTPROC m_glxReleaseTexImageEXT; - -private: - Display *mDisplay = nullptr; - int mScreen; - XCompositeHandler *mHandler = nullptr; -}; - -class XCompositeGLXClientBuffer : public QtWayland::ClientBuffer -{ -public: - XCompositeGLXClientBuffer(XCompositeGLXClientBufferIntegration *integration, wl_resource *bufferResource); - - QSize size() const override; - QWaylandSurface::Origin origin() const override; - QOpenGLTexture *toOpenGlTexture(int plane) override; - QWaylandBufferRef::BufferFormatEgl bufferFormatEgl() const override { - return QWaylandBufferRef::BufferFormatEgl_RGBA; - } - -private: - QOpenGLTexture *m_texture = nullptr; - XCompositeGLXClientBufferIntegration *m_integration = nullptr; - GLXPixmap m_glxPixmap = 0; -}; - -QT_END_NAMESPACE - -#endif // XCOMPOSITEGLXINTEGRATION_H diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri b/src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri deleted file mode 100644 index 69ab6aa10..000000000 --- a/src/hardwareintegration/compositor/xcomposite_share/xcomposite_share.pri +++ /dev/null @@ -1,16 +0,0 @@ -INCLUDEPATH += $$PWD - -QMAKE_USE += xcomposite -CONFIG += wayland-scanner -WAYLANDSERVERSOURCES += $$PWD/../../../extensions/xcomposite.xml $$PWD/../../../3rdparty/protocol/wayland.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/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp deleted file mode 100644 index b79a713a1..000000000 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositehandler.h" -#include "xcompositebuffer.h" - -QT_BEGIN_NAMESPACE - -XCompositeBuffer::XCompositeBuffer(Window window, const QSize &size, - struct ::wl_client *client, uint32_t id, XCompositeHandler *handler) - : QtWaylandServer::wl_buffer(client, id, 1) - , mWindow(window) - , mOrigin(QWaylandSurface::OriginBottomLeft) - , mSize(size) - , mHandler(handler) -{ -} - -void XCompositeBuffer::buffer_destroy_resource(Resource *resource) -{ - mHandler->removeBuffer(resource->handle); - delete this; -} - -void XCompositeBuffer::buffer_destroy(Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -Window XCompositeBuffer::window() -{ - return mWindow; -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h deleted file mode 100644 index 0e6e63457..000000000 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEBUFFER_H -#define XCOMPOSITEBUFFER_H - -#include <qwayland-server-wayland.h> - -#include <QtWaylandCompositor/private/qwaylandutils_p.h> - -#include <QtWaylandCompositor/QWaylandSurface> -#include <QtWaylandCompositor/QWaylandCompositor> - -#include <QtCore/QSize> - -#include <QtCore/QTextStream> -#include <QtCore/QDataStream> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> - -#include <X11/X.h> - -QT_BEGIN_NAMESPACE - -class XCompositeHandler; - -class XCompositeBuffer : public QtWaylandServer::wl_buffer -{ -public: - XCompositeBuffer(Window window, const QSize &size, - struct ::wl_client *client, uint32_t id, XCompositeHandler *handler); - - Window window(); - - QWaylandSurface::Origin origin() const { return mOrigin; } - void setOrigin(QWaylandSurface::Origin origin) { mOrigin = origin; } - - QSize size() const { return mSize; } - - static XCompositeBuffer *fromResource(struct ::wl_resource *resource) { return QtWayland::fromResource<XCompositeBuffer *>(resource); } - -protected: - void buffer_destroy_resource(Resource *) override; - void buffer_destroy(Resource *) override; - -private: - Window mWindow; - QWaylandSurface::Origin mOrigin; - QSize mSize; - XCompositeHandler *mHandler = nullptr; -}; - -QT_END_NAMESPACE - -#endif // XCOMPOSITORBUFFER_H diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp deleted file mode 100644 index c4e2d2264..000000000 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "xcompositehandler.h" - -#include "wayland-xcomposite-server-protocol.h" - -#include "xcompositebuffer.h" -#include <X11/extensions/Xcomposite.h> - -QT_BEGIN_NAMESPACE - -XCompositeHandler::XCompositeHandler(QWaylandCompositor *compositor, Display *display) - : QtWaylandServer::qt_xcomposite(compositor->display(), 1) -{ - mFakeRootWindow = new QWindow(); - mFakeRootWindow->setGeometry(QRect(-1,-1,1,1)); - mFakeRootWindow->create(); - mFakeRootWindow->show(); - - int composite_event_base, composite_error_base; - if (!XCompositeQueryExtension(display, &composite_event_base, &composite_error_base)) - qFatal("XComposite required"); - - mDisplayString = QString::fromLocal8Bit(XDisplayString(display)); -} - -void XCompositeHandler::xcomposite_bind_resource(Resource *resource) -{ - send_root(resource->handle, mDisplayString, mFakeRootWindow->winId()); -} - -void XCompositeHandler::xcomposite_create_buffer(Resource *resource, uint32_t id, uint32_t window, - int32_t width, int32_t height) -{ - auto *buf = new XCompositeBuffer(Window(window), QSize(width, height), resource->client(), id, this); - mKnownBuffers.insert(buf->resource()->handle); -} - -QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h deleted file mode 100644 index 4f7dc406c..000000000 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef XCOMPOSITEHANDLER_H -#define XCOMPOSITEHANDLER_H - -#include <QtWaylandCompositor/QWaylandCompositor> - -#include "xlibinclude.h" - -#include "qwayland-server-xcomposite.h" -#include <wayland-server-core.h> - -QT_BEGIN_NAMESPACE - -class XCompositeHandler : public QtWaylandServer::qt_xcomposite -{ -public: - XCompositeHandler(QWaylandCompositor *compositor, Display *display); - bool isXCompositeBuffer(wl_resource *resource) { return mKnownBuffers.contains(resource); } - void removeBuffer(wl_resource *resource) { mKnownBuffers.remove(resource); } - -private: - QWindow *mFakeRootWindow = nullptr; - QString mDisplayString; - QSet<wl_resource *> mKnownBuffers; - - void xcomposite_bind_resource(Resource *resource) override; - void xcomposite_create_buffer(Resource *resource, uint32_t id, uint32_t x_window, - int32_t width, int32_t height) override; -}; - -QT_END_NAMESPACE - -#endif // XCOMPOSITEHANDLER_H diff --git a/src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h b/src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h deleted file mode 100644 index ca3542aaa..000000000 --- a/src/hardwareintegration/compositor/xcomposite_share/xlibinclude.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $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 |