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

Unified Diff: ui/gfx/animation/linear_animation.cc

Issue 2329633003: Implement progress bar spec (determinate and indeterminate). (Closed)
Patch Set: self review Created 4 years, 3 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: ui/gfx/animation/linear_animation.cc
diff --git a/ui/gfx/animation/linear_animation.cc b/ui/gfx/animation/linear_animation.cc
index 7c7327958b2ce2abe61dd5f429667904214b475b..28c338d670ee3890ec2e859439859e5fabdae5f5 100644
--- a/ui/gfx/animation/linear_animation.cc
+++ b/ui/gfx/animation/linear_animation.cc
@@ -17,6 +17,9 @@ using base::TimeDelta;
namespace gfx {
+// How many frames per second to target.
+static const int kDefaultFrameRateHz = 60;
+
static TimeDelta CalculateInterval(int frame_rate) {
int timer_interval = 1000000 / frame_rate;
if (timer_interval < 10000)
@@ -24,19 +27,16 @@ static TimeDelta CalculateInterval(int frame_rate) {
return TimeDelta::FromMicroseconds(timer_interval);
}
-LinearAnimation::LinearAnimation(int frame_rate,
- AnimationDelegate* delegate)
- : Animation(CalculateInterval(frame_rate)),
- state_(0.0),
- in_end_(false) {
- set_delegate(delegate);
-}
+LinearAnimation::LinearAnimation(int frame_rate, AnimationDelegate* delegate)
+ : LinearAnimation(0, frame_rate, delegate) {}
+
+LinearAnimation::LinearAnimation(AnimationDelegate* delegate)
+ : LinearAnimation(kDefaultFrameRateHz, delegate) {}
LinearAnimation::LinearAnimation(int duration,
int frame_rate,
AnimationDelegate* delegate)
: Animation(CalculateInterval(frame_rate)),
- duration_(TimeDelta::FromMilliseconds(duration)),
state_(0.0),
in_end_(false) {
set_delegate(delegate);

Powered by Google App Engine
This is Rietveld 408576698