| 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 |
| 11 #include "ui/gfx/geometry/point_f.h" | |
| 12 #include "ui/gfx/geometry/vector2d.h" | 11 #include "ui/gfx/geometry/vector2d.h" |
| 13 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
| 14 | 13 |
| 15 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 16 typedef unsigned long DWORD; | 15 typedef unsigned long DWORD; |
| 17 typedef struct tagPOINT POINT; | 16 typedef struct tagPOINT POINT; |
| 18 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) |
| 19 typedef struct CGPoint CGPoint; | 18 typedef struct CGPoint CGPoint; |
| 20 #endif | 19 #endif |
| 21 | 20 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // A point is less than another point if its y-value is closer | 79 // A point is less than another point if its y-value is closer |
| 81 // to the origin. If the y-values are the same, then point with | 80 // to the origin. If the y-values are the same, then point with |
| 82 // the x-value closer to the origin is considered less than the | 81 // the x-value closer to the origin is considered less than the |
| 83 // other. | 82 // other. |
| 84 // This comparison is required to use Point in sets, or sorted | 83 // This comparison is required to use Point in sets, or sorted |
| 85 // vectors. | 84 // vectors. |
| 86 bool operator<(const Point& rhs) const { | 85 bool operator<(const Point& rhs) const { |
| 87 return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); | 86 return (y_ == rhs.y_) ? (x_ < rhs.x_) : (y_ < rhs.y_); |
| 88 } | 87 } |
| 89 | 88 |
| 90 operator PointF() const { | |
| 91 return PointF(static_cast<float>(x()), static_cast<float>(y())); | |
| 92 } | |
| 93 | |
| 94 // Returns a string representation of point. | 89 // Returns a string representation of point. |
| 95 std::string ToString() const; | 90 std::string ToString() const; |
| 96 | 91 |
| 97 private: | 92 private: |
| 98 int x_; | 93 int x_; |
| 99 int y_; | 94 int y_; |
| 100 }; | 95 }; |
| 101 | 96 |
| 102 inline bool operator==(const Point& lhs, const Point& rhs) { | 97 inline bool operator==(const Point& lhs, const Point& rhs) { |
| 103 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); | 98 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 float y_scale); | 137 float y_scale); |
| 143 GFX_EXPORT Point ScaleToFlooredPoint(const Point& point, float x_scale); | 138 GFX_EXPORT Point ScaleToFlooredPoint(const Point& point, float x_scale); |
| 144 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, | 139 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, |
| 145 float x_scale, | 140 float x_scale, |
| 146 float y_scale); | 141 float y_scale); |
| 147 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, float x_scale); | 142 GFX_EXPORT Point ScaleToRoundedPoint(const Point& point, float x_scale); |
| 148 | 143 |
| 149 } // namespace gfx | 144 } // namespace gfx |
| 150 | 145 |
| 151 #endif // UI_GFX_GEOMETRY_POINT_H_ | 146 #endif // UI_GFX_GEOMETRY_POINT_H_ |
| OLD | NEW |