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

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

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! Created 6 years, 11 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/math_util.cc ('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
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_BASE_REGION_H_ 5 #ifndef CC_BASE_REGION_H_
6 #define CC_BASE_REGION_H_ 6 #define CC_BASE_REGION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 #include "third_party/skia/include/core/SkRegion.h" 13 #include "third_party/skia/include/core/SkRegion.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
16 16
17 namespace base { 17 namespace base {
18 class Value; 18 class Value;
19 } 19 }
20 20
21 namespace cc { 21 namespace cc {
22 22
23 class CC_EXPORT Region { 23 class CC_EXPORT Region {
24 public: 24 public:
25 Region(); 25 Region();
26 Region(const Region& region); 26 Region(const Region& region);
27 Region(gfx::Rect rect); // NOLINT(runtime/explicit) 27 Region(const gfx::Rect& rect); // NOLINT(runtime/explicit)
28 ~Region(); 28 ~Region();
29 29
30 const Region& operator=(gfx::Rect rect); 30 const Region& operator=(const gfx::Rect& rect);
31 const Region& operator=(const Region& region); 31 const Region& operator=(const Region& region);
32 32
33 void Swap(Region* region); 33 void Swap(Region* region);
34 void Clear(); 34 void Clear();
35 bool IsEmpty() const; 35 bool IsEmpty() const;
36 int GetRegionComplexity() const; 36 int GetRegionComplexity() const;
37 37
38 bool Contains(gfx::Point point) const; 38 bool Contains(gfx::Point point) const;
39 bool Contains(gfx::Rect rect) const; 39 bool Contains(const gfx::Rect& rect) const;
40 bool Contains(const Region& region) const; 40 bool Contains(const Region& region) const;
41 41
42 bool Intersects(gfx::Rect rect) const; 42 bool Intersects(const gfx::Rect& rect) const;
43 bool Intersects(const Region& region) const; 43 bool Intersects(const Region& region) const;
44 44
45 void Subtract(gfx::Rect rect); 45 void Subtract(const gfx::Rect& rect);
46 void Subtract(const Region& region); 46 void Subtract(const Region& region);
47 void Union(gfx::Rect rect); 47 void Union(const gfx::Rect& rect);
48 void Union(const Region& region); 48 void Union(const Region& region);
49 void Intersect(gfx::Rect rect); 49 void Intersect(const gfx::Rect& rect);
50 void Intersect(const Region& region); 50 void Intersect(const Region& region);
51 51
52 bool Equals(const Region& other) const { 52 bool Equals(const Region& other) const {
53 return skregion_ == other.skregion_; 53 return skregion_ == other.skregion_;
54 } 54 }
55 55
56 gfx::Rect bounds() const { 56 gfx::Rect bounds() const {
57 return gfx::SkIRectToRect(skregion_.getBounds()); 57 return gfx::SkIRectToRect(skregion_.getBounds());
58 } 58 }
59 59
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 inline bool operator!=(const Region& a, const Region& b) { 93 inline bool operator!=(const Region& a, const Region& b) {
94 return !(a == b); 94 return !(a == b);
95 } 95 }
96 96
97 inline Region SubtractRegions(const Region& a, const Region& b) { 97 inline Region SubtractRegions(const Region& a, const Region& b) {
98 Region result = a; 98 Region result = a;
99 result.Subtract(b); 99 result.Subtract(b);
100 return result; 100 return result;
101 } 101 }
102 102
103 inline Region SubtractRegions(const Region& a, gfx::Rect b) { 103 inline Region SubtractRegions(const Region& a, const gfx::Rect& b) {
104 Region result = a; 104 Region result = a;
105 result.Subtract(b); 105 result.Subtract(b);
106 return result; 106 return result;
107 } 107 }
108 108
109 inline Region IntersectRegions(const Region& a, const Region& b) { 109 inline Region IntersectRegions(const Region& a, const Region& b) {
110 Region result = a; 110 Region result = a;
111 result.Intersect(b); 111 result.Intersect(b);
112 return result; 112 return result;
113 } 113 }
114 114
115 inline Region IntersectRegions(const Region& a, gfx::Rect b) { 115 inline Region IntersectRegions(const Region& a, const gfx::Rect& b) {
116 Region result = a; 116 Region result = a;
117 result.Intersect(b); 117 result.Intersect(b);
118 return result; 118 return result;
119 } 119 }
120 120
121 inline Region UnionRegions(const Region& a, const Region& b) { 121 inline Region UnionRegions(const Region& a, const Region& b) {
122 Region result = a; 122 Region result = a;
123 result.Union(b); 123 result.Union(b);
124 return result; 124 return result;
125 } 125 }
126 126
127 inline Region UnionRegions(const Region& a, gfx::Rect b) { 127 inline Region UnionRegions(const Region& a, const gfx::Rect& b) {
128 Region result = a; 128 Region result = a;
129 result.Union(b); 129 result.Union(b);
130 return result; 130 return result;
131 } 131 }
132 132
133 } // namespace cc 133 } // namespace cc
134 134
135 #endif // CC_BASE_REGION_H_ 135 #endif // CC_BASE_REGION_H_
OLDNEW
« no previous file with comments | « cc/base/math_util.cc ('k') | cc/base/region.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698