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

Unified Diff: cc/math/float_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/float_rect.h
diff --git a/cc/math/float_rect.h b/cc/math/float_rect.h
new file mode 100644
index 0000000000000000000000000000000000000000..372f13008ad2c65639c2cdfdbd8553afbd80eecf
--- /dev/null
+++ b/cc/math/float_rect.h
@@ -0,0 +1,86 @@
+// 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_FLOAT_RECT_H_
+#define CC_MATH_FLOAT_RECT_H_
+
+#include "cc/math/float_point.h"
+#include "cc/math/float_size.h"
+#include "cc/math/int_rect.h"
+
+namespace ccmath {
+
+class FloatRect {
+public:
+ FloatRect() { }
+ FloatRect(float x, float y, float w, float h)
+ : m_location(x, y),
+ m_size(w, h) {
+ }
+ FloatRect(FloatPoint location, FloatSize size)
+ : m_location(location),
+ m_size(size) {
+ }
+ FloatRect(const FloatRect& rect)
+ : m_location(rect.m_location),
+ m_size(rect.m_size) {
+ }
+ FloatRect(IntRect rect)
+ : m_location(rect.location()),
+ m_size(rect.size()) {
+ }
+
+ float x() const { return m_location.x(); }
+ float y() const { return m_location.y(); }
+ float width() const { return m_size.width(); }
+ float height() const { return m_size.height(); }
+
+ void set_x(float x) { m_location.set_x(x); }
+ void set_y(float y) { m_location.set_y(y); }
+ void set_width(float width) { m_size.set_width(width); }
+ void set_height(float height) { m_size.set_height(height); }
+
+ FloatPoint location() const { return m_location; }
+ FloatSize size() const { return m_size; }
+
+ void set_location(FloatPoint location) { m_location = location; }
+ void set_size(FloatSize size) { m_size = size; }
+
+ float max_x() const { return m_location.x() + m_size.width(); }
+ float max_y() const { return m_location.y() + m_size.height(); }
+
+ bool Contains(IntRect other) const;
+ bool IsEmpty() const;
+
+ IntRect EnclosingIntRect() const;
+ IntRect EnclosedIntRect() const;
+
+ void InflateX(float amount);
+ void InflateY(float amount);
+ void InflateWidth(float amount);
+ void InflateHeight(float amount);
+
+ void Intersect(FloatRect other);
+ void Scale(float scale_x, float scale_y);
+ void Unite(FloatRect other);
+
+ static FloatRect Intersection(FloatRect a, FloatRect b);
+ static FloatRect Union(FloatRect a, FloatRect b);
+
+private:
+ FloatPoint m_location;
+ FloatSize m_size;
+};
+
+inline bool operator==(const FloatRect& a, const FloatRect& b) {
+ return a.location() == b.location() && a.size() == b.size();
+}
+
+inline bool operator!=(const FloatRect& a, const FloatRect& b) {
+ return !(a == b);
+}
+
+} // namespace ccmath
+
+#endif // CC_MATH_FLOAT_RECT_H_

Powered by Google App Engine
This is Rietveld 408576698