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

Unified Diff: cc/base/tiling_data.h

Issue 1017713003: cc: Reduce duplicated tiling data difference iterator code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Naming Created 5 years, 9 months 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 | « no previous file | cc/base/tiling_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/tiling_data.h
diff --git a/cc/base/tiling_data.h b/cc/base/tiling_data.h
index 45b763e9ef0ba5c906a69c4eb29176bc9aed9f88..a35be59f7484ccaacd51e32f8a7c9c626db4c2a7 100644
--- a/cc/base/tiling_data.h
+++ b/cc/base/tiling_data.h
@@ -101,19 +101,21 @@ class CC_EXPORT TilingData {
int bottom_;
};
- // Iterate through all indices whose bounds (not including borders) intersect
- // with |consider| but which also do not intersect with |ignore|.
- class CC_EXPORT DifferenceIterator : public BaseIterator {
- public:
- DifferenceIterator(const TilingData* tiling_data,
- const gfx::Rect& consider_rect,
- const gfx::Rect& ignore_rect);
- DifferenceIterator& operator++();
+ class CC_EXPORT BaseDifferenceIterator : public BaseIterator {
+ protected:
+ BaseDifferenceIterator();
+ BaseDifferenceIterator(const TilingData* tiling_data,
+ const gfx::Rect& consider_rect,
+ const gfx::Rect& ignore_rect);
- private:
+ bool HasConsiderRect() const;
+ bool in_consider_rect() const {
+ return index_x_ >= consider_left_ && index_x_ <= consider_right_ &&
+ index_y_ >= consider_top_ && index_y_ <= consider_bottom_;
+ }
bool in_ignore_rect() const {
- return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ &&
- index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_;
+ return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ &&
+ index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_;
}
int consider_left_;
@@ -126,10 +128,20 @@ class CC_EXPORT TilingData {
int ignore_bottom_;
};
+ // Iterate through all indices whose bounds (not including borders) intersect
+ // with |consider| but which also do not intersect with |ignore|.
+ class CC_EXPORT DifferenceIterator : public BaseDifferenceIterator {
+ public:
+ DifferenceIterator(const TilingData* tiling_data,
+ const gfx::Rect& consider_rect,
+ const gfx::Rect& ignore_rect);
+ DifferenceIterator& operator++();
+ };
+
// Iterate through all indices whose bounds + border intersect with
// |consider| but which also do not intersect with |ignore|. The iterator
// order is a counterclockwise spiral around the given center.
- class CC_EXPORT SpiralDifferenceIterator : public BaseIterator {
+ class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator {
public:
SpiralDifferenceIterator();
SpiralDifferenceIterator(const TilingData* tiling_data,
@@ -139,14 +151,6 @@ class CC_EXPORT TilingData {
SpiralDifferenceIterator& operator++();
private:
- bool in_consider_rect() const {
- return index_x_ >= consider_left_ && index_x_ <= consider_right_ &&
- index_y_ >= consider_top_ && index_y_ <= consider_bottom_;
- }
- bool in_ignore_rect() const {
- return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ &&
- index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_;
- }
bool valid_column() const {
return index_x_ >= consider_left_ && index_x_ <= consider_right_;
}
@@ -162,15 +166,6 @@ class CC_EXPORT TilingData {
bool needs_direction_switch() const;
void switch_direction();
- int consider_left_;
- int consider_top_;
- int consider_right_;
- int consider_bottom_;
- int ignore_left_;
- int ignore_top_;
- int ignore_right_;
- int ignore_bottom_;
-
enum Direction { UP, LEFT, DOWN, RIGHT };
Direction direction_;
@@ -181,7 +176,8 @@ class CC_EXPORT TilingData {
int vertical_step_count_;
};
- class CC_EXPORT ReverseSpiralDifferenceIterator : public BaseIterator {
+ class CC_EXPORT ReverseSpiralDifferenceIterator
+ : public BaseDifferenceIterator {
public:
ReverseSpiralDifferenceIterator();
ReverseSpiralDifferenceIterator(const TilingData* tiling_data,
@@ -191,18 +187,10 @@ class CC_EXPORT TilingData {
ReverseSpiralDifferenceIterator& operator++();
private:
- bool in_consider_rect() const {
- return index_x_ >= consider_left_ && index_x_ <= consider_right_ &&
- index_y_ >= consider_top_ && index_y_ <= consider_bottom_;
- }
bool in_around_rect() const {
return index_x_ >= around_left_ && index_x_ <= around_right_ &&
index_y_ >= around_top_ && index_y_ <= around_bottom_;
}
- bool in_ignore_rect() const {
- return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ &&
- index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_;
- }
bool valid_column() const {
return index_x_ >= consider_left_ && index_x_ <= consider_right_;
}
@@ -218,18 +206,10 @@ class CC_EXPORT TilingData {
bool needs_direction_switch() const;
void switch_direction();
- int consider_left_;
- int consider_top_;
- int consider_right_;
- int consider_bottom_;
int around_left_;
int around_top_;
int around_right_;
int around_bottom_;
- int ignore_left_;
- int ignore_top_;
- int ignore_right_;
- int ignore_bottom_;
enum Direction { LEFT, UP, RIGHT, DOWN };
« no previous file with comments | « no previous file | cc/base/tiling_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698