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

Side by Side Diff: ui/gfx/animation/linear_animation.cc

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP Created 7 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/animation/linear_animation.h ('k') | ui/gfx/animation/multi_animation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/animation/linear_animation.h" 5 #include "ui/gfx/animation/linear_animation.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "ui/gfx/animation/animation_container.h" 9 #include "ui/gfx/animation/animation_container.h"
10 #include "ui/gfx/animation/animation_delegate.h" 10 #include "ui/gfx/animation/animation_delegate.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 void LinearAnimation::SetDuration(int duration) { 66 void LinearAnimation::SetDuration(int duration) {
67 duration_ = TimeDelta::FromMilliseconds(duration); 67 duration_ = TimeDelta::FromMilliseconds(duration);
68 if (duration_ < timer_interval()) 68 if (duration_ < timer_interval())
69 duration_ = timer_interval(); 69 duration_ = timer_interval();
70 if (is_animating()) 70 if (is_animating())
71 SetStartTime(container()->last_tick_time()); 71 SetStartTime(container()->last_tick_time());
72 } 72 }
73 73
74 void LinearAnimation::Step(base::TimeTicks time_now) { 74 void LinearAnimation::Step(gfx::FrameTime time_now) {
75 TimeDelta elapsed_time = time_now - start_time(); 75 TimeDelta elapsed_time = time_now - start_time();
76 state_ = static_cast<double>(elapsed_time.InMicroseconds()) / 76 state_ = static_cast<double>(elapsed_time.InMicroseconds()) /
77 static_cast<double>(duration_.InMicroseconds()); 77 static_cast<double>(duration_.InMicroseconds());
78 if (state_ >= 1.0) 78 if (state_ >= 1.0)
79 state_ = 1.0; 79 state_ = 1.0;
80 80
81 AnimateToState(state_); 81 AnimateToState(state_);
82 82
83 if (delegate()) 83 if (delegate())
84 delegate()->AnimationProgressed(this); 84 delegate()->AnimationProgressed(this);
(...skipping 14 matching lines...) Expand all
99 // Set state_ to ensure we send ended to delegate and not canceled. 99 // Set state_ to ensure we send ended to delegate and not canceled.
100 state_ = 1; 100 state_ = 1;
101 AnimateToState(1.0); 101 AnimateToState(1.0);
102 } 102 }
103 103
104 bool LinearAnimation::ShouldSendCanceledFromStop() { 104 bool LinearAnimation::ShouldSendCanceledFromStop() {
105 return state_ != 1; 105 return state_ != 1;
106 } 106 }
107 107
108 } // namespace gfx 108 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/animation/linear_animation.h ('k') | ui/gfx/animation/multi_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698