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

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

Issue 1543183002: Switch to standard integer types in ui/gfx/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 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 #include <stdint.h>
8 9
9 #include <algorithm> 10 #include <algorithm>
10 11
11 #include "ui/gfx/animation/animation_container.h" 12 #include "ui/gfx/animation/animation_container.h"
12 #include "ui/gfx/animation/animation_delegate.h" 13 #include "ui/gfx/animation/animation_delegate.h"
13 14
14 using base::Time; 15 using base::Time;
15 using base::TimeDelta; 16 using base::TimeDelta;
16 17
17 namespace gfx { 18 namespace gfx {
(...skipping 25 matching lines...) Expand all
43 } 44 }
44 45
45 double LinearAnimation::GetCurrentValue() const { 46 double LinearAnimation::GetCurrentValue() const {
46 // Default is linear relationship, subclass to adapt. 47 // Default is linear relationship, subclass to adapt.
47 return state_; 48 return state_;
48 } 49 }
49 50
50 void LinearAnimation::SetCurrentValue(double new_value) { 51 void LinearAnimation::SetCurrentValue(double new_value) {
51 new_value = std::max(0.0, std::min(1.0, new_value)); 52 new_value = std::max(0.0, std::min(1.0, new_value));
52 base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds( 53 base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds(
53 static_cast<int64>(duration_.InMicroseconds() * (new_value - state_))); 54 static_cast<int64_t>(duration_.InMicroseconds() * (new_value - state_)));
54 SetStartTime(start_time() - time_delta); 55 SetStartTime(start_time() - time_delta);
55 state_ = new_value; 56 state_ = new_value;
56 } 57 }
57 58
58 void LinearAnimation::End() { 59 void LinearAnimation::End() {
59 if (!is_animating()) 60 if (!is_animating())
60 return; 61 return;
61 62
62 // NOTE: We don't use AutoReset here as Stop may end up deleting us (by way 63 // NOTE: We don't use AutoReset here as Stop may end up deleting us (by way
63 // of the delegate). 64 // of the delegate).
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Set state_ to ensure we send ended to delegate and not canceled. 102 // Set state_ to ensure we send ended to delegate and not canceled.
102 state_ = 1; 103 state_ = 1;
103 AnimateToState(1.0); 104 AnimateToState(1.0);
104 } 105 }
105 106
106 bool LinearAnimation::ShouldSendCanceledFromStop() { 107 bool LinearAnimation::ShouldSendCanceledFromStop() {
107 return state_ != 1; 108 return state_ != 1;
108 } 109 }
109 110
110 } // namespace gfx 111 } // 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