| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) { | 529 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) { |
| 530 scoped_ptr<base::ListValue> res(new base::ListValue()); | 530 scoped_ptr<base::ListValue> res(new base::ListValue()); |
| 531 res->AppendInteger(r.x()); | 531 res->AppendInteger(r.x()); |
| 532 res->AppendInteger(r.y()); | 532 res->AppendInteger(r.y()); |
| 533 res->AppendInteger(r.width()); | 533 res->AppendInteger(r.width()); |
| 534 res->AppendInteger(r.height()); | 534 res->AppendInteger(r.height()); |
| 535 return res.PassAs<base::Value>(); | 535 return res.PassAs<base::Value>(); |
| 536 } | 536 } |
| 537 | 537 |
| 538 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { | 538 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { |
| 539 const ListValue* value = NULL; | 539 const base::ListValue* value = NULL; |
| 540 if (!raw_value->GetAsList(&value)) | 540 if (!raw_value->GetAsList(&value)) |
| 541 return false; | 541 return false; |
| 542 | 542 |
| 543 if (value->GetSize() != 4) | 543 if (value->GetSize() != 4) |
| 544 return false; | 544 return false; |
| 545 | 545 |
| 546 int x, y, w, h; | 546 int x, y, w, h; |
| 547 bool ok = true; | 547 bool ok = true; |
| 548 ok &= value->GetInteger(0, &x); | 548 ok &= value->GetInteger(0, &x); |
| 549 ok &= value->GetInteger(1, &y); | 549 ok &= value->GetInteger(1, &y); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( | 589 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( |
| 590 std::min(value, std::numeric_limits<double>::max()))); | 590 std::min(value, std::numeric_limits<double>::max()))); |
| 591 } | 591 } |
| 592 | 592 |
| 593 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { | 593 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { |
| 594 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( | 594 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( |
| 595 std::min(value, std::numeric_limits<float>::max()))); | 595 std::min(value, std::numeric_limits<float>::max()))); |
| 596 } | 596 } |
| 597 | 597 |
| 598 } // namespace cc | 598 } // namespace cc |
| OLD | NEW |