summaryrefslogtreecommitdiffstats
path: root/ui/gfx/point_f.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_f.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_f.h')
-rw-r--r--ui/gfx/point_f.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/ui/gfx/point_f.h b/ui/gfx/point_f.h
index e1871d8..ff1c4df 100644
--- a/ui/gfx/point_f.h
+++ b/ui/gfx/point_f.h
@@ -11,22 +11,26 @@
#include "ui/gfx/point_base.h"
namespace gfx {
-class Point;
// A floating version of gfx::Point.
class UI_EXPORT PointF : public PointBase<PointF, float> {
public:
PointF();
PointF(float x, float y);
- explicit PointF(Point& point);
- ~PointF() {}
-
- Point ToPoint() const;
+ ~PointF();
// Returns a string representation of point.
std::string ToString() const;
};
+inline PointF operator+(PointF lhs, PointF rhs) {
+ return lhs.Add(rhs);
+}
+
+inline PointF operator-(PointF lhs, PointF rhs) {
+ return lhs.Subtract(rhs);
+}
+
#if !defined(COMPILER_MSVC)
extern template class PointBase<PointF, float>;
#endif