From e013eba2037c49385918a0ab1324bf58a18ee173 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Sep 2013 19:01:59 +0200 Subject: eglfs: Set swap interval only when there is a context available Mesa does not like eglSwapInterval calls without a current context. Change-Id: I7ec2d4311586cf74da0461bc951a0e5d9399c35b Reviewed-by: Gunnar Sletta --- src/plugins/platforms/eglfs/qeglfscontext.cpp | 21 +++++++++++++++++++-- src/plugins/platforms/eglfs/qeglfscontext.h | 3 +++ src/plugins/platforms/eglfs/qeglfsintegration.cpp | 10 ---------- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 51439646c6..2c6846132d 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -53,13 +53,30 @@ QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLenum eglApi) - : QEGLPlatformContext(QEglFSHooks::hooks()->surfaceFormatFor(format), share, display, QEglFSIntegration::chooseConfig(display, QEglFSHooks::hooks()->surfaceFormatFor(format)), eglApi) + : QEGLPlatformContext(QEglFSHooks::hooks()->surfaceFormatFor(format), share, display, + QEglFSIntegration::chooseConfig(display, QEglFSHooks::hooks()->surfaceFormatFor(format)), eglApi), + m_swapIntervalSet(false) { } bool QEglFSContext::makeCurrent(QPlatformSurface *surface) { - return QEGLPlatformContext::makeCurrent(surface); + bool success = QEGLPlatformContext::makeCurrent(surface); + + if (success && !m_swapIntervalSet) { + m_swapIntervalSet = true; + int swapInterval = 1; + QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL"); + if (!swapIntervalString.isEmpty()) { + bool ok; + swapInterval = swapIntervalString.toInt(&ok); + if (!ok) + swapInterval = 1; + } + eglSwapInterval(eglDisplay(), swapInterval); + } + + return success; } EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h index 6caa49ab4f..8db340252c 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.h +++ b/src/plugins/platforms/eglfs/qeglfscontext.h @@ -55,6 +55,9 @@ public: bool makeCurrent(QPlatformSurface *surface); EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); void swapBuffers(QPlatformSurface *surface); + +private: + bool m_swapIntervalSet; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index c2d04b17c8..487a2a15ec 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -107,16 +107,6 @@ QEglFSIntegration::QEglFSIntegration() qFatal("EGL error"); } - int swapInterval = 1; - QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL"); - if (!swapIntervalString.isEmpty()) { - bool ok; - swapInterval = swapIntervalString.toInt(&ok); - if (!ok) - swapInterval = 1; - } - eglSwapInterval(mDisplay, swapInterval); - mScreen = new QEglFSScreen(mDisplay); screenAdded(mScreen); -- cgit v1.2.3