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

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: Self review changes. Created 6 years, 7 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 239a29ae30d5d56972eafe636649c717a81df1eb..1dd936af7262d10bf0e6c7dde8bad2bf1c39b3a5 100644
--- a/cc/animation/layer_animation_controller.cc
+++ b/cc/animation/layer_animation_controller.cc
@@ -14,6 +14,7 @@
#include "cc/animation/layer_animation_value_provider.h"
#include "cc/animation/scroll_offset_animation_curve.h"
#include "cc/base/scoped_ptr_algorithm.h"
+#include "cc/base/time_util.h"
#include "cc/output/filter_operations.h"
#include "ui/gfx/box_f.h"
#include "ui/gfx/transform.h"
@@ -24,9 +25,10 @@ LayerAnimationController::LayerAnimationController(int id)
: registrar_(0),
id_(id),
is_active_(false),
- last_tick_time_(0),
+ last_tick_time_(),
value_provider_(NULL),
- layer_animation_delegate_(NULL) {}
+ layer_animation_delegate_(NULL) {
+}
LayerAnimationController::~LayerAnimationController() {
if (registrar_)
@@ -39,7 +41,7 @@ scoped_refptr<LayerAnimationController> LayerAnimationController::Create(
}
void LayerAnimationController::PauseAnimation(int animation_id,
- double time_offset) {
+ base::TimeDelta time_offset) {
for (size_t i = 0; i < animations_.size(); ++i) {
if (animations_[i]->id() == animation_id) {
animations_[i]->SetRunState(Animation::Paused,
@@ -121,8 +123,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;
@@ -132,7 +134,7 @@ void LayerAnimationController::Animate(double monotonic_time) {
}
void LayerAnimationController::AccumulatePropertyUpdates(
- double monotonic_time,
+ base::TimeTicks monotonic_time,
AnimationEventsVector* events) {
if (!events)
return;
@@ -203,7 +205,7 @@ void LayerAnimationController::UpdateState(bool start_ready_animations,
if (!HasActiveValueObserver())
return;
- DCHECK(last_tick_time_);
+ DCHECK(TimeUtil::TicksInSecondsF(last_tick_time_));
ajuma 2014/05/05 15:13:32 DCHECK(last_tick_time != base::TimeTicks()) (This
Sikugu_ 2014/05/07 14:49:07 Done.
if (start_ready_animations)
PromoteStartedAnimations(last_tick_time_, events);
@@ -300,15 +302,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;
}
@@ -324,7 +323,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;
}
@@ -333,11 +332,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;
}
@@ -348,7 +345,7 @@ void LayerAnimationController::NotifyAnimationFinished(
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;
}
@@ -598,7 +595,7 @@ void LayerAnimationController::PushPropertiesToImplThread(
}
}
-void LayerAnimationController::StartAnimations(double monotonic_time) {
+void LayerAnimationController::StartAnimations(base::TimeTicks monotonic_time) {
// First collect running properties affecting each type of observer.
TargetProperties blocked_properties_for_active_observers;
TargetProperties blocked_properties_for_pending_observers;
@@ -669,7 +666,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 < animations_.size(); ++i) {
if (animations_[i]->run_state() == Animation::Starting &&
@@ -691,7 +688,8 @@ void LayerAnimationController::PromoteStartedAnimations(
}
}
-void LayerAnimationController::MarkFinishedAnimations(double monotonic_time) {
+void LayerAnimationController::MarkFinishedAnimations(
+ base::TimeTicks monotonic_time) {
for (size_t i = 0; i < animations_.size(); ++i) {
if (animations_[i]->IsFinishedAt(monotonic_time) &&
animations_[i]->run_state() != Animation::Aborted &&
@@ -701,7 +699,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
@@ -788,7 +787,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 < animations_.size(); ++i) {
if (animations_[i]->run_state() == Animation::Starting ||
animations_[i]->run_state() == Animation::Running ||

Powered by Google App Engine
This is Rietveld 408576698