[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / gfx / geometry / point_f.h
blob82d00e6eb507b0b86c9f12bd74f8bd393fd7b30a
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_GEOMETRY_POINT_F_H_
6 #define UI_GFX_GEOMETRY_POINT_F_H_
8 #include <iosfwd>
9 #include <string>
11 #include "ui/gfx/geometry/point_base.h"
12 #include "ui/gfx/geometry/vector2d_f.h"
13 #include "ui/gfx/gfx_export.h"
15 namespace gfx {
17 // A floating version of gfx::Point.
18 class GFX_EXPORT PointF : public PointBase<PointF, float, Vector2dF> {
19 public:
20 PointF() : PointBase<PointF, float, Vector2dF>(0, 0) {}
21 PointF(float x, float y) : PointBase<PointF, float, Vector2dF>(x, y) {}
22 ~PointF() {}
24 void Scale(float scale) {
25 Scale(scale, scale);
28 void Scale(float x_scale, float y_scale) {
29 SetPoint(x() * x_scale, y() * y_scale);
32 // Returns a string representation of point.
33 std::string ToString() const;
36 inline bool operator==(const PointF& lhs, const PointF& rhs) {
37 return lhs.x() == rhs.x() && lhs.y() == rhs.y();
40 inline bool operator!=(const PointF& lhs, const PointF& rhs) {
41 return !(lhs == rhs);
44 inline PointF operator+(const PointF& lhs, const Vector2dF& rhs) {
45 PointF result(lhs);
46 result += rhs;
47 return result;
50 inline PointF operator-(const PointF& lhs, const Vector2dF& rhs) {
51 PointF result(lhs);
52 result -= rhs;
53 return result;
56 inline Vector2dF operator-(const PointF& lhs, const PointF& rhs) {
57 return Vector2dF(lhs.x() - rhs.x(), lhs.y() - rhs.y());
60 inline PointF PointAtOffsetFromOrigin(const Vector2dF& offset_from_origin) {
61 return PointF(offset_from_origin.x(), offset_from_origin.y());
64 GFX_EXPORT PointF ScalePoint(const PointF& p, float x_scale, float y_scale);
66 inline PointF ScalePoint(const PointF& p, float scale) {
67 return ScalePoint(p, scale, scale);
70 #if !defined(COMPILER_MSVC)
71 extern template class PointBase<PointF, float, Vector2dF>;
72 #endif
74 // This is declared here for use in gtest-based unit tests but is defined in
75 // the gfx_test_support target. Depend on that to use this in your unit test.
76 // This should not be used in production code - call ToString() instead.
77 void PrintTo(const PointF& point, ::std::ostream* os);
79 } // namespace gfx
81 #endif // UI_GFX_GEOMETRY_POINT_F_H_