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_GEOMETRY_POINT_H_ | 5 #ifndef UI_GFX_GEOMETRY_POINT_H_ |
6 #define UI_GFX_GEOMETRY_POINT_H_ | 6 #define UI_GFX_GEOMETRY_POINT_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // to the origin. If the y-values are the same, then point with | 83 // to the origin. If the y-values are the same, then point with |
84 // the x-value closer to the origin is considered less than the | 84 // the x-value closer to the origin is considered less than the |
85 // other. | 85 // other. |
86 // This comparison is required to use Point in sets, or sorted | 86 // This comparison is required to use Point in sets, or sorted |
87 // vectors. | 87 // vectors. |
88 bool operator<(const Point& rhs) const { | 88 bool operator<(const Point& rhs) const { |
89 return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); | 89 return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); |
90 } | 90 } |
91 | 91 |
92 operator PointF() const { | 92 operator PointF() const { |
93 return PointF(x(), y()); | 93 return PointF(static_cast<float>(x()), static_cast<float>(y())); |
94 } | 94 } |
95 | 95 |
96 // Returns a string representation of point. | 96 // Returns a string representation of point. |
97 std::string ToString() const; | 97 std::string ToString() const; |
98 | 98 |
99 private: | 99 private: |
100 int x_; | 100 int x_; |
101 int y_; | 101 int y_; |
102 }; | 102 }; |
103 | 103 |
(...skipping 26 matching lines...) Expand all Loading... |
130 } | 130 } |
131 | 131 |
132 // This is declared here for use in gtest-based unit tests but is defined in | 132 // This is declared here for use in gtest-based unit tests but is defined in |
133 // the gfx_test_support target. Depend on that to use this in your unit test. | 133 // the gfx_test_support target. Depend on that to use this in your unit test. |
134 // This should not be used in production code - call ToString() instead. | 134 // This should not be used in production code - call ToString() instead. |
135 void PrintTo(const Point& point, ::std::ostream* os); | 135 void PrintTo(const Point& point, ::std::ostream* os); |
136 | 136 |
137 } // namespace gfx | 137 } // namespace gfx |
138 | 138 |
139 #endif // UI_GFX_GEOMETRY_POINT_H_ | 139 #endif // UI_GFX_GEOMETRY_POINT_H_ |
OLD | NEW |