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

Unified Diff: cc/base/tiling_data.h

Issue 183123004: cc: Added a spiral difference iterator to tiling data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 6 years, 10 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') | cc/base/tiling_data_unittest.cc » ('J')
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 9540c3896b1e3999522f5e34a626ad95cb327b27..8acb0cb66a0f70f978b7d1521fe420ea0da4ce44 100644
--- a/cc/base/tiling_data.h
+++ b/cc/base/tiling_data.h
@@ -124,7 +124,66 @@ class CC_EXPORT TilingData {
int ignore_bottom_;
};
+ // 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 {
+ public:
+ SpiralDifferenceIterator(const TilingData* tiling_data,
+ const gfx::Rect& consider_rect,
+ const gfx::Rect& ignore_rect,
+ const gfx::Rect& center_rect);
+ SpiralDifferenceIterator& operator++();
+
+ private:
+ inline bool in_consider_rect() const {
aelias_OOO_until_Jul13 2014/03/01 01:15:17 nit: I don't think "inline" does anything, may as
vmpstr 2014/03/03 18:32:23 Done.
+ return index_x_ >= consider_left_ && index_x_ <= consider_right_ &&
+ index_y_ >= consider_top_ && index_y_ <= consider_bottom_;
+ }
+ inline bool in_ignore_rect() const {
+ return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ &&
+ index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_;
+ }
+ inline bool valid_column() const {
+ return index_x_ >= consider_left_ && index_x_ <= consider_right_;
+ }
+ inline bool valid_row() const {
+ return index_y_ >= consider_top_ && index_y_ <= consider_bottom_;
+ }
+
+ int current_step_count() const {
+ return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_
+ : horizontal_step_count_;
+ }
+
+ 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_;
+ int delta_x_;
+ int delta_y_;
+ int current_step_;
+ int horizontal_step_count_;
+ int vertical_step_count_;
+ };
+
private:
+ std::pair<int, int> UnclampedFirstBorderTileIndexFromSrcCoord(int x,
+ int y) const;
+ std::pair<int, int> UnclampedLastBorderTileIndexFromSrcCoord(int x,
+ int y) const;
+
void AssertTile(int i, int j) const {
DCHECK_GE(i, 0);
DCHECK_LT(i, num_tiles_x_);
« no previous file with comments | « no previous file | cc/base/tiling_data.cc » ('j') | cc/base/tiling_data_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698