From 38df9798da4d9645d0620b9053f2a3f6ec35f80b Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Fri, 5 Aug 2011 15:34:01 +0300 Subject: Fix to QGLWidget rendering with VG graphics system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QEGLContext don't expect EGL based API to change on runtime (e.g. VG->GL). QEGLContext caches current API context pointer and uses this cached value to determine whether to make eglMakeCurrent call or not. VG graphics system and QGLWidget creates own separate QEGLContext objects, but both of those objects consider themself to be current context, so no eglMakeCurrent call occurs even though the API has changed. This patch adds ifdef'd current context check for Symbian which enables eglMakeCurrent call if EGL API has changed. (Symbian is the only supported platform currently where this scenario happens). Task-number: QT-5012 Reviewed-by: Samuel Rødal --- src/gui/egl/qegl.cpp | 21 ++++++++++++++++++++- src/gui/egl/qeglcontext_p.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index d9c5ea2..4db4a6a 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -94,6 +94,7 @@ QEglContext::QEglContext() , current(false) , ownsContext(true) , sharing(false) + , apiChanged(false) { QEglContextTracker::ref(); } @@ -435,9 +436,20 @@ bool QEglContext::makeCurrent(EGLSurface surface) return false; } +#ifdef Q_OS_SYMBIAN + apiChanged = false; + if (currentContext(apiType) + && currentContext(apiType)->ctx != eglGetCurrentContext()) { + // some other EGL based API active. Complete its rendering + eglWaitClient(); + apiChanged = true; + } +#endif + // If lazyDoneCurrent() was called on the surface, then we may be able // to assume that it is still current within the thread. - if (surface == currentSurface && currentContext(apiType) == this) { + if (surface == currentSurface && currentContext(apiType) == this + && !apiChanged) { current = true; return true; } @@ -512,6 +524,13 @@ bool QEglContext::swapBuffers(EGLSurface surface) bool ok = eglSwapBuffers(QEgl::display(), surface); if (!ok) qWarning() << "QEglContext::swapBuffers():" << QEgl::errorString(); + +#ifdef Q_OS_SYMBIAN + if (apiChanged) { + eglWaitClient(); + apiChanged = false; + } +#endif return ok; } diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index 6cd76b3..0cdaae7 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -104,6 +104,7 @@ private: bool current; bool ownsContext; bool sharing; + bool apiChanged; static QEglContext *currentContext(QEgl::API api); static void setCurrentContext(QEgl::API api, QEglContext *context); -- cgit v0.12