Chromium Code Reviews| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 projected_length * destination.y()); | 519 projected_length * destination.y()); |
| 520 } | 520 } |
| 521 | 521 |
| 522 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) { | 522 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) { |
| 523 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 523 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 524 res->SetDouble("width", s.width()); | 524 res->SetDouble("width", s.width()); |
| 525 res->SetDouble("height", s.height()); | 525 res->SetDouble("height", s.height()); |
| 526 return res.PassAs<base::Value>(); | 526 return res.PassAs<base::Value>(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 scoped_ptr<base::Value> MathUtil::AsValue(gfx::Rect r) { | |
| 530 scoped_ptr<base::ListValue> res(new base::ListValue()); | |
| 531 res->AppendDouble(r.x()); | |
|
enne (OOO)
2013/05/14 15:55:18
AppendInteger?
| |
| 532 res->AppendDouble(r.y()); | |
| 533 res->AppendDouble(r.width()); | |
| 534 res->AppendDouble(r.height()); | |
| 535 return res.PassAs<base::Value>(); | |
| 536 } | |
| 537 | |
| 529 scoped_ptr<base::Value> MathUtil::AsValue(gfx::PointF pt) { | 538 scoped_ptr<base::Value> MathUtil::AsValue(gfx::PointF pt) { |
| 530 scoped_ptr<base::ListValue> res(new base::ListValue()); | 539 scoped_ptr<base::ListValue> res(new base::ListValue()); |
| 531 res->AppendDouble(pt.x()); | 540 res->AppendDouble(pt.x()); |
| 532 res->AppendDouble(pt.y()); | 541 res->AppendDouble(pt.y()); |
| 533 return res.PassAs<base::Value>(); | 542 return res.PassAs<base::Value>(); |
| 534 } | 543 } |
| 535 | 544 |
| 536 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) { | 545 scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) { |
| 537 scoped_ptr<base::ListValue> res(new base::ListValue()); | 546 scoped_ptr<base::ListValue> res(new base::ListValue()); |
| 538 res->AppendDouble(q.p1().x()); | 547 res->AppendDouble(q.p1().x()); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 559 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( | 568 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( |
| 560 std::min(value, std::numeric_limits<double>::max()))); | 569 std::min(value, std::numeric_limits<double>::max()))); |
| 561 } | 570 } |
| 562 | 571 |
| 563 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { | 572 scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { |
| 564 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( | 573 return scoped_ptr<base::Value>(base::Value::CreateDoubleValue( |
| 565 std::min(value, std::numeric_limits<float>::max()))); | 574 std::min(value, std::numeric_limits<float>::max()))); |
| 566 } | 575 } |
| 567 | 576 |
| 568 } // namespace cc | 577 } // namespace cc |
| OLD | NEW |