OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_REGION_H_ | 5 #ifndef CC_REGION_H_ |
6 #define CC_REGION_H_ | 6 #define CC_REGION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "cc/cc_export.h" | 11 #include "cc/cc_export.h" |
12 #include "third_party/skia/include/core/SkRegion.h" | 12 #include "third_party/skia/include/core/SkRegion.h" |
13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 14 #include "ui/gfx/skia_util.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 | 17 |
17 class CC_EXPORT Region { | 18 class CC_EXPORT Region { |
18 public: | 19 public: |
19 Region(); | 20 Region(); |
20 Region(const Region& region); | 21 Region(const Region& region); |
21 Region(gfx::Rect rect); | 22 Region(gfx::Rect rect); |
22 ~Region(); | 23 ~Region(); |
23 | 24 |
(...skipping 11 matching lines...) Expand all Loading... |
35 bool Intersects(gfx::Rect rect) const; | 36 bool Intersects(gfx::Rect rect) const; |
36 bool Intersects(const Region& region) const; | 37 bool Intersects(const Region& region) const; |
37 | 38 |
38 void Subtract(gfx::Rect rect); | 39 void Subtract(gfx::Rect rect); |
39 void Subtract(const Region& region); | 40 void Subtract(const Region& region); |
40 void Union(gfx::Rect rect); | 41 void Union(gfx::Rect rect); |
41 void Union(const Region& region); | 42 void Union(const Region& region); |
42 void Intersect(gfx::Rect rect); | 43 void Intersect(gfx::Rect rect); |
43 void Intersect(const Region& region); | 44 void Intersect(const Region& region); |
44 | 45 |
45 bool Equals(const Region& other) const { return skregion_ == other.skregion_;
} | 46 bool Equals(const Region& other) const { |
| 47 return skregion_ == other.skregion_; |
| 48 } |
46 | 49 |
47 gfx::Rect bounds() const { | 50 gfx::Rect bounds() const { |
48 SkIRect r = skregion_.getBounds(); | 51 return gfx::SkIRectToRect(skregion_.getBounds()); |
49 // TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists. | |
50 return gfx::Rect(r.x(), r.y(), r.width(), r.height()); | |
51 } | 52 } |
52 | 53 |
53 std::string ToString() const; | 54 std::string ToString() const; |
54 | 55 |
55 class CC_EXPORT Iterator { | 56 class CC_EXPORT Iterator { |
56 public: | 57 public: |
57 Iterator(const Region& region); | 58 Iterator(const Region& region); |
58 ~Iterator(); | 59 ~Iterator(); |
59 | 60 |
60 gfx::Rect rect() const { | 61 gfx::Rect rect() const { |
61 SkIRect r = it_.rect(); | 62 return gfx::SkIRectToRect(it_.rect()); |
62 // TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists. | |
63 return gfx::Rect(r.x(), r.y(), r.width(), r.height()); | |
64 } | 63 } |
65 | 64 |
66 void next() { | 65 void next() { |
67 it_.next(); | 66 it_.next(); |
68 } | 67 } |
| 68 |
69 bool has_rect() const { | 69 bool has_rect() const { |
70 return !it_.done(); | 70 return !it_.done(); |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 SkRegion::Iterator it_; | 74 SkRegion::Iterator it_; |
75 }; | 75 }; |
76 | 76 |
77 private: | 77 private: |
78 SkRegion skregion_; | 78 SkRegion skregion_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 inline Region UnionRegions(const Region& a, gfx::Rect b) { | 119 inline Region UnionRegions(const Region& a, gfx::Rect b) { |
120 Region result = a; | 120 Region result = a; |
121 result.Union(b); | 121 result.Union(b); |
122 return result; | 122 return result; |
123 } | 123 } |
124 | 124 |
125 } // namespace cc | 125 } // namespace cc |
126 | 126 |
127 #endif // CC_REGION_H_ | 127 #endif // CC_REGION_H_ |
OLD | NEW |