Enable QML_FIXED_ANIMATION_STEP by default with buffer queueing.
authorGunnar Sletta <gunnar.sletta@nokia.com>
Thu, 24 May 2012 14:05:17 +0000 (16:05 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 29 May 2012 08:54:05 +0000 (10:54 +0200)
On Mac OS X and other systems with buffer queueing GL,
we have very jerky animations as the pipeline
does not block at regular intervals, causing the
current-time based animations to come out very jerky
despite us rendering at 60 FPS with a very good margin.

To remedy this, we switch the default so that we by default
advance with a fixed increment, making the uneven frames
not a problem. This then comes at the cost of that animations
will slow down if the application does not manage to render
within 16 ms, but this is an acceptible compromise. Aka,
now it will occationally look bad, as opposed to always bad
which it currently does.

Change-Id: I44a6c3e51f434e4235e49485182380ea531876d9
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/quick/items/qquickwindowmanager.cpp

index 392085a..2022d24 100644 (file)
@@ -135,7 +135,6 @@ extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_
   after shouldExit has been set to true.
  */
 
-DEFINE_BOOL_CONFIG_OPTION(qmlFixedAnimationStep, QML_FIXED_ANIMATION_STEP);
 DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP);
 DEFINE_BOOL_CONFIG_OPTION(qmlForceThreadedRenderer, QML_FORCE_THREADED_RENDERER); // Might trigger graphics driver threading bugs, use at own risk
 
@@ -332,14 +331,22 @@ QQuickWindowManager *QQuickWindowManager::instance()
 
         theInstance = QSGContext::createWindowManager();
 
-        bool fancy = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::BufferQueueingOpenGL)
+        bool bufferQueuing = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::BufferQueueingOpenGL);
+        bool fancy = bufferQueuing
             && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL);
         if (qmlNoThreadedRenderer())
             fancy = false;
         else if (qmlForceThreadedRenderer())
             fancy = true;
 
-        if (qmlFixedAnimationStep())
+        // Enable fixed animation steps...
+        QByteArray fixed = qgetenv("QML_FIXED_ANIMATION_STEP");
+        bool fixedAnimationSteps = bufferQueuing;
+        if (fixed == "no")
+            fixedAnimationSteps = false;
+        else if (fixed.length())
+            fixedAnimationSteps = true;
+        if (fixedAnimationSteps)
             QUnifiedTimer::instance(true)->setConsistentTiming(true);
 
         if (!theInstance) {