Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4272)

Unified Diff: cc/animation/layer_animation_controller.cc

Issue 226543005: CC should use TimeTicks and TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests related changes Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/animation/layer_animation_controller.cc
diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc
index 464801ce92fb02a3803c27cfe2b837f4d066c1e5..207c34fbf97a17c7d2e095b71ddbb95f95f33695 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -24,7 +24,7 @@ LayerAnimationController::LayerAnimationController(int id)
: registrar_(0),
id_(id),
is_active_(false),
- last_tick_time_(0),
+ last_tick_time_(base::TimeTicks()),
value_provider_(NULL),
layer_animation_delegate_(NULL) {}
@@ -39,11 +39,13 @@ scoped_refptr<LayerAnimationController> LayerAnimationController::Create(
}
void LayerAnimationController::PauseAnimation(int animation_id,
- double time_offset) {
+ base::TimeTicks time_offset) {
for (size_t i = 0; i < active_animations_.size(); ++i) {
if (active_animations_[i]->id() == animation_id) {
active_animations_[i]->SetRunState(
- Animation::Paused, time_offset + active_animations_[i]->start_time());
+ Animation::Paused,
+ (time_offset - base::TimeTicks()) +
+ active_animations_[i]->start_time());
}
}
}
@@ -123,8 +125,8 @@ void LayerAnimationController::PushAnimationUpdatesTo(
UpdateActivation(NormalActivation);
}
-void LayerAnimationController::Animate(double monotonic_time) {
- DCHECK(monotonic_time);
+void LayerAnimationController::Animate(base::TimeTicks monotonic_time) {
+ DCHECK(monotonic_time != base::TimeTicks());
if (!HasValueObserver())
return;
@@ -134,7 +136,7 @@ void LayerAnimationController::Animate(double monotonic_time) {
}
void LayerAnimationController::AccumulatePropertyUpdates(
- double monotonic_time,
+ base::TimeTicks monotonic_time,
AnimationEventsVector* events) {
if (!events)
return;
@@ -281,8 +283,7 @@ void LayerAnimationController::SetAnimationRegistrar(
void LayerAnimationController::NotifyAnimationStarted(
const AnimationEvent& event) {
- base::TimeTicks monotonic_time = base::TimeTicks::FromInternalValue(
- event.monotonic_time * base::Time::kMicrosecondsPerSecond);
+ base::TimeTicks monotonic_time = event.monotonic_time;
if (event.is_impl_only) {
FOR_EACH_OBSERVER(LayerAnimationEventObserver, event_observers_,
OnAnimationStarted(event));
@@ -314,8 +315,7 @@ void LayerAnimationController::NotifyAnimationStarted(
void LayerAnimationController::NotifyAnimationFinished(
const AnimationEvent& event) {
- base::TimeTicks monotonic_time = base::TimeTicks::FromInternalValue(
- event.monotonic_time * base::Time::kMicrosecondsPerSecond);
+ base::TimeTicks monotonic_time = event.monotonic_time;
if (event.is_impl_only) {
if (layer_animation_delegate_)
layer_animation_delegate_->NotifyAnimationFinished(monotonic_time,
@@ -575,7 +575,7 @@ void LayerAnimationController::PushPropertiesToImplThread(
}
}
-void LayerAnimationController::StartAnimations(double monotonic_time) {
+void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) {
// First collect running properties.
TargetProperties blocked_properties;
for (size_t i = 0; i < active_animations_.size(); ++i) {
@@ -616,8 +616,8 @@ void LayerAnimationController::StartAnimations(double monotonic_time) {
for (size_t j = i + 1; j < active_animations_.size(); ++j) {
if (active_animations_[i]->group() ==
active_animations_[j]->group()) {
- active_animations_[j]->SetRunState(
- Animation::Starting, monotonic_time);
+ active_animations_[j]->SetRunState(Animation::Starting,
+ monotonic_time);
}
}
}
@@ -626,7 +626,7 @@ void LayerAnimationController::StartAnimations(double monotonic_time) {
}
void LayerAnimationController::PromoteStartedAnimations(
- double monotonic_time,
+ base::TimeTicks monotonic_time,
AnimationEventsVector* events) {
for (size_t i = 0; i < active_animations_.size(); ++i) {
if (active_animations_[i]->run_state() == Animation::Starting) {
@@ -648,7 +648,8 @@ void LayerAnimationController::PromoteStartedAnimations(
}
}
-void LayerAnimationController::MarkFinishedAnimations(double monotonic_time) {
+void LayerAnimationController::MarkFinishedAnimations(
+ base::TimeTicks monotonic_time) {
for (size_t i = 0; i < active_animations_.size(); ++i) {
if (active_animations_[i]->IsFinishedAt(monotonic_time) &&
active_animations_[i]->run_state() != Animation::Aborted &&
@@ -658,7 +659,8 @@ void LayerAnimationController::MarkFinishedAnimations(double monotonic_time) {
}
void LayerAnimationController::MarkAnimationsForDeletion(
- double monotonic_time, AnimationEventsVector* events) {
+ base::TimeTicks monotonic_time,
+ AnimationEventsVector* events) {
bool marked_animations_for_deletions = false;
// Non-aborted animations are marked for deletion after a corresponding
@@ -748,7 +750,7 @@ void LayerAnimationController::PurgeAnimationsMarkedForDeletion() {
animations.end());
}
-void LayerAnimationController::TickAnimations(double monotonic_time) {
+void LayerAnimationController::TickAnimations(base::TimeTicks monotonic_time) {
for (size_t i = 0; i < active_animations_.size(); ++i) {
if (active_animations_[i]->run_state() == Animation::Starting ||
active_animations_[i]->run_state() == Animation::Running ||

Powered by Google App Engine
This is Rietveld 408576698