[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.
This commit is contained in:
Martin Gräßlin 2015-08-18 08:35:34 +02:00
parent 9272d01a2d
commit b9d7726f7a
3 changed files with 35 additions and 3 deletions

View file

@ -19,9 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "abstract_backend.h"
#include <config-kwin.h>
#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<SceneOpenGL*>(c->scene())) {
return static_cast<AbstractEglBackend*>(s->backend())->eglDisplay();
}
}
return EGL_NO_DISPLAY;
}
EGLContext AbstractBackend::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;
}
}

View file

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_ABSTRACT_BACKEND_H
#define KWIN_ABSTRACT_BACKEND_H
#include <kwin_export.h>
#include <epoxy/egl.h>
#include <fixx11h.h>
#include <QImage>
#include <QObject>
@ -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;

View file

@ -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;
}