| OLD | NEW | 
|---|
| 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  Loading... | 
| 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  Loading... | 
| 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 | 
| OLD | NEW | 
|---|