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_POINT_F_H_ | 5 #ifndef UI_GFX_POINT_F_H_ |
6 #define UI_GFX_POINT_F_H_ | 6 #define UI_GFX_POINT_F_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
11 #include "ui/gfx/point_base.h" | 11 #include "ui/gfx/point_base.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 // A floating version of gfx::Point. | 15 // A floating version of gfx::Point. |
16 class UI_EXPORT PointF : public PointBase<PointF, float> { | 16 class UI_EXPORT PointF : public PointBase<PointF, float> { |
17 public: | 17 public: |
18 PointF(); | 18 PointF(); |
19 PointF(float x, float y); | 19 PointF(float x, float y); |
20 ~PointF(); | 20 ~PointF(); |
21 | 21 |
| 22 PointF Scale(float scale) const WARN_UNUSED_RESULT { |
| 23 return Scale(scale, scale); |
| 24 } |
| 25 |
| 26 PointF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT { |
| 27 return PointF(x() * x_scale, y() * y_scale); |
| 28 } |
| 29 |
22 // Returns a string representation of point. | 30 // Returns a string representation of point. |
23 std::string ToString() const; | 31 std::string ToString() const; |
24 }; | 32 }; |
25 | 33 |
26 inline PointF operator+(PointF lhs, PointF rhs) { | 34 inline PointF operator+(PointF lhs, PointF rhs) { |
27 return lhs.Add(rhs); | 35 return lhs.Add(rhs); |
28 } | 36 } |
29 | 37 |
30 inline PointF operator-(PointF lhs, PointF rhs) { | 38 inline PointF operator-(PointF lhs, PointF rhs) { |
31 return lhs.Subtract(rhs); | 39 return lhs.Subtract(rhs); |
32 } | 40 } |
33 | 41 |
34 #if !defined(COMPILER_MSVC) | 42 #if !defined(COMPILER_MSVC) |
35 extern template class PointBase<PointF, float>; | 43 extern template class PointBase<PointF, float>; |
36 #endif | 44 #endif |
37 | 45 |
38 } // namespace gfx | 46 } // namespace gfx |
39 | 47 |
40 #endif // UI_GFX_POINT_F_H_ | 48 #endif // UI_GFX_POINT_F_H_ |
OLD | NEW |