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

Unified Diff: cc/animation/animation.h

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
« no previous file with comments | « no previous file | cc/animation/animation.cc » ('j') | cc/layers/layer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation.h
diff --git a/cc/animation/animation.h b/cc/animation/animation.h
index 3cfc8bb82abe29e042a7db7123727a1e2fd6d105..2fec80a2410ce9f51da7055f3c1a6d7962825e1b 100644
--- a/cc/animation/animation.h
+++ b/cc/animation/animation.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
#include "cc/base/cc_export.h"
namespace cc {
@@ -60,7 +61,7 @@ class CC_EXPORT Animation {
TargetProperty target_property() const { return target_property_; }
RunState run_state() const { return run_state_; }
- void SetRunState(RunState run_state, double monotonic_time);
+ void SetRunState(RunState run_state, base::TimeTicks monotonic_time);
// This is the number of times that the animation will play. If this
// value is zero the animation will not play. If it is negative, then
@@ -68,15 +69,25 @@ class CC_EXPORT Animation {
int iterations() const { return iterations_; }
void set_iterations(int n) { iterations_ = n; }
- double start_time() const { return start_time_; }
- void set_start_time(double monotonic_time) { start_time_ = monotonic_time; }
- bool has_set_start_time() const { return !!start_time_; }
+ base::TimeTicks start_time() const { return start_time_; }
+ double ticks_inseconds(base::TimeTicks base_time) const {
enne (OOO) 2014/04/11 14:41:10 I don't think this merits a member function. Just
+ return (base_time - base::TimeTicks()).InSecondsF();
+ }
+ double delta_inseconds(base::TimeDelta delta) const {
enne (OOO) 2014/04/11 14:41:10 This doesn't need to be a member function either.
+ return delta.InSecondsF();
+ }
+ void set_start_time(base::TimeTicks monotonic_time) {
+ start_time_ = monotonic_time;
+ }
+ bool has_set_start_time() const { return (start_time_ != base::TimeTicks()); }
- double time_offset() const { return time_offset_; }
- void set_time_offset(double monotonic_time) { time_offset_ = monotonic_time; }
+ base::TimeDelta time_offset() const { return time_offset_; }
+ void set_time_offset(base::TimeDelta monotonic_time) {
+ time_offset_ = monotonic_time;
+ }
- void Suspend(double monotonic_time);
- void Resume(double monotonic_time);
+ void Suspend(base::TimeTicks monotonic_time);
+ void Resume(base::TimeTicks monotonic_time);
// If alternates_direction is true, on odd numbered iterations we reverse the
// curve.
@@ -85,7 +96,7 @@ class CC_EXPORT Animation {
alternates_direction_ = alternates;
}
- bool IsFinishedAt(double monotonic_time) const;
+ bool IsFinishedAt(base::TimeTicks monotonic_time) const;
bool is_finished() const {
return run_state_ == Finished ||
run_state_ == Aborted ||
@@ -116,9 +127,10 @@ class CC_EXPORT Animation {
// Takes the given absolute time, and using the start time and the number
// of iterations, returns the relative time in the current iteration.
- double TrimTimeToCurrentIteration(double monotonic_time) const;
+ double TrimTimeToCurrentIteration(base::TimeTicks monotonic_time) const;
scoped_ptr<Animation> CloneAndInitialize(RunState initial_run_state) const;
+
bool is_controlling_instance() const { return is_controlling_instance_; }
void PushPropertiesTo(Animation* other) const;
@@ -147,14 +159,14 @@ class CC_EXPORT Animation {
TargetProperty target_property_;
RunState run_state_;
int iterations_;
- double start_time_;
+ base::TimeTicks start_time_;
bool alternates_direction_;
// The time offset effectively pushes the start of the animation back in time.
// This is used for resuming paused animations -- an animation is added with a
// non-zero time offset, causing the animation to skip ahead to the desired
// point in time.
- double time_offset_;
+ base::TimeDelta time_offset_;
bool needs_synchronized_start_time_;
bool received_finished_event_;
@@ -168,8 +180,8 @@ class CC_EXPORT Animation {
// spent while paused. This is not included in AnimationState since it
// there is absolutely no need for clients of this controller to know
// about these values.
- double pause_time_;
- double total_paused_time_;
+ base::TimeTicks pause_time_;
+ base::TimeTicks total_paused_time_;
enne (OOO) 2014/04/11 14:41:10 total_paused_time_ seems like it should be a delta
// Animations lead dual lives. An active animation will be conceptually owned
// by two controllers, one on the impl thread and one on the main. In reality,
« no previous file with comments | « no previous file | cc/animation/animation.cc » ('j') | cc/layers/layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698