| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Defines a simple float vector class. This class is used to indicate a | 5 // Defines a simple float vector class. This class is used to indicate a |
| 6 // distance in two dimensions between two points. Subtracting two points should | 6 // distance in two dimensions between two points. Subtracting two points should |
| 7 // produce a vector, and adding a vector to a point produces the point at the | 7 // produce a vector, and adding a vector to a point produces the point at the |
| 8 // vector's distance from the original point. | 8 // vector's distance from the original point. |
| 9 | 9 |
| 10 #ifndef UI_GFX_VECTOR2D_F_H_ | 10 #ifndef UI_GFX_VECTOR2D_F_H_ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 float x_; | 65 float x_; |
| 66 float y_; | 66 float y_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 inline bool operator==(const Vector2dF& lhs, const Vector2dF& rhs) { | 69 inline bool operator==(const Vector2dF& lhs, const Vector2dF& rhs) { |
| 70 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); | 70 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 inline bool operator!=(const Vector2dF& lhs, const Vector2dF& rhs) { |
| 74 return !(lhs == rhs); |
| 75 } |
| 76 |
| 73 inline Vector2dF operator-(const Vector2dF& v) { | 77 inline Vector2dF operator-(const Vector2dF& v) { |
| 74 return Vector2dF(-v.x(), -v.y()); | 78 return Vector2dF(-v.x(), -v.y()); |
| 75 } | 79 } |
| 76 | 80 |
| 77 inline Vector2dF operator+(const Vector2dF& lhs, const Vector2dF& rhs) { | 81 inline Vector2dF operator+(const Vector2dF& lhs, const Vector2dF& rhs) { |
| 78 Vector2dF result = lhs; | 82 Vector2dF result = lhs; |
| 79 result.Add(rhs); | 83 result.Add(rhs); |
| 80 return result; | 84 return result; |
| 81 } | 85 } |
| 82 | 86 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 float y_scale); | 103 float y_scale); |
| 100 | 104 |
| 101 // Return a vector that is |v| scaled by the given scale factor. | 105 // Return a vector that is |v| scaled by the given scale factor. |
| 102 inline Vector2dF ScaleVector2d(const Vector2dF& v, float scale) { | 106 inline Vector2dF ScaleVector2d(const Vector2dF& v, float scale) { |
| 103 return ScaleVector2d(v, scale, scale); | 107 return ScaleVector2d(v, scale, scale); |
| 104 } | 108 } |
| 105 | 109 |
| 106 } // namespace gfx | 110 } // namespace gfx |
| 107 | 111 |
| 108 #endif // UI_GFX_VECTOR2D_F_H_ | 112 #endif // UI_GFX_VECTOR2D_F_H_ |
| OLD | NEW |