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

Side by Side Diff: cc/base/tiling_data.h

Issue 2067213002: cc: Implement tile iteration order based on pyramid sequence. [old] Base URL: https://chromium.googlesource.com/chromium/src.git@tiling_data_fix
Patch Set: tild Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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_BASE_TILING_DATA_H_ 5 #ifndef CC_BASE_TILING_DATA_H_
6 #define CC_BASE_TILING_DATA_H_ 6 #define CC_BASE_TILING_DATA_H_
7 7
8 #include <list>
8 #include <utility> 9 #include <utility>
10 #include <vector>
9 11
10 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
11 #include "cc/base/cc_export.h" 14 #include "cc/base/cc_export.h"
15 #include "cc/base/pyramid_sequence.h"
12 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
14 18
15 namespace gfx { 19 namespace gfx {
16 class Vector2d; 20 class Vector2d;
17 } 21 }
18 22
19 namespace cc { 23 namespace cc {
20 24
21 class CC_EXPORT TilingData { 25 class CC_EXPORT TilingData {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // with |consider| but which also do not intersect with |ignore|. 137 // with |consider| but which also do not intersect with |ignore|.
134 class CC_EXPORT DifferenceIterator : public BaseDifferenceIterator { 138 class CC_EXPORT DifferenceIterator : public BaseDifferenceIterator {
135 public: 139 public:
136 DifferenceIterator(); 140 DifferenceIterator();
137 DifferenceIterator(const TilingData* tiling_data, 141 DifferenceIterator(const TilingData* tiling_data,
138 const gfx::Rect& consider_rect, 142 const gfx::Rect& consider_rect,
139 const gfx::Rect& ignore_rect); 143 const gfx::Rect& ignore_rect);
140 DifferenceIterator& operator++(); 144 DifferenceIterator& operator++();
141 }; 145 };
142 146
147 struct LevelDistance {
148 int level;
149 int distance;
150 };
151
152 class LDSequence {
vmpstr 2016/06/16 18:28:58 I prefer to not abberviate here
vmpstr 2016/06/16 18:28:58 Needs a comment
153 public:
154 typedef std::list<LDSequence> List;
155
156 LDSequence(PyramidSequence traversal_seq,
vmpstr 2016/06/16 18:28:58 don't abbreviate seq
157 PyramidSequence level_seq,
158 bool swapped,
159 int distance);
160 LDSequence(const LDSequence& other);
161 ~LDSequence();
162
163 bool IsValid() const { return !level_distances_.empty(); }
164 int GetIndexX() const;
165 int GetIndexY() const;
166 int GetTopDistance();
167 bool Advance();
168
169 private:
170 void Reset();
171
172 PyramidSequence traversal_seq_;
173 bool swapped_;
174 int current_seq_index_;
175 int current_level_index_;
176 std::vector<LevelDistance> level_distances_;
177 };
178
143 // Iterate through all indices whose bounds + border intersect with 179 // Iterate through all indices whose bounds + border intersect with
144 // |consider| but which also do not intersect with |ignore|. The iterator 180 // |consider| but which also do not intersect with |ignore|. The iterator
145 // order is a counterclockwise spiral around the given center. 181 // order is a counterclockwise spiral around the given center.
146 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { 182 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator {
147 public: 183 public:
148 SpiralDifferenceIterator(); 184 SpiralDifferenceIterator();
149 SpiralDifferenceIterator(const TilingData* tiling_data, 185 SpiralDifferenceIterator(const TilingData* tiling_data,
150 const gfx::Rect& consider_rect, 186 const gfx::Rect& consider_rect,
151 const gfx::Rect& ignore_rect, 187 const gfx::Rect& ignore_rect,
152 const gfx::Rect& center_rect); 188 const gfx::Rect& center_rect);
189 ~SpiralDifferenceIterator();
153 SpiralDifferenceIterator& operator++(); 190 SpiralDifferenceIterator& operator++();
154 191
155 private: 192 bool valid_column(int column) const {
156 bool valid_column() const { 193 return column >= 0 && column <= num_tiles_x_;
157 return index_x_ >= consider_left_ && index_x_ <= consider_right_;
158 }
159 bool valid_row() const {
160 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_;
161 } 194 }
162 195
163 int current_step_count() const { 196 bool valid_row(int row) const { return row >= 0 && row <= num_tiles_y_; }
164 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_
165 : horizontal_step_count_;
166 }
167 197
168 bool needs_direction_switch() const; 198 private:
169 void switch_direction(); 199 LDSequence::List::iterator GetNextLDSequence();
170 200
171 enum Direction { UP, LEFT, DOWN, RIGHT }; 201 int num_tiles_x_;
172 202 int num_tiles_y_;
173 Direction direction_; 203 LDSequence::List ld_sequences_;
174 int delta_x_; 204 LDSequence::List::iterator current_ld_seq;
175 int delta_y_;
176 int current_step_;
177 int horizontal_step_count_;
178 int vertical_step_count_;
179 }; 205 };
180 206
181 class CC_EXPORT ReverseSpiralDifferenceIterator 207 class CC_EXPORT ReverseSpiralDifferenceIterator
182 : public BaseDifferenceIterator { 208 : public BaseDifferenceIterator {
183 public: 209 public:
184 ReverseSpiralDifferenceIterator(); 210 ReverseSpiralDifferenceIterator();
185 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, 211 ReverseSpiralDifferenceIterator(const TilingData* tiling_data,
186 const gfx::Rect& consider_rect, 212 const gfx::Rect& consider_rect,
187 const gfx::Rect& ignore_rect, 213 const gfx::Rect& ignore_rect,
188 const gfx::Rect& center_rect); 214 const gfx::Rect& center_rect);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 gfx::Size borderless_max_texture_size_; 265 gfx::Size borderless_max_texture_size_;
240 266
241 // These are computed values. 267 // These are computed values.
242 int num_tiles_x_; 268 int num_tiles_x_;
243 int num_tiles_y_; 269 int num_tiles_y_;
244 }; 270 };
245 271
246 } // namespace cc 272 } // namespace cc
247 273
248 #endif // CC_BASE_TILING_DATA_H_ 274 #endif // CC_BASE_TILING_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698