Index: ui/gfx/animation/tween.cc |
diff --git a/ui/gfx/animation/tween.cc b/ui/gfx/animation/tween.cc |
index 483d772b5b4d47f4f7ba7f65d391f665df5819db..c05c3c38fb67c2d817887b0f0a52173e8363856c 100644 |
--- a/ui/gfx/animation/tween.cc |
+++ b/ui/gfx/animation/tween.cc |
@@ -14,6 +14,7 @@ |
#include "base/basictypes.h" |
#include "base/logging.h" |
+#include "base/numerics/safe_conversions.h" |
#include "ui/gfx/geometry/cubic_bezier.h" |
#include "ui/gfx/safe_integer_conversions.h" |
@@ -71,7 +72,7 @@ double Tween::CalculateValue(Tween::Type type, double state) { |
namespace { |
uint8 FloatToColorByte(float f) { |
- return std::min(std::max(ToRoundedInt(f * 255.f), 0), 255); |
+ return base::saturated_cast<uint8>(ToRoundedInt(f * 255.f)); |
} |
uint8 BlendColorComponents(uint8 start, |
@@ -149,7 +150,7 @@ int Tween::IntValueBetween(double value, int start, int target) { |
//static |
int Tween::LinearIntValueBetween(double value, int start, int target) { |
- return std::floor(0.5 + DoubleValueBetween(value, start, target)); |
+ return ToRoundedInt(DoubleValueBetween(value, start, target)); |
Peter Kasting
2014/10/21 00:53:56
Note: This causes test failures in TweenTest.Linea
danakj
2014/10/23 15:20:42
We should have ajuma decide the right thing here,
ajuma
2014/10/23 15:44:39
Rounding towards positive infinity is indeed part
Peter Kasting
2014/10/23 17:29:45
This isn't used for CSS transitions, though. This
ajuma
2014/10/23 17:37:11
It's used by cc::FilterOperation when animating CS
Peter Kasting
2014/10/23 17:39:52
I see...
I'll change this; in the future it would
ajuma
2014/10/23 17:42:14
FWIW, the .h file has such a comment :) But it's
danakj
2014/10/23 17:43:23
I'm not proposing that. ToRoundedInt should work l
|
} |
// static |