OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GEOMETRY_POINT3_F_H_ | 5 #ifndef UI_GFX_GEOMETRY_POINT3_F_H_ |
6 #define UI_GFX_GEOMETRY_POINT3_F_H_ | 6 #define UI_GFX_GEOMETRY_POINT3_F_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
12 #include "ui/gfx/geometry/vector3d_f.h" | 12 #include "ui/gfx/geometry/vector3d_f.h" |
13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 | 16 |
17 // A point has an x, y and z coordinate. | 17 // A point has an x, y and z coordinate. |
18 class GFX_EXPORT Point3F { | 18 class GFX_EXPORT Point3F { |
19 public: | 19 public: |
20 Point3F() : x_(0), y_(0), z_(0) {} | 20 constexpr Point3F() : x_(0), y_(0), z_(0) {} |
| 21 constexpr Point3F(float x, float y, float z) : x_(x), y_(y), z_(z) {} |
21 | 22 |
22 Point3F(float x, float y, float z) : x_(x), y_(y), z_(z) {} | 23 constexpr explicit Point3F(const PointF& point) |
23 | 24 : x_(point.x()), y_(point.y()), z_(0) {} |
24 explicit Point3F(const PointF& point) : x_(point.x()), y_(point.y()), z_(0) {} | |
25 | |
26 ~Point3F() {} | |
27 | 25 |
28 void Scale(float scale) { | 26 void Scale(float scale) { |
29 Scale(scale, scale, scale); | 27 Scale(scale, scale, scale); |
30 } | 28 } |
31 | 29 |
32 void Scale(float x_scale, float y_scale, float z_scale) { | 30 void Scale(float x_scale, float y_scale, float z_scale) { |
33 SetPoint(x() * x_scale, y() * y_scale, z() * z_scale); | 31 SetPoint(x() * x_scale, y() * y_scale, z() * z_scale); |
34 } | 32 } |
35 | 33 |
36 float x() const { return x_; } | 34 constexpr float x() const { return x_; } |
37 float y() const { return y_; } | 35 constexpr float y() const { return y_; } |
38 float z() const { return z_; } | 36 constexpr float z() const { return z_; } |
39 | 37 |
40 void set_x(float x) { x_ = x; } | 38 void set_x(float x) { x_ = x; } |
41 void set_y(float y) { y_ = y; } | 39 void set_y(float y) { y_ = y; } |
42 void set_z(float z) { z_ = z; } | 40 void set_z(float z) { z_ = z; } |
43 | 41 |
44 void SetPoint(float x, float y, float z) { | 42 void SetPoint(float x, float y, float z) { |
45 x_ = x; | 43 x_ = x; |
46 y_ = y; | 44 y_ = y; |
47 z_ = z; | 45 z_ = z; |
48 } | 46 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 115 } |
118 | 116 |
119 // This is declared here for use in gtest-based unit tests but is defined in | 117 // This is declared here for use in gtest-based unit tests but is defined in |
120 // the gfx_test_support target. Depend on that to use this in your unit test. | 118 // the gfx_test_support target. Depend on that to use this in your unit test. |
121 // This should not be used in production code - call ToString() instead. | 119 // This should not be used in production code - call ToString() instead. |
122 void PrintTo(const Point3F& point, ::std::ostream* os); | 120 void PrintTo(const Point3F& point, ::std::ostream* os); |
123 | 121 |
124 } // namespace gfx | 122 } // namespace gfx |
125 | 123 |
126 #endif // UI_GFX_GEOMETRY_POINT3_F_H_ | 124 #endif // UI_GFX_GEOMETRY_POINT3_F_H_ |
OLD | NEW |