| 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) | |
| 10 #include <float.h> | |
| 11 #endif | |
| 12 | |
| 13 #include <algorithm> | 9 #include <algorithm> |
| 14 | 10 |
| 15 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 16 #include "base/logging.h" | 12 #include "base/logging.h" |
| 17 #include "ui/gfx/geometry/cubic_bezier.h" | 13 #include "ui/gfx/geometry/cubic_bezier.h" |
| 18 #include "ui/gfx/safe_integer_conversions.h" | 14 #include "ui/gfx/safe_integer_conversions.h" |
| 19 | 15 |
| 20 namespace gfx { | 16 namespace gfx { |
| 21 | 17 |
| 22 // static | 18 // static |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 129 |
| 134 // static | 130 // static |
| 135 int Tween::IntValueBetween(double value, int start, int target) { | 131 int Tween::IntValueBetween(double value, int start, int target) { |
| 136 if (start == target) | 132 if (start == target) |
| 137 return start; | 133 return start; |
| 138 double delta = static_cast<double>(target - start); | 134 double delta = static_cast<double>(target - start); |
| 139 if (delta < 0) | 135 if (delta < 0) |
| 140 delta--; | 136 delta--; |
| 141 else | 137 else |
| 142 delta++; | 138 delta++; |
| 143 #if defined(OS_WIN) | |
| 144 return start + static_cast<int>(value * _nextafter(delta, 0)); | |
| 145 #else | |
| 146 return start + static_cast<int>(value * nextafter(delta, 0)); | 139 return start + static_cast<int>(value * nextafter(delta, 0)); |
| 147 #endif | |
| 148 } | 140 } |
| 149 | 141 |
| 150 //static | 142 //static |
| 151 int Tween::LinearIntValueBetween(double value, int start, int target) { | 143 int Tween::LinearIntValueBetween(double value, int start, int target) { |
| 152 return std::floor(0.5 + DoubleValueBetween(value, start, target)); | 144 return std::floor(0.5 + DoubleValueBetween(value, start, target)); |
| 153 } | 145 } |
| 154 | 146 |
| 155 // static | 147 // static |
| 156 gfx::Rect Tween::RectValueBetween(double value, | 148 gfx::Rect Tween::RectValueBetween(double value, |
| 157 const gfx::Rect& start_bounds, | 149 const gfx::Rect& start_bounds, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 174 if (value <= 0.0) | 166 if (value <= 0.0) |
| 175 return start_transform; | 167 return start_transform; |
| 176 | 168 |
| 177 gfx::Transform to_return = end_transform; | 169 gfx::Transform to_return = end_transform; |
| 178 to_return.Blend(start_transform, value); | 170 to_return.Blend(start_transform, value); |
| 179 | 171 |
| 180 return to_return; | 172 return to_return; |
| 181 } | 173 } |
| 182 | 174 |
| 183 } // namespace gfx | 175 } // namespace gfx |
| OLD | NEW |