When there is no render pending, renderWindow() is not called and so
there is no blocking for vsync. Advancing the animations without any
sleep is wrong in this case and results in animations running at 3x
speed in case there is no change in the scenegraph contents.
To solve this, import the threaded render loop's sleep call.
Task-number: QTBUG-42699
Change-Id: I3658a827af12d4bc2ac05c7b0b29c65e9fc99675
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
#include <QtCore/QCoreApplication>
#include <QtCore/QLibraryInfo>
+#include <QtCore/QThread>
#include <QtGui/QScreen>
#include <QtGui/QGuiApplication>
void QSGWindowsRenderLoop::render()
{
RLDEBUG("render");
+ bool rendered = false;
foreach (const WindowData &wd, m_windows) {
if (wd.pendingUpdate) {
const_cast<WindowData &>(wd).pendingUpdate = false;
renderWindow(wd.window);
+ rendered = true;
}
}
+ if (!rendered) {
+ RLDEBUG("no changes, sleep");
+ QThread::msleep(m_vsyncDelta);
+ }
+
if (m_animationDriver->isRunning()) {
RLDEBUG("advancing animations");
QSG_LOG_TIME_SAMPLE(time_start);