Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4334)

Unified Diff: cc/math/int_rect.h

Issue 10984053: cc: Use ui/gfx geometry types for the CCRenderPass and CCDrawQuad classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_
« cc/math/int_point.h ('K') | « cc/math/int_point.h ('k') | cc/math/int_rect.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698