| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 static inline void AddVertexToClippedQuad(gfx::PointF new_vertex, | 97 static inline void AddVertexToClippedQuad(gfx::PointF new_vertex, |
| 98 gfx::PointF clipped_quad[8], | 98 gfx::PointF clipped_quad[8], |
| 99 int* num_vertices_in_clipped_quad) { | 99 int* num_vertices_in_clipped_quad) { |
| 100 clipped_quad[*num_vertices_in_clipped_quad] = new_vertex; | 100 clipped_quad[*num_vertices_in_clipped_quad] = new_vertex; |
| 101 (*num_vertices_in_clipped_quad)++; | 101 (*num_vertices_in_clipped_quad)++; |
| 102 } | 102 } |
| 103 | 103 |
| 104 gfx::Rect MathUtil::MapClippedRect(const gfx::Transform& transform, | 104 gfx::Rect MathUtil::MapClippedRect(const gfx::Transform& transform, |
| 105 gfx::Rect src_rect) { | 105 const gfx::Rect& src_rect) { |
| 106 return gfx::ToEnclosingRect(MapClippedRect(transform, gfx::RectF(src_rect))); | 106 return gfx::ToEnclosingRect(MapClippedRect(transform, gfx::RectF(src_rect))); |
| 107 } | 107 } |
| 108 | 108 |
| 109 gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform, | 109 gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform, |
| 110 const gfx::RectF& src_rect) { | 110 const gfx::RectF& src_rect) { |
| 111 if (transform.IsIdentityOrTranslation()) { | 111 if (transform.IsIdentityOrTranslation()) { |
| 112 return src_rect + | 112 return src_rect + |
| 113 gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)), | 113 gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)), |
| 114 SkMScalarToFloat(transform.matrix().get(1, 3))); | 114 SkMScalarToFloat(transform.matrix().get(1, 3))); |
| 115 } | 115 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(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(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()); |
| 528 res->AppendInteger(r.width()); | 528 res->AppendInteger(r.width()); |
| 529 res->AppendInteger(r.height()); | 529 res->AppendInteger(r.height()); |
| 530 return res.PassAs<base::Value>(); | 530 return res.PassAs<base::Value>(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { | 533 bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { |
| 534 const base::ListValue* value = NULL; | 534 const base::ListValue* value = NULL; |
| (...skipping 70 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 |