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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_MATH_FLOAT_POINT_H_
6 #define CC_MATH_FLOAT_POINT_H_
7
8 #include "cc/math/clamp.h"
9 #include "cc/math/float_vector_2d.h"
10 #include "cc/math/int_point.h"
11
12 namespace ccmath {
13
14 class FloatPoint {
15 public:
16 FloatPoint()
17 : m_x(0),
18 m_y(0) {
19 }
20 FloatPoint(float x, float y)
21 : m_x(x),
22 m_y(y) {
23 }
24 FloatPoint(const FloatPoint& point)
25 : m_x(point.m_x),
26 m_y(point.m_y) {
27 }
28 FloatPoint(IntPoint point)
29 : m_x(point.x()),
30 m_y(point.y()) {
31 }
32
33 float x() const { return m_x; }
34 float y() const { return m_y; }
35
36 void set_x(float x) { m_x = x; }
37 void set_y(float y) { m_y = y; }
38
39 IntPoint CeiledIntPoint() const;
40 IntPoint FlooredIntPoint() const;
41
42 private:
43 float m_x;
44 float m_y;
45 };
46
47 inline bool operator==(const FloatPoint& a, const FloatPoint& b) {
48 return a.x() == b.x() && a.y() == b.y();
49 }
50
51 inline bool operator!=(const FloatPoint& a, const FloatPoint& b) {
52 return !(a == b);
53 }
54
55 inline FloatPoint operator+(const FloatPoint& p, const IntVector2d& v) {
56 return FloatPoint(p.x() + v.v1(), p.y() + v.v2());
57 }
58
59 inline FloatPoint operator+(const FloatPoint& p, const FloatVector2d& v) {
60 return FloatPoint(p.x() + v.v1(), p.y() + v.v2());
61 }
62
63 inline FloatVector2d operator-(const FloatPoint& a, const FloatPoint& b) {
64 return FloatVector2d(a.x() - b.x(), a.y() - b.y());
65 }
66
67 } // namespace ccmath
68
69 #endif // CC_MATH_FLOAT_POINT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698