| 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_INT_SIZE_H_ |
| 6 #define CC_MATH_INT_SIZE_H_ |
| 7 |
| 8 namespace ccmath { |
| 9 |
| 10 class IntSize { |
| 11 public: |
| 12 IntSize() |
| 13 : m_width(0), |
| 14 m_height(0) { |
| 15 } |
| 16 IntSize(int width, int height) |
| 17 : m_width(width), |
| 18 m_height(height) { |
| 19 } |
| 20 IntSize(const IntSize& size) |
| 21 : m_width(size.m_width), |
| 22 m_height(size.m_height) { |
| 23 } |
| 24 |
| 25 int width() const { return m_width; } |
| 26 int height() const { return m_height; } |
| 27 |
| 28 void set_width(int width) { m_width = width; } |
| 29 void set_height(int height) { m_height = height; } |
| 30 |
| 31 IntSize& ClampToNonNegative() { |
| 32 m_width = m_width < 0 ? 0 : m_width; |
| 33 m_height = m_height < 0 ? 0 : m_height; |
| 34 return *this; |
| 35 } |
| 36 |
| 37 void ClampNegativeToZero(); |
| 38 |
| 39 bool IsEmpty() const; |
| 40 |
| 41 private: |
| 42 int m_width; |
| 43 int m_height; |
| 44 }; |
| 45 |
| 46 inline bool operator==(const IntSize& a, const IntSize& b) { |
| 47 return a.width() == b.width() && a.height() == b.height(); |
| 48 } |
| 49 |
| 50 inline bool operator!=(const IntSize& a, const IntSize& b) { |
| 51 return !(a == b); |
| 52 } |
| 53 |
| 54 } // namespace ccmath |
| 55 |
| 56 #endif // CC_MATH_INT_SIZE_H_ |
| OLD | NEW |