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 <gunnar.sletta@digia.com>
This commit is contained in:
Laszlo Agocs 2013-09-11 19:01:59 +02:00 committed by The Qt Project
parent 5fd344389e
commit e013eba203
3 changed files with 22 additions and 12 deletions

View File

@ -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)

View File

@ -55,6 +55,9 @@ public:
bool makeCurrent(QPlatformSurface *surface);
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
void swapBuffers(QPlatformSurface *surface);
private:
bool m_swapIntervalSet;
};
QT_END_NAMESPACE

View File

@ -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);