diff --git a/abstract_egl_backend.h b/abstract_egl_backend.h --- a/abstract_egl_backend.h +++ b/abstract_egl_backend.h @@ -54,12 +54,8 @@ protected: AbstractEglBackend(); void setEglDisplay(const EGLDisplay &display); - void setSurface(const EGLSurface &surface) { - m_surface = surface; - } - void setConfig(const EGLConfig &config) { - m_config = config; - } + void setSurface(const EGLSurface &surface); + void setConfig(const EGLConfig &config); void cleanup(); virtual void cleanupSurfaces(); bool initEglAPI(); diff --git a/abstract_egl_backend.cpp b/abstract_egl_backend.cpp --- a/abstract_egl_backend.cpp +++ b/abstract_egl_backend.cpp @@ -75,6 +75,9 @@ eglDestroyContext(m_display, m_context); cleanupSurfaces(); eglReleaseThread(); + kwinApp()->platform()->setSceneEglContext(EGL_NO_CONTEXT); + kwinApp()->platform()->setSceneEglSurface(EGL_NO_SURFACE); + kwinApp()->platform()->setSceneEglConfig(nullptr); } void AbstractEglBackend::cleanupSurfaces() @@ -255,14 +258,27 @@ return false; } m_context = ctx; + kwinApp()->platform()->setSceneEglContext(m_context); return true; } void AbstractEglBackend::setEglDisplay(const EGLDisplay &display) { m_display = display; kwinApp()->platform()->setSceneEglDisplay(display); } +void AbstractEglBackend::setConfig(const EGLConfig &config) +{ + m_config = config; + kwinApp()->platform()->setSceneEglConfig(config); +} + +void AbstractEglBackend::setSurface(const EGLSurface &surface) +{ + m_surface = surface; + kwinApp()->platform()->setSceneEglSurface(surface); +} + AbstractEglTexture::AbstractEglTexture(SceneOpenGL::Texture *texture, AbstractEglBackend *backend) : SceneOpenGL::TexturePrivate() , q(texture) diff --git a/platform.h b/platform.h --- a/platform.h +++ b/platform.h @@ -90,16 +90,42 @@ /** * The EGLContext used by the compositing scene. **/ - virtual EGLContext sceneEglContext() const; + virtual EGLContext sceneEglContext() const { + return m_context; + } + /** + * Sets the @p context used by the compositing scene. + **/ + void setSceneEglContext(EGLContext context) { + m_context = context; + } /** * The first (in case of multiple) EGLSurface used by the compositing scene. **/ - EGLSurface sceneEglSurface() const; + EGLSurface sceneEglSurface() const { + return m_surface; + } + /** + * Sets the first @p surface used by the compositing scene. + * @see sceneEglSurface + **/ + void setSceneEglSurface(EGLSurface surface) { + m_surface = surface; + } /** * The EglConfig used by the compositing scene. **/ - EGLConfig sceneEglConfig() const; + EGLConfig sceneEglConfig() const { + return m_eglConfig; + } + /** + * Sets the @p config used by the compositing scene. + * @see sceneEglConfig + **/ + void setSceneEglConfig(EGLConfig config) { + m_eglConfig = config; + } /** * Implementing subclasses should provide a size in case the backend represents @@ -436,6 +462,9 @@ int m_initialOutputCount = 1; qreal m_initialOutputScale = 1; EGLDisplay m_eglDisplay; + EGLConfig m_eglConfig = nullptr; + EGLContext m_context = EGL_NO_CONTEXT; + EGLSurface m_surface = EGL_NO_SURFACE; int m_hideCursorCounter = 0; }; diff --git a/platform.cpp b/platform.cpp --- a/platform.cpp +++ b/platform.cpp @@ -370,36 +370,6 @@ m_eglDisplay = display; } -EGLContext Platform::sceneEglContext() const -{ - if (Compositor *c = Compositor::self()) { - if (SceneOpenGL *s = dynamic_cast(c->scene())) { - return static_cast(s->backend())->context(); - } - } - return EGL_NO_CONTEXT; -} - -EGLSurface Platform::sceneEglSurface() const -{ - if (Compositor *c = Compositor::self()) { - if (SceneOpenGL *s = dynamic_cast(c->scene())) { - return static_cast(s->backend())->surface(); - } - } - return EGL_NO_SURFACE; -} - -EGLConfig Platform::sceneEglConfig() const -{ - if (Compositor *c = Compositor::self()) { - if (SceneOpenGL *s = dynamic_cast(c->scene())) { - return static_cast(s->backend())->config(); - } - } - return nullptr; -} - QSize Platform::screenSize() const { return QSize();