From e48d9df14f3099065c990e4d20287d7e2b022a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Thu, 14 Feb 2019 17:45:03 +0100 Subject: [PATCH] [qpa] Drop PlatformContextWayland which uses wayland egl for OpenGL Summary: Using the Wayland protocol for OpenGL is no longer used or useful. KWin internal windows only use OpenGL through QtQuick. We either have the sharing context (KWin uses OpenGL for compositing) or we have the QPainter compositor which also turns QtQuick to use software renderer. Thus a situation where the Wayland platform context is useful doesn't exist any more. Removing it helps getting the QPA plugin Wayland free. Test Plan: Run nested KWin triggering Outline once with OpenGL and once with QPainter compositor. Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D19012 --- plugins/qpa/CMakeLists.txt | 5 -- plugins/qpa/integration.cpp | 41 +------------- plugins/qpa/integration.h | 1 - plugins/qpa/platformcontextwayland.cpp | 77 -------------------------- plugins/qpa/platformcontextwayland.h | 49 ---------------- plugins/qpa/window.cpp | 29 ---------- plugins/qpa/window.h | 16 ------ 7 files changed, 1 insertion(+), 217 deletions(-) delete mode 100644 plugins/qpa/platformcontextwayland.cpp delete mode 100644 plugins/qpa/platformcontextwayland.h diff --git a/plugins/qpa/CMakeLists.txt b/plugins/qpa/CMakeLists.txt index 8da7465877..71077e50c4 100644 --- a/plugins/qpa/CMakeLists.txt +++ b/plugins/qpa/CMakeLists.txt @@ -7,7 +7,6 @@ set(QPA_SOURCES integration.cpp main.cpp nativeinterface.cpp - platformcontextwayland.cpp platformcursor.cpp screen.cpp sharingplatformcontext.cpp @@ -34,10 +33,6 @@ target_link_libraries(KWinQpaPlugin ${FREETYPE_LIBRARIES} ) -if(HAVE_WAYLAND_EGL) - target_link_libraries(KWinQpaPlugin Wayland::Egl) -endif() - install( TARGETS KWinQpaPlugin diff --git a/plugins/qpa/integration.cpp b/plugins/qpa/integration.cpp index 49459ab930..4bf5fb8bef 100644 --- a/plugins/qpa/integration.cpp +++ b/plugins/qpa/integration.cpp @@ -22,7 +22,6 @@ along with this program. If not, see . #include "platform.h" #include "backingstore.h" #include "nativeinterface.h" -#include "platformcontextwayland.h" #include "screen.h" #include "sharingplatformcontext.h" #include "window.h" @@ -192,13 +191,7 @@ QPlatformOpenGLContext *Integration::createPlatformOpenGLContext(QOpenGLContext return new SharingPlatformContext(context, s, kwinApp()->platform()->sceneEglConfig()); } } - if (m_eglDisplay == EGL_NO_DISPLAY) { - const_cast(this)->initEgl(); - } - if (m_eglDisplay == EGL_NO_DISPLAY) { - return nullptr; - } - return new PlatformContextWayland(context, const_cast(this)); + return nullptr; } void Integration::initScreens() @@ -252,38 +245,6 @@ EGLDisplay Integration::eglDisplay() const return m_eglDisplay; } -void Integration::initEgl() -{ - Q_ASSERT(m_eglDisplay == EGL_NO_DISPLAY); - // This variant uses Wayland as the EGL platform - qputenv("EGL_PLATFORM", "wayland"); - m_eglDisplay = eglGetDisplay(waylandServer()->internalClientConection()->display()); - if (m_eglDisplay == EGL_NO_DISPLAY) { - return; - } - // call eglInitialize in a thread to not block - QFuture future = QtConcurrent::run([this] () -> bool { - EGLint major, minor; - if (eglInitialize(m_eglDisplay, &major, &minor) == EGL_FALSE) { - return false; - } - EGLint error = eglGetError(); - if (error != EGL_SUCCESS) { - return false; - } - return true; - }); - // TODO: make this better - while (!future.isFinished()) { - waylandServer()->internalClientConection()->flush(); - QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); - } - if (!future.result()) { - eglTerminate(m_eglDisplay); - m_eglDisplay = EGL_NO_DISPLAY; - } -} - QPlatformInputContext *Integration::inputContext() const { return m_inputContext.data(); diff --git a/plugins/qpa/integration.h b/plugins/qpa/integration.h index d8bf6bcbec..708c751a66 100644 --- a/plugins/qpa/integration.h +++ b/plugins/qpa/integration.h @@ -69,7 +69,6 @@ public: private: void initScreens(); - void initEgl(); KWayland::Client::Shell *shell() const; QPlatformFontDatabase *m_fontDb; diff --git a/plugins/qpa/platformcontextwayland.cpp b/plugins/qpa/platformcontextwayland.cpp deleted file mode 100644 index f43ae9f792..0000000000 --- a/plugins/qpa/platformcontextwayland.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************** - KWin - the KDE window manager - This file is part of the KDE project. - -Copyright (C) 2015 Martin Gräßlin - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*********************************************************************/ -#include "platformcontextwayland.h" -#include "integration.h" -#include "window.h" - -namespace KWin -{ - -namespace QPA -{ - -PlatformContextWayland::PlatformContextWayland(QOpenGLContext *context, Integration *integration) - : AbstractPlatformContext(context, integration, integration->eglDisplay()) -{ - create(); -} - -bool PlatformContextWayland::makeCurrent(QPlatformSurface *surface) -{ - Window *window = static_cast(surface); - EGLSurface s = window->eglSurface(); - if (s == EGL_NO_SURFACE) { - window->createEglSurface(eglDisplay(), config()); - s = window->eglSurface(); - if (s == EGL_NO_SURFACE) { - return false; - } - } - return eglMakeCurrent(eglDisplay(), s, s, eglContext()); -} - -bool PlatformContextWayland::isSharing() const -{ - return false; -} - -void PlatformContextWayland::swapBuffers(QPlatformSurface *surface) -{ - Window *window = static_cast(surface); - EGLSurface s = window->eglSurface(); - if (s == EGL_NO_SURFACE) { - return; - } - eglSwapBuffers(eglDisplay(), s); -} - -void PlatformContextWayland::create() -{ - if (config() == 0) { - return; - } - if (!bindApi()) { - return; - } - createContext(); -} - -} -} diff --git a/plugins/qpa/platformcontextwayland.h b/plugins/qpa/platformcontextwayland.h deleted file mode 100644 index fbf7c210e1..0000000000 --- a/plugins/qpa/platformcontextwayland.h +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************** - KWin - the KDE window manager - This file is part of the KDE project. - -Copyright (C) 2015 Martin Gräßlin - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*********************************************************************/ -#ifndef KWIN_QPA_PLATFORMCONTEXTWAYLAND_H -#define KWIN_QPA_PLATFORMCONTEXTWAYLAND_H - -#include "abstractplatformcontext.h" - -namespace KWin -{ -namespace QPA -{ -class Integration; - -class PlatformContextWayland : public AbstractPlatformContext -{ -public: - explicit PlatformContextWayland(QOpenGLContext *context, Integration *integration); - - void swapBuffers(QPlatformSurface *surface) override; - - bool makeCurrent(QPlatformSurface *surface) override; - - bool isSharing() const override; - -private: - void create(); -}; - -} -} - -#endif diff --git a/plugins/qpa/window.cpp b/plugins/qpa/window.cpp index 04deadbe8b..8b0717321a 100644 --- a/plugins/qpa/window.cpp +++ b/plugins/qpa/window.cpp @@ -17,7 +17,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -#define WL_EGL_PLATFORM 1 #include "integration.h" #include "window.h" #include "screens.h" @@ -57,14 +56,6 @@ Window::Window(QWindow *window, KWayland::Client::Surface *surface, KWayland::Cl Window::~Window() { unmap(); - if (m_eglSurface != EGL_NO_SURFACE) { - eglDestroySurface(m_integration->eglDisplay(), m_eglSurface); - } -#if HAVE_WAYLAND_EGL - if (m_eglWaylandWindow) { - wl_egl_window_destroy(m_eglWaylandWindow); - } -#endif delete m_shellSurface; delete m_surface; } @@ -106,11 +97,6 @@ void Window::setGeometry(const QRect &rect) m_resized = true; } } -#if HAVE_WAYLAND_EGL - if (m_eglWaylandWindow) { - wl_egl_window_resize(m_eglWaylandWindow, nativeSize.width(), nativeSize.height(), 0, 0); - } -#endif QWindowSystemInterface::handleGeometryChange(window(), geometry()); } @@ -128,21 +114,6 @@ void Window::unmap() } } -void Window::createEglSurface(EGLDisplay dpy, EGLConfig config) -{ -#if HAVE_WAYLAND_EGL - const QSize size = window()->size() * m_scale; - m_eglWaylandWindow = wl_egl_window_create(*m_surface, size.width(), size.height()); - if (!m_eglWaylandWindow) { - return; - } - m_eglSurface = eglCreateWindowSurface(dpy, config, m_eglWaylandWindow, nullptr); -#else - Q_UNUSED(dpy) - Q_UNUSED(config) -#endif -} - void Window::bindContentFBO() { if (m_resized || !m_contentFBO) { diff --git a/plugins/qpa/window.h b/plugins/qpa/window.h index bc334c359c..f430195355 100644 --- a/plugins/qpa/window.h +++ b/plugins/qpa/window.h @@ -25,17 +25,9 @@ along with this program. If not, see . #include #include -// wayland -#include -#if HAVE_WAYLAND_EGL -#include -#endif class QOpenGLFramebufferObject; -#if HAVE_WAYLAND_EGL -struct wl_egl_window; -#endif namespace KWayland { @@ -69,10 +61,6 @@ public: KWayland::Client::Surface *surface() const { return m_surface; } - EGLSurface eglSurface() const { - return m_eglSurface; - } - void createEglSurface(EGLDisplay dpy, EGLConfig config); int scale() const; qreal devicePixelRatio() const override; @@ -90,13 +78,9 @@ private: KWayland::Client::Surface *m_surface; KWayland::Client::ShellSurface *m_shellSurface; - EGLSurface m_eglSurface = EGL_NO_SURFACE; QSharedPointer m_contentFBO; bool m_resized = false; ShellClient *m_shellClient = nullptr; -#if HAVE_WAYLAND_EGL - wl_egl_window *m_eglWaylandWindow = nullptr; -#endif quint32 m_windowId; const Integration *m_integration; int m_scale = 1;