| Index: cc/math/int_size.h
|
| diff --git a/cc/math/int_size.h b/cc/math/int_size.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5bfa1998468a2be205750b8b78231445fe90e246
|
| --- /dev/null
|
| +++ b/cc/math/int_size.h
|
| @@ -0,0 +1,56 @@
|
| +// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CC_MATH_INT_SIZE_H_
|
| +#define CC_MATH_INT_SIZE_H_
|
| +
|
| +namespace ccmath {
|
| +
|
| +class IntSize {
|
| +public:
|
| + IntSize()
|
| + : m_width(0),
|
| + m_height(0) {
|
| + }
|
| + IntSize(int width, int height)
|
| + : m_width(width),
|
| + m_height(height) {
|
| + }
|
| + IntSize(const IntSize& size)
|
| + : m_width(size.m_width),
|
| + m_height(size.m_height) {
|
| + }
|
| +
|
| + int width() const { return m_width; }
|
| + int height() const { return m_height; }
|
| +
|
| + void set_width(int width) { m_width = width; }
|
| + void set_height(int height) { m_height = height; }
|
| +
|
| + IntSize& ClampToNonNegative() {
|
| + m_width = m_width < 0 ? 0 : m_width;
|
| + m_height = m_height < 0 ? 0 : m_height;
|
| + return *this;
|
| + }
|
| +
|
| + void ClampNegativeToZero();
|
| +
|
| + bool IsEmpty() const;
|
| +
|
| +private:
|
| + int m_width;
|
| + int m_height;
|
| +};
|
| +
|
| +inline bool operator==(const IntSize& a, const IntSize& b) {
|
| + return a.width() == b.width() && a.height() == b.height();
|
| +}
|
| +
|
| +inline bool operator!=(const IntSize& a, const IntSize& b) {
|
| + return !(a == b);
|
| +}
|
| +
|
| +} // namespace ccmath
|
| +
|
| +#endif // CC_MATH_INT_SIZE_H_
|
|
|