Skip to content

Commit

Permalink
Remove wall time from NotifyAnimationStarted and NotifyAnimationFinis…
Browse files Browse the repository at this point in the history
…hed.

With the change to Blink only needing the monotonic time the wall time can be
removed.

DEPS=185633002,185643002
BUG=299945

Review URL: https://codereview.chromium.org/184433007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255888 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mithro@mithis.com committed Mar 10, 2014
1 parent 5801159 commit 6b81e34
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 57 deletions.
4 changes: 0 additions & 4 deletions cc/animation/animation_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ namespace cc {

class AnimationDelegate {
public:
// 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;

Expand Down
18 changes: 8 additions & 10 deletions cc/animation/layer_animation_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,15 @@ void LayerAnimationController::SetAnimationRegistrar(
}

void LayerAnimationController::NotifyAnimationStarted(
const AnimationEvent& event,
double wall_clock_time) {
const AnimationEvent& event) {
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, monotonic_time, event.target_property);
layer_animation_delegate_->NotifyAnimationStarted(monotonic_time,
event.target_property);

return;
}
Expand All @@ -305,22 +304,21 @@ void LayerAnimationController::NotifyAnimationStarted(
OnAnimationStarted(event));
if (layer_animation_delegate_)
layer_animation_delegate_->NotifyAnimationStarted(
wall_clock_time, monotonic_time, event.target_property);
monotonic_time, event.target_property);

return;
}
}
}

void LayerAnimationController::NotifyAnimationFinished(
const AnimationEvent& event,
double wall_clock_time) {
const AnimationEvent& event) {
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, monotonic_time, event.target_property);
layer_animation_delegate_->NotifyAnimationFinished(monotonic_time,
event.target_property);
return;
}

Expand All @@ -330,7 +328,7 @@ void LayerAnimationController::NotifyAnimationFinished(
active_animations_[i]->set_received_finished_event(true);
if (layer_animation_delegate_)
layer_animation_delegate_->NotifyAnimationFinished(
wall_clock_time, monotonic_time, event.target_property);
monotonic_time, event.target_property);

return;
}
Expand Down
6 changes: 2 additions & 4 deletions cc/animation/layer_animation_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ class CC_EXPORT LayerAnimationController
void SetAnimationRegistrar(AnimationRegistrar* registrar);
AnimationRegistrar* animation_registrar() { return registrar_; }

void NotifyAnimationStarted(const AnimationEvent& event,
double wall_clock_time);
void NotifyAnimationFinished(const AnimationEvent& event,
double wall_clock_time);
void NotifyAnimationStarted(const AnimationEvent& event);
void NotifyAnimationFinished(const AnimationEvent& event);
void NotifyAnimationAborted(const AnimationEvent& event);
void NotifyAnimationPropertyUpdate(const AnimationEvent& event);

