[go: nahoru, domu]

[ScrollTimeline] Support composited scroll-linked Web Animation (2/2)

crrev.com/c/2084088 implemented the necessary plumbing from blink to cc
to support composited scroll-linked animations. This patch completes the
ticking logic in cc.

Major changes include:
 - Passing ticking_animations_ to cc::AnimationTimeline and ticking
   animations from AnimationTimeline such that cc::Animation does not
   need to be aware of upper level concepts such as ScrollTree.
 - Splitting ticking methods for time/scroll linked animations.
 - Using KeyframeEffect::Pause() instead of Tick() for scroll linked
   animations.
 - Updating KeyframeEffect::last_tick_time_ to base::Optional to be
   compatible with both time/scroll linked animations.

Bug: 1023508
Change-Id: Ic1952c06205dea6ef2eaed37eceb86ae35db9c91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106820
Commit-Queue: Yi Gu <yigu@chromium.org>
Reviewed-by: Majid Valipour <majidvp@chromium.org>
Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763555}
diff --git a/cc/animation/animation_timeline.cc b/cc/animation/animation_timeline.cc
index 766257ac..7f79b387 100644
--- a/cc/animation/animation_timeline.cc
+++ b/cc/animation/animation_timeline.cc
@@ -8,6 +8,7 @@
 
 #include "cc/animation/animation.h"
 #include "cc/animation/animation_host.h"
+#include "cc/trees/property_tree.h"
 
 namespace cc {
 
@@ -82,6 +83,36 @@
   SetNeedsPushProperties();
 }
 
+bool AnimationTimeline::TickTimeLinkedAnimations(
+    const std::vector<scoped_refptr<Animation>>& ticking_animations,
+    base::TimeTicks monotonic_time) {
+  DCHECK(!IsScrollTimeline());
+
+  bool animated = false;
+  for (auto& animation : ticking_animations) {
+    if (animation->animation_timeline() != this)
+      continue;
+    // Worklet animations are ticked separately by AnimationHost.
+    if (animation->IsWorkletAnimation())
+      continue;
+
+    // Scroll-linked animations are ticked separately.
+    if (animation->IsScrollLinkedAnimation())
+      continue;
+
+    animation->Tick(monotonic_time);
+    animated = true;
+  }
+  return animated;
+}
+
+bool AnimationTimeline::TickScrollLinkedAnimations(
+    const std::vector<scoped_refptr<Animation>>& ticking_animations,
+    const ScrollTree& scroll_tree,
+    bool is_active_tree) {
+  return false;
+}
+
 void AnimationTimeline::SetNeedsPushProperties() {
   needs_push_properties_ = true;
   if (animation_host_)