Chromium Code Reviews| Index: ui/gfx/geometry/size_f.h |
| diff --git a/ui/gfx/geometry/size_f.h b/ui/gfx/geometry/size_f.h |
| index 9d1bb5d7e3ed6c18d4ff3d3193a510ae85c70c48..27f100d97036c6512a189b3d26e177e2703439b4 100644 |
| --- a/ui/gfx/geometry/size_f.h |
| +++ b/ui/gfx/geometry/size_f.h |
| @@ -14,12 +14,15 @@ |
| namespace gfx { |
| +static constexpr float kTrivial = 8.f * std::numeric_limits<float>::epsilon(); |
|
danakj
2017/03/23 20:12:06
I don't think a kTrivial should be part of the gfx
Peter Mayo
2017/03/23 23:58:41
I was trying to get the compilers to be able to in
danakj
2017/03/24 14:55:35
Sorry, I meant inside the class as a private stati
Peter Mayo
2017/03/24 21:05:41
I don't think you addressed this part. If kTrivial
|
| + |
| // A floating version of gfx::Size. |
| class GFX_EXPORT SizeF { |
| public: |
| constexpr SizeF() : width_(0.f), height_(0.f) {} |
| constexpr SizeF(float width, float height) |
| - : width_(width >= 0 ? width : 0), height_(height >= 0 ? height : 0) {} |
| + : width_(width > kTrivial ? width : 0.f), |
| + height_(height > kTrivial ? height : 0.f) {} |
| constexpr explicit SizeF(const Size& size) |
| : SizeF(static_cast<float>(size.width()), |
| @@ -28,8 +31,8 @@ class GFX_EXPORT SizeF { |
| constexpr float width() const { return width_; } |
| constexpr float height() const { return height_; } |
| - void set_width(float width) { width_ = fmaxf(0, width); } |
| - void set_height(float height) { height_ = fmaxf(0, height); } |
| + void set_width(float width) { width_ = width > kTrivial ? width : 0.f; } |
|
danakj
2017/03/23 20:12:06
When I wrote the fmaxf I tried >?: vs std::max vs
Peter Mayo
2017/03/23 23:58:41
Ack - I'll put it back.
Peter Mayo
2017/03/24 01:17:45
Ick - um, no, we want to clamp to 0, not kTrivial.
danakj
2017/03/24 14:55:35
Oh, I see. The comparison but output are different
|
| + void set_height(float height) { height_ = height > kTrivial ? height : 0.f; } |
| float GetArea() const; |
| @@ -43,7 +46,7 @@ class GFX_EXPORT SizeF { |
| void SetToMin(const SizeF& other); |
| void SetToMax(const SizeF& other); |
| - bool IsEmpty() const { return !width() || !height(); } |
| + bool IsEmpty() const { return !height_ || !width_; } |
| void Scale(float scale) { |
| Scale(scale, scale); |