From b9d7726f7a35e0c47aef12082c61b26d0e26714d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 18 Aug 2015 08:35:34 +0200 Subject: [PATCH] [wayland] Forward EGLDisplay and EGLContext from Scene to Backend AbstractBackend can forward the egl display and context, so that it can be used from other parts. --- abstract_backend.cpp | 22 ++++++++++++++++++++++ abstract_backend.h | 10 ++++++++++ abstract_egl_backend.h | 6 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/abstract_backend.cpp b/abstract_backend.cpp index d30f6f6249..bdded1f75b 100644 --- a/abstract_backend.cpp +++ b/abstract_backend.cpp @@ -19,9 +19,11 @@ along with this program. If not, see . *********************************************************************/ #include "abstract_backend.h" #include +#include "abstract_egl_backend.h" #include "composite.h" #include "cursor.h" #include "input.h" +#include "scene_opengl.h" #include "wayland_server.h" #include "wayland_cursor_theme.h" // KWayland @@ -303,4 +305,24 @@ void AbstractBackend::warpPointer(const QPointF &globalPos) Q_UNUSED(globalPos) } +EGLDisplay AbstractBackend::sceneEglDisplay() const +{ + if (Compositor *c = Compositor::self()) { + if (SceneOpenGL *s = dynamic_cast(c->scene())) { + return static_cast(s->backend())->eglDisplay(); + } + } + return EGL_NO_DISPLAY; +} + +EGLContext AbstractBackend::sceneEglContext() const +{ + if (Compositor *c = Compositor::self()) { + if (SceneOpenGL *s = dynamic_cast(c->scene())) { + return static_cast(s->backend())->context(); + } + } + return EGL_NO_CONTEXT; +} + } diff --git a/abstract_backend.h b/abstract_backend.h index 4efbac5165..bb93f783d8 100644 --- a/abstract_backend.h +++ b/abstract_backend.h @@ -20,6 +20,8 @@ along with this program. If not, see . #ifndef KWIN_ABSTRACT_BACKEND_H #define KWIN_ABSTRACT_BACKEND_H #include +#include +#include #include #include @@ -44,6 +46,14 @@ public: virtual OpenGLBackend *createOpenGLBackend(); virtual QPainterBackend *createQPainterBackend(); virtual void warpPointer(const QPointF &globalPos); + /** + * The EGLDisplay used by the compositing scene. + **/ + virtual EGLDisplay sceneEglDisplay() const; + /** + * The EGLContext used by the compositing scene. + **/ + virtual EGLContext sceneEglContext() const; bool usesSoftwareCursor() const { return m_softWareCursor; diff --git a/abstract_egl_backend.h b/abstract_egl_backend.h index 858986971b..b2ae051905 100644 --- a/abstract_egl_backend.h +++ b/abstract_egl_backend.h @@ -34,12 +34,12 @@ public: EGLDisplay eglDisplay() const { return m_display; } - -protected: - AbstractEglBackend(); EGLContext context() const { return m_context; } + +protected: + AbstractEglBackend(); EGLSurface surface() const { return m_surface; }