Expand Down
30 changes: 12 additions & 18 deletions cc/animation/layer_animation_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) {

// Synchronize the start times.
EXPECT_EQ(1u, events.size());
controller->NotifyAnimationStarted(events[0], 0.0);
controller->NotifyAnimationStarted(events[0]);
EXPECT_EQ(controller->GetAnimation(group_id,
Animation::Opacity)->start_time(),
controller_impl->GetAnimation(group_id,
Expand Down Expand Up @@ -136,7 +136,7 @@ TEST(LayerAnimationControllerTest, Activation) {
controller_impl->Animate(kInitialTickTime);
controller_impl->UpdateState(true, events.get());
EXPECT_EQ(1u, events->size());
controller->NotifyAnimationStarted((*events)[0], 0.0);
controller->NotifyAnimationStarted((*events)[0]);

EXPECT_EQ(1u, registrar->active_animation_controllers().size());
EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
Expand All @@ -161,7 +161,7 @@ TEST(LayerAnimationControllerTest, Activation) {
EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size());

EXPECT_EQ(1u, events->size());
controller->NotifyAnimationFinished((*events)[0], 0.0);
controller->NotifyAnimationFinished((*events)[0]);
controller->Animate(kInitialTickTime + 1.5);
controller->UpdateState(true, NULL);

Expand Down Expand Up @@ -258,7 +258,7 @@ TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) {
group_id,
Animation::Opacity,
kInitialTickTime);
controller->NotifyAnimationStarted(animation_started_event, 0.0);
controller->NotifyAnimationStarted(animation_started_event);

// Force animation to complete on impl thread.
controller_impl->RemoveAnimation(animation_id);
Expand Down Expand Up @@ -297,7 +297,7 @@ TEST(LayerAnimationControllerTest, AnimationsAreDeleted) {
// There should be a Started event for the animation.
EXPECT_EQ(1u, events->size());
EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
controller->NotifyAnimationStarted((*events)[0], 0.0);
controller->NotifyAnimationStarted((*events)[0]);

controller->Animate(kInitialTickTime + 1.0);
controller->UpdateState(true, NULL);
Expand All @@ -319,7 +319,7 @@ TEST(LayerAnimationControllerTest, AnimationsAreDeleted) {
EXPECT_TRUE(controller->GetAnimation(Animation::Opacity));
EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity));

controller->NotifyAnimationFinished((*events)[0], 0.0);
controller->NotifyAnimationFinished((*events)[0]);

controller->Animate(kInitialTickTime + 3.0);
controller->UpdateState(true, NULL);
Expand Down Expand Up @@ -611,7 +611,7 @@ TEST(LayerAnimationControllerTest, ScrollOffsetTransition) {
const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
EXPECT_FALSE(event);

controller->NotifyAnimationStarted((*events)[0], 0.0);
controller->NotifyAnimationStarted((*events)[0]);
controller->Animate(kInitialTickTime + duration/2.0);
controller->UpdateState(true, NULL);
EXPECT_TRUE(controller->HasActiveAnimation());
Expand Down Expand Up @@ -689,7 +689,7 @@ TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) {
const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
EXPECT_FALSE(event);

controller->NotifyAnimationStarted((*events)[0], 0.0);
controller->NotifyAnimationStarted((*events)[0]);
controller->Animate(kInitialTickTime + duration/2.0);
controller->UpdateState(true, NULL);
EXPECT_TRUE(controller->HasActiveAnimation());
Expand Down Expand Up @@ -767,14 +767,12 @@ class FakeAnimationDelegate : public AnimationDelegate {
finished_(false) {}

virtual void NotifyAnimationStarted(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
started_ = true;
}

virtual void NotifyAnimationFinished(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
finished_ = true;
Expand Down Expand Up @@ -826,7 +824,7 @@ TEST(LayerAnimationControllerTest,
// Passing on the start event to the main thread controller should cause the
// delegate to get notified.
EXPECT_FALSE(delegate.started());
controller->NotifyAnimationStarted((*events)[0], 0.0);
controller->NotifyAnimationStarted((*events)[0]);
EXPECT_TRUE(delegate.started());

events.reset(new AnimationEventsVector);
Expand All @@ -843,7 +841,7 @@ TEST(LayerAnimationControllerTest,
// Passing on the finished event to the main thread controller should cause
// the delegate to get notified.
EXPECT_FALSE(delegate.finished());
controller->NotifyAnimationFinished((*events)[0], 0.0);
controller->NotifyAnimationFinished((*events)[0]);
EXPECT_TRUE(delegate.finished());
}

Expand Down Expand Up @@ -881,12 +879,8 @@ TEST(LayerAnimationControllerTest,
EXPECT_EQ(0.f, dummy.opacity());

// Send the synchronized start time.
controller->NotifyAnimationStarted(AnimationEvent(AnimationEvent::Started,
0,
1,
Animation::Opacity,
kInitialTickTime + 2),
0.0);
controller->NotifyAnimationStarted(AnimationEvent(
AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2));
controller->Animate(kInitialTickTime + 5.0);
controller->UpdateState(true, events.get());
EXPECT_EQ(1.f, dummy.opacity());
Expand Down
4 changes: 1 addition & 3 deletions cc/test/layer_tree_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ class TestHooks : public AnimationDelegate {
virtual base::TimeDelta LowFrequencyAnimationInterval() const;

// Implementation of AnimationDelegate:
virtual void NotifyAnimationStarted(double wall_clock_time,
base::TimeTicks monotonic_time,
virtual void NotifyAnimationStarted(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 {}

Expand Down
6 changes: 2 additions & 4 deletions cc/trees/layer_tree_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,11 @@ void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events,
if (iter != animation_controllers.end()) {
switch ((*events)[event_index].type) {
case AnimationEvent::Started:
(*iter).second->NotifyAnimationStarted((*events)[event_index],
wall_clock_time.ToDoubleT());
(*iter).second->NotifyAnimationStarted((*events)[event_index]);
break;

case AnimationEvent::Finished:
(*iter).second->NotifyAnimationFinished((*events)[event_index],
wall_clock_time.ToDoubleT());
(*iter).second->NotifyAnimationFinished((*events)[event_index]);
break;

case AnimationEvent::Aborted:
Expand Down
10 changes: 0 additions & 10 deletions cc/trees/layer_tree_host_unittest_animation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class LayerTreeHostAnimationTestAddAnimation
}

virtual void NotifyAnimationStarted(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
received_animation_started_notification_ = true;
Expand Down Expand Up @@ -243,7 +242,6 @@ class LayerTreeHostAnimationTestAnimationsGetDeleted
}

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,
Expand Down Expand Up @@ -371,7 +369,6 @@ class LayerTreeHostAnimationTestNoBackgroundTickingWithoutActiveTree
}

virtual void NotifyAnimationFinished(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
// Replace animated commits with an empty tree.
Expand Down Expand Up @@ -564,7 +561,6 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes
}

virtual void NotifyAnimationStarted(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
LayerAnimationController* controller =
Expand Down Expand Up @@ -622,7 +618,6 @@ class LayerTreeHostAnimationTestAnimationFinishedEvents
}

virtual void NotifyAnimationFinished(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
LayerAnimationController* controller =
Expand Down Expand Up @@ -958,14 +953,12 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw
}

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,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
EndTest();
Expand Down Expand Up @@ -1010,15 +1003,13 @@ class LayerTreeHostAnimationTestRunAnimationWhenNotVisible
}

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,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
EXPECT_FALSE(visible_);
Expand Down Expand Up @@ -1095,7 +1086,6 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations
}

virtual void NotifyAnimationStarted(
double wall_clock_time,
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) OVERRIDE {
if (TestEnded())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ WebToCCAnimationDelegateAdapter::WebToCCAnimationDelegateAdapter(
: delegate_(delegate) {}

void WebToCCAnimationDelegateAdapter::NotifyAnimationStarted(
double wall_clock_time,
base::TimeTicks monotonic_time,
cc::Animation::TargetProperty target_property) {
delegate_->notifyAnimationStarted(
Expand All @@ -22,7 +21,6 @@ void WebToCCAnimationDelegateAdapter::NotifyAnimationStarted(
}

void WebToCCAnimationDelegateAdapter::NotifyAnimationFinished(
double wall_clock_time,
base::TimeTicks monotonic_time,
cc::Animation::TargetProperty target_property) {
delegate_->notifyAnimationFinished(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ class WebToCCAnimationDelegateAdapter : public cc::AnimationDelegate {

private:
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;

Expand Down

0 comments on commit 6b81e34

Please sign in to comment.