Introduce config option for OpenGLPlatformInterface
A new config option "GLPlatformInterface" is added to the Compositing settings group. Valid values are "glx" and "egl". This config option is honored by the Scene to decide which backend to create. The setting gets sanitized by the operation mode (egl for Wayland), the environment variable KWIN_OPENGL_INTERFACE and the compile time support. These switches are removed from the Scene to not have them duplicated.
This commit is contained in:
parent
83ad1386dc
commit
be33c59c16
4 changed files with 70 additions and 20 deletions
|
@ -265,6 +265,9 @@
|
|||
<min>0</min>
|
||||
<max>6</max>
|
||||
</entry>
|
||||
<entry name="GLPlatformInterface" type="String">
|
||||
<default>glx</default>
|
||||
</entry>
|
||||
</group>
|
||||
<group name="TabBox">
|
||||
<entry name="ShowDelay" type="Bool">
|
||||
|
|
56
options.cpp
56
options.cpp
|
@ -147,6 +147,7 @@ Options::Options(QObject *parent)
|
|||
, m_glStrictBindingFollowsDriver(Options::defaultGlStrictBindingFollowsDriver())
|
||||
, m_glCoreProfile(Options::defaultGLCoreProfile())
|
||||
, m_glPreferBufferSwap(Options::defaultGlPreferBufferSwap())
|
||||
, m_glPlatformInterface(Options::defaultGlPlatformInterface())
|
||||
, OpTitlebarDblClick(Options::defaultOperationTitlebarDblClick())
|
||||
, CmdActiveTitlebar1(Options::defaultCommandActiveTitlebar1())
|
||||
, CmdActiveTitlebar2(Options::defaultCommandActiveTitlebar2())
|
||||
|
@ -750,6 +751,41 @@ void Options::setGlPreferBufferSwap(char glPreferBufferSwap)
|
|||
emit glPreferBufferSwapChanged();
|
||||
}
|
||||
|
||||
void Options::setGlPlatformInterface(OpenGLPlatformInterface interface)
|
||||
{
|
||||
// check environment variable
|
||||
const QByteArray envOpenGLInterface(qgetenv("KWIN_OPENGL_INTERFACE"));
|
||||
if (!envOpenGLInterface.isEmpty()) {
|
||||
if (qstrcmp(envOpenGLInterface, "egl") == 0) {
|
||||
qDebug() << "Forcing EGL native interface through environment variable";
|
||||
interface = EglPlatformInterface;
|
||||
} else if (qstrcmp(envOpenGLInterface, "glx") == 0) {
|
||||
qDebug() << "Forcing GLX native interface through environment variable";
|
||||
interface = GlxPlatformInterface;
|
||||
}
|
||||
}
|
||||
if (kwinApp()->shouldUseWaylandForCompositing() && interface == GlxPlatformInterface) {
|
||||
// Glx is impossible on Wayland, enforce egl
|
||||
qDebug() << "Forcing EGL native interface for Wayland mode";
|
||||
interface = EglPlatformInterface;
|
||||
}
|
||||
#ifdef KWIN_HAVE_OPENGLES
|
||||
qDebug() << "Forcing EGL native interface as compiled against OpenGL ES";
|
||||
interface = EglPlatformInterface;
|
||||
#else
|
||||
#ifndef KWIN_HAVE_EGL
|
||||
qDebug() << "Forcing GLX native interface as compiled without EGL support";
|
||||
interface = GlxPlatformInterface;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (m_glPlatformInterface == interface) {
|
||||
return;
|
||||
}
|
||||
m_glPlatformInterface = interface;
|
||||
emit glPlatformInterfaceChanged();
|
||||
}
|
||||
|
||||
void Options::reparseConfiguration()
|
||||
{
|
||||
m_settings->config()->reparseConfiguration();
|
||||
|
@ -958,6 +994,26 @@ void Options::reloadCompositingSettings(bool force)
|
|||
setUnredirectFullscreen(config.readEntry("UnredirectFullscreen", Options::defaultUnredirectFullscreen()));
|
||||
// TOOD: add setter
|
||||
animationSpeed = qBound(0, config.readEntry("AnimationSpeed", Options::defaultAnimationSpeed()), 6);
|
||||
|
||||
auto interfaceToKey = [](OpenGLPlatformInterface interface) {
|
||||
switch (interface) {
|
||||
case GlxPlatformInterface:
|
||||
return QStringLiteral("glx");
|
||||
case EglPlatformInterface:
|
||||
return QStringLiteral("egl");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
auto keyToInterface = [](const QString &key) {
|
||||
if (key == QStringLiteral("glx")) {
|
||||
return GlxPlatformInterface;
|
||||
} else if (key == QStringLiteral("egl")) {
|
||||
return EglPlatformInterface;
|
||||
}
|
||||
return defaultGlPlatformInterface();
|
||||
};
|
||||
setGlPlatformInterface(keyToInterface(config.readEntry("GLPlatformInterface", interfaceToKey(m_glPlatformInterface))));
|
||||
}
|
||||
|
||||
// restricted should be true for operations that the user may not be able to repeat
|
||||
|
|
10
options.h
10
options.h
|
@ -189,6 +189,7 @@ class Options : public KDecorationOptions
|
|||
Q_PROPERTY(bool glStrictBindingFollowsDriver READ isGlStrictBindingFollowsDriver WRITE setGlStrictBindingFollowsDriver NOTIFY glStrictBindingFollowsDriverChanged)
|
||||
Q_PROPERTY(bool glCoreProfile READ glCoreProfile WRITE setGLCoreProfile NOTIFY glCoreProfileChanged)
|
||||
Q_PROPERTY(GlSwapStrategy glPreferBufferSwap READ glPreferBufferSwap WRITE setGlPreferBufferSwap NOTIFY glPreferBufferSwapChanged)
|
||||
Q_PROPERTY(OpenGLPlatformInterface glPlatformInterface READ glPlatformInterface WRITE setGlPlatformInterface NOTIFY glPlatformInterfaceChanged)
|
||||
public:
|
||||
|
||||
explicit Options(QObject *parent = NULL);
|
||||
|
@ -540,6 +541,9 @@ public:
|
|||
bool glCoreProfile() const {
|
||||
return m_glCoreProfile;
|
||||
}
|
||||
OpenGLPlatformInterface glPlatformInterface() const {
|
||||
return m_glPlatformInterface;
|
||||
}
|
||||
|
||||
enum GlSwapStrategy { NoSwapEncourage = 0, CopyFrontBuffer = 'c', PaintFullScreen = 'p', ExtendDamage = 'e', AutoSwapStrategy = 'a' };
|
||||
GlSwapStrategy glPreferBufferSwap() const {
|
||||
|
@ -605,6 +609,7 @@ public:
|
|||
void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver);
|
||||
void setGLCoreProfile(bool glCoreProfile);
|
||||
void setGlPreferBufferSwap(char glPreferBufferSwap);
|
||||
void setGlPlatformInterface(OpenGLPlatformInterface interface);
|
||||
|
||||
// default values
|
||||
static WindowOperation defaultOperationTitlebarDblClick() {
|
||||
|
@ -709,6 +714,9 @@ public:
|
|||
static GlSwapStrategy defaultGlPreferBufferSwap() {
|
||||
return AutoSwapStrategy;
|
||||
}
|
||||
static OpenGLPlatformInterface defaultGlPlatformInterface() {
|
||||
return kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface;
|
||||
};
|
||||
static int defaultAnimationSpeed() {
|
||||
return 3;
|
||||
}
|
||||
|
@ -786,6 +794,7 @@ Q_SIGNALS:
|
|||
void glStrictBindingFollowsDriverChanged();
|
||||
void glCoreProfileChanged();
|
||||
void glPreferBufferSwapChanged();
|
||||
void glPlatformInterfaceChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void setColorCorrected(bool colorCorrected = false);
|
||||
|
@ -834,6 +843,7 @@ private:
|
|||
bool m_glStrictBindingFollowsDriver;
|
||||
bool m_glCoreProfile;
|
||||
GlSwapStrategy m_glPreferBufferSwap;
|
||||
OpenGLPlatformInterface m_glPlatformInterface;
|
||||
|
||||
WindowOperation OpTitlebarDblClick;
|
||||
|
||||
|
|
|
@ -194,26 +194,7 @@ SceneOpenGL::~SceneOpenGL()
|
|||
SceneOpenGL *SceneOpenGL::createScene()
|
||||
{
|
||||
OpenGLBackend *backend = NULL;
|
||||
OpenGLPlatformInterface platformInterface = NoOpenGLPlatformInterface;
|
||||
// should we use glx?
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
// on OpenGL we default to glx on X11 and to egl on Wayland
|
||||
platformInterface = kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface;
|
||||
#endif
|
||||
|
||||
const QByteArray envOpenGLInterface(qgetenv("KWIN_OPENGL_INTERFACE"));
|
||||
#ifdef KWIN_HAVE_EGL
|
||||
#ifdef KWIN_HAVE_OPENGLES
|
||||
// for OpenGL ES we need to use the Egl Backend
|
||||
platformInterface = EglPlatformInterface;
|
||||
#else
|
||||
// check environment variable
|
||||
if (qstrcmp(envOpenGLInterface, "egl") == 0) {
|
||||
qDebug() << "Forcing EGL native interface through environment variable";
|
||||
platformInterface = EglPlatformInterface;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
OpenGLPlatformInterface platformInterface = options->glPlatformInterface();
|
||||
|
||||
switch (platformInterface) {
|
||||
case GlxPlatformInterface:
|
||||
|
|
Loading…
Reference in a new issue