OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <utility> | 5 #include <utility> |
6 | 6 |
7 #include "cc/resources/tiling_set_eviction_queue.h" | 7 #include "cc/resources/tiling_set_eviction_queue.h" |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 namespace { | |
11 | |
12 bool IsSharedOutOfOrderTile(WhichTree tree, const Tile* tile) { | |
13 if (!tile->is_shared()) | |
14 return false; | |
15 | |
16 // The priority for tile priority of a shared tile will be a combined | |
17 // priority thus return shared tiles from a higher priority tree as | |
18 // it is out of order for a lower priority tree. | |
19 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | |
20 const TilePriority& priority = tile->priority(tree); | |
21 const TilePriority& twin_priority = tile->priority(twin_tree); | |
22 if (priority.priority_bin != twin_priority.priority_bin) | |
23 return priority.priority_bin > twin_priority.priority_bin; | |
24 const bool occluded = tile->is_occluded(tree); | |
25 const bool twin_occluded = tile->is_occluded(twin_tree); | |
26 if (occluded != twin_occluded) | |
27 return occluded; | |
28 if (priority.distance_to_visible != twin_priority.distance_to_visible) | |
29 return priority.distance_to_visible > twin_priority.distance_to_visible; | |
30 | |
31 // If priorities are the same, it does not matter which tree returns | |
32 // the tile. Let's pick the pending tree. | |
33 return tree != PENDING_TREE; | |
34 } | |
35 | |
36 } // namespace | |
37 | 10 |
38 TilingSetEvictionQueue::TilingSetEvictionQueue( | 11 TilingSetEvictionQueue::TilingSetEvictionQueue( |
39 PictureLayerTilingSet* tiling_set, | 12 PictureLayerTilingSet* tiling_set, |
40 bool skip_shared_out_of_order_tiles) | 13 bool skip_shared_out_of_order_tiles) |
41 : tree_(tiling_set->client()->GetTree()), | 14 : tree_(tiling_set->client()->GetTree()), |
42 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), | 15 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), |
43 phase_(EVENTUALLY_RECT), | 16 phase_(EVENTUALLY_RECT), |
44 current_tile_(nullptr) { | 17 current_tile_(nullptr) { |
45 // Early out if the layer has no tilings. | 18 // Early out if the layer has no tilings. |
46 if (!tiling_set->num_tilings()) | 19 if (!tiling_set->num_tilings()) |
(...skipping 11 matching lines...) Expand all Loading... | |
58 TilingSetEvictionQueue::~TilingSetEvictionQueue() { | 31 TilingSetEvictionQueue::~TilingSetEvictionQueue() { |
59 } | 32 } |
60 | 33 |
61 void TilingSetEvictionQueue::GenerateTilingOrder( | 34 void TilingSetEvictionQueue::GenerateTilingOrder( |
62 PictureLayerTilingSet* tiling_set) { | 35 PictureLayerTilingSet* tiling_set) { |
63 tilings_.reserve(tiling_set->num_tilings()); | 36 tilings_.reserve(tiling_set->num_tilings()); |
64 // Generate all of the tilings in the order described in the header comment | 37 // Generate all of the tilings in the order described in the header comment |
65 // for this class. | 38 // for this class. |
66 auto range = | 39 auto range = |
67 tiling_set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); | 40 tiling_set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); |
68 for (int i = range.start; i < range.end; ++i) | 41 for (int i = range.start; i < range.end; ++i) { |
69 tilings_.push_back(tiling_set->tiling_at(i)); | 42 auto* tiling = tiling_set->tiling_at(i); |
enne (OOO)
2015/04/20 22:36:28
style nit: don't use auto here.
vmpstr
2015/04/22 18:38:57
Done.
| |
43 if (tiling->has_tiles()) | |
44 tilings_.push_back(tiling); | |
45 } | |
70 | 46 |
71 range = tiling_set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); | 47 range = tiling_set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); |
72 for (int i = range.end - 1; i >= range.start; --i) | 48 for (int i = range.end - 1; i >= range.start; --i) { |
73 tilings_.push_back(tiling_set->tiling_at(i)); | 49 auto* tiling = tiling_set->tiling_at(i); |
50 if (tiling->has_tiles()) | |
51 tilings_.push_back(tiling); | |
52 } | |
74 | 53 |
75 range = tiling_set->GetTilingRange( | 54 range = tiling_set->GetTilingRange( |
76 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); | 55 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); |
77 for (int i = range.end - 1; i >= range.start; --i) | 56 for (int i = range.end - 1; i >= range.start; --i) { |
78 tilings_.push_back(tiling_set->tiling_at(i)); | 57 auto* tiling = tiling_set->tiling_at(i); |
58 if (tiling->has_tiles()) | |
59 tilings_.push_back(tiling); | |
60 } | |
79 | 61 |
80 range = tiling_set->GetTilingRange(PictureLayerTilingSet::LOW_RES); | 62 range = tiling_set->GetTilingRange(PictureLayerTilingSet::LOW_RES); |
81 for (int i = range.start; i < range.end; ++i) | 63 for (int i = range.start; i < range.end; ++i) { |
82 tilings_.push_back(tiling_set->tiling_at(i)); | 64 auto* tiling = tiling_set->tiling_at(i); |
65 if (tiling->has_tiles()) | |
66 tilings_.push_back(tiling); | |
67 } | |
83 | 68 |
84 range = tiling_set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); | 69 range = tiling_set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); |
85 for (int i = range.start; i < range.end; ++i) | 70 for (int i = range.start; i < range.end; ++i) { |
86 tilings_.push_back(tiling_set->tiling_at(i)); | 71 auto* tiling = tiling_set->tiling_at(i); |
87 DCHECK_EQ(tiling_set->num_tilings(), tilings_.size()); | 72 if (tiling->has_tiles()) |
73 tilings_.push_back(tiling); | |
74 } | |
75 DCHECK_GE(tiling_set->num_tilings(), tilings_.size()); | |
88 } | 76 } |
89 | 77 |
90 void TilingSetEvictionQueue::AdvancePhase() { | 78 void TilingSetEvictionQueue::AdvancePhase() { |
91 current_tile_ = nullptr; | 79 current_tile_ = nullptr; |
92 while (!current_tile_ && | 80 while (!current_tile_ && |
93 phase_ != VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED) { | 81 phase_ != VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED) { |
94 phase_ = static_cast<Phase>(phase_ + 1); | 82 phase_ = static_cast<Phase>(phase_ + 1); |
95 switch (phase_) { | 83 switch (phase_) { |
96 case EVENTUALLY_RECT: | 84 case EVENTUALLY_RECT: |
97 NOTREACHED(); | 85 NOTREACHED(); |
98 break; | 86 break; |
99 case SOON_BORDER_RECT: | 87 case SOON_BORDER_RECT: |
100 soon_iterator_ = SoonBorderTilingIterator( | 88 soon_iterator_ = SoonBorderTilingIterator( |
101 &tilings_, tree_, skip_shared_out_of_order_tiles_); | 89 &tilings_, tree_, skip_shared_out_of_order_tiles_); |
102 if (!soon_iterator_.done()) | 90 if (!soon_iterator_.done()) |
103 current_tile_ = *soon_iterator_; | 91 current_tile_ = *soon_iterator_; |
104 break; | 92 break; |
105 case SKEWPORT_RECT: | 93 case SKEWPORT_RECT: |
106 skewport_iterator_ = SkewportTilingIterator( | 94 skewport_iterator_ = SkewportTilingIterator( |
107 &tilings_, tree_, skip_shared_out_of_order_tiles_); | 95 &tilings_, tree_, skip_shared_out_of_order_tiles_); |
108 if (!skewport_iterator_.done()) | 96 if (!skewport_iterator_.done()) |
109 current_tile_ = *skewport_iterator_; | 97 current_tile_ = *skewport_iterator_; |
110 break; | 98 break; |
99 case PENDING_VISIBLE_RECT: | |
100 pending_visible_iterator_ = PendingVisibleTilingIterator( | |
101 &tilings_, tree_, skip_shared_out_of_order_tiles_, | |
102 false /* return required for activation tiles */); | |
103 if (!pending_visible_iterator_.done()) | |
104 current_tile_ = *pending_visible_iterator_; | |
105 break; | |
106 case PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION: | |
107 pending_visible_iterator_ = PendingVisibleTilingIterator( | |
108 &tilings_, tree_, skip_shared_out_of_order_tiles_, | |
109 true /* return required for activation tiles */); | |
110 if (!pending_visible_iterator_.done()) | |
111 current_tile_ = *pending_visible_iterator_; | |
112 break; | |
111 case VISIBLE_RECT_OCCLUDED: | 113 case VISIBLE_RECT_OCCLUDED: |
112 visible_iterator_ = VisibleTilingIterator( | 114 visible_iterator_ = VisibleTilingIterator( |
113 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 115 &tilings_, tree_, skip_shared_out_of_order_tiles_, |
114 true /* return occluded tiles */, | 116 true /* return occluded tiles */, |
115 false /* return required for activation tiles */); | 117 false /* return required for activation tiles */); |
116 if (!visible_iterator_.done()) | 118 if (!visible_iterator_.done()) |
117 current_tile_ = *visible_iterator_; | 119 current_tile_ = *visible_iterator_; |
118 break; | 120 break; |
119 case VISIBLE_RECT_UNOCCLUDED: | 121 case VISIBLE_RECT_UNOCCLUDED: |
120 visible_iterator_ = VisibleTilingIterator( | 122 visible_iterator_ = VisibleTilingIterator( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 case SOON_BORDER_RECT: | 172 case SOON_BORDER_RECT: |
171 ++soon_iterator_; | 173 ++soon_iterator_; |
172 if (!soon_iterator_.done()) | 174 if (!soon_iterator_.done()) |
173 current_tile_ = *soon_iterator_; | 175 current_tile_ = *soon_iterator_; |
174 break; | 176 break; |
175 case SKEWPORT_RECT: | 177 case SKEWPORT_RECT: |
176 ++skewport_iterator_; | 178 ++skewport_iterator_; |
177 if (!skewport_iterator_.done()) | 179 if (!skewport_iterator_.done()) |
178 current_tile_ = *skewport_iterator_; | 180 current_tile_ = *skewport_iterator_; |
179 break; | 181 break; |
182 case PENDING_VISIBLE_RECT: | |
183 case PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION: | |
184 ++pending_visible_iterator_; | |
185 if (!pending_visible_iterator_.done()) | |
186 current_tile_ = *pending_visible_iterator_; | |
187 break; | |
180 case VISIBLE_RECT_OCCLUDED: | 188 case VISIBLE_RECT_OCCLUDED: |
181 case VISIBLE_RECT_UNOCCLUDED: | 189 case VISIBLE_RECT_UNOCCLUDED: |
182 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED: | 190 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED: |
183 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED: | 191 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED: |
184 ++visible_iterator_; | 192 ++visible_iterator_; |
185 if (!visible_iterator_.done()) | 193 if (!visible_iterator_.done()) |
186 current_tile_ = *visible_iterator_; | 194 current_tile_ = *visible_iterator_; |
187 break; | 195 break; |
188 } | 196 } |
189 if (!current_tile_) | 197 if (!current_tile_) |
190 AdvancePhase(); | 198 AdvancePhase(); |
191 } | 199 } |
192 | 200 |
193 // EvictionRectIterator | 201 // EvictionRectIterator |
194 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator() | 202 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator() |
195 : tile_(nullptr), | 203 : tile_(nullptr), |
196 tilings_(nullptr), | 204 tilings_(nullptr), |
197 tree_(ACTIVE_TREE), | 205 tree_(ACTIVE_TREE), |
198 skip_shared_out_of_order_tiles_(false), | 206 skip_shared_out_of_order_tiles_(false), |
199 tiling_index_(0) { | 207 tiling_index_(0) { |
200 } | 208 } |
201 | 209 |
202 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator( | 210 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator( |
203 std::vector<PictureLayerTiling*>* tilings, | 211 std::vector<PictureLayerTiling*>* tilings, |
204 WhichTree tree, | 212 WhichTree tree, |
205 bool skip_shared_out_of_order_tiles) | 213 bool skip_shared_out_of_order_tiles, |
214 bool skip_pending_visible_rect) | |
206 : tile_(nullptr), | 215 : tile_(nullptr), |
207 tilings_(tilings), | 216 tilings_(tilings), |
208 tree_(tree), | 217 tree_(tree), |
209 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), | 218 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), |
219 skip_pending_visible_rect_(skip_pending_visible_rect), | |
210 tiling_index_(0) { | 220 tiling_index_(0) { |
211 } | 221 } |
212 | 222 |
213 template <typename TilingIteratorType> | 223 template <typename TilingIteratorType> |
214 bool TilingSetEvictionQueue::EvictionRectIterator::AdvanceToNextTile( | 224 bool TilingSetEvictionQueue::EvictionRectIterator::AdvanceToNextTile( |
215 TilingIteratorType* iterator) { | 225 TilingIteratorType* iterator) { |
216 bool found_tile = false; | 226 bool found_tile = false; |
217 while (!found_tile) { | 227 while (!found_tile) { |
218 ++(*iterator); | 228 ++(*iterator); |
219 if (!(*iterator)) { | 229 if (!(*iterator)) { |
220 tile_ = nullptr; | 230 tile_ = nullptr; |
221 break; | 231 break; |
222 } | 232 } |
223 found_tile = GetFirstTileAndCheckIfValid(iterator); | 233 found_tile = GetFirstTileAndCheckIfValid(iterator); |
224 } | 234 } |
225 return found_tile; | 235 return found_tile; |
226 } | 236 } |
227 | 237 |
228 template <typename TilingIteratorType> | 238 template <typename TilingIteratorType> |
229 bool TilingSetEvictionQueue::EvictionRectIterator::GetFirstTileAndCheckIfValid( | 239 bool TilingSetEvictionQueue::EvictionRectIterator::GetFirstTileAndCheckIfValid( |
230 TilingIteratorType* iterator) { | 240 TilingIteratorType* iterator) { |
231 tile_ = (*tilings_)[tiling_index_]->TileAt(iterator->index_x(), | 241 PictureLayerTiling* tiling = (*tilings_)[tiling_index_]; |
232 iterator->index_y()); | 242 tile_ = tiling->TileAt(iterator->index_x(), iterator->index_y()); |
233 // If there's nothing to evict, return false. | 243 // If there's nothing to evict, return false. |
234 if (!tile_ || !tile_->HasResource()) | 244 if (!tile_ || !tile_->HasResource()) |
235 return false; | 245 return false; |
246 if (skip_pending_visible_rect_ && | |
247 tiling->pending_visible_rect().Intersects(tile_->content_rect())) { | |
248 return false; | |
249 } | |
236 (*tilings_)[tiling_index_]->UpdateTileAndTwinPriority(tile_); | 250 (*tilings_)[tiling_index_]->UpdateTileAndTwinPriority(tile_); |
237 // If the tile is out of order, return false. | |
238 if (skip_shared_out_of_order_tiles_ && IsSharedOutOfOrderTile(tree_, tile_)) | |
239 return false; | |
240 // In other cases, the tile we got is a viable candidate, return true. | 251 // In other cases, the tile we got is a viable candidate, return true. |
241 return true; | 252 return true; |
242 } | 253 } |
243 | 254 |
244 // EventuallyTilingIterator | 255 // EventuallyTilingIterator |
245 TilingSetEvictionQueue::EventuallyTilingIterator::EventuallyTilingIterator( | 256 TilingSetEvictionQueue::EventuallyTilingIterator::EventuallyTilingIterator( |
246 std::vector<PictureLayerTiling*>* tilings, | 257 std::vector<PictureLayerTiling*>* tilings, |
247 WhichTree tree, | 258 WhichTree tree, |
248 bool skip_shared_out_of_order_tiles) | 259 bool skip_shared_out_of_order_tiles) |
249 : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles) { | 260 : EvictionRectIterator(tilings, |
261 tree, | |
262 skip_shared_out_of_order_tiles, | |
263 true /* skip_pending_visible_rect */) { | |
250 // Find the first tiling with a tile. | 264 // Find the first tiling with a tile. |
251 while (tiling_index_ < tilings_->size()) { | 265 while (tiling_index_ < tilings_->size()) { |
252 if (!((*tilings_))[tiling_index_]->has_eventually_rect_tiles()) { | 266 if (!(*tilings_)[tiling_index_]->has_eventually_rect_tiles()) { |
253 ++tiling_index_; | 267 ++tiling_index_; |
254 continue; | 268 continue; |
255 } | 269 } |
256 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 270 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
257 ((*tilings_))[tiling_index_]->tiling_data(), | 271 (*tilings_)[tiling_index_]->tiling_data(), |
258 ((*tilings_))[tiling_index_]->current_eventually_rect(), | 272 (*tilings_)[tiling_index_]->current_eventually_rect(), |
259 ((*tilings_))[tiling_index_]->current_skewport_rect(), | 273 (*tilings_)[tiling_index_]->current_skewport_rect(), |
260 ((*tilings_))[tiling_index_]->current_soon_border_rect()); | 274 (*tilings_)[tiling_index_]->current_soon_border_rect()); |
261 if (!iterator_) { | 275 if (!iterator_) { |
262 ++tiling_index_; | 276 ++tiling_index_; |
263 continue; | 277 continue; |
264 } | 278 } |
265 break; | 279 break; |
266 } | 280 } |
267 if (tiling_index_ >= tilings_->size()) | 281 if (tiling_index_ >= tilings_->size()) |
268 return; | 282 return; |
269 if (!GetFirstTileAndCheckIfValid(&iterator_)) | 283 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
270 ++(*this); | 284 ++(*this); |
271 } | 285 } |
272 | 286 |
273 TilingSetEvictionQueue::EventuallyTilingIterator& | 287 TilingSetEvictionQueue::EventuallyTilingIterator& |
274 TilingSetEvictionQueue::EventuallyTilingIterator:: | 288 TilingSetEvictionQueue::EventuallyTilingIterator:: |
275 operator++() { | 289 operator++() { |
276 bool found_tile = AdvanceToNextTile(&iterator_); | 290 bool found_tile = AdvanceToNextTile(&iterator_); |
277 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { | 291 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
278 ++tiling_index_; | 292 ++tiling_index_; |
279 if (!((*tilings_))[tiling_index_]->has_eventually_rect_tiles()) | 293 if (!(*tilings_)[tiling_index_]->has_eventually_rect_tiles()) |
280 continue; | 294 continue; |
281 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 295 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
282 ((*tilings_))[tiling_index_]->tiling_data(), | 296 (*tilings_)[tiling_index_]->tiling_data(), |
283 ((*tilings_))[tiling_index_]->current_eventually_rect(), | 297 (*tilings_)[tiling_index_]->current_eventually_rect(), |
284 ((*tilings_))[tiling_index_]->current_skewport_rect(), | 298 (*tilings_)[tiling_index_]->current_skewport_rect(), |
285 ((*tilings_))[tiling_index_]->current_soon_border_rect()); | 299 (*tilings_)[tiling_index_]->current_soon_border_rect()); |
286 if (!iterator_) | 300 if (!iterator_) |
287 continue; | 301 continue; |
288 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | 302 found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
289 if (!found_tile) | 303 if (!found_tile) |
290 found_tile = AdvanceToNextTile(&iterator_); | 304 found_tile = AdvanceToNextTile(&iterator_); |
291 } | 305 } |
292 return *this; | 306 return *this; |
293 } | 307 } |
294 | 308 |
295 // SoonBorderTilingIterator | 309 // SoonBorderTilingIterator |
296 TilingSetEvictionQueue::SoonBorderTilingIterator::SoonBorderTilingIterator( | 310 TilingSetEvictionQueue::SoonBorderTilingIterator::SoonBorderTilingIterator( |
297 std::vector<PictureLayerTiling*>* tilings, | 311 std::vector<PictureLayerTiling*>* tilings, |
298 WhichTree tree, | 312 WhichTree tree, |
299 bool skip_shared_out_of_order_tiles) | 313 bool skip_shared_out_of_order_tiles) |
300 : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles) { | 314 : EvictionRectIterator(tilings, |
315 tree, | |
316 skip_shared_out_of_order_tiles, | |
317 true /* skip_pending_visible_rect */) { | |
301 // Find the first tiling with a tile. | 318 // Find the first tiling with a tile. |
302 while (tiling_index_ < tilings_->size()) { | 319 while (tiling_index_ < tilings_->size()) { |
303 if (!((*tilings_))[tiling_index_]->has_soon_border_rect_tiles()) { | 320 if (!(*tilings_)[tiling_index_]->has_soon_border_rect_tiles()) { |
304 ++tiling_index_; | 321 ++tiling_index_; |
305 continue; | 322 continue; |
306 } | 323 } |
307 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 324 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
308 ((*tilings_))[tiling_index_]->tiling_data(), | 325 (*tilings_)[tiling_index_]->tiling_data(), |
309 ((*tilings_))[tiling_index_]->current_soon_border_rect(), | 326 (*tilings_)[tiling_index_]->current_soon_border_rect(), |
310 ((*tilings_))[tiling_index_]->current_skewport_rect(), | 327 (*tilings_)[tiling_index_]->current_skewport_rect(), |
311 ((*tilings_))[tiling_index_]->current_visible_rect()); | 328 (*tilings_)[tiling_index_]->current_visible_rect()); |
312 if (!iterator_) { | 329 if (!iterator_) { |
313 ++tiling_index_; | 330 ++tiling_index_; |
314 continue; | 331 continue; |
315 } | 332 } |
316 break; | 333 break; |
317 } | 334 } |
318 if (tiling_index_ >= tilings_->size()) | 335 if (tiling_index_ >= tilings_->size()) |
319 return; | 336 return; |
320 if (!GetFirstTileAndCheckIfValid(&iterator_)) | 337 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
321 ++(*this); | 338 ++(*this); |
322 } | 339 } |
323 | 340 |
324 TilingSetEvictionQueue::SoonBorderTilingIterator& | 341 TilingSetEvictionQueue::SoonBorderTilingIterator& |
325 TilingSetEvictionQueue::SoonBorderTilingIterator:: | 342 TilingSetEvictionQueue::SoonBorderTilingIterator:: |
326 operator++() { | 343 operator++() { |
327 bool found_tile = AdvanceToNextTile(&iterator_); | 344 bool found_tile = AdvanceToNextTile(&iterator_); |
328 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { | 345 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
329 ++tiling_index_; | 346 ++tiling_index_; |
330 if (!((*tilings_))[tiling_index_]->has_soon_border_rect_tiles()) | 347 if (!(*tilings_)[tiling_index_]->has_soon_border_rect_tiles()) |
331 continue; | 348 continue; |
332 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 349 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
333 ((*tilings_))[tiling_index_]->tiling_data(), | 350 (*tilings_)[tiling_index_]->tiling_data(), |
334 ((*tilings_))[tiling_index_]->current_soon_border_rect(), | 351 (*tilings_)[tiling_index_]->current_soon_border_rect(), |
335 ((*tilings_))[tiling_index_]->current_skewport_rect(), | 352 (*tilings_)[tiling_index_]->current_skewport_rect(), |
336 ((*tilings_))[tiling_index_]->current_visible_rect()); | 353 (*tilings_)[tiling_index_]->current_visible_rect()); |
337 if (!iterator_) | 354 if (!iterator_) |
338 continue; | 355 continue; |
339 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | 356 found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
340 if (!found_tile) | 357 if (!found_tile) |
341 found_tile = AdvanceToNextTile(&iterator_); | 358 found_tile = AdvanceToNextTile(&iterator_); |
342 } | 359 } |
343 return *this; | 360 return *this; |
344 } | 361 } |
345 | 362 |
346 // SkewportTilingIterator | 363 // SkewportTilingIterator |
347 TilingSetEvictionQueue::SkewportTilingIterator::SkewportTilingIterator( | 364 TilingSetEvictionQueue::SkewportTilingIterator::SkewportTilingIterator( |
348 std::vector<PictureLayerTiling*>* tilings, | 365 std::vector<PictureLayerTiling*>* tilings, |
349 WhichTree tree, | 366 WhichTree tree, |
350 bool skip_shared_out_of_order_tiles) | 367 bool skip_shared_out_of_order_tiles) |
351 : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles) { | 368 : EvictionRectIterator(tilings, |
369 tree, | |
370 skip_shared_out_of_order_tiles, | |
371 true /* skip_pending_visible_rect */) { | |
352 // Find the first tiling with a tile. | 372 // Find the first tiling with a tile. |
353 while (tiling_index_ < tilings_->size()) { | 373 while (tiling_index_ < tilings_->size()) { |
354 if (!((*tilings_))[tiling_index_]->has_skewport_rect_tiles()) { | 374 if (!(*tilings_)[tiling_index_]->has_skewport_rect_tiles()) { |
355 ++tiling_index_; | 375 ++tiling_index_; |
356 continue; | 376 continue; |
357 } | 377 } |
358 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 378 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
359 ((*tilings_))[tiling_index_]->tiling_data(), | 379 (*tilings_)[tiling_index_]->tiling_data(), |
360 ((*tilings_))[tiling_index_]->current_skewport_rect(), | 380 (*tilings_)[tiling_index_]->current_skewport_rect(), |
361 ((*tilings_))[tiling_index_]->current_visible_rect(), | 381 (*tilings_)[tiling_index_]->current_visible_rect(), |
362 ((*tilings_))[tiling_index_]->current_visible_rect()); | 382 (*tilings_)[tiling_index_]->current_visible_rect()); |
363 if (!iterator_) { | 383 if (!iterator_) { |
364 ++tiling_index_; | 384 ++tiling_index_; |
365 continue; | 385 continue; |
366 } | 386 } |
367 break; | 387 break; |
368 } | 388 } |
369 if (tiling_index_ >= tilings_->size()) | 389 if (tiling_index_ >= tilings_->size()) |
370 return; | 390 return; |
371 if (!GetFirstTileAndCheckIfValid(&iterator_)) | 391 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
372 ++(*this); | 392 ++(*this); |
373 } | 393 } |
374 | 394 |
375 TilingSetEvictionQueue::SkewportTilingIterator& | 395 TilingSetEvictionQueue::SkewportTilingIterator& |
376 TilingSetEvictionQueue::SkewportTilingIterator:: | 396 TilingSetEvictionQueue::SkewportTilingIterator:: |
377 operator++() { | 397 operator++() { |
378 bool found_tile = AdvanceToNextTile(&iterator_); | 398 bool found_tile = AdvanceToNextTile(&iterator_); |
379 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { | 399 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
380 ++tiling_index_; | 400 ++tiling_index_; |
381 if (!((*tilings_))[tiling_index_]->has_skewport_rect_tiles()) | 401 if (!(*tilings_)[tiling_index_]->has_skewport_rect_tiles()) |
382 continue; | 402 continue; |
383 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 403 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
384 ((*tilings_))[tiling_index_]->tiling_data(), | 404 (*tilings_)[tiling_index_]->tiling_data(), |
385 ((*tilings_))[tiling_index_]->current_skewport_rect(), | 405 (*tilings_)[tiling_index_]->current_skewport_rect(), |
386 ((*tilings_))[tiling_index_]->current_visible_rect(), | 406 (*tilings_)[tiling_index_]->current_visible_rect(), |
387 ((*tilings_))[tiling_index_]->current_visible_rect()); | 407 (*tilings_)[tiling_index_]->current_visible_rect()); |
388 if (!iterator_) | 408 if (!iterator_) |
389 continue; | 409 continue; |
390 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | 410 found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
391 if (!found_tile) | 411 if (!found_tile) |
392 found_tile = AdvanceToNextTile(&iterator_); | 412 found_tile = AdvanceToNextTile(&iterator_); |
393 } | 413 } |
394 return *this; | 414 return *this; |
395 } | 415 } |
396 | 416 |
417 // PendingVisibleIterator | |
418 TilingSetEvictionQueue::PendingVisibleTilingIterator:: | |
419 PendingVisibleTilingIterator(std::vector<PictureLayerTiling*>* tilings, | |
420 WhichTree tree, | |
421 bool skip_shared_out_of_order_tiles, | |
422 bool return_required_for_activation_tiles) | |
423 : EvictionRectIterator(tilings, | |
424 tree, | |
425 skip_shared_out_of_order_tiles, | |
426 false /* skip_pending_visible_rect */), | |
427 return_required_for_activation_tiles_( | |
428 return_required_for_activation_tiles) { | |
429 // Find the first tiling with a tile. | |
430 while (tiling_index_ < tilings_->size()) { | |
431 iterator_ = TilingData::DifferenceIterator( | |
432 (*tilings_)[tiling_index_]->tiling_data(), | |
433 (*tilings_)[tiling_index_]->pending_visible_rect(), | |
434 (*tilings_)[tiling_index_]->current_visible_rect()); | |
435 if (!iterator_) { | |
436 ++tiling_index_; | |
437 continue; | |
438 } | |
439 break; | |
440 } | |
441 if (tiling_index_ >= tilings_->size()) | |
442 return; | |
443 if (!GetFirstTileAndCheckIfValid(&iterator_)) { | |
444 ++(*this); | |
445 return; | |
446 } | |
447 if (!TileMatchesRequiredFlags(tile_)) { | |
448 ++(*this); | |
449 return; | |
450 } | |
451 } | |
452 | |
453 TilingSetEvictionQueue::PendingVisibleTilingIterator& | |
454 TilingSetEvictionQueue::PendingVisibleTilingIterator:: | |
455 operator++() { | |
456 bool found_tile = AdvanceToNextTile(&iterator_); | |
457 while (found_tile && !TileMatchesRequiredFlags(tile_)) | |
458 found_tile = AdvanceToNextTile(&iterator_); | |
459 | |
460 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { | |
461 ++tiling_index_; | |
462 iterator_ = TilingData::DifferenceIterator( | |
463 (*tilings_)[tiling_index_]->tiling_data(), | |
464 (*tilings_)[tiling_index_]->pending_visible_rect(), | |
465 (*tilings_)[tiling_index_]->current_visible_rect()); | |
466 if (!iterator_) | |
467 continue; | |
468 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | |
469 if (!found_tile) | |
470 found_tile = AdvanceToNextTile(&iterator_); | |
471 while (found_tile && !TileMatchesRequiredFlags(tile_)) | |
472 found_tile = AdvanceToNextTile(&iterator_); | |
473 } | |
474 return *this; | |
475 } | |
476 | |
477 bool TilingSetEvictionQueue::PendingVisibleTilingIterator:: | |
478 TileMatchesRequiredFlags(const Tile* tile) const { | |
479 bool activation_flag_matches = | |
480 tile->required_for_activation() == return_required_for_activation_tiles_; | |
481 return activation_flag_matches; | |
482 } | |
483 | |
397 // VisibleTilingIterator | 484 // VisibleTilingIterator |
398 TilingSetEvictionQueue::VisibleTilingIterator::VisibleTilingIterator( | 485 TilingSetEvictionQueue::VisibleTilingIterator::VisibleTilingIterator( |
399 std::vector<PictureLayerTiling*>* tilings, | 486 std::vector<PictureLayerTiling*>* tilings, |
400 WhichTree tree, | 487 WhichTree tree, |
401 bool skip_shared_out_of_order_tiles, | 488 bool skip_shared_out_of_order_tiles, |
402 bool return_occluded_tiles, | 489 bool return_occluded_tiles, |
403 bool return_required_for_activation_tiles) | 490 bool return_required_for_activation_tiles) |
404 : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles), | 491 : EvictionRectIterator(tilings, |
492 tree, | |
493 skip_shared_out_of_order_tiles, | |
494 false /* skip_pending_visible_rect */), | |
405 return_occluded_tiles_(return_occluded_tiles), | 495 return_occluded_tiles_(return_occluded_tiles), |
406 return_required_for_activation_tiles_( | 496 return_required_for_activation_tiles_( |
407 return_required_for_activation_tiles) { | 497 return_required_for_activation_tiles) { |
408 // Find the first tiling with a tile. | 498 // Find the first tiling with a tile. |
409 while (tiling_index_ < tilings_->size()) { | 499 while (tiling_index_ < tilings_->size()) { |
410 if (!((*tilings_))[tiling_index_]->has_visible_rect_tiles()) { | 500 if (!(*tilings_)[tiling_index_]->has_visible_rect_tiles()) { |
411 ++tiling_index_; | 501 ++tiling_index_; |
412 continue; | 502 continue; |
413 } | 503 } |
414 iterator_ = TilingData::Iterator( | 504 iterator_ = TilingData::Iterator( |
415 ((*tilings_))[tiling_index_]->tiling_data(), | 505 (*tilings_)[tiling_index_]->tiling_data(), |
416 ((*tilings_))[tiling_index_]->current_visible_rect(), false); | 506 (*tilings_)[tiling_index_]->current_visible_rect(), false); |
417 if (!iterator_) { | 507 if (!iterator_) { |
418 ++tiling_index_; | 508 ++tiling_index_; |
419 continue; | 509 continue; |
420 } | 510 } |
421 break; | 511 break; |
422 } | 512 } |
423 if (tiling_index_ >= tilings_->size()) | 513 if (tiling_index_ >= tilings_->size()) |
424 return; | 514 return; |
425 if (!GetFirstTileAndCheckIfValid(&iterator_)) { | 515 if (!GetFirstTileAndCheckIfValid(&iterator_)) { |
426 ++(*this); | 516 ++(*this); |
427 return; | 517 return; |
428 } | 518 } |
429 if (!TileMatchesRequiredFlags(tile_)) { | 519 if (!TileMatchesRequiredFlags(tile_)) { |
430 ++(*this); | 520 ++(*this); |
431 return; | 521 return; |
432 } | 522 } |
433 } | 523 } |
434 | 524 |
435 TilingSetEvictionQueue::VisibleTilingIterator& | 525 TilingSetEvictionQueue::VisibleTilingIterator& |
436 TilingSetEvictionQueue::VisibleTilingIterator:: | 526 TilingSetEvictionQueue::VisibleTilingIterator:: |
437 operator++() { | 527 operator++() { |
438 bool found_tile = AdvanceToNextTile(&iterator_); | 528 bool found_tile = AdvanceToNextTile(&iterator_); |
439 while (found_tile && !TileMatchesRequiredFlags(tile_)) | 529 while (found_tile && !TileMatchesRequiredFlags(tile_)) |
440 found_tile = AdvanceToNextTile(&iterator_); | 530 found_tile = AdvanceToNextTile(&iterator_); |
441 | 531 |
442 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { | 532 while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
443 ++tiling_index_; | 533 ++tiling_index_; |
444 if (!((*tilings_))[tiling_index_]->has_visible_rect_tiles()) | 534 if (!(*tilings_)[tiling_index_]->has_visible_rect_tiles()) |
445 continue; | 535 continue; |
446 iterator_ = TilingData::Iterator( | 536 iterator_ = TilingData::Iterator( |
447 ((*tilings_))[tiling_index_]->tiling_data(), | 537 (*tilings_)[tiling_index_]->tiling_data(), |
448 ((*tilings_))[tiling_index_]->current_visible_rect(), false); | 538 (*tilings_)[tiling_index_]->current_visible_rect(), false); |
449 if (!iterator_) | 539 if (!iterator_) |
450 continue; | 540 continue; |
451 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | 541 found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
452 if (!found_tile) | 542 if (!found_tile) |
453 found_tile = AdvanceToNextTile(&iterator_); | 543 found_tile = AdvanceToNextTile(&iterator_); |
454 while (found_tile && !TileMatchesRequiredFlags(tile_)) | 544 while (found_tile && !TileMatchesRequiredFlags(tile_)) |
455 found_tile = AdvanceToNextTile(&iterator_); | 545 found_tile = AdvanceToNextTile(&iterator_); |
456 } | 546 } |
457 return *this; | 547 return *this; |
458 } | 548 } |
459 | 549 |
460 bool TilingSetEvictionQueue::VisibleTilingIterator::TileMatchesRequiredFlags( | 550 bool TilingSetEvictionQueue::VisibleTilingIterator::TileMatchesRequiredFlags( |
461 const Tile* tile) const { | 551 const Tile* tile) const { |
462 bool activation_flag_matches = | 552 bool activation_flag_matches = |
463 tile->required_for_activation() == return_required_for_activation_tiles_; | 553 tile->required_for_activation() == return_required_for_activation_tiles_; |
464 bool occluded_flag_matches = | 554 bool occluded_flag_matches = tile->is_occluded() == return_occluded_tiles_; |
465 tile->is_occluded(tree_) == return_occluded_tiles_; | |
466 return activation_flag_matches && occluded_flag_matches; | 555 return activation_flag_matches && occluded_flag_matches; |
467 } | 556 } |
468 | 557 |
469 } // namespace cc | 558 } // namespace cc |
OLD | NEW |