summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx/qqnxglcontext.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer.qnx@kdab.com>2012-06-28 08:50:34 +0100
committerQt by Nokia <qt-info@nokia.com>2012-07-03 00:40:58 +0200
commitca456f34b0a7c6229f43bb932b3aaa2d15ce8740 (patch)
treeb6a7f2d69b07a72ece8addea2f35a36ec94fc8d5 /src/plugins/platforms/qnx/qqnxglcontext.cpp
parentab2fb14b466173a5230d07a768f46203eb9ae08a (diff)
QNX: Enable threaded OpenGL rendering on QNX
The only complicated aspect to this was deferring EGLsurface re-creation as a result of window geometry changes (e.g. when we receive an orientation change event). To allow this to be done in a controlled way we defer the surface manipulation until the next call to QQnxGLContext::makeCurrent(). Change-Id: I8062d3e4d19220a822fbc3b8ca563bb1e3be09d0 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/qnx/qqnxglcontext.cpp')
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp
index 0b030bd5fe..44935f7e36 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.cpp
+++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp
@@ -88,7 +88,8 @@ static EGLenum checkEGLError(const char *msg)
QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext)
: QPlatformOpenGLContext(),
m_glContext(glContext),
- m_eglSurface(EGL_NO_SURFACE)
+ m_eglSurface(EGL_NO_SURFACE),
+ m_newSurfaceRequested(true) // Create a surface the first time makeCurrent() is called
{
qGLContextDebug() << Q_FUNC_INFO;
QSurfaceFormat format = m_glContext->format();
@@ -201,6 +202,12 @@ void QQnxGLContext::shutdown()
eglTerminate(ms_eglDisplay);
}
+void QQnxGLContext::requestSurfaceChange()
+{
+ qGLContextDebug() << Q_FUNC_INFO;
+ m_newSurfaceRequested.testAndSetRelease(false, true);
+}
+
bool QQnxGLContext::makeCurrent(QPlatformSurface *surface)
{
qGLContextDebug() << Q_FUNC_INFO;
@@ -213,8 +220,12 @@ bool QQnxGLContext::makeCurrent(QPlatformSurface *surface)
qFatal("QQNXQBBWindow: failed to set EGL API, err=%d", eglGetError());
}
- if (m_eglSurface == EGL_NO_SURFACE)
+ if (m_newSurfaceRequested.testAndSetOrdered(true, false)) {
+ qGLContextDebug() << "New EGL surface requested";
+ doneCurrent();
+ destroySurface();
createSurface(surface);
+ }
eglResult = eglMakeCurrent(ms_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
if (eglResult != EGL_TRUE) {
@@ -302,14 +313,13 @@ void QQnxGLContext::createSurface(QPlatformSurface *surface)
qFatal("QQNX: unable to create EGLSurface without a QQnxWindow");
}
- // If the platform window does not yet have any buffers, we create
- // a temporary set of buffers with a size of 1x1 pixels. This will
- // suffice until such time as the platform window has obtained
- // buffers of the proper size
- if (!platformWindow->hasBuffers()) {
- platformWindow->setPlatformOpenGLContext(this);
- platformWindow->setBufferSize(platformWindow->geometry().size());
- }
+ // Link the window and context
+ platformWindow->setPlatformOpenGLContext(this);
+
+ // Fetch the surface size from the window and update
+ // the window's buffers before we create the EGL surface
+ const QSize surfaceSize = platformWindow->requestedBufferSize();
+ platformWindow->setBufferSize(surfaceSize);
// Obtain the native handle for our window
screen_window_t handle = platformWindow->nativeHandle();