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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 return res.PassAs<base::Value>(); | 599 return res.PassAs<base::Value>(); |
600 } | 600 } |
601 | 601 |
602 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2d& v) { | 602 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2d& v) { |
603 scoped_ptr<base::ListValue> res(new base::ListValue()); | 603 scoped_ptr<base::ListValue> res(new base::ListValue()); |
604 res->AppendInteger(v.x()); | 604 res->AppendInteger(v.x()); |
605 res->AppendInteger(v.y()); | 605 res->AppendInteger(v.y()); |
606 return res.PassAs<base::Value>(); | 606 return res.PassAs<base::Value>(); |
607 } | 607 } |
608 | 608 |
| 609 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2dF& v) { |
| 610 scoped_ptr<base::ListValue> res(new base::ListValue()); |
| 611 res->AppendDouble(v.x()); |
| 612 res->AppendDouble(v.y()); |
| 613 return res.PassAs<base::Value>(); |
| 614 } |
| 615 |
609 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) { | 616 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) { |
610 scoped_ptr<base::ListValue> res(new base::ListValue()); | 617 scoped_ptr<base::ListValue> res(new base::ListValue()); |
611 res->AppendDouble(q.p1().x()); | 618 res->AppendDouble(q.p1().x()); |
612 res->AppendDouble(q.p1().y()); | 619 res->AppendDouble(q.p1().y()); |
613 res->AppendDouble(q.p2().x()); | 620 res->AppendDouble(q.p2().x()); |
614 res->AppendDouble(q.p2().y()); | 621 res->AppendDouble(q.p2().y()); |
615 res->AppendDouble(q.p3().x()); | 622 res->AppendDouble(q.p3().x()); |
616 res->AppendDouble(q.p3().y()); | 623 res->AppendDouble(q.p3().y()); |
617 res->AppendDouble(q.p4().x()); | 624 res->AppendDouble(q.p4().x()); |
618 res->AppendDouble(q.p4().y()); | 625 res->AppendDouble(q.p4().y()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 return scoped_ptr<base::Value>(new base::FundamentalValue( | 660 return scoped_ptr<base::Value>(new base::FundamentalValue( |
654 std::min(value, std::numeric_limits<double>::max()))); | 661 std::min(value, std::numeric_limits<double>::max()))); |
655 } | 662 } |
656 | 663 |
657 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { | 664 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { |
658 return scoped_ptr<base::Value>(new base::FundamentalValue( | 665 return scoped_ptr<base::Value>(new base::FundamentalValue( |
659 std::min(value, std::numeric_limits<float>::max()))); | 666 std::min(value, std::numeric_limits<float>::max()))); |
660 } | 667 } |
661 | 668 |
662 } // namespace cc | 669 } // namespace cc |
OLD | NEW |