Commit cbbe94d7 authored by Martin Flöser's avatar Martin Flöser

Restrict available supported compositors based on first initialized one

Summary:
On Wayland we cannot switch from OpenGL to QPainter compositor as this
would break any running OpenGL application. KWin registers it's
EGLDisplay to Wayland and without OpenGL this doesn't make sense any
more. We are not able to render OpenGL buffers in the QPainter
compositor.

While it's theoretically possible to switch from QPainter to OpenGL it
doesn't make any sense for the same reason. Any running OpenGL
application would be using llvmpipe and could not be switched to proper
OpenGL.

This change stores the selected compositing type in Platform and the
implementations can use it to restrict the supported compositors. On X11
we don't need this, all other Platforms implement the restriction. Thus
it's no longer possible to switch the backends at runtime.

Test Plan:
Adjusted tests run, no runtime test as gui doesn't support
switching to QPainter anyway.

Reviewers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19084
parent e48d9df1
......@@ -79,6 +79,7 @@ void GenericSceneOpenGLTest::initTestCase()
auto scene = KWin::Compositor::self()->scene();
QVERIFY(scene);
QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing);
QCOMPARE(kwinApp()->platform()->selectedCompositor(), KWin::OpenGLCompositing);
}
void GenericSceneOpenGLTest::testRestart_data()
......@@ -109,6 +110,7 @@ void GenericSceneOpenGLTest::testRestart()
auto scene = KWin::Compositor::self()->scene();
QVERIFY(scene);
QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing);
QCOMPARE(kwinApp()->platform()->selectedCompositor(), KWin::OpenGLCompositing);
// trigger a repaint
KWin::Compositor::self()->addRepaintFull();
......
......@@ -108,6 +108,7 @@ void SceneQPainterTest::testStartFrame()
Compositor::self()->addRepaintFull();
auto scene = Compositor::self()->scene();
QVERIFY(scene);
QCOMPARE(kwinApp()->platform()->selectedCompositor(), QPainterCompositing);
QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered);
QVERIFY(frameRenderedSpy.isValid());
QVERIFY(frameRenderedSpy.wait());
......
......@@ -260,6 +260,8 @@ void Compositor::slotCompositingOptionsInitialized()
return;
}
kwinApp()->platform()->setSelectedCompositor(m_scene->compositingType() & OpenGLCompositing ? OpenGLCompositing : m_scene->compositingType());
if (!Workspace::self() && m_scene && m_scene->compositingType() == QPainterCompositing) {
// Force Software QtQuick on first startup with QPainter
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
......
......@@ -430,6 +430,25 @@ public:
**/
virtual QString supportInformation() const;
/**
* The compositor plugin which got selected from @link{supportedCompositors}.
* Prior to selecting a compositor this returns @c NoCompositing.
*
* This method allows the platforms to limit the offerings in @link{supportedCompositors}
* in case they do not support runtime compositor switching
**/
CompositingType selectedCompositor() const
{
return m_selectedCompositor;
}
/**
* Used by Compositor to set the used compositor.
**/
void setSelectedCompositor(CompositingType type)
{
m_selectedCompositor = type;
}
public Q_SLOTS:
void pointerMotion(const QPointF &position, quint32 time);
void pointerButtonPressed(quint32 button, quint32 time);
......@@ -531,6 +550,7 @@ private:
int m_hideCursorCounter = 0;
ColorCorrect::Manager *m_colorCorrect = nullptr;
bool m_supportsGammaControl = false;
CompositingType m_selectedCompositor = NoCompositing;
};
}
......
......@@ -769,6 +769,9 @@ void DrmBackend::outputDpmsChanged()
QVector<CompositingType> DrmBackend::supportedCompositors() const
{
if (selectedCompositor() != NoCompositing) {
return {selectedCompositor()};
}
#if HAVE_GBM
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
#else
......
......@@ -58,6 +58,9 @@ public:
Outputs enabledOutputs() const override;
QVector<CompositingType> supportedCompositors() const override {
if (selectedCompositor() != NoCompositing) {
return {selectedCompositor()};
}
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
}
......
......@@ -655,6 +655,9 @@ void WaylandBackend::updateWindowTitle()
QVector<CompositingType> WaylandBackend::supportedCompositors() const
{
if (selectedCompositor() != NoCompositing) {
return {selectedCompositor()};
}
#if HAVE_WAYLAND_EGL
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
#else
......
......@@ -70,6 +70,9 @@ public:
void warpPointer(const QPointF &globalPos) override;
QVector<CompositingType> supportedCompositors() const override {
if (selectedCompositor() != NoCompositing) {
return {selectedCompositor()};
}
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment