From 01ddbe7d751ab2f31a2698fc236713530c1631ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 3 Sep 2017 10:26:20 +0200 Subject: [PATCH] Make AbstractEglBackend a QObject Summary: Several of the subclasses are already derived from QObject. The main reason is that the class should be moved out of KWin core in order to move the OpenGL scene into a plugin. As Compositor calls into the AbstractEglBackend to unbind the wayland display this creates a problem which is easily solved by turning the AbstractEglBackend into a QObject and connect to the signal emitted by the Compositor. Test Plan: Compiles Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7669 --- abstract_egl_backend.cpp | 10 ++++++---- abstract_egl_backend.h | 7 ++++--- composite.cpp | 2 -- plugins/platforms/drm/egl_gbm_backend.cpp | 3 +-- plugins/platforms/drm/egl_gbm_backend.h | 2 +- plugins/platforms/virtual/egl_gbm_backend.cpp | 3 +-- plugins/platforms/virtual/egl_gbm_backend.h | 3 +-- plugins/platforms/wayland/egl_wayland_backend.cpp | 3 +-- plugins/platforms/wayland/egl_wayland_backend.h | 2 +- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/abstract_egl_backend.cpp b/abstract_egl_backend.cpp index 85b42b9496..209d372614 100644 --- a/abstract_egl_backend.cpp +++ b/abstract_egl_backend.cpp @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "abstract_egl_backend.h" +#include "composite.h" #include "egl_context_attribute_builder.h" #include "options.h" #include "platform.h" @@ -54,17 +55,18 @@ eglQueryWaylandBufferWL_func eglQueryWaylandBufferWL = nullptr; #endif AbstractEglBackend::AbstractEglBackend() - : OpenGLBackend() + : QObject(nullptr) + , OpenGLBackend() { + connect(Compositor::self(), &Compositor::aboutToDestroy, this, &AbstractEglBackend::unbindWaylandDisplay); } AbstractEglBackend::~AbstractEglBackend() = default; void AbstractEglBackend::unbindWaylandDisplay() { - auto display = kwinApp()->platform()->sceneEglDisplay(); - if (eglUnbindWaylandDisplayWL && display != EGL_NO_DISPLAY) { - eglUnbindWaylandDisplayWL(display, *(WaylandServer::self()->display())); + if (eglUnbindWaylandDisplayWL && m_display != EGL_NO_DISPLAY) { + eglUnbindWaylandDisplayWL(m_display, *(WaylandServer::self()->display())); } } diff --git a/abstract_egl_backend.h b/abstract_egl_backend.h index 6d11f36841..35b4f3bb90 100644 --- a/abstract_egl_backend.h +++ b/abstract_egl_backend.h @@ -29,8 +29,9 @@ class QOpenGLFramebufferObject; namespace KWin { -class KWIN_EXPORT AbstractEglBackend : public OpenGLBackend +class KWIN_EXPORT AbstractEglBackend : public QObject, public OpenGLBackend { + Q_OBJECT public: virtual ~AbstractEglBackend(); bool makeCurrent() override; @@ -49,8 +50,6 @@ public: return m_config; } - static void unbindWaylandDisplay(); - protected: AbstractEglBackend(); void setEglDisplay(const EGLDisplay &display); @@ -69,6 +68,8 @@ protected: bool createContext(); private: + void unbindWaylandDisplay(); + EGLDisplay m_display = EGL_NO_DISPLAY; EGLSurface m_surface = EGL_NO_SURFACE; EGLContext m_context = EGL_NO_CONTEXT; diff --git a/composite.cpp b/composite.cpp index 9c5d9e4412..767f0850db 100644 --- a/composite.cpp +++ b/composite.cpp @@ -19,7 +19,6 @@ along with this program. If not, see . *********************************************************************/ #include "composite.h" -#include "abstract_egl_backend.h" #include "dbusinterface.h" #include "utils.h" #include @@ -146,7 +145,6 @@ Compositor::Compositor(QObject* workspace) Compositor::~Compositor() { emit aboutToDestroy(); - AbstractEglBackend::unbindWaylandDisplay(); finish(); deleteUnusedSupportProperties(); delete cm_selection; diff --git a/plugins/platforms/drm/egl_gbm_backend.cpp b/plugins/platforms/drm/egl_gbm_backend.cpp index a1d722857d..646e775666 100644 --- a/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/plugins/platforms/drm/egl_gbm_backend.cpp @@ -36,8 +36,7 @@ namespace KWin { EglGbmBackend::EglGbmBackend(DrmBackend *b) - : QObject(NULL) - , AbstractEglBackend() + : AbstractEglBackend() , m_backend(b) { // Egl is always direct rendering diff --git a/plugins/platforms/drm/egl_gbm_backend.h b/plugins/platforms/drm/egl_gbm_backend.h index f43a75c0d8..30e17e6824 100644 --- a/plugins/platforms/drm/egl_gbm_backend.h +++ b/plugins/platforms/drm/egl_gbm_backend.h @@ -33,7 +33,7 @@ class DrmOutput; /** * @brief OpenGL Backend using Egl on a GBM surface. **/ -class EglGbmBackend : public QObject, public AbstractEglBackend +class EglGbmBackend : public AbstractEglBackend { Q_OBJECT public: diff --git a/plugins/platforms/virtual/egl_gbm_backend.cpp b/plugins/platforms/virtual/egl_gbm_backend.cpp index 6e676f3fcb..f009003ced 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.cpp +++ b/plugins/platforms/virtual/egl_gbm_backend.cpp @@ -42,8 +42,7 @@ namespace KWin { EglGbmBackend::EglGbmBackend(VirtualBackend *b) - : QObject(nullptr) - , AbstractEglBackend() + : AbstractEglBackend() , m_backend(b) { // Egl is always direct rendering diff --git a/plugins/platforms/virtual/egl_gbm_backend.h b/plugins/platforms/virtual/egl_gbm_backend.h index 409fafbc40..b4560ed259 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.h +++ b/plugins/platforms/virtual/egl_gbm_backend.h @@ -31,9 +31,8 @@ class GLRenderTarget; /** * @brief OpenGL Backend using Egl on a GBM surface. **/ -class EglGbmBackend : public QObject, public AbstractEglBackend +class EglGbmBackend : public AbstractEglBackend { - Q_OBJECT public: EglGbmBackend(VirtualBackend *b); virtual ~EglGbmBackend(); diff --git a/plugins/platforms/wayland/egl_wayland_backend.cpp b/plugins/platforms/wayland/egl_wayland_backend.cpp index 1c3910ff8a..3107780f3e 100644 --- a/plugins/platforms/wayland/egl_wayland_backend.cpp +++ b/plugins/platforms/wayland/egl_wayland_backend.cpp @@ -39,8 +39,7 @@ namespace KWin { EglWaylandBackend::EglWaylandBackend(Wayland::WaylandBackend *b) - : QObject(NULL) - , AbstractEglBackend() + : AbstractEglBackend() , m_bufferAge(0) , m_wayland(b) , m_overlay(NULL) diff --git a/plugins/platforms/wayland/egl_wayland_backend.h b/plugins/platforms/wayland/egl_wayland_backend.h index 3057c2c384..0b2893d86f 100644 --- a/plugins/platforms/wayland/egl_wayland_backend.h +++ b/plugins/platforms/wayland/egl_wayland_backend.h @@ -47,7 +47,7 @@ namespace Wayland { * repaints, which is obviously not optimal. Best solution is probably to go for buffer_age extension * and make it the only available solution next to fullscreen repaints. **/ -class EglWaylandBackend : public QObject, public AbstractEglBackend +class EglWaylandBackend : public AbstractEglBackend { Q_OBJECT public: