| Index: cc/math/int_rect.h
|
| diff --git a/cc/math/int_rect.h b/cc/math/int_rect.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f2f56aa58723f4f5caed9eec56a4ea57e82385b6
|
| --- /dev/null
|
| +++ b/cc/math/int_rect.h
|
| @@ -0,0 +1,77 @@
|
| +// 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_RECT_H_
|
| +#define CC_MATH_INT_RECT_H_
|
| +
|
| +#include "cc/math/int_point.h"
|
| +#include "cc/math/int_size.h"
|
| +
|
| +namespace ccmath {
|
| +
|
| +class IntRect {
|
| +public:
|
| + IntRect() { }
|
| + IntRect(int x, int y, int w, int h)
|
| + : m_location(x, y),
|
| + m_size(w, h) {
|
| + }
|
| + IntRect(IntPoint location, IntSize size)
|
| + : m_location(location),
|
| + m_size(size) {
|
| + }
|
| + IntRect(const IntRect& rect)
|
| + : m_location(rect.m_location),
|
| + m_size(rect.m_size) {
|
| + }
|
| +
|
| + int x() const { return m_location.x(); }
|
| + int y() const { return m_location.y(); }
|
| + int width() const { return m_size.width(); }
|
| + int height() const { return m_size.height(); }
|
| +
|
| + int max_x() const { return m_location.x() + m_size.width(); }
|
| + int max_y() const { return m_location.y() + m_size.height(); }
|
| +
|
| + void set_x(int x) { m_location.set_x(x); }
|
| + void set_y(int y) { m_location.set_y(y); }
|
| + void set_width(int width) { m_size.set_width(width); }
|
| + void set_height(int height) { m_size.set_height(height); }
|
| +
|
| + IntPoint location() const { return m_location; }
|
| + IntSize size() const { return m_size; }
|
| +
|
| + void set_location(IntPoint location) { m_location = location; }
|
| + void set_size(IntSize size) { m_size = size; }
|
| +
|
| + bool Contains(IntRect other) const;
|
| + bool IsEmpty() const;
|
| +
|
| + void InflateX(float amount);
|
| + void InflateY(float amount);
|
| + void InflateWidth(float amount);
|
| + void InflateHeight(float amount);
|
| +
|
| + void Intersect(IntRect other);
|
| + void Unite(IntRect other);
|
| +
|
| + static IntRect Intersection(IntRect a, IntRect b);
|
| + static IntRect Union(IntRect a, IntRect b);
|
| +
|
| +private:
|
| + IntPoint m_location;
|
| + IntSize m_size;
|
| +};
|
| +
|
| +inline bool operator==(const IntRect& a, const IntRect& b) {
|
| + return a.location() == b.location() && a.size() == b.size();
|
| +}
|
| +
|
| +inline bool operator!=(const IntRect& a, const IntRect& b) {
|
| + return !(a == b);
|
| +}
|
| +
|
| +} // namespace ccmath
|
| +
|
| +#endif // CC_MATH_INT_RECT_H_
|
|
|