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

Side by Side Diff: cc/base/region.h

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « cc/base/ref_counted_managed.h ('k') | cc/base/region.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_BASE_REGION_H_
6 #define CC_BASE_REGION_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/base/cc_export.h"
12 #include "third_party/skia/include/core/SkRegion.h"
13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/skia_util.h"
15
16 namespace base {
17 class Value;
18 namespace trace_event {
19 class TracedValue;
20 }
21 }
22
23 namespace cc {
24 class SimpleEnclosedRegion;
25
26 class CC_EXPORT Region {
27 public:
28 Region();
29 Region(const Region& region);
30 Region(const gfx::Rect& rect); // NOLINT(runtime/explicit)
31 ~Region();
32
33 const Region& operator=(const gfx::Rect& rect);
34 const Region& operator=(const Region& region);
35
36 void Swap(Region* region);
37 void Clear();
38 bool IsEmpty() const;
39 int GetRegionComplexity() const;
40
41 bool Contains(const gfx::Point& point) const;
42 bool Contains(const gfx::Rect& rect) const;
43 bool Contains(const Region& region) const;
44
45 bool Intersects(const gfx::Rect& rect) const;
46 bool Intersects(const Region& region) const;
47
48 void Subtract(const gfx::Rect& rect);
49 void Subtract(const Region& region);
50 void Subtract(const SimpleEnclosedRegion& region);
51 void Union(const gfx::Rect& rect);
52 void Union(const Region& region);
53 void Intersect(const gfx::Rect& rect);
54 void Intersect(const Region& region);
55
56 bool Equals(const Region& other) const {
57 return skregion_ == other.skregion_;
58 }
59
60 gfx::Rect bounds() const {
61 return gfx::SkIRectToRect(skregion_.getBounds());
62 }
63
64 std::string ToString() const;
65 scoped_ptr<base::Value> AsValue() const;
66 void AsValueInto(base::trace_event::TracedValue* array) const;
67
68 class CC_EXPORT Iterator {
69 public:
70 Iterator();
71 explicit Iterator(const Region& region);
72 ~Iterator();
73
74 gfx::Rect rect() const {
75 return gfx::SkIRectToRect(it_.rect());
76 }
77
78 void next() {
79 it_.next();
80 }
81
82 bool has_rect() const {
83 return !it_.done();
84 }
85
86 private:
87 SkRegion::Iterator it_;
88 };
89
90 private:
91 SkRegion skregion_;
92 };
93
94 inline bool operator==(const Region& a, const Region& b) {
95 return a.Equals(b);
96 }
97
98 inline bool operator!=(const Region& a, const Region& b) {
99 return !(a == b);
100 }
101
102 inline Region SubtractRegions(const Region& a, const Region& b) {
103 Region result = a;
104 result.Subtract(b);
105 return result;
106 }
107
108 inline Region SubtractRegions(const Region& a, const gfx::Rect& b) {
109 Region result = a;
110 result.Subtract(b);
111 return result;
112 }
113
114 inline Region IntersectRegions(const Region& a, const Region& b) {
115 Region result = a;
116 result.Intersect(b);
117 return result;
118 }
119
120 inline Region IntersectRegions(const Region& a, const gfx::Rect& b) {
121 Region result = a;
122 result.Intersect(b);
123 return result;
124 }
125
126 inline Region UnionRegions(const Region& a, const Region& b) {
127 Region result = a;
128 result.Union(b);
129 return result;
130 }
131
132 inline Region UnionRegions(const Region& a, const gfx::Rect& b) {
133 Region result = a;
134 result.Union(b);
135 return result;
136 }
137
138 } // namespace cc
139
140 #endif // CC_BASE_REGION_H_
OLDNEW
« no previous file with comments | « cc/base/ref_counted_managed.h ('k') | cc/base/region.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698