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

Side by Side 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, 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_RECT_H_
6 #define CC_MATH_FLOAT_RECT_H_
7
8 #include "cc/math/float_point.h"
9 #include "cc/math/float_size.h"
10 #include "cc/math/int_rect.h"
11
12 namespace ccmath {
13
14 class FloatRect {
15 public:
16 FloatRect() { }
17 FloatRect(float x, float y, float w, float h)
18 : m_location(x, y),
19 m_size(w, h) {
20 }
21 FloatRect(FloatPoint location, FloatSize size)
22 : m_location(location),
23 m_size(size) {
24 }
25 FloatRect(const FloatRect& rect)
26 : m_location(rect.m_location),
27 m_size(rect.m_size) {
28 }
29 FloatRect(IntRect rect)
30 : m_location(rect.location()),
31 m_size(rect.size()) {
32 }
33
34 float x() const { return m_location.x(); }
35 float y() const { return m_location.y(); }
36 float width() const { return m_size.width(); }
37 float height() const { return m_size.height(); }
38
39 void set_x(float x) { m_location.set_x(x); }
40 void set_y(float y) { m_location.set_y(y); }
41 void set_width(float width) { m_size.set_width(width); }
42 void set_height(float height) { m_size.set_height(height); }
43
44 FloatPoint location() const { return m_location; }
45 FloatSize size() const { return m_size; }
46
47 void set_location(FloatPoint location) { m_location = location; }
48 void set_size(FloatSize size) { m_size = size; }
49
50 float max_x() const { return m_location.x() + m_size.width(); }
51 float max_y() const { return m_location.y() + m_size.height(); }
52
53 bool Contains(IntRect other) const;
54 bool IsEmpty() const;
55
56 IntRect EnclosingIntRect() const;
57 IntRect EnclosedIntRect() const;
58
59 void InflateX(float amount);
60 void InflateY(float amount);
61 void InflateWidth(float amount);
62 void InflateHeight(float amount);
63
64 void Intersect(FloatRect other);
65 void Scale(float scale_x, float scale_y);
66 void Unite(FloatRect other);
67
68 static FloatRect Intersection(FloatRect a, FloatRect b);
69 static FloatRect Union(FloatRect a, FloatRect b);
70
71 private:
72 FloatPoint m_location;
73 FloatSize m_size;
74 };
75
76 inline bool operator==(const FloatRect& a, const FloatRect& b) {
77 return a.location() == b.location() && a.size() == b.size();
78 }
79
80 inline bool operator!=(const FloatRect& a, const FloatRect& b) {
81 return !(a == b);
82 }
83
84 } // namespace ccmath
85
86 #endif // CC_MATH_FLOAT_RECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698