diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-01-28 09:48:26 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-04-24 12:09:30 +0000 |
commit | 85bb158ddf08aca4d76c13c6a9fcd2637d84d3ea (patch) | |
tree | 1136cf05b7e0ab62e7dc11e794affeb6ab5e073f /src/hardwareintegration/client/wayland-egl | |
parent | 821cd2eae36ddbd9642208ad75a669c8c15f1b5f (diff) | |
download | qtwayland-85bb158ddf08aca4d76c13c6a9fcd2637d84d3ea.tar.gz |
Client: Full implementation for frame callbacks (second try)
The Wayland plugin now takes full control over delivering update request and
implement frame callbacks for both egl and shm.
[ChangeLog][QPA plugin] The non-blocking version of eglSwapBuffers is now used, if
supported. This fixed a bug where minimized windows would block the event loop.
[ChangeLog][QPA plugin] Windows that don't get frame callbacks from the
compositor within 100 ms are now set as not exposed. This should stop most
clients from rendering unnecessary frames to minimized or hidden windows.
Also, when we relied on the QPA version of requestUpdate, we would sometimes
deliver one update request while we were waiting for a frame callback. When we
implement the fallback timer ourselves we can make sure we only deliver the
fallback if there are no pending frame callbacks.
QtQuick and other applications often depend on blocking swapBuffers to throttle
animations. If the context's surface format has a non-zero swapInterval, try to
emulate a blocking swap.
Fixes: QTBUG-69077
Change-Id: I3c6964f31a16e9aff70b8ec3c5340e640a30fef2
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/hardwareintegration/client/wayland-egl')
-rw-r--r-- | src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index c9bd8375..6b9776e9 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -316,7 +316,9 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis mSupportNonBlockingSwap = false; } if (!mSupportNonBlockingSwap) { - qWarning() << "Non-blocking swap buffers not supported. Subsurface rendering can be affected."; + qWarning(lcQpaWayland) << "Non-blocking swap buffers not supported." + << "Subsurface rendering can be affected." + << "It may also cause the event loop to freeze in some situations"; } updateGLFormat(); @@ -556,20 +558,15 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) m_blitter->blit(window); } - - QWaylandSubSurface *sub = window->subSurfaceWindow(); - if (sub) { - QMutexLocker l(sub->syncMutex()); - - int si = (sub->isSync() && mSupportNonBlockingSwap) ? 0 : m_format.swapInterval(); - - eglSwapInterval(m_eglDisplay, si); - eglSwapBuffers(m_eglDisplay, eglSurface); - } else { - eglSwapInterval(m_eglDisplay, m_format.swapInterval()); - eglSwapBuffers(m_eglDisplay, eglSurface); + int swapInterval = mSupportNonBlockingSwap ? 0 : m_format.swapInterval(); + eglSwapInterval(m_eglDisplay, swapInterval); + if (swapInterval == 0 && m_format.swapInterval() > 0) { + // Emulating a blocking swap + glFlush(); // Flush before waiting so we can swap more quickly when the frame event arrives + window->waitForFrameSync(100); } - + window->handleUpdate(); + eglSwapBuffers(m_eglDisplay, eglSurface); window->setCanResize(true); } |