Fixed context sharing in wayland_egl backend.
authorSamuel Rødal <samuel.rodal@nokia.com>
Fri, 18 May 2012 07:36:15 +0000 (09:36 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Fri, 18 May 2012 13:57:33 +0000 (15:57 +0200)
Properly implement isSharing() and isValid().

Change-Id: I7ec9bd8a1e6d4af87a418568f1d5d18a9153eafc
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h

index 665944d..143bcb7 100644 (file)
@@ -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<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
+    m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(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());
index 7dbba25..56b862e 100644 (file)
@@ -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;
 };