| 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 projected_length * destination.y()); | 507 projected_length * destination.y()); |
| 508 } | 508 } |
| 509 | 509 |
| 510 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) { | 510 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) { |
| 511 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 511 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 512 res->SetDouble("width", s.width()); | 512 res->SetDouble("width", s.width()); |
| 513 res->SetDouble("height", s.height()); | 513 res->SetDouble("height", s.height()); |
| 514 return res.PassAs<base::Value>(); | 514 return res.PassAs<base::Value>(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 scoped_ptr<base::Value> MathUtil::AsValue(gfx::SizeF s) { | 517 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::SizeF& s) { |
| 518 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 518 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 519 res->SetDouble("width", s.width()); | 519 res->SetDouble("width", s.width()); |
| 520 res->SetDouble("height", s.height()); | 520 res->SetDouble("height", s.height()); |
| 521 return res.PassAs<base::Value>(); | 521 return res.PassAs<base::Value>(); |
| 522 } | 522 } |
| 523 | 523 |
| 524 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Rect& r) { | 524 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Rect& r) { |
| 525 scoped_ptr<base::ListValue> res(new base::ListValue()); | 525 scoped_ptr<base::ListValue> res(new base::ListValue()); |
| 526 res->AppendInteger(r.x()); | 526 res->AppendInteger(r.x()); |
| 527 res->AppendInteger(r.y()); | 527 res->AppendInteger(r.y()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( | 605 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( |
| 606 std::min(value, std::numeric_limits<double>::max()))); | 606 std::min(value, std::numeric_limits<double>::max()))); |
| 607 } | 607 } |
| 608 | 608 |
| 609 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { | 609 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { |
| 610 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( | 610 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( |
| 611 std::min(value, std::numeric_limits<float>::max()))); | 611 std::min(value, std::numeric_limits<float>::max()))); |
| 612 } | 612 } |
| 613 | 613 |
| 614 } // namespace cc | 614 } // namespace cc |
| OLD | NEW |