summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-09 21:30:25 +0000
committerajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-09 21:30:25 +0000
commit8dec4d09a4b963fe41e8dc36584bea451c7b39fd (patch)
treed899f9f1e83d8f888ef894fe28f2e994bc9a850e
parentadd747d17d785bfbb8cebbcd5f34ee7d66e647c5 (diff)
downloadchromium_src-8dec4d09a4b963fe41e8dc36584bea451c7b39fd.zip
chromium_src-8dec4d09a4b963fe41e8dc36584bea451c7b39fd.tar.gz
chromium_src-8dec4d09a4b963fe41e8dc36584bea451c7b39fd.tar.bz2
Add monotonic time and target property to cc::AnimationDelegate notifications
This adds monotonic time and target property as arguments to cc::AnimationDelegate::NotifyAnimation{Started, Finished}. The existing wall clock time argument can be removed once Blink's legacy implementation of CSS animations and transitions is removed. The target property argument is needed so that Blink can distinguish between notifications for CSS animations/transitions and notifications for the scroll animations being added for the CSSOM View smooth scroll API. BUG=299945,243871 Review URL: https://codereview.chromium.org/99733003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239554 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/animation/animation_delegate.h15
-rw-r--r--cc/animation/layer_animation_controller.cc16
-rw-r--r--cc/animation/layer_animation_controller_unittest.cc10
-rw-r--r--cc/test/layer_tree_test.h10
-rw-r--r--cc/trees/layer_tree_host_unittest_animation.cc66
-rw-r--r--webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc28
-rw-r--r--webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h10
7 files changed, 122 insertions, 33 deletions
diff --git a/cc/animation/animation_delegate.h b/cc/animation/animation_delegate.h
index c9367b8..f1176a3 100644
--- a/cc/animation/animation_delegate.h
+++ b/cc/animation/animation_delegate.h
@@ -5,12 +5,23 @@
#ifndef CC_ANIMATION_ANIMATION_DELEGATE_H_
#define CC_ANIMATION_ANIMATION_DELEGATE_H_
+#include "base/time/time.h"
+#include "cc/animation/animation.h"
+
namespace cc {
class AnimationDelegate {
public:
- virtual void NotifyAnimationStarted(double time) = 0;
- virtual void NotifyAnimationFinished(double time) = 0;
+ // TODO(ajuma): Remove wall_clock_time once the legacy implementation of
+ // CSS animations and transitions in Blink is removed.
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) = 0;
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) = 0;
protected:
virtual ~AnimationDelegate() {}
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc
index d8c976a..43d680b 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -282,11 +282,14 @@ void LayerAnimationController::SetAnimationRegistrar(
void LayerAnimationController::NotifyAnimationStarted(
const AnimationEvent& event,
double wall_clock_time) {
+ base::TimeTicks monotonic_time = base::TimeTicks::FromInternalValue(
+ event.monotonic_time * base::Time::kMicrosecondsPerSecond);
if (event.is_impl_only) {
FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_,
OnAnimationStarted(event));
if (layer_animation_delegate_)
- layer_animation_delegate_->NotifyAnimationStarted(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationStarted(
+ wall_clock_time, monotonic_time, event.target_property);
return;
}
@@ -301,7 +304,8 @@ void LayerAnimationController::NotifyAnimationStarted(
FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_,
OnAnimationStarted(event));
if (layer_animation_delegate_)
- layer_animation_delegate_->NotifyAnimationStarted(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationStarted(
+ wall_clock_time, monotonic_time, event.target_property);
return;
}
@@ -311,9 +315,12 @@ void LayerAnimationController::NotifyAnimationStarted(
void LayerAnimationController::NotifyAnimationFinished(
const AnimationEvent& event,
double wall_clock_time) {
+ base::TimeTicks monotonic_time = base::TimeTicks::FromInternalValue(
+ event.monotonic_time * base::Time::kMicrosecondsPerSecond);
if (event.is_impl_only) {
if (layer_animation_delegate_)
- layer_animation_delegate_->NotifyAnimationFinished(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationFinished(
+ wall_clock_time, monotonic_time, event.target_property);
return;
}
@@ -322,7 +329,8 @@ void LayerAnimationController::NotifyAnimationFinished(
active_animations_[i]->target_property() == event.target_property) {
active_animations_[i]->set_received_finished_event(true);
if (layer_animation_delegate_)
- layer_animation_delegate_->NotifyAnimationFinished(wall_clock_time);
+ layer_animation_delegate_->NotifyAnimationFinished(
+ wall_clock_time, monotonic_time, event.target_property);
return;
}
diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc
index 8ccfec8..47c714f 100644
--- a/cc/animation/layer_animation_controller_unittest.cc
+++ b/cc/animation/layer_animation_controller_unittest.cc
@@ -766,11 +766,17 @@ class FakeAnimationDelegate : public AnimationDelegate {
: started_(false),
finished_(false) {}
- virtual void NotifyAnimationStarted(double time) OVERRIDE {
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
started_ = true;
}
- virtual void NotifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
finished_ = true;
}
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index ac35a65..dd5a8d5 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -75,8 +75,14 @@ class TestHooks : public AnimationDelegate {
virtual base::TimeDelta LowFrequencyAnimationInterval() const;
// Implementation of AnimationDelegate:
- virtual void NotifyAnimationStarted(double time) OVERRIDE {}
- virtual void NotifyAnimationFinished(double time) OVERRIDE {}
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {}
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {}
virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) = 0;
virtual scoped_refptr<ContextProvider> OffscreenContextProvider() = 0;
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index e3ddf7f..22c8965 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -116,8 +116,7 @@ class LayerTreeHostAnimationTestAddAnimation
public:
LayerTreeHostAnimationTestAddAnimation()
: num_animates_(0),
- received_animation_started_notification_(false),
- start_time_(0.0) {
+ received_animation_started_notification_(false) {
}
virtual void BeginTest() OVERRIDE {
@@ -136,7 +135,7 @@ class LayerTreeHostAnimationTestAddAnimation
}
if (received_animation_started_notification_) {
- EXPECT_LT(0.0, start_time_);
+ EXPECT_LT(base::TimeTicks(), start_time_);
LayerAnimationController* controller_impl =
host_impl->active_tree()->root_layer()->layer_animation_controller();
@@ -149,11 +148,14 @@ class LayerTreeHostAnimationTestAddAnimation
}
}
- virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
received_animation_started_notification_ = true;
- start_time_ = wall_clock_time;
+ start_time_ = monotonic_time;
if (num_animates_) {
- EXPECT_LT(0.0, start_time_);
+ EXPECT_LT(base::TimeTicks(), start_time_);
LayerAnimationController* controller =
layer_tree_host()->root_layer()->layer_animation_controller();
@@ -171,7 +173,7 @@ class LayerTreeHostAnimationTestAddAnimation
private:
int num_animates_;
bool received_animation_started_notification_;
- double start_time_;
+ base::TimeTicks start_time_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestAddAnimation);
@@ -240,7 +242,10 @@ class LayerTreeHostAnimationTestAnimationsGetDeleted
EndTest();
}
- virtual void NotifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
// Animations on the impl-side controller only get deleted during a commit,
// so we need to schedule a commit.
layer_tree_host()->SetNeedsCommit();
@@ -310,7 +315,10 @@ class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree
PostAddAnimationToMainThread(layer_tree_host()->root_layer());
}
- virtual void NotifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
// Replace animated commits with an empty tree.
layer_tree_host()->SetRootLayer(make_scoped_refptr<Layer>(NULL));
}
@@ -500,7 +508,10 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
PostAddAnimationToMainThread(content_.get());
}
- virtual void NotifyAnimationStarted(double time) OVERRIDE {
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
LayerAnimationController* controller =
layer_tree_host()->root_layer()->children()[0]->
layer_animation_controller();
@@ -555,7 +566,10 @@ class LayerTreeHostAnimationTestAnimationFinishedEvents
PostAddInstantAnimationToMainThread(layer_tree_host()->root_layer());
}
- virtual void NotifyAnimationFinished(double time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
LayerAnimationController* controller =
layer_tree_host()->root_layer()->layer_animation_controller();
Animation* animation =
@@ -771,11 +785,17 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
PostAddAnimationToMainThread(content_.get());
}
- virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
started_times_++;
}
- virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
EndTest();
}
@@ -817,12 +837,18 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotVisible
layer_tree_host()->SetVisible(false);
}
- virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
EXPECT_FALSE(visible_);
started_times_++;
}
- virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
EXPECT_FALSE(visible_);
EXPECT_EQ(1, started_times_);
EndTest();
@@ -894,13 +920,19 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
}
}
- virtual void NotifyAnimationStarted(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
if (TestEnded())
return;
started_times_++;
}
- virtual void NotifyAnimationFinished(double wall_clock_time) OVERRIDE {
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ Animation::TargetProperty target_property) OVERRIDE {
// We should be checkerboarding already, but it should still finish the
// first animation.
EXPECT_EQ(2, added_animations_);
diff --git a/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
index 3e25b88..f5894d3 100644
--- a/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
+++ b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
@@ -12,12 +12,32 @@ WebToCCAnimationDelegateAdapter::WebToCCAnimationDelegateAdapter(
blink::WebAnimationDelegate* delegate)
: delegate_(delegate) {}
-void WebToCCAnimationDelegateAdapter::NotifyAnimationStarted(double time) {
- delegate_->notifyAnimationStarted(time);
+void WebToCCAnimationDelegateAdapter::NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ cc::Animation::TargetProperty target_property) {
+#if WEB_ANIMATION_DELEGATE_TAKES_MONOTONIC_TIME
+ delegate_->notifyAnimationStarted(
+ wall_clock_time,
+ (monotonic_time - base::TimeTicks()).InSecondsF(),
+ static_cast<blink::WebAnimation::TargetProperty>(target_property));
+#else
+ delegate_->notifyAnimationStarted(wall_clock_time);
+#endif
}
-void WebToCCAnimationDelegateAdapter::NotifyAnimationFinished(double time) {
- delegate_->notifyAnimationFinished(time);
+void WebToCCAnimationDelegateAdapter::NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ cc::Animation::TargetProperty target_property) {
+#if WEB_ANIMATION_DELEGATE_TAKES_MONOTONIC_TIME
+ delegate_->notifyAnimationFinished(
+ wall_clock_time,
+ (monotonic_time - base::TimeTicks()).InSecondsF(),
+ static_cast<blink::WebAnimation::TargetProperty>(target_property));
+#else
+ delegate_->notifyAnimationFinished(wall_clock_time);
+#endif
}
} // namespace webkit
diff --git a/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
index 9d673aa..7338322 100644
--- a/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
+++ b/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
@@ -19,8 +19,14 @@ class WebToCCAnimationDelegateAdapter : public cc::AnimationDelegate {
blink::WebAnimationDelegate* delegate);
private:
- virtual void NotifyAnimationStarted(double time) OVERRIDE;
- virtual void NotifyAnimationFinished(double time) OVERRIDE;
+ virtual void NotifyAnimationStarted(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ cc::Animation::TargetProperty target_property) OVERRIDE;
+ virtual void NotifyAnimationFinished(
+ double wall_clock_time,
+ base::TimeTicks monotonic_time,
+ cc::Animation::TargetProperty target_property) OVERRIDE;
blink::WebAnimationDelegate* delegate_;