diff options
Diffstat (limited to 'src/platformsupport/eglconvenience/qeglplatformcontext.cpp')
-rw-r--r-- | src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 716b01b4d9..614d086178 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -40,12 +40,27 @@ ****************************************************************************/ #include "qeglplatformcontext_p.h" - #include "qeglconvenience_p.h" - #include <qpa/qplatformwindow.h> -#include <EGL/egl.h> +QT_BEGIN_NAMESPACE + +/*! + \class QEGLPlatformContext + \brief An EGL context implementation. + \since 5.2 + \internal + \ingroup qpa + + Implement QPlatformOpenGLContext using EGL. To use it in platform + plugins a subclass must be created since + eglSurfaceForPlatformSurface() has to be reimplemented. This + function is used for mapping platform surfaces (windows) to EGL + surfaces and is necessary since different platform plugins may + have different ways of handling native windows (for example, a + plugin may choose not to back every platform window by a real EGL + surface). Other than that, no further customization is necessary. + */ static inline void bindApi(const QSurfaceFormat &format) { @@ -72,6 +87,9 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform EGLenum eglApi) : m_eglDisplay(display) , m_eglConfig(q_configFromGLFormat(display, format)) + , m_swapInterval(-1) + , m_swapIntervalEnvChecked(false) + , m_swapIntervalFromEnv(-1) { init(format, share); Q_UNUSED(eglApi); @@ -81,6 +99,9 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform EGLConfig config, EGLenum eglApi) : m_eglDisplay(display) , m_eglConfig(config) + , m_swapInterval(-1) + , m_swapIntervalEnvChecked(false) + , m_swapIntervalFromEnv(-1) { init(format, share); Q_UNUSED(eglApi); @@ -145,6 +166,27 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) } #endif + + if (ok) { + if (!m_swapIntervalEnvChecked) { + m_swapIntervalEnvChecked = true; + if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_SWAPINTERVAL")) { + QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL"); + bool ok; + const int swapInterval = swapIntervalString.toInt(&ok); + if (ok) + m_swapIntervalFromEnv = swapInterval; + } + } + const int requestedSwapInterval = m_swapIntervalFromEnv >= 0 + ? m_swapIntervalFromEnv + : surface->format().swapInterval(); + if (requestedSwapInterval >= 0 && m_swapInterval != requestedSwapInterval) { + m_swapInterval = requestedSwapInterval; + eglSwapInterval(eglDisplay(), m_swapInterval); + } + } + return ok; } @@ -210,3 +252,5 @@ EGLConfig QEGLPlatformContext::eglConfig() const { return m_eglConfig; } + +QT_END_NAMESPACE |