| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tween.h" | 5 #include "ui/gfx/animation/tween.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <float.h> | 10 #include <float.h> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // static | 124 // static |
| 125 int Tween::IntValueBetween(double value, int start, int target) { | 125 int Tween::IntValueBetween(double value, int start, int target) { |
| 126 if (start == target) | 126 if (start == target) |
| 127 return start; | 127 return start; |
| 128 double delta = static_cast<double>(target - start); | 128 double delta = static_cast<double>(target - start); |
| 129 if (delta < 0) | 129 if (delta < 0) |
| 130 delta--; | 130 delta--; |
| 131 else | 131 else |
| 132 delta++; | 132 delta++; |
| 133 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
| 134 return start + static_cast<int>(value * _nextafter(delta, 0)); | 134 value *= _nextafter(delta, 0); |
| 135 #else | 135 #else |
| 136 return start + static_cast<int>(value * nextafter(delta, 0)); | 136 value *= nextafter(delta, 0); |
| 137 #endif | 137 #endif |
| 138 return start + static_cast<int>(value); |
| 138 } | 139 } |
| 139 | 140 |
| 140 //static | 141 //static |
| 141 int Tween::LinearIntValueBetween(double value, int start, int target) { | 142 int Tween::LinearIntValueBetween(double value, int start, int target) { |
| 142 return std::floor(0.5 + DoubleValueBetween(value, start, target)); | 143 return std::floor(0.5 + DoubleValueBetween(value, start, target)); |
| 143 } | 144 } |
| 144 | 145 |
| 145 // static | 146 // static |
| 146 gfx::Rect Tween::RectValueBetween(double value, | 147 gfx::Rect Tween::RectValueBetween(double value, |
| 147 const gfx::Rect& start_bounds, | 148 const gfx::Rect& start_bounds, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 164 if (value <= 0.0) | 165 if (value <= 0.0) |
| 165 return start_transform; | 166 return start_transform; |
| 166 | 167 |
| 167 gfx::Transform to_return = end_transform; | 168 gfx::Transform to_return = end_transform; |
| 168 to_return.Blend(start_transform, value); | 169 to_return.Blend(start_transform, value); |
| 169 | 170 |
| 170 return to_return; | 171 return to_return; |
| 171 } | 172 } |
| 172 | 173 |
| 173 } // namespace gfx | 174 } // namespace gfx |
| OLD | NEW |