summaryrefslogtreecommitdiffstats
path: root/ui/gfx/point.h
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 18:25:28 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 18:25:28 +0000
commitd23f84d28a54b80d57d946963b9c91b5f332a062 (patch)
tree3238a48aad214238b190e80e353ba80ba5cd3090 /ui/gfx/point.h
parent1423b89d2d0002555f06533539719ae3a7db6009 (diff)
downloadchromium_src-d23f84d28a54b80d57d946963b9c91b5f332a062.zip
chromium_src-d23f84d28a54b80d57d946963b9c91b5f332a062.tar.gz
chromium_src-d23f84d28a54b80d57d946963b9c91b5f332a062.tar.bz2
Make adding and subtracting gfx:: point types simpler.
1) Removed iffy flooring conversion from Float types to Int types. 2) Added methods to convert from Int to Float types so you can do things like add a Point to a PointF and viceversa. 3) Added operator+ and operator- for point types. This had to be done in both Point and PointF headers to allow (Point+PointF) to compile. 4) Move the PointF::~PointF() destructor to the .cc file to be consistent with other types. 5) Remove the unimplemented PointF::PointF(Point) constructor from the header. BUG=152473 R=sky,jamesr Review URL: https://codereview.chromium.org/10993094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/point.h')
-rw-r--r--ui/gfx/point.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/gfx/point.h b/ui/gfx/point.h
index dfb227d..4bf9d55 100644
--- a/ui/gfx/point.h
+++ b/ui/gfx/point.h
@@ -7,6 +7,7 @@
#include "ui/base/ui_export.h"
#include "ui/gfx/point_base.h"
+#include "ui/gfx/point_f.h"
#if defined(OS_WIN)
typedef unsigned long DWORD;
@@ -43,10 +44,22 @@ class UI_EXPORT Point : public PointBase<Point, int> {
CGPoint ToCGPoint() const;
#endif
+ PointF ToPointF() const {
+ return PointF(x(), y());
+ }
+
// Returns a string representation of point.
std::string ToString() const;
};
+inline Point operator+(Point lhs, Point rhs) {
+ return lhs.Add(rhs);
+}
+
+inline Point operator-(Point lhs, Point rhs) {
+ return lhs.Subtract(rhs);
+}
+
#if !defined(COMPILER_MSVC)
extern template class PointBase<Point, int>;
#endif