Commit 5871f3e8 authored by Gunnar Sletta's avatar Gunnar Sletta
Browse files

Tweak new animation driver.


We're removing the bad/reallyBad concept for the benefit of an
accumulated lag. When the lag passes over a certain threshold, we
switch to time based. The logic for switching back remains unchanged.

We also fixed the switching so that elapsed() does not jump from the
predicted time to the animation system's wall time, but rather
continues from the predicted time with a walltime offset (this is how
it was always intended to be).

Task-number: QTBUG-42020
Change-Id: I7ee9181aca46cbc18a74fae5e8d513365906c017
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
parent 09a67ad9
dev 5.10 5.11 5.12 5.12.1 5.12.10 5.12.11 5.12.12 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13 5.13.0 5.13.1 5.13.2 5.14 5.14.0 5.14.1 5.14.2 5.15 5.15.0 5.15.1 5.15.2 5.4 5.5 5.6 5.7 5.8 5.9 5.9.8 6.0 6.0.0 6.1 6.1.0 6.1.1 6.1.2 6.1.3 6.2 6.2.0 6.2.1 6.2.2 wip/cmake wip/dbus wip/itemviews wip/nacl wip/new-backend wip/pointerhandler wip/propertycache-refactor wip/qquickdeliveryagent wip/scenegraphng wip/tizen wip/webassembly v5.15.0-alpha1 v5.14.1 v5.14.0 v5.14.0-rc2 v5.14.0-rc1 v5.14.0-beta3 v5.14.0-beta2 v5.14.0-beta1 v5.14.0-alpha1 v5.13.2 v5.13.1 v5.13.0 v5.13.0-rc3 v5.13.0-rc2 v5.13.0-rc1 v5.13.0-beta4 v5.13.0-beta3 v5.13.0-beta2 v5.13.0-beta1 v5.13.0-alpha1 v5.12.7 v5.12.6 v5.12.5 v5.12.4 v5.12.3 v5.12.2 v5.12.1 v5.12.0 v5.12.0-rc2 v5.12.0-rc1 v5.12.0-beta4 v5.12.0-beta3 v5.12.0-beta2 v5.12.0-beta1 v5.12.0-alpha1 v5.11.3 v5.11.2 v5.11.1 v5.11.0 v5.11.0-rc2 v5.11.0-rc1 v5.11.0-beta4 v5.11.0-beta3 v5.11.0-beta2 v5.11.0-beta1 v5.11.0-alpha1 v5.10.1 v5.10.0 v5.10.0-rc3 v5.10.0-rc2 v5.10.0-rc1 v5.10.0-beta4 v5.10.0-beta3 v5.10.0-beta2 v5.10.0-beta1 v5.10.0-alpha1 v5.9.9 v5.9.8 v5.9.7 v5.9.6 v5.9.5 v5.9.4 v5.9.3 v5.9.2 v5.9.1 v5.9.0 v5.9.0-rc2 v5.9.0-rc1 v5.9.0-beta4 v5.9.0-beta3 v5.9.0-beta2 v5.9.0-beta1 v5.9.0-alpha1 v5.8.0 v5.8.0-rc1 v5.8.0-beta1 v5.8.0-alpha1 v5.7.1 v5.7.0 v5.7.0-rc1 v5.7.0-beta1 v5.7.0-alpha1 v5.6.3 v5.6.2 v5.6.1 v5.6.1-1 v5.6.0 v5.6.0-rc1 v5.6.0-beta1 v5.6.0-alpha1 v5.5.1 v5.5.0 v5.5.0-rc1 v5.5.0-beta1 v5.5.0-alpha1 v5.4.2 v5.4.1 v5.4.0 v5.4.0-rc1
No related merge requests found
Showing with 18 additions and 18 deletions
......@@ -162,7 +162,6 @@ public:
, m_vsync(0)
, m_mode(VSyncMode)
, m_bad(0)
, m_reallyBad(0)
, m_good(0)
{
QScreen *screen = QGuiApplication::primaryScreen();
......@@ -185,6 +184,7 @@ public:
{
m_time = 0;
m_timer.start();
m_wallTime.restart();
QAnimationDriver::start();
}
......@@ -192,7 +192,7 @@ public:
{
return m_mode == VSyncMode
? qint64(m_time)
: QAnimationDriver::elapsed();
: qint64(m_time) + m_wallTime.elapsed();
}
void advance() Q_DECL_OVERRIDE
......@@ -217,25 +217,22 @@ public:
m_time += m_vsync;
if (delta > m_vsync * 5) {
++m_reallyBad;
++m_bad;
} else if (delta > m_vsync * 1.25) {
++m_bad;
if (delta > m_vsync * 1.25) {
m_lag += (delta / m_vsync);
m_bad++;
// We tolerate one bad frame without resorting to timer based. This is
// done to cope with a slow loader frame followed by smooth animation.
// However, on the second frame with massive lag, we switch.
if (m_lag > 10 && m_bad > 2) {
m_mode = TimerMode;
qCDebug(QSG_LOG_INFO, "animation driver switched to timer mode");
m_wallTime.restart();
}
} else {
// reset counters on a good frame.
m_reallyBad = 0;
m_lag = 0;
m_bad = 0;
}
// rational for the 3 and 50. If we have several really bad frames
// in a row, that would indicate a huge performance problem and we should
// switch right away. For the case of m_bad, we're a bit more tolerant.
if (m_reallyBad > 3 || m_bad > 50) {
m_mode = TimerMode;
qCDebug(QSG_LOG_INFO, "animation driver switched to timer mode");
}
} else {
if (delta < 1.25 * m_vsync) {
++m_good;
......@@ -249,6 +246,8 @@ public:
if (m_good > 10 && !qsg_useConsistentTiming()) {
m_time = elapsed();
m_mode = VSyncMode;
m_bad = 0;
m_lag = 0;
qCDebug(QSG_LOG_INFO, "animation driver switched to vsync mode");
}
}
......@@ -260,8 +259,9 @@ public:
float m_vsync;
Mode m_mode;
QElapsedTimer m_timer;
QElapsedTimer m_wallTime;
float m_lag;
int m_bad;
int m_reallyBad;
int m_good;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment