Delay renderWindow with a timer
authorRobin Burchell <robin.burchell@jollamobile.com>
Tue, 26 Nov 2013 13:59:19 +0000 (14:59 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 27 Nov 2013 13:19:13 +0000 (14:19 +0100)
Add an exhaust delay to QSGGuiThreadRenderLoop. Some updates
may be done with posted events, and maybeUpdate event competed
with those, leading to partial updates and frames drawn twice.

Change-Id: I532bff692c597eeba5bbd6def89ae68c80fdd69b
Done-with: Mikko Harju <mikko.harju@jollamobile.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
src/quick/scenegraph/qsgrenderloop.cpp

index aa0d7b5..52df55f 100644 (file)
@@ -122,6 +122,7 @@ public:
     QSGRenderContext *rc;
 
     QImage grabContent;
+    int m_update_timer;
 
     bool eventPending;
 };
@@ -384,7 +385,8 @@ void QSGGuiThreadRenderLoop::maybeUpdate(QQuickWindow *window)
     m_windows[window].updatePending = true;
 
     if (!eventPending) {
-        QCoreApplication::postEvent(this, new QEvent(QEvent::User));
+        const int exhaust_delay = 5;
+        m_update_timer = startTimer(exhaust_delay, Qt::PreciseTimer);
         eventPending = true;
     }
 }
@@ -399,8 +401,10 @@ QSGContext *QSGGuiThreadRenderLoop::sceneGraphContext() const
 
 bool QSGGuiThreadRenderLoop::event(QEvent *e)
 {
-    if (e->type() == QEvent::User) {
+    if (e->type() == QEvent::Timer) {
         eventPending = false;
+        killTimer(m_update_timer);
+        m_update_timer = 0;
         for (QHash<QQuickWindow *, WindowData>::const_iterator it = m_windows.constBegin();
              it != m_windows.constEnd(); ++it) {
             const WindowData &data = it.value();