Pass EGL information from AbstractEglBackend to Platform instead of query

Summary:
So far the Platform performed a deep query into the AbstractEglBackend
to get information such as EGLContext, EGLConfig, EGLSurface. This
change adjusts this so that the AbstractEGLPlatform forwards it directly
whenever it gets informed about one following the approach already used
for EGLDisplay. This simplifies the code a lot and allows to remove the
dependency on the actual scene backend from the Platform (in order to
split out the SceneOpenGL into a plugin).

Test Plan:
Run nested kwin_wayland, triggered Outline which requires all
those methods.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7698
This commit is contained in:
Martin Flöser 2017-09-05 20:37:40 +02:00
parent 5d9027b110
commit 9381411b91
4 changed files with 50 additions and 39 deletions

View file

@ -75,6 +75,9 @@ void AbstractEglBackend::cleanup()
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,6 +258,7 @@ bool AbstractEglBackend::createContext()
return false;
}
m_context = ctx;
kwinApp()->platform()->setSceneEglContext(m_context);
return true;
}
@ -263,6 +267,18 @@ void AbstractEglBackend::setEglDisplay(const EGLDisplay &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)

View file

@ -54,12 +54,8 @@ public:
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();

View file

@ -370,36 +370,6 @@ void Platform::setSceneEglDisplay(EGLDisplay display)
m_eglDisplay = display;
}
EGLContext Platform::sceneEglContext() const
{
if (Compositor *c = Compositor::self()) {
if (SceneOpenGL *s = dynamic_cast<SceneOpenGL*>(c->scene())) {
return static_cast<AbstractEglBackend*>(s->backend())->context();
}
}
return EGL_NO_CONTEXT;
}
EGLSurface Platform::sceneEglSurface() const
{
if (Compositor *c = Compositor::self()) {
if (SceneOpenGL *s = dynamic_cast<SceneOpenGL*>(c->scene())) {
return static_cast<AbstractEglBackend*>(s->backend())->surface();
}
}
return EGL_NO_SURFACE;
}
EGLConfig Platform::sceneEglConfig() const
{
if (Compositor *c = Compositor::self()) {
if (SceneOpenGL *s = dynamic_cast<SceneOpenGL*>(c->scene())) {
return static_cast<AbstractEglBackend*>(s->backend())->config();
}
}
return nullptr;
}
QSize Platform::screenSize() const
{
return QSize();

View file

@ -90,16 +90,42 @@ public:
/**
* 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 @@ private:
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;
};