From 004b928c8dada6350500df3f5677c144aa2892e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 30 Oct 2015 13:18:30 +0100 Subject: [PATCH] Core uses runtime checks for whether we are on OpenGLES --- composite.cpp | 5 ++--- compositingprefs.cpp | 7 ++++--- dbusinterface.cpp | 17 +++++++++-------- options.cpp | 9 +++++---- workspace.cpp | 11 +++++------ 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/composite.cpp b/composite.cpp index 0e525233fb..70f2e13aba 100644 --- a/composite.cpp +++ b/composite.cpp @@ -51,6 +51,7 @@ along with this program. If not, see . #include #include #include +#include #include #include #include @@ -207,14 +208,12 @@ void Compositor::slotCompositingOptionsInitialized() else { unsafeConfig.writeEntry(openGLIsUnsafe, true); unsafeConfig.sync(); -#ifndef KWIN_HAVE_OPENGLES - if (!kwinApp()->shouldUseWaylandForCompositing() && !CompositingPrefs::hasGlx()) { + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL && !kwinApp()->shouldUseWaylandForCompositing() && !CompositingPrefs::hasGlx()) { unsafeConfig.writeEntry(openGLIsUnsafe, false); unsafeConfig.sync(); qCDebug(KWIN_CORE) << "No glx extensions available"; break; } -#endif m_scene = SceneOpenGL::createScene(this); diff --git a/compositingprefs.cpp b/compositingprefs.cpp index 103123f2ba..4d32ad40fc 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -82,9 +83,9 @@ bool CompositingPrefs::compositingPossible() if (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable()) return true; #endif -#ifdef KWIN_HAVE_OPENGLES - return true; -#endif + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { + return true; + } qCDebug(KWIN_CORE) << "No OpenGL or XRender/XFixes support"; return false; } diff --git a/dbusinterface.cpp b/dbusinterface.cpp index 6bc79f7608..9392808825 100644 --- a/dbusinterface.cpp +++ b/dbusinterface.cpp @@ -37,6 +37,7 @@ along with this program. If not, see . #endif // Qt +#include #include namespace KWin @@ -200,11 +201,11 @@ QString CompositorDBusInterface::compositingType() const case XRenderCompositing: return QStringLiteral("xrender"); case OpenGL2Compositing: -#ifdef KWIN_HAVE_OPENGLES - return QStringLiteral("gles"); -#else - return QStringLiteral("gl2"); -#endif + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { + return QStringLiteral("gles"); + } else { + return QStringLiteral("gl2"); + } case QPainterCompositing: return QStringLiteral("qpainter"); case NoCompositing: @@ -245,9 +246,9 @@ QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const #if HAVE_EPOXY_GLX supportsGlx = (kwinApp()->operationMode() == Application::OperationModeX11); #endif -#ifdef KWIN_HAVE_OPENGLES - supportsGlx = false; -#endif + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { + supportsGlx = false; + } if (supportsGlx) { interfaces << QStringLiteral("glx"); } diff --git a/options.cpp b/options.cpp index 424838fa0a..d7332f22c6 100644 --- a/options.cpp +++ b/options.cpp @@ -33,6 +33,7 @@ along with this program. If not, see . #include "settings.h" #include "xcbutils.h" #include +#include #endif //KCMRULES @@ -768,10 +769,10 @@ void Options::setGlPlatformInterface(OpenGLPlatformInterface interface) qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled without GLX support"; interface = EglPlatformInterface; #endif -#ifdef KWIN_HAVE_OPENGLES - qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled against OpenGL ES"; - interface = EglPlatformInterface; -#endif + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { + qCDebug(KWIN_CORE) << "Forcing EGL native interface as Qt uses OpenGL ES"; + interface = EglPlatformInterface; + } if (m_glPlatformInterface == interface) { return; diff --git a/workspace.cpp b/workspace.cpp index 0d97f4a235..1fd44e6b31 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1477,13 +1477,12 @@ QString Workspace::supportInformation() const switch (effects->compositingType()) { case OpenGL2Compositing: case OpenGLCompositing: { -#ifdef KWIN_HAVE_OPENGLES - support.append(QStringLiteral("Compositing Type: OpenGL ES 2.0\n")); -#else - support.append(QStringLiteral("Compositing Type: OpenGL\n")); -#endif - GLPlatform *platform = GLPlatform::instance(); + if (platform->isGLES()) { + support.append(QStringLiteral("Compositing Type: OpenGL ES 2.0\n")); + } else { + support.append(QStringLiteral("Compositing Type: OpenGL\n")); + } support.append(QStringLiteral("OpenGL vendor string: ") + QString::fromUtf8(platform->glVendorString()) + QStringLiteral("\n")); support.append(QStringLiteral("OpenGL renderer string: ") + QString::fromUtf8(platform->glRendererString()) + QStringLiteral("\n")); support.append(QStringLiteral("OpenGL version string: ") + QString::fromUtf8(platform->glVersionString()) + QStringLiteral("\n"));