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-11 21:52:22 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 21:52:22 +0000
commit95af087dc056a84e8047eb1e8c195f99119f9de3 (patch)
tree908d33204819f4274080dfdce7652fa5bb2c5178 /ui/gfx/point_f.h
parent81289ac3e1919387b4554fa82b4d8f5d61f0380f (diff)
downloadchromium_src-95af087dc056a84e8047eb1e8c195f99119f9de3.zip
chromium_src-95af087dc056a84e8047eb1e8c195f99119f9de3.tar.gz
chromium_src-95af087dc056a84e8047eb1e8c195f99119f9de3.tar.bz2
Implicit coversion operators from integer geometry types to floating point.
This change allows you to call a function that expects a floating point object with an integer object and have things just work. The addition operator for Points is outside the Point classes so it can add/subtract integer and float points together implicitly. Tested to verify compilation with: ui_unittests:RectTest.ToRectF ui_unittests:SizeTest.ToSizeF ui_unittests:PointTest.ToPointF BUG=147395 R=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/11028127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/point_f.h')
-rw-r--r--ui/gfx/point_f.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/ui/gfx/point_f.h b/ui/gfx/point_f.h
index a0b367f..d6cded9 100644
--- a/ui/gfx/point_f.h
+++ b/ui/gfx/point_f.h
@@ -31,6 +31,14 @@ class UI_EXPORT PointF : public PointBase<PointF, float> {
std::string ToString() const;
};
+inline bool operator==(const PointF& lhs, const PointF& rhs) {
+ return lhs.x() == rhs.x() && lhs.y() == rhs.y();
+}
+
+inline bool operator!=(const PointF& lhs, const PointF& rhs) {
+ return !(lhs == rhs);
+}
+
inline PointF operator+(PointF lhs, PointF rhs) {
return lhs.Add(rhs);
}