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

Unified Diff: cc/stubs/Region.h

Issue 11360066: cc: Remove WebCore rect use from the compositor, except within Region. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Signs Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/stubs/IntRect.h ('k') | cc/stubs/float_rect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/stubs/Region.h
diff --git a/cc/stubs/Region.h b/cc/stubs/Region.h
index 130e3e6dfe279307a6d2c4765359e3d99eeb8870..9f886ac41d2b9ed32d6a5bea701f61a0a0c53f77 100644
--- a/cc/stubs/Region.h
+++ b/cc/stubs/Region.h
@@ -5,12 +5,12 @@
#ifndef CC_STUBS_REGION_H_
#define CC_STUBS_REGION_H_
-#include "IntRect.h"
#if INSIDE_WEBKIT_BUILD
#include "Source/WebCore/platform/graphics/Region.h"
#else
#include "third_party/WebKit/Source/WebCore/platform/graphics/Region.h"
#endif
+#include "base/logging.h"
#include "ui/gfx/rect.h"
namespace cc {
@@ -19,16 +19,6 @@ class Region : public WebCore::Region {
public:
Region() { }
- Region(const IntRect& rect)
- : WebCore::Region(rect)
- {
- }
-
- Region(const WebCore::IntRect& rect)
- : WebCore::Region(rect)
- {
- }
-
Region(const WebCore::Region& region)
: WebCore::Region(region)
{
@@ -41,31 +31,67 @@ public:
bool IsEmpty() const { return isEmpty(); }
- bool Contains(const gfx::Point& point) const { return contains(cc::IntPoint(point)); }
- bool Contains(const gfx::Rect& rect) const { return contains(cc::IntRect(rect)); }
- void Subtract(const gfx::Rect& rect) { subtract(cc::IntRect(rect)); }
+ bool Contains(const gfx::Point& point) const { return contains(WebCore::IntPoint(point.x(), point.y())); }
+ bool Contains(const gfx::Rect& rect) const { return contains(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
+ void Subtract(const gfx::Rect& rect) { subtract(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
void Subtract(const Region& region) { subtract(region); }
- void Union(const gfx::Rect& rect) { unite(cc::IntRect(rect)); }
+ void Union(const gfx::Rect& rect) { unite(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
void Union(const Region& region) { unite(region); }
- void Intersect(const gfx::Rect& rect) { intersect(cc::IntRect(rect)); }
+ void Intersect(const gfx::Rect& rect) { intersect(WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
void Intersect(const Region& region) { intersect(region); }
- gfx::Rect bounds() const { return cc::IntRect(WebCore::Region::bounds()); }
+ gfx::Rect bounds() const
+ {
+ WebCore::IntRect bounds = WebCore::Region::bounds();
+ return gfx::Rect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
+ }
+
+ class Iterator {
+ public:
+ Iterator(const Region& region);
+ ~Iterator();
+
+ gfx::Rect rect() const {
+ DCHECK(has_rect());
+ if (!has_rect())
+ return gfx::Rect();
+ return gfx::Rect(m_rects[m_pos].x(), m_rects[m_pos].y(), m_rects[m_pos].width(), m_rects[m_pos].height());
+ }
+
+ void next() { ++m_pos; }
+ bool has_rect() const { return m_pos < m_rects.size(); }
+
+ // It is expensive to construct the iterator just to get this size. Only
+ // do this for testing.
+ size_t size() const { return m_rects.size(); }
+ private:
+ size_t m_pos;
+ Vector<WebCore::IntRect> m_rects;
+ };
private:
bool isEmpty() const { return WebCore::Region::isEmpty(); }
- bool contains(const IntPoint& point) const { return WebCore::Region::contains(point); }
- bool contains(const IntRect& rect) const { return WebCore::Region::contains(rect); }
- void subtract(const IntRect& rect) { return WebCore::Region::subtract(rect); }
+ bool contains(const WebCore::IntPoint& point) const { return WebCore::Region::contains(point); }
+ bool contains(const WebCore::IntRect& rect) const { return WebCore::Region::contains(rect); }
+ void subtract(const WebCore::IntRect& rect) { return WebCore::Region::subtract(rect); }
void subtract(const Region& region) { return WebCore::Region::subtract(region); }
- void unite(const IntRect& rect) { return WebCore::Region::unite(rect); }
+ void unite(const WebCore::IntRect& rect) { return WebCore::Region::unite(rect); }
void unite(const Region& region) { return WebCore::Region::unite(region); }
- void intersect(const IntRect& rect) { return WebCore::Region::intersect(rect); }
+ void intersect(const WebCore::IntRect& rect) { return WebCore::Region::intersect(rect); }
void intersect(const Region& region) { return WebCore::Region::intersect(region); }
+ Vector<WebCore::IntRect> rects() const { return WebCore::Region::rects(); }
};
-inline Region subtract(const Region& region, const gfx::Rect& rect) { return WebCore::intersect(region, cc::IntRect(rect)); }
-inline Region intersect(const Region& region, const gfx::Rect& rect) { return WebCore::intersect(region, cc::IntRect(rect)); }
+inline Region subtract(const Region& region, const gfx::Rect& rect) { return WebCore::intersect(region, WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
+inline Region intersect(const Region& region, const gfx::Rect& rect) { return WebCore::intersect(region, WebCore::IntRect(rect.x(), rect.y(), rect.width(), rect.height())); }
+
+inline Region::Iterator::Iterator(const Region& region)
+ : m_pos(0)
+ , m_rects(region.rects())
+{
+}
+
+inline Region::Iterator::~Iterator() { }
}
« no previous file with comments | « cc/stubs/IntRect.h ('k') | cc/stubs/float_rect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698