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_STUBS_REGION_H_ | 5 #ifndef CC_STUBS_REGION_H_ |
6 #define CC_STUBS_REGION_H_ | 6 #define CC_STUBS_REGION_H_ |
7 | 7 |
8 #include "IntRect.h" | 8 #include "IntRect.h" |
9 #if INSIDE_WEBKIT_BUILD | 9 #if INSIDE_WEBKIT_BUILD |
10 #include "Source/WebCore/platform/graphics/Region.h" | 10 #include "Source/WebCore/platform/graphics/Region.h" |
11 #else | 11 #else |
12 #include "third_party/WebKit/Source/WebCore/platform/graphics/Region.h" | 12 #include "third_party/WebKit/Source/WebCore/platform/graphics/Region.h" |
13 #endif | 13 #endif |
| 14 #include "ui/gfx/rect.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 | 17 |
17 class Region : public WebCore::Region { | 18 class Region : public WebCore::Region { |
18 public: | 19 public: |
19 Region() { } | 20 Region() { } |
20 | 21 |
21 Region(const IntRect& rect) | 22 Region(const IntRect& rect) |
22 : WebCore::Region(rect) | 23 : WebCore::Region(rect) |
23 { | 24 { |
24 } | 25 } |
25 | 26 |
26 Region(const WebCore::IntRect& rect) | 27 Region(const WebCore::IntRect& rect) |
27 : WebCore::Region(rect) | 28 : WebCore::Region(rect) |
28 { | 29 { |
29 } | 30 } |
30 | 31 |
31 Region(const WebCore::Region& region) | 32 Region(const WebCore::Region& region) |
32 : WebCore::Region(region) | 33 : WebCore::Region(region) |
33 { | 34 { |
34 } | 35 } |
| 36 |
| 37 Region(const gfx::Rect& rect) |
| 38 : WebCore::Region(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rec
t.height())) |
| 39 { |
| 40 } |
| 41 |
| 42 bool IsEmpty() const { return isEmpty(); } |
| 43 |
| 44 bool Contains(const gfx::Point& point) const { return contains(cc::IntPoint(
point)); } |
| 45 bool Contains(const gfx::Rect& rect) const { return contains(cc::IntRect(rec
t)); } |
| 46 void Subtract(const gfx::Rect& rect) { subtract(cc::IntRect(rect)); } |
| 47 void Subtract(const Region& region) { subtract(region); } |
| 48 void Union(const gfx::Rect& rect) { unite(cc::IntRect(rect)); } |
| 49 void Union(const Region& region) { unite(region); } |
| 50 void Intersect(const gfx::Rect& rect) { intersect(cc::IntRect(rect)); } |
| 51 void Intersect(const Region& region) { intersect(region); } |
| 52 |
| 53 gfx::Rect bounds() const { return cc::IntRect(WebCore::Region::bounds()); } |
| 54 |
| 55 private: |
| 56 bool isEmpty() const { return WebCore::Region::isEmpty(); } |
| 57 bool contains(const IntPoint& point) const { return WebCore::Region::contain
s(point); } |
| 58 bool contains(const IntRect& rect) const { return WebCore::Region::contains(
rect); } |
| 59 void subtract(const IntRect& rect) { return WebCore::Region::subtract(rect);
} |
| 60 void subtract(const Region& region) { return WebCore::Region::subtract(regio
n); } |
| 61 void unite(const IntRect& rect) { return WebCore::Region::unite(rect); } |
| 62 void unite(const Region& region) { return WebCore::Region::unite(region); } |
| 63 void intersect(const IntRect& rect) { return WebCore::Region::intersect(rect
); } |
| 64 void intersect(const Region& region) { return WebCore::Region::intersect(reg
ion); } |
35 }; | 65 }; |
36 | 66 |
| 67 inline Region subtract(const Region& region, const gfx::Rect& rect) { return Web
Core::intersect(region, cc::IntRect(rect)); } |
| 68 inline Region intersect(const Region& region, const gfx::Rect& rect) { return We
bCore::intersect(region, cc::IntRect(rect)); } |
| 69 |
37 } | 70 } |
38 | 71 |
39 #endif // CC_STUBS_REGION_H_ | 72 #endif // CC_STUBS_REGION_H_ |
OLD | NEW |