[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin/scene-opengl-plugin] /: Add virtual method to Scene to get the EGL/GLX extensions
From:       Martin_Flöser <null () kde ! org>
Date:       2017-09-11 14:40:01
Message-ID: E1drPsX-0001TV-Ju () code ! kde ! org
[Download RAW message or body]

Git commit db2ddec23d51b1d43ca99788c8c63aa76b8d5b57 by Martin Flöser.
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 \
<http://www.gnu.org/licenses/>.  #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->glVersion()));
     m_ui->glslLabel->setText(GLPlatform::versionToString(gl->glslVersion()));
 
-    auto extensionsString = [] (const QList<QByteArray> &extensions) {
+    auto extensionsString = [] (const auto &extensions) {
         QString text = QStringLiteral("<ul>");
         for (auto extension : extensions) {
             text.append(QStringLiteral("<li>%1</li>").arg(QString::fromLocal8Bit(extension)));
 @@ -537,7 +537,7 @@ void DebugConsole::initGLTab()
         return text;
     };
 
-    m_ui->platformExtensionsLabel->setText(extensionsString(static_cast<SceneOpenGL*>(Compositor::self()->scene())->backend()->extensions()));
 +    m_ui->platformExtensionsLabel->setText(extensionsString(Compositor::self()->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 \
                <http://www.gnu.org/licenses/>.
 *********************************************************************/
 #include "platform.h"
 #include <config-kwin.h>
-#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 \
<http://www.gnu.org/licenses/>.  #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 = Compositor::self()) {
-        if (SceneOpenGL *s = dynamic_cast<SceneOpenGL*>(c->scene())) {
-            return s->backend()->hasExtension(QByteArrayLiteral("EGL_KHR_surfaceless_context"));
                
-        }
+        return c->scene()->openGLPlatformInterfaceExtensions().contains(QByteArrayLiteral("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<QByteArray> Scene::openGLPlatformInterfaceExtensions() const
+{
+    return QVector<QByteArray>{};
+}
+
 //****************************************
 // 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<QByteArray> 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<QByteArray> 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<QByteArray> openGLPlatformInterfaceExtensions() const override;
+
     /**
      * Copy a region of pixels from the current read to the current draw buffer
      */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic