Chromium Code Reviews| Index: ui/gfx/geometry/box_f.h |
| diff --git a/ui/gfx/geometry/box_f.h b/ui/gfx/geometry/box_f.h |
| index deb359abdd30ad8d513148ea9e3d10babdde46e9..dff23c0f4f840bc7aed213d2936c83d0815fef6c 100644 |
| --- a/ui/gfx/geometry/box_f.h |
| +++ b/ui/gfx/geometry/box_f.h |
| @@ -17,30 +17,33 @@ namespace gfx { |
| // the camera. |
| class GFX_EXPORT BoxF { |
| public: |
| - BoxF() |
| + constexpr BoxF() |
| : width_(0.f), |
| height_(0.f), |
| depth_(0.f) {} |
| - BoxF(float width, float height, float depth) |
| + constexpr BoxF(float width, float height, float depth) |
| : width_(width < 0 ? 0 : width), |
| height_(height < 0 ? 0 : height), |
| depth_(depth < 0 ? 0 : depth) {} |
| - BoxF(float x, float y, float z, float width, float height, float depth) |
| + constexpr BoxF(float x, |
| + float y, |
| + float z, |
| + float width, |
| + float height, |
| + float depth) |
| : origin_(x, y, z), |
| width_(width < 0 ? 0 : width), |
| height_(height < 0 ? 0 : height), |
| depth_(depth < 0 ? 0 : depth) {} |
| - BoxF(const Point3F& origin, float width, float height, float depth) |
| + constexpr BoxF(const Point3F& origin, float width, float height, float depth) |
| : origin_(origin), |
| width_(width < 0 ? 0 : width), |
| height_(height < 0 ? 0 : height), |
| depth_(depth < 0 ? 0 : depth) {} |
| - ~BoxF() {} |
| - |
| // Scales all three axes by the given scale. |
| void Scale(float scale) { |
| Scale(scale, scale, scale); |
| @@ -66,27 +69,27 @@ class GFX_EXPORT BoxF { |
| std::string ToString() const; |
| - float x() const { return origin_.x(); } |
| + constexpr float x() const { return origin_.x(); } |
|
danakj
2016/06/10 00:36:47
is this constexpr and const not redundant? Why is
vmpstr
2016/06/10 00:46:15
I think in C++14, non-static constexpr member func
Peter Kasting
2016/06/10 05:50:06
No, they're not redundant. Originally, constexpr
|
| void set_x(float x) { origin_.set_x(x); } |
| - float y() const { return origin_.y(); } |
| + constexpr float y() const { return origin_.y(); } |
| void set_y(float y) { origin_.set_y(y); } |
| - float z() const { return origin_.z(); } |
| + constexpr float z() const { return origin_.z(); } |
| void set_z(float z) { origin_.set_z(z); } |
| - float width() const { return width_; } |
| + constexpr float width() const { return width_; } |
| void set_width(float width) { width_ = width < 0 ? 0 : width; } |
| - float height() const { return height_; } |
| + constexpr float height() const { return height_; } |
| void set_height(float height) { height_ = height < 0 ? 0 : height; } |
| - float depth() const { return depth_; } |
| + constexpr float depth() const { return depth_; } |
| void set_depth(float depth) { depth_ = depth < 0 ? 0 : depth; } |
| - float right() const { return x() + width(); } |
| - float bottom() const { return y() + height(); } |
| - float front() const { return z() + depth(); } |
| + constexpr float right() const { return x() + width(); } |
| + constexpr float bottom() const { return y() + height(); } |
| + constexpr float front() const { return z() + depth(); } |
| void set_size(float width, float height, float depth) { |
| width_ = width < 0 ? 0 : width; |
| @@ -94,7 +97,7 @@ class GFX_EXPORT BoxF { |
| depth_ = depth < 0 ? 0 : depth; |
| } |
| - const Point3F& origin() const { return origin_; } |
| + constexpr const Point3F& origin() const { return origin_; } |
| void set_origin(const Point3F& origin) { origin_ = origin; } |
| // Expands |this| to contain the given point, if necessary. Please note, even |