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

Unified Diff: cc/math/float_point.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_point.h
diff --git a/cc/math/float_point.h b/cc/math/float_point.h
new file mode 100644
index 0000000000000000000000000000000000000000..be24e20a6e249f3553b447e01ed6d0e393d80d9c
--- /dev/null
+++ b/cc/math/float_point.h
@@ -0,0 +1,69 @@
+// 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_POINT_H_
+#define CC_MATH_FLOAT_POINT_H_
+
+#include "cc/math/clamp.h"
+#include "cc/math/float_vector_2d.h"
+#include "cc/math/int_point.h"
+
+namespace ccmath {
+
+class FloatPoint {
+public:
+ FloatPoint()
+ : m_x(0),
+ m_y(0) {
+ }
+ FloatPoint(float x, float y)
+ : m_x(x),
+ m_y(y) {
+ }
+ FloatPoint(const FloatPoint& point)
+ : m_x(point.m_x),
+ m_y(point.m_y) {
+ }
+ FloatPoint(IntPoint point)
+ : m_x(point.x()),
+ m_y(point.y()) {
+ }
+
+ float x() const { return m_x; }
+ float y() const { return m_y; }
+
+ void set_x(float x) { m_x = x; }
+ void set_y(float y) { m_y = y; }
+
+ IntPoint CeiledIntPoint() const;
+ IntPoint FlooredIntPoint() const;
+
+private:
+ float m_x;
+ float m_y;
+};
+
+inline bool operator==(const FloatPoint& a, const FloatPoint& b) {
+ return a.x() == b.x() && a.y() == b.y();
+}
+
+inline bool operator!=(const FloatPoint& a, const FloatPoint& b) {
+ return !(a == b);
+}
+
+inline FloatPoint operator+(const FloatPoint& p, const IntVector2d& v) {
+ return FloatPoint(p.x() + v.v1(), p.y() + v.v2());
+}
+
+inline FloatPoint operator+(const FloatPoint& p, const FloatVector2d& v) {
+ return FloatPoint(p.x() + v.v1(), p.y() + v.v2());
+}
+
+inline FloatVector2d operator-(const FloatPoint& a, const FloatPoint& b) {
+ return FloatVector2d(a.x() - b.x(), a.y() - b.y());
+}
+
+} // namespace ccmath
+
+#endif // CC_MATH_FLOAT_POINT_H_

Powered by Google App Engine
This is Rietveld 408576698