| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/base/math_util.h" | 5 #include "cc/base/math_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Rect& r) { | 699 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Rect& r) { |
| 700 scoped_ptr<base::ListValue> res(new base::ListValue()); | 700 scoped_ptr<base::ListValue> res(new base::ListValue()); |
| 701 res->AppendInteger(r.x()); | 701 res->AppendInteger(r.x()); |
| 702 res->AppendInteger(r.y()); | 702 res->AppendInteger(r.y()); |
| 703 res->AppendInteger(r.width()); | 703 res->AppendInteger(r.width()); |
| 704 res->AppendInteger(r.height()); | 704 res->AppendInteger(r.height()); |
| 705 return res.Pass(); | 705 return res.Pass(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { | 708 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { |
| 709 const base::ListValue* value = NULL; | 709 const base::ListValue* value = nullptr; |
| 710 if (!raw_value->GetAsList(&value)) | 710 if (!raw_value->GetAsList(&value)) |
| 711 return false; | 711 return false; |
| 712 | 712 |
| 713 if (value->GetSize() != 4) | 713 if (value->GetSize() != 4) |
| 714 return false; | 714 return false; |
| 715 | 715 |
| 716 int x, y, w, h; | 716 int x, y, w, h; |
| 717 bool ok = true; | 717 bool ok = true; |
| 718 ok &= value->GetInteger(0, &x); | 718 ok &= value->GetInteger(0, &x); |
| 719 ok &= value->GetInteger(1, &y); | 719 ok &= value->GetInteger(1, &y); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 819 |
| 820 double MathUtil::AsDoubleSafely(double value) { | 820 double MathUtil::AsDoubleSafely(double value) { |
| 821 return std::min(value, std::numeric_limits<double>::max()); | 821 return std::min(value, std::numeric_limits<double>::max()); |
| 822 } | 822 } |
| 823 | 823 |
| 824 float MathUtil::AsFloatSafely(float value) { | 824 float MathUtil::AsFloatSafely(float value) { |
| 825 return std::min(value, std::numeric_limits<float>::max()); | 825 return std::min(value, std::numeric_limits<float>::max()); |
| 826 } | 826 } |
| 827 | 827 |
| 828 } // namespace cc | 828 } // namespace cc |
| OLD | NEW |