From kde-commits Mon Sep 11 14:40:01 2017 From: =?utf-8?q?Martin_Fl=C3=B6ser?= Date: Mon, 11 Sep 2017 14:40:01 +0000 To: kde-commits Subject: [kwin/scene-opengl-plugin] /: Add virtual method to Scene to get the EGL/GLX extensions Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=150514081311588 Git commit db2ddec23d51b1d43ca99788c8c63aa76b8d5b57 by Martin Fl=C3=B6ser. Committed on 08/09/2017 at 14:09. Pushed by graesslin into branch 'scene-opengl-plugin'. Add virtual method to Scene to get the EGL/GLX extensions Summary: We had a few places (e.g. DebugConsole, Platform) where the Scene was cased into a SceneOpenGL to access the backend and get the extensions. This change simplifies that by adding a virtual method to Scene directly which is implemented in SceneOpenGL and returns the backend's extensions. Thus the casts to SceneOpenGL are no longer required. Test Plan: Opened debug console to verify extensions are listed, triggered Outline to verify the sharing QPA context gets created. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7734 M +3 -3 debug_console.cpp M +2 -5 platform.cpp M +5 -0 scene.cpp M +9 -0 scene.h M +5 -0 scene_opengl.cpp M +2 -0 scene_opengl.h https://commits.kde.org/kwin/db2ddec23d51b1d43ca99788c8c63aa76b8d5b57 diff --git a/debug_console.cpp b/debug_console.cpp index ce1469e44..bbc8c5a9c 100644 --- a/debug_console.cpp +++ b/debug_console.cpp @@ -22,7 +22,7 @@ along with this program. If not, see . #include "client.h" #include "input_event.h" #include "main.h" -#include "scene_opengl.h" +#include "scene.h" #include "shell_client.h" #include "unmanaged.h" #include "wayland_server.h" @@ -528,7 +528,7 @@ void DebugConsole::initGLTab() m_ui->glVersionLabel->setText(GLPlatform::versionToString(gl->glVersio= n())); m_ui->glslLabel->setText(GLPlatform::versionToString(gl->glslVersion()= )); = - auto extensionsString =3D [] (const QList &extensions) { + auto extensionsString =3D [] (const auto &extensions) { QString text =3D QStringLiteral("
    "); for (auto extension : extensions) { text.append(QStringLiteral("
  • %1
  • ").arg(QString::fromLoc= al8Bit(extension))); @@ -537,7 +537,7 @@ void DebugConsole::initGLTab() return text; }; = - m_ui->platformExtensionsLabel->setText(extensionsString(static_cast(Compositor::self()->scene())->backend()->extensions())); + m_ui->platformExtensionsLabel->setText(extensionsString(Compositor::se= lf()->scene()->openGLPlatformInterfaceExtensions())); m_ui->openGLExtensionsLabel->setText(extensionsString(openGLExtensions= ())); } = diff --git a/platform.cpp b/platform.cpp index 04a267c3a..68e94e267 100644 --- a/platform.cpp +++ b/platform.cpp @@ -19,7 +19,6 @@ along with this program. If not, see . *********************************************************************/ #include "platform.h" #include -#include "abstract_egl_backend.h" #include "composite.h" #include "cursor.h" #include "effects.h" @@ -27,7 +26,7 @@ along with this program. If not, see . #include "overlaywindow.h" #include "outline.h" #include "pointer_input.h" -#include "scene_opengl.h" +#include "scene.h" #include "screenedge.h" #include "wayland_server.h" = @@ -353,9 +352,7 @@ void Platform::warpPointer(const QPointF &globalPos) bool Platform::supportsQpaContext() const { if (Compositor *c =3D Compositor::self()) { - if (SceneOpenGL *s =3D dynamic_cast(c->scene())) { - return s->backend()->hasExtension(QByteArrayLiteral("EGL_KHR_s= urfaceless_context")); - } + return c->scene()->openGLPlatformInterfaceExtensions().contains(QB= yteArrayLiteral("EGL_KHR_surfaceless_context")); } return false; } diff --git a/scene.cpp b/scene.cpp index 1c68864e3..36a459ad6 100644 --- a/scene.cpp +++ b/scene.cpp @@ -671,6 +671,11 @@ QImage *Scene::qpainterRenderBuffer() const return nullptr; } = +QVector Scene::openGLPlatformInterfaceExtensions() const +{ + return QVector{}; +} + //**************************************** // Scene::Window //**************************************** diff --git a/scene.h b/scene.h index 616e9b12b..d80217b95 100644 --- a/scene.h +++ b/scene.h @@ -175,6 +175,15 @@ public: **/ virtual QImage *qpainterRenderBuffer() const; = + /** + * The backend specific extensions (e.g. EGL/GLX extensions). + * + * Not the OpenGL (ES) extension! + * + * Default implementation returns empty list + **/ + virtual QVector openGLPlatformInterfaceExtensions() const; + Q_SIGNALS: void frameRendered(); = diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 74fa0574a..94b5bb15c 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -1021,6 +1021,11 @@ bool SceneOpenGL::animationsSupported() const return !GLPlatform::instance()->isSoftwareEmulation(); } = +QVector SceneOpenGL::openGLPlatformInterfaceExtensions() const +{ + return m_backend->extensions().toVector(); +} + //**************************************** // SceneOpenGL2 //**************************************** diff --git a/scene_opengl.h b/scene_opengl.h index f7a7de75e..86360aca2 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -82,6 +82,8 @@ public: return m_backend; } = + QVector openGLPlatformInterfaceExtensions() const override; + /** * Copy a region of pixels from the current read to the current draw b= uffer */