summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-12 21:44:44 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-12 21:44:44 +0000
commit6c50bfb93535623550aeab906f2119610c28cb29 (patch)
treef0cbce7830db3c0ad328cc13aaa90960b7d86f64 /cc
parente5de0f7c04d74d4e7b5d11466f4b9279c29b2f82 (diff)
downloadchromium_src-6c50bfb93535623550aeab906f2119610c28cb29.zip
chromium_src-6c50bfb93535623550aeab906f2119610c28cb29.tar.gz
chromium_src-6c50bfb93535623550aeab906f2119610c28cb29.tar.bz2
ui: Add SkIRectToRect() function to convert from SkIRect type to gfx::Rect.
This fixes the 3 TODOs for Dana from region.* TEST=cc_unittests,ui_unittests R=danakj@chromium.org Review URL: https://codereview.chromium.org/11410025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/region.cc20
-rw-r--r--cc/region.h14
2 files changed, 14 insertions, 20 deletions
diff --git a/cc/region.cc b/cc/region.cc
index a33965c..3cd9b5d 100644
--- a/cc/region.cc
+++ b/cc/region.cc
@@ -6,12 +6,6 @@
namespace cc {
-// TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
-static inline SkIRect ToSkIRect(gfx::Rect rect)
-{
- return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
Region::Region() {
}
@@ -20,14 +14,14 @@ Region::Region(const Region& region)
}
Region::Region(gfx::Rect rect)
- : skregion_(ToSkIRect(rect)) {
+ : skregion_(gfx::RectToSkIRect(rect)) {
}
Region::~Region() {
}
const Region& Region::operator=(gfx::Rect rect) {
- skregion_ = SkRegion(ToSkIRect(rect));
+ skregion_ = SkRegion(gfx::RectToSkIRect(rect));
return *this;
}
@@ -55,7 +49,7 @@ bool Region::Contains(gfx::Point point) const {
bool Region::Contains(gfx::Rect rect) const {
if (rect.IsEmpty())
return true;
- return skregion_.contains(ToSkIRect(rect));
+ return skregion_.contains(gfx::RectToSkIRect(rect));
}
bool Region::Contains(const Region& region) const {
@@ -65,7 +59,7 @@ bool Region::Contains(const Region& region) const {
}
bool Region::Intersects(gfx::Rect rect) const {
- return skregion_.intersects(ToSkIRect(rect));
+ return skregion_.intersects(gfx::RectToSkIRect(rect));
}
bool Region::Intersects(const Region& region) const {
@@ -73,7 +67,7 @@ bool Region::Intersects(const Region& region) const {
}
void Region::Subtract(gfx::Rect rect) {
- skregion_.op(ToSkIRect(rect), SkRegion::kDifference_Op);
+ skregion_.op(gfx::RectToSkIRect(rect), SkRegion::kDifference_Op);
}
void Region::Subtract(const Region& region) {
@@ -81,7 +75,7 @@ void Region::Subtract(const Region& region) {
}
void Region::Union(gfx::Rect rect) {
- skregion_.op(ToSkIRect(rect), SkRegion::kUnion_Op);
+ skregion_.op(gfx::RectToSkIRect(rect), SkRegion::kUnion_Op);
}
void Region::Union(const Region& region) {
@@ -89,7 +83,7 @@ void Region::Union(const Region& region) {
}
void Region::Intersect(gfx::Rect rect) {
- skregion_.op(ToSkIRect(rect), SkRegion::kIntersect_Op);
+ skregion_.op(gfx::RectToSkIRect(rect), SkRegion::kIntersect_Op);
}
void Region::Intersect(const Region& region) {
diff --git a/cc/region.h b/cc/region.h
index 00e2bd1..badd33c 100644
--- a/cc/region.h
+++ b/cc/region.h
@@ -11,6 +11,7 @@
#include "cc/cc_export.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/skia_util.h"
namespace cc {
@@ -42,12 +43,12 @@ class CC_EXPORT Region {
void Intersect(gfx::Rect rect);
void Intersect(const Region& region);
- bool Equals(const Region& other) const { return skregion_ == other.skregion_; }
+ bool Equals(const Region& other) const {
+ return skregion_ == other.skregion_;
+ }
gfx::Rect bounds() const {
- SkIRect r = skregion_.getBounds();
- // TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
- return gfx::Rect(r.x(), r.y(), r.width(), r.height());
+ return gfx::SkIRectToRect(skregion_.getBounds());
}
std::string ToString() const;
@@ -58,14 +59,13 @@ class CC_EXPORT Region {
~Iterator();
gfx::Rect rect() const {
- SkIRect r = it_.rect();
- // TODO(danakj) Use method from ui/gfx/skia_utils.h when it exists.
- return gfx::Rect(r.x(), r.y(), r.width(), r.height());
+ return gfx::SkIRectToRect(it_.rect());
}
void next() {
it_.next();
}
+
bool has_rect() const {
return !it_.done();
}