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

Side by Side Diff: ui/gfx/geometry/point3_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/point.h ('k') | ui/gfx/geometry/point_f.h » ('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) 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
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_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/point.h ('k') | ui/gfx/geometry/point_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698