Bug 1495350 - Adjust fill mode to use on the compositor based on the playback rate; r=hiro
authorBrian Birtles <birtles@gmail.com>
Fri, 05 Oct 2018 05:43:49 +0000
changeset 495493 1bcc72890955ece4a5b54ee17fdffcfb4ed1401d
parent 495492 5f734ee8bbdb5faf76de55f945be1d792aa1724c
child 495494 62b3452c006c4066e0d44ffdfa6b20ac9a0a984c
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1495350
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1495350 - Adjust fill mode to use on the compositor based on the playback rate; r=hiro When a compositor animation finishes that doesn't apply a fill, rather than jumping back to the underlying value immediately we should apply a fill mode until the main thread has a chance to remove the animation from the compositor. This ensures that any main thread effects that are intended to synchronize with the end of the animation have a chance to run before we show the underlying style and helps to avoid flicker in such cases. Currently we apply this synthesized fill mode to animations when they run forwards (i.e. positive playback rate), but not backwards. This patch makes us apply the same handling when running in reverse. Differential Revision: https://phabricator.services.mozilla.com/D7259
gfx/layers/AnimationHelper.cpp
--- a/gfx/layers/AnimationHelper.cpp
+++ b/gfx/layers/AnimationHelper.cpp
@@ -549,25 +549,36 @@ ToAnimationValue(const Animatable& aAnim
 void
 AnimationHelper::SetAnimations(
   AnimationArray& aAnimations,
   InfallibleTArray<AnimData>& aAnimData,
   RefPtr<RawServoAnimationValue>& aBaseAnimationStyle)
 {
   for (uint32_t i = 0; i < aAnimations.Length(); i++) {
     Animation& animation = aAnimations[i];
-    // Adjust fill mode to fill forwards so that if the main thread is delayed
-    // in clearing this animation we don't introduce flicker by jumping back to
-    // the old underlying value
+    // Adjust fill mode so that if the main thread is delayed in clearing
+    // this animation we don't introduce flicker by jumping back to the old
+    // underlying value.
     switch (static_cast<dom::FillMode>(animation.fillMode())) {
       case dom::FillMode::None:
-        animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Forwards);
+        if (animation.playbackRate() > 0) {
+          animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Forwards);
+        } else if (animation.playbackRate() < 0) {
+          animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Backwards);
+        }
         break;
       case dom::FillMode::Backwards:
-        animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Both);
+        if (animation.playbackRate() > 0) {
+          animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Both);
+        }
+        break;
+      case dom::FillMode::Forwards:
+        if (animation.playbackRate() < 0) {
+          animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Both);
+        }
         break;
       default:
         break;
     }
 
     if (animation.baseStyle().type() != Animatable::Tnull_t) {
       aBaseAnimationStyle = ToAnimationValue(animation.baseStyle());
     }