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.
5 #ifndef CC_BASE_REGION_H_
6 #define CC_BASE_REGION_H_
10 #include "base/logging.h"
11 #include "cc/base/cc_export.h"
12 #include "third_party/skia/include/core/SkRegion.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/skia_util.h"
18 class CC_EXPORT Region
{
21 Region(const Region
& region
);
22 Region(gfx::Rect rect
);
25 const Region
& operator=(gfx::Rect rect
);
26 const Region
& operator=(const Region
& region
);
28 void Swap(Region
* region
);
32 bool Contains(gfx::Point point
) const;
33 bool Contains(gfx::Rect rect
) const;
34 bool Contains(const Region
& region
) const;
36 bool Intersects(gfx::Rect rect
) const;
37 bool Intersects(const Region
& region
) const;
39 void Subtract(gfx::Rect rect
);
40 void Subtract(const Region
& region
);
41 void Union(gfx::Rect rect
);
42 void Union(const Region
& region
);
43 void Intersect(gfx::Rect rect
);
44 void Intersect(const Region
& region
);
46 bool Equals(const Region
& other
) const {
47 return skregion_
== other
.skregion_
;
50 gfx::Rect
bounds() const {
51 return gfx::SkIRectToRect(skregion_
.getBounds());
54 std::string
ToString() const;
56 class CC_EXPORT Iterator
{
59 Iterator(const Region
& region
);
62 gfx::Rect
rect() const {
63 return gfx::SkIRectToRect(it_
.rect());
70 bool has_rect() const {
75 SkRegion::Iterator it_
;
82 inline bool operator==(const Region
& a
, const Region
& b
) {
86 inline bool operator!=(const Region
& a
, const Region
& b
) {
90 inline Region
SubtractRegions(const Region
& a
, const Region
& b
) {
96 inline Region
SubtractRegions(const Region
& a
, gfx::Rect b
) {
102 inline Region
IntersectRegions(const Region
& a
, const Region
& b
) {
108 inline Region
IntersectRegions(const Region
& a
, gfx::Rect b
) {
114 inline Region
UnionRegions(const Region
& a
, const Region
& b
) {
120 inline Region
UnionRegions(const Region
& a
, gfx::Rect b
) {
128 #endif // CC_BASE_REGION_H_