From 581fcfcea081cdc80e09b09a13b336d7cf9d9ef6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Samuel=20R=C3=B8dal?= Date: Fri, 18 May 2012 09:36:15 +0200 Subject: [PATCH] Fixed context sharing in wayland_egl backend. Properly implement isSharing() and isValid(). Change-Id: I7ec9bd8a1e6d4af87a418568f1d5d18a9153eafc Reviewed-by: Laszlo Agocs --- .../gl_integration/wayland_egl/qwaylandglcontext.cpp | 19 +++++++++++++++++-- .../gl_integration/wayland_egl/qwaylandglcontext.h | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index 665944d..143bcb7 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -56,7 +56,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat , m_config(q_configFromGLFormat(m_eglDisplay, format, true)) , m_format(q_glFormatFromConfig(m_eglDisplay, m_config)) { - EGLContext shareEGLContext = share ? static_cast(share)->eglContext() : EGL_NO_CONTEXT; + m_shareEGLContext = share ? static_cast(share)->eglContext() : EGL_NO_CONTEXT; eglBindAPI(EGL_OPENGL_ES_API); @@ -65,7 +65,12 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2); eglContextAttrs.append(EGL_NONE); - m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData()); + m_context = eglCreateContext(m_eglDisplay, m_config, m_shareEGLContext, eglContextAttrs.constData()); + + if (m_context == EGL_NO_CONTEXT) { + m_context = eglCreateContext(m_eglDisplay, m_config, EGL_NO_CONTEXT, eglContextAttrs.constData()); + m_shareEGLContext = EGL_NO_CONTEXT; + } } QWaylandGLContext::~QWaylandGLContext() @@ -90,6 +95,16 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) eglSwapBuffers(m_eglDisplay, eglSurface); } +bool QWaylandGLContext::isSharing() const +{ + return m_shareEGLContext != EGL_NO_CONTEXT; +} + +bool QWaylandGLContext::isValid() const +{ + return m_context != EGL_NO_CONTEXT; +} + void (*QWaylandGLContext::getProcAddress(const QByteArray &procName)) () { return eglGetProcAddress(procName.constData()); diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h index 7dbba25..56b862e 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -61,6 +61,9 @@ public: bool makeCurrent(QPlatformSurface *surface); void doneCurrent(); + bool isSharing() const; + bool isValid() const; + void (*getProcAddress(const QByteArray &procName)) (); QSurfaceFormat format() const { return m_format; } @@ -72,6 +75,7 @@ private: EGLDisplay m_eglDisplay; EGLContext m_context; + EGLContext m_shareEGLContext; EGLConfig m_config; QSurfaceFormat m_format; }; -- 2.7.4