[egl/wayland] Bind Wayland Display to EGL display

This commit is contained in:
Martin Gräßlin 2015-02-17 10:54:25 +01:00
parent a0b2a938aa
commit 2c169e4bca

View file

@ -1,3 +1,4 @@
/******************************************************************** /********************************************************************
KWin - the KDE window manager KWin - the KDE window manager
This file is part of the KDE project. This file is part of the KDE project.
@ -23,17 +24,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "composite.h" #include "composite.h"
#include "options.h" #include "options.h"
#include "wayland_backend.h" #include "wayland_backend.h"
#include "wayland_server.h"
#include <KWayland/Client/surface.h> #include <KWayland/Client/surface.h>
// kwin libs // kwin libs
#include <kwinglplatform.h> #include <kwinglplatform.h>
// KDE // KDE
#include <KWayland/Server/buffer_interface.h> #include <KWayland/Server/buffer_interface.h>
#include <KWayland/Server/display.h>
// Qt // Qt
#include <QOpenGLContext> #include <QOpenGLContext>
namespace KWin namespace KWin
{ {
typedef GLboolean(*eglBindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display);
typedef GLboolean(*eglUnbindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display);
eglBindWaylandDisplayWL_func eglBindWaylandDisplayWL = nullptr;
eglUnbindWaylandDisplayWL_func eglUnbindWaylandDisplayWL = nullptr;
EglWaylandBackend::EglWaylandBackend() EglWaylandBackend::EglWaylandBackend()
: QObject(NULL) : QObject(NULL)
, OpenGLBackend() , OpenGLBackend()
@ -64,6 +72,9 @@ EglWaylandBackend::EglWaylandBackend()
EglWaylandBackend::~EglWaylandBackend() EglWaylandBackend::~EglWaylandBackend()
{ {
if (eglUnbindWaylandDisplayWL && m_display != EGL_NO_DISPLAY) {
eglUnbindWaylandDisplayWL(m_display, *(WaylandServer::self()->display()));
}
cleanupGL(); cleanupGL();
doneCurrent(); doneCurrent();
eglDestroyContext(m_display, m_context); eglDestroyContext(m_display, m_context);
@ -147,6 +158,14 @@ void EglWaylandBackend::init()
if (useBufferAge != "0") if (useBufferAge != "0")
setSupportsBufferAge(true); setSupportsBufferAge(true);
} }
if (hasGLExtension(QByteArrayLiteral("EGL_WL_bind_wayland_display"))) {
eglBindWaylandDisplayWL = (eglBindWaylandDisplayWL_func)eglGetProcAddress("eglBindWaylandDisplayWL");
eglUnbindWaylandDisplayWL = (eglUnbindWaylandDisplayWL_func)eglGetProcAddress("eglUnbindWaylandDisplayWL");
if (!eglBindWaylandDisplayWL(m_display, *(WaylandServer::self()->display()))) {
eglUnbindWaylandDisplayWL = nullptr;
}
}
} }
bool EglWaylandBackend::initRenderingContext() bool EglWaylandBackend::initRenderingContext()