Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: ui/gfx/geometry/vector3d_f.h

Issue 2051343002: Make various gfx classes more amenable to use as compile-time constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete destructor Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/geometry/vector2d_f.h ('k') | ui/gfx/geometry/vector3d_f.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Defines a simple float vector class. This class is used to indicate a 5 // Defines a simple float vector class. This class is used to indicate a
6 // distance in two dimensions between two points. Subtracting two points should 6 // distance in two dimensions between two points. Subtracting two points should
7 // produce a vector, and adding a vector to a point produces the point at the 7 // produce a vector, and adding a vector to a point produces the point at the
8 // vector's distance from the original point. 8 // vector's distance from the original point.
9 9
10 #ifndef UI_GFX_GEOMETRY_VECTOR3D_F_H_ 10 #ifndef UI_GFX_GEOMETRY_VECTOR3D_F_H_
11 #define UI_GFX_GEOMETRY_VECTOR3D_F_H_ 11 #define UI_GFX_GEOMETRY_VECTOR3D_F_H_
12 12
13 #include <iosfwd> 13 #include <iosfwd>
14 #include <string> 14 #include <string>
15 15
16 #include "ui/gfx/geometry/vector2d_f.h" 16 #include "ui/gfx/geometry/vector2d_f.h"
17 #include "ui/gfx/gfx_export.h" 17 #include "ui/gfx/gfx_export.h"
18 18
19 namespace gfx { 19 namespace gfx {
20 20
21 class GFX_EXPORT Vector3dF { 21 class GFX_EXPORT Vector3dF {
22 public: 22 public:
23 Vector3dF(); 23 constexpr Vector3dF() : x_(0), y_(0), z_(0) {}
24 Vector3dF(float x, float y, float z); 24 constexpr Vector3dF(float x, float y, float z) : x_(x), y_(y), z_(z) {}
25 25
26 explicit Vector3dF(const Vector2dF& other); 26 constexpr explicit Vector3dF(const Vector2dF& other)
27 : x_(other.x()), y_(other.y()), z_(0) {}
27 28
28 float x() const { return x_; } 29 constexpr float x() const { return x_; }
29 void set_x(float x) { x_ = x; } 30 void set_x(float x) { x_ = x; }
30 31
31 float y() const { return y_; } 32 constexpr float y() const { return y_; }
32 void set_y(float y) { y_ = y; } 33 void set_y(float y) { y_ = y; }
33 34
34 float z() const { return z_; } 35 constexpr float z() const { return z_; }
35 void set_z(float z) { z_ = z; } 36 void set_z(float z) { z_ = z; }
36 37
37 // True if all components of the vector are 0. 38 // True if all components of the vector are 0.
38 bool IsZero() const; 39 bool IsZero() const;
39 40
40 // Add the components of the |other| vector to the current vector. 41 // Add the components of the |other| vector to the current vector.
41 void Add(const Vector3dF& other); 42 void Add(const Vector3dF& other);
42 // Subtract the components of the |other| vector from the current vector. 43 // Subtract the components of the |other| vector from the current vector.
43 void Subtract(const Vector3dF& other); 44 void Subtract(const Vector3dF& other);
44 45
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const gfx::Vector3dF& normal); 133 const gfx::Vector3dF& normal);
133 134
134 // This is declared here for use in gtest-based unit tests but is defined in 135 // This is declared here for use in gtest-based unit tests but is defined in
135 // the gfx_test_support target. Depend on that to use this in your unit test. 136 // the gfx_test_support target. Depend on that to use this in your unit test.
136 // This should not be used in production code - call ToString() instead. 137 // This should not be used in production code - call ToString() instead.
137 void PrintTo(const Vector3dF& vector, ::std::ostream* os); 138 void PrintTo(const Vector3dF& vector, ::std::ostream* os);
138 139
139 } // namespace gfx 140 } // namespace gfx
140 141
141 #endif // UI_GFX_GEOMETRY_VECTOR3D_F_H_ 142 #endif // UI_GFX_GEOMETRY_VECTOR3D_F_H_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/vector2d_f.h ('k') | ui/gfx/geometry/vector3d_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698