From 09489a4c2b5bf1d085be33bdf30f004d627f85cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 15 Oct 2017 22:24:49 +0200 Subject: [PATCH] Add a pure virtual method to Platform to describe the supported compositors Summary: So far KWin does not know which Compositors the platform actually supports. This results in KWin happily trying to use the OpenGL compositor on fbdev or the QPainter compositor on hwcomposer although that is obviously going to fail as the platform doesn't support this. By adding a pure virtual method all Platforms can define what they support. In a later step the Compositor can use this to create an appropriate scene and also perform proper fallback handling in case the scene creation fails. Test Plan: Compiles Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D8316 --- platform.h | 6 ++++++ plugins/platforms/drm/drm_backend.cpp | 9 +++++++++ plugins/platforms/drm/drm_backend.h | 2 ++ plugins/platforms/fbdev/fb_backend.h | 4 ++++ plugins/platforms/hwcomposer/hwcomposer_backend.h | 4 ++++ plugins/platforms/virtual/virtual_backend.h | 4 ++++ plugins/platforms/wayland/wayland_backend.cpp | 10 ++++++++++ plugins/platforms/wayland/wayland_backend.h | 2 ++ plugins/platforms/x11/standalone/x11_platform.cpp | 13 +++++++++++++ plugins/platforms/x11/standalone/x11_platform.h | 1 + .../platforms/x11/windowed/x11windowed_backend.h | 4 ++++ 11 files changed, 59 insertions(+) diff --git a/platform.h b/platform.h index 78820cfcb3..45855df516 100644 --- a/platform.h +++ b/platform.h @@ -376,6 +376,12 @@ public: * Default implementation creates an EffectsHandlerImp; **/ virtual void createEffectsHandler(Compositor *compositor, Scene *scene); + /** + * The CompositingTypes supported by the Platform. + * The first item should be the most preferred one. + * @since 5.11 + **/ + virtual QVector supportedCompositors() const = 0; public Q_SLOTS: void pointerMotion(const QPointF &position, quint32 time); diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp index fa6af90412..963ed8cec2 100644 --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -738,4 +738,13 @@ void DrmBackend::outputDpmsChanged() setOutputsEnabled(enabled); } +QVector DrmBackend::supportedCompositors() const +{ +#if HAVE_GBM + return QVector{OpenGLCompositing, QPainterCompositing}; +#else + return QVector{QPainterCompositing}; +#endif +} + } diff --git a/plugins/platforms/drm/drm_backend.h b/plugins/platforms/drm/drm_backend.h index c44d3f0188..e3563e9965 100644 --- a/plugins/platforms/drm/drm_backend.h +++ b/plugins/platforms/drm/drm_backend.h @@ -118,6 +118,8 @@ public: return m_gbmDevice; } + QVector supportedCompositors() const override; + public Q_SLOTS: void turnOutputsOn(); diff --git a/plugins/platforms/fbdev/fb_backend.h b/plugins/platforms/fbdev/fb_backend.h index e888994722..2ffca0eb96 100644 --- a/plugins/platforms/fbdev/fb_backend.h +++ b/plugins/platforms/fbdev/fb_backend.h @@ -78,6 +78,10 @@ public: return m_bgr; } + QVector supportedCompositors() const override { + return QVector{QPainterCompositing}; + } + private: void openFrameBuffer(); bool queryScreenInfo(); diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.h b/plugins/platforms/hwcomposer/hwcomposer_backend.h index 691c35fb06..e4b2aa6723 100644 --- a/plugins/platforms/hwcomposer/hwcomposer_backend.h +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.h @@ -82,6 +82,10 @@ public: return m_outputBlank; } + QVector supportedCompositors() const override { + return QVector{OpenGLCompositing}; + } + Q_SIGNALS: void outputBlankChanged(); diff --git a/plugins/platforms/virtual/virtual_backend.h b/plugins/platforms/virtual/virtual_backend.h index 9a03362251..ea19b4f5ac 100644 --- a/plugins/platforms/virtual/virtual_backend.h +++ b/plugins/platforms/virtual/virtual_backend.h @@ -85,6 +85,10 @@ public: m_gbmDevice = device; } + QVector supportedCompositors() const override { + return QVector{OpenGLCompositing, QPainterCompositing}; + } + Q_SIGNALS: void sizeChanged(); void outputGeometriesChanged(const QVector &geometries); diff --git a/plugins/platforms/wayland/wayland_backend.cpp b/plugins/platforms/wayland/wayland_backend.cpp index d5324ed13a..1beec17101 100644 --- a/plugins/platforms/wayland/wayland_backend.cpp +++ b/plugins/platforms/wayland/wayland_backend.cpp @@ -653,6 +653,16 @@ void WaylandBackend::updateWindowTitle() } } +QVector WaylandBackend::supportedCompositors() const +{ +#if HAVE_WAYLAND_EGL + return QVector{OpenGLCompositing, QPainterCompositing}; +#else + return QVector{QPainterCompositing}; +#endif +} + + } } // KWin diff --git a/plugins/platforms/wayland/wayland_backend.h b/plugins/platforms/wayland/wayland_backend.h index 3241e7a15a..898479c33c 100644 --- a/plugins/platforms/wayland/wayland_backend.h +++ b/plugins/platforms/wayland/wayland_backend.h @@ -148,6 +148,8 @@ public: void togglePointerConfinement(); + QVector supportedCompositors() const override; + Q_SIGNALS: void shellSurfaceSizeChanged(const QSize &size); void systemCompositorDied(); diff --git a/plugins/platforms/x11/standalone/x11_platform.cpp b/plugins/platforms/x11/standalone/x11_platform.cpp index 5ab7ac4bad..6010339c1d 100644 --- a/plugins/platforms/x11/standalone/x11_platform.cpp +++ b/plugins/platforms/x11/standalone/x11_platform.cpp @@ -410,4 +410,17 @@ void X11StandalonePlatform::createEffectsHandler(Compositor *compositor, Scene * new EffectsHandlerImplX11(compositor, scene); } +QVector X11StandalonePlatform::supportedCompositors() const +{ + QVector compositors; +#if HAVE_EPOXY_GLX + compositors << OpenGLCompositing; +#endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING + compositors << XRenderCompositing; +#endif + compositors << NoCompositing; + return compositors; +} + } diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h index 7c653de55b..48dc89d22f 100644 --- a/plugins/platforms/x11/standalone/x11_platform.h +++ b/plugins/platforms/x11/standalone/x11_platform.h @@ -65,6 +65,7 @@ public: void invertScreen() override; void createEffectsHandler(Compositor *compositor, Scene *scene) override; + QVector supportedCompositors() const override; protected: void doHideCursor() override; diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.h b/plugins/platforms/x11/windowed/x11windowed_backend.h index 511cd2ad3d..e17149a790 100644 --- a/plugins/platforms/x11/windowed/x11windowed_backend.h +++ b/plugins/platforms/x11/windowed/x11windowed_backend.h @@ -69,6 +69,10 @@ public: QPainterBackend* createQPainterBackend() override; void warpPointer(const QPointF &globalPos) override; + QVector supportedCompositors() const override { + return QVector{OpenGLCompositing, QPainterCompositing}; + } + Q_SIGNALS: void sizeChanged();