Chromium Code Reviews| 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/skia_util.h" | |
|
danakj
2012/11/11 18:57:02
sort order
tfarina
2012/11/11 19:58:15
Done.
| |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.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(); |
| (...skipping 12 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; |
|
danakj
2012/11/11 18:57:02
Why moved?
tfarina
2012/11/11 19:43:25
For two reasons:
- To be consistent with the abov
danakj
2012/11/11 19:45:45
Ya, I'd rather keep simple methods like that in th
tfarina
2012/11/11 19:58:15
Done.
| |
| 46 | 47 |
| 47 gfx::Rect bounds() const { | 48 gfx::Rect bounds() const { |
| 48 SkIRect r = skregion_.getBounds(); | 49 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 } | 50 } |
| 52 | 51 |
| 53 std::string ToString() const; | 52 std::string ToString() const; |
| 54 | 53 |
| 55 class CC_EXPORT Iterator { | 54 class CC_EXPORT Iterator { |
| 56 public: | 55 public: |
| 57 Iterator(const Region& region); | 56 Iterator(const Region& region); |
| 58 ~Iterator(); | 57 ~Iterator(); |
| 59 | 58 |
| 60 gfx::Rect rect() const { | 59 gfx::Rect rect() const { |
| 61 SkIRect r = it_.rect(); | 60 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 } | 61 } |
| 65 | 62 |
| 66 void next() { | 63 void next() { |
| 67 it_.next(); | 64 it_.next(); |
| 68 } | 65 } |
| 66 | |
| 69 bool has_rect() const { | 67 bool has_rect() const { |
| 70 return !it_.done(); | 68 return !it_.done(); |
| 71 } | 69 } |
| 72 | 70 |
| 73 private: | 71 private: |
| 74 SkRegion::Iterator it_; | 72 SkRegion::Iterator it_; |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 private: | 75 private: |
| 78 SkRegion skregion_; | 76 SkRegion skregion_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 116 |
| 119 inline Region UnionRegions(const Region& a, gfx::Rect b) { | 117 inline Region UnionRegions(const Region& a, gfx::Rect b) { |
| 120 Region result = a; | 118 Region result = a; |
| 121 result.Union(b); | 119 result.Union(b); |
| 122 return result; | 120 return result; |
| 123 } | 121 } |
| 124 | 122 |
| 125 } // namespace cc | 123 } // namespace cc |
| 126 | 124 |
| 127 #endif // CC_REGION_H_ | 125 #endif // CC_REGION_H_ |
| OLD | NEW |