| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_MATH_FLOAT_SIZE_H_ |
| 6 #define CC_MATH_FLOAT_SIZE_H_ |
| 7 |
| 8 #include "cc/math/int_size.h" |
| 9 |
| 10 namespace ccmath { |
| 11 |
| 12 class FloatSize { |
| 13 public: |
| 14 FloatSize() |
| 15 : m_width(0), |
| 16 m_height(0) { |
| 17 } |
| 18 FloatSize(float width, float height) |
| 19 : m_width(width), |
| 20 m_height(height) { |
| 21 } |
| 22 FloatSize(const FloatSize& size) |
| 23 : m_width(size.m_width), |
| 24 m_height(size.m_height) { |
| 25 } |
| 26 FloatSize(IntSize size) |
| 27 : m_width(size.width()), |
| 28 m_height(size.height()) { |
| 29 } |
| 30 |
| 31 float width() const { return m_width; } |
| 32 float height() const { return m_height; } |
| 33 |
| 34 void set_width(float width) { m_width = width; } |
| 35 void set_height(float height) { m_height = height; } |
| 36 |
| 37 void ClampToNonNegative(); |
| 38 |
| 39 bool IsEmpty() const; |
| 40 |
| 41 private: |
| 42 float m_width; |
| 43 float m_height; |
| 44 }; |
| 45 |
| 46 inline bool operator==(const FloatSize& a, const FloatSize& b) { |
| 47 return a.width() == b.width() && a.height() == b.height(); |
| 48 } |
| 49 |
| 50 inline bool operator!=(const FloatSize& a, const FloatSize& b) { |
| 51 return !(a == b); |
| 52 } |
| 53 |
| 54 } // namespace ccmath |
| 55 |
| 56 #endif // CC_MATH_FLOAT_SIZE_H_ |
| OLD | NEW |