diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-29 10:48:54 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-29 10:48:54 +0100 |
commit | 4e33b069c426c975319d91e11223114fd0d8ad40 (patch) | |
tree | d73e1251bc313b7303fdb000c0789cdfb4c7bb1f /src/quick/scenegraph/qsgcontext.cpp | |
parent | d9e70d1a49af347f79db7e64bdd8e2e8083a77b5 (diff) | |
parent | 05d8ffb4dff5e693967c8ee7cee6d6158eadccbd (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/quick/items/qquickaccessibleattached_p.h
src/quick/items/qquickwindow.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp
Change-Id: I8bf07487a75f9d1b0d6efa5914dd06875fc9654d
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index b87ab3686f..2a0fae9f72 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -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; }; |