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 #ifndef UI_GFX_RECT_F_H_ | 5 #ifndef UI_GFX_RECT_F_H_ |
6 #define UI_GFX_RECT_F_H_ | 6 #define UI_GFX_RECT_F_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ui/gfx/point_f.h" | 10 #include "ui/gfx/point_f.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 }; | 62 }; |
63 | 63 |
64 inline bool operator==(const RectF& lhs, const RectF& rhs) { | 64 inline bool operator==(const RectF& lhs, const RectF& rhs) { |
65 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); | 65 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); |
66 } | 66 } |
67 | 67 |
68 inline bool operator!=(const RectF& lhs, const RectF& rhs) { | 68 inline bool operator!=(const RectF& lhs, const RectF& rhs) { |
69 return !(lhs == rhs); | 69 return !(lhs == rhs); |
70 } | 70 } |
71 | 71 |
72 UI_EXPORT RectF operator+(const RectF& lhs, const Vector2dF& rhs); | 72 inline RectF operator+(const RectF& lhs, const Vector2dF& rhs) { |
73 UI_EXPORT RectF operator-(const RectF& lhs, const Vector2dF& rhs); | 73 return RectF(lhs.x() + rhs.x(), lhs.y() + rhs.y(), |
| 74 lhs.width(), lhs.height()); |
| 75 } |
| 76 |
| 77 inline RectF operator-(const RectF& lhs, const Vector2dF& rhs) { |
| 78 return RectF(lhs.x() - rhs.x(), lhs.y() - rhs.y(), |
| 79 lhs.width(), lhs.height()); |
| 80 } |
74 | 81 |
75 inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { | 82 inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { |
76 return rhs + lhs; | 83 return rhs + lhs; |
77 } | 84 } |
78 | 85 |
79 UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); | 86 UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); |
80 UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b); | 87 UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b); |
81 UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); | 88 UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); |
82 UI_EXPORT RectF ScaleRect(const RectF& r, float x_scale, float y_scale); | 89 |
| 90 inline RectF ScaleRect(const RectF& r, float x_scale, float y_scale) { |
| 91 return RectF(r.x() * x_scale, r.y() * y_scale, |
| 92 r.width() * x_scale, r.height() * y_scale); |
| 93 } |
83 | 94 |
84 inline RectF ScaleRect(const RectF& r, float scale) { | 95 inline RectF ScaleRect(const RectF& r, float scale) { |
85 return ScaleRect(r, scale, scale); | 96 return ScaleRect(r, scale, scale); |
86 } | 97 } |
87 | 98 |
88 // Constructs a rectangle with |p1| and |p2| as opposite corners. | 99 // Constructs a rectangle with |p1| and |p2| as opposite corners. |
89 // | 100 // |
90 // This could also be thought of as "the smallest rect that contains both | 101 // This could also be thought of as "the smallest rect that contains both |
91 // points", except that we consider points on the right/bottom edges of the | 102 // points", except that we consider points on the right/bottom edges of the |
92 // rect to be outside the rect. So technically one or both points will not be | 103 // rect to be outside the rect. So technically one or both points will not be |
93 // contained within the rect, because they will appear on one of these edges. | 104 // contained within the rect, because they will appear on one of these edges. |
94 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); | 105 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); |
95 | 106 |
96 #if !defined(COMPILER_MSVC) | 107 #if !defined(COMPILER_MSVC) |
97 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; | 108 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; |
98 #endif | 109 #endif |
99 | 110 |
100 } // namespace gfx | 111 } // namespace gfx |
101 | 112 |
102 #endif // UI_GFX_RECT_F_H_ | 113 #endif // UI_GFX_RECT_F_H_ |
OLD | NEW |