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

Unified Diff: cc/animation/layer_animation_controller.cc

Issue 231133002: CC::Animations should use TimeTicks & TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding Animation related changes and unittests 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..c1e6dc2207031741111d6b55d8340503bb9c9a0b 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,9 +39,12 @@ scoped_refptr<LayerAnimationController> LayerAnimationController::Create(
}
void LayerAnimationController::PauseAnimation(int animation_id,
- double time_offset) {
+ base::TimeDelta time_offset) {
for (size_t i = 0; i < active_animations_.size(); ++i) {
if (active_animations_[i]->id() == animation_id) {
+ // TODO(sikugu): http://crbug.com/178171 - Remove double
+ // and use base::TimeTicks/TimeDelta instead all over the file.
+ // Remove usage of TimeTicksToDoubleTime.
active_animations_[i]->SetRunState(
Animation::Paused, time_offset + active_animations_[i]->start_time());
}
@@ -123,8 +126,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 +137,7 @@ void LayerAnimationController::Animate(double monotonic_time) {
}
void LayerAnimationController::AccumulatePropertyUpdates(
- double monotonic_time,
+ base::TimeTicks monotonic_time,
AnimationEventsVector* events) {
if (!events)
return;
@@ -281,15 +284,12 @@ void LayerAnimationController::SetAnimationRegistrar(
void LayerAnimationController::NotifyAnimationStarted(
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(monotonic_time,
+ layer_animation_delegate_->NotifyAnimationStarted(event.monotonic_time,
event.target_property);
-
return;
}
@@ -305,7 +305,7 @@ void LayerAnimationController::NotifyAnimationStarted(
OnAnimationStarted(event));
if (layer_animation_delegate_)
layer_animation_delegate_->NotifyAnimationStarted(
- monotonic_time, event.target_property);
+ event.monotonic_time, event.target_property);
return;
}
@@ -314,11 +314,9 @@ void LayerAnimationController::NotifyAnimationStarted(
void LayerAnimationController::NotifyAnimationFinished(
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(monotonic_time,
+ layer_animation_delegate_->NotifyAnimationFinished(event.monotonic_time,
event.target_property);
return;
}
@@ -329,7 +327,7 @@ void LayerAnimationController::NotifyAnimationFinished(
active_animations_[i]->set_received_finished_event(true);
if (layer_animation_delegate_)
layer_animation_delegate_->NotifyAnimationFinished(
- monotonic_time, event.target_property);
+ event.monotonic_time, event.target_property);
return;
}
@@ -575,7 +573,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) {
@@ -626,7 +624,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 +646,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 +657,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 +748,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