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 | 10 |
11 TilingSetEvictionQueue::TilingSetEvictionQueue( | 11 TilingSetEvictionQueue::TilingSetEvictionQueue( |
12 PictureLayerTilingSet* tiling_set, | 12 PictureLayerTilingSet* tiling_set) |
13 bool skip_shared_out_of_order_tiles) | |
14 : tree_(tiling_set->tree()), | 13 : tree_(tiling_set->tree()), |
15 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), | |
16 phase_(EVENTUALLY_RECT), | 14 phase_(EVENTUALLY_RECT), |
17 current_tile_(nullptr) { | 15 current_tile_(nullptr) { |
18 // Early out if the layer has no tilings. | 16 // Early out if the layer has no tilings. |
19 if (!tiling_set->num_tilings()) | 17 if (!tiling_set->num_tilings()) |
20 return; | 18 return; |
21 GenerateTilingOrder(tiling_set); | 19 GenerateTilingOrder(tiling_set); |
22 eventually_iterator_ = EventuallyTilingIterator( | 20 eventually_iterator_ = EventuallyTilingIterator(&tilings_, tree_); |
23 &tilings_, tree_, skip_shared_out_of_order_tiles_); | |
24 if (eventually_iterator_.done()) { | 21 if (eventually_iterator_.done()) { |
25 AdvancePhase(); | 22 AdvancePhase(); |
26 return; | 23 return; |
27 } | 24 } |
28 current_tile_ = *eventually_iterator_; | 25 current_tile_ = *eventually_iterator_; |
29 } | 26 } |
30 | 27 |
31 TilingSetEvictionQueue::~TilingSetEvictionQueue() { | 28 TilingSetEvictionQueue::~TilingSetEvictionQueue() { |
32 } | 29 } |
33 | 30 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void TilingSetEvictionQueue::AdvancePhase() { | 75 void TilingSetEvictionQueue::AdvancePhase() { |
79 current_tile_ = nullptr; | 76 current_tile_ = nullptr; |
80 while (!current_tile_ && | 77 while (!current_tile_ && |
81 phase_ != VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED) { | 78 phase_ != VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED) { |
82 phase_ = static_cast<Phase>(phase_ + 1); | 79 phase_ = static_cast<Phase>(phase_ + 1); |
83 switch (phase_) { | 80 switch (phase_) { |
84 case EVENTUALLY_RECT: | 81 case EVENTUALLY_RECT: |
85 NOTREACHED(); | 82 NOTREACHED(); |
86 break; | 83 break; |
87 case SOON_BORDER_RECT: | 84 case SOON_BORDER_RECT: |
88 soon_iterator_ = SoonBorderTilingIterator( | 85 soon_iterator_ = SoonBorderTilingIterator(&tilings_, tree_); |
89 &tilings_, tree_, skip_shared_out_of_order_tiles_); | |
90 if (!soon_iterator_.done()) | 86 if (!soon_iterator_.done()) |
91 current_tile_ = *soon_iterator_; | 87 current_tile_ = *soon_iterator_; |
92 break; | 88 break; |
93 case SKEWPORT_RECT: | 89 case SKEWPORT_RECT: |
94 skewport_iterator_ = SkewportTilingIterator( | 90 skewport_iterator_ = SkewportTilingIterator(&tilings_, tree_); |
95 &tilings_, tree_, skip_shared_out_of_order_tiles_); | |
96 if (!skewport_iterator_.done()) | 91 if (!skewport_iterator_.done()) |
97 current_tile_ = *skewport_iterator_; | 92 current_tile_ = *skewport_iterator_; |
98 break; | 93 break; |
99 case PENDING_VISIBLE_RECT: | 94 case PENDING_VISIBLE_RECT: |
100 pending_visible_iterator_ = PendingVisibleTilingIterator( | 95 pending_visible_iterator_ = PendingVisibleTilingIterator( |
101 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 96 &tilings_, tree_, false /* return required for activation tiles */); |
102 false /* return required for activation tiles */); | |
103 if (!pending_visible_iterator_.done()) | 97 if (!pending_visible_iterator_.done()) |
104 current_tile_ = *pending_visible_iterator_; | 98 current_tile_ = *pending_visible_iterator_; |
105 break; | 99 break; |
106 case PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION: | 100 case PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION: |
107 pending_visible_iterator_ = PendingVisibleTilingIterator( | 101 pending_visible_iterator_ = PendingVisibleTilingIterator( |
108 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 102 &tilings_, tree_, true /* return required for activation tiles */); |
109 true /* return required for activation tiles */); | |
110 if (!pending_visible_iterator_.done()) | 103 if (!pending_visible_iterator_.done()) |
111 current_tile_ = *pending_visible_iterator_; | 104 current_tile_ = *pending_visible_iterator_; |
112 break; | 105 break; |
113 case VISIBLE_RECT_OCCLUDED: | 106 case VISIBLE_RECT_OCCLUDED: |
114 visible_iterator_ = VisibleTilingIterator( | 107 visible_iterator_ = VisibleTilingIterator( |
115 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 108 &tilings_, tree_, true /* return occluded tiles */, |
116 true /* return occluded tiles */, | |
117 false /* return required for activation tiles */); | 109 false /* return required for activation tiles */); |
118 if (!visible_iterator_.done()) | 110 if (!visible_iterator_.done()) |
119 current_tile_ = *visible_iterator_; | 111 current_tile_ = *visible_iterator_; |
120 break; | 112 break; |
121 case VISIBLE_RECT_UNOCCLUDED: | 113 case VISIBLE_RECT_UNOCCLUDED: |
122 visible_iterator_ = VisibleTilingIterator( | 114 visible_iterator_ = VisibleTilingIterator( |
123 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 115 &tilings_, tree_, false /* return occluded tiles */, |
124 false /* return occluded tiles */, | |
125 false /* return required for activation tiles */); | 116 false /* return required for activation tiles */); |
126 if (!visible_iterator_.done()) | 117 if (!visible_iterator_.done()) |
127 current_tile_ = *visible_iterator_; | 118 current_tile_ = *visible_iterator_; |
128 break; | 119 break; |
129 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED: | 120 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED: |
130 visible_iterator_ = VisibleTilingIterator( | 121 visible_iterator_ = VisibleTilingIterator( |
131 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 122 &tilings_, tree_, true /* return occluded tiles */, |
132 true /* return occluded tiles */, | |
133 true /* return required for activation tiles */); | 123 true /* return required for activation tiles */); |
134 if (!visible_iterator_.done()) | 124 if (!visible_iterator_.done()) |
135 current_tile_ = *visible_iterator_; | 125 current_tile_ = *visible_iterator_; |
136 break; | 126 break; |
137 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED: | 127 case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED: |
138 visible_iterator_ = VisibleTilingIterator( | 128 visible_iterator_ = VisibleTilingIterator( |
139 &tilings_, tree_, skip_shared_out_of_order_tiles_, | 129 &tilings_, tree_, false /* return occluded tiles */, |
140 false /* return occluded tiles */, | |
141 true /* return required for activation tiles */); | 130 true /* return required for activation tiles */); |
142 if (!visible_iterator_.done()) | 131 if (!visible_iterator_.done()) |
143 current_tile_ = *visible_iterator_; | 132 current_tile_ = *visible_iterator_; |
144 break; | 133 break; |
145 } | 134 } |
146 } | 135 } |
147 } | 136 } |
148 | 137 |
149 bool TilingSetEvictionQueue::IsEmpty() const { | 138 bool TilingSetEvictionQueue::IsEmpty() const { |
150 return !current_tile_; | 139 return !current_tile_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 185 } |
197 if (!current_tile_) | 186 if (!current_tile_) |
198 AdvancePhase(); | 187 AdvancePhase(); |
199 } | 188 } |
200 | 189 |
201 // EvictionRectIterator | 190 // EvictionRectIterator |
202 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator() | 191 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator() |
203 : tile_(nullptr), | 192 : tile_(nullptr), |
204 tilings_(nullptr), | 193 tilings_(nullptr), |
205 tree_(ACTIVE_TREE), | 194 tree_(ACTIVE_TREE), |
206 skip_shared_out_of_order_tiles_(false), | |
207 tiling_index_(0) { | 195 tiling_index_(0) { |
208 } | 196 } |
209 | 197 |
210 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator( | 198 TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator( |
211 std::vector<PictureLayerTiling*>* tilings, | 199 std::vector<PictureLayerTiling*>* tilings, |
212 WhichTree tree, | 200 WhichTree tree, |
213 bool skip_shared_out_of_order_tiles, | |
214 bool skip_pending_visible_rect) | 201 bool skip_pending_visible_rect) |
215 : tile_(nullptr), | 202 : tile_(nullptr), |
216 tilings_(tilings), | 203 tilings_(tilings), |
217 tree_(tree), | 204 tree_(tree), |
218 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), | |
219 skip_pending_visible_rect_(skip_pending_visible_rect), | 205 skip_pending_visible_rect_(skip_pending_visible_rect), |
220 tiling_index_(0) { | 206 tiling_index_(0) { |
221 } | 207 } |
222 | 208 |
223 template <typename TilingIteratorType> | 209 template <typename TilingIteratorType> |
224 bool TilingSetEvictionQueue::EvictionRectIterator::AdvanceToNextTile( | 210 bool TilingSetEvictionQueue::EvictionRectIterator::AdvanceToNextTile( |
225 TilingIteratorType* iterator) { | 211 TilingIteratorType* iterator) { |
226 bool found_tile = false; | 212 bool found_tile = false; |
227 while (!found_tile) { | 213 while (!found_tile) { |
228 ++(*iterator); | 214 ++(*iterator); |
(...skipping 19 matching lines...) Expand all Loading... |
248 return false; | 234 return false; |
249 } | 235 } |
250 (*tilings_)[tiling_index_]->UpdateTileAndTwinPriority(tile_); | 236 (*tilings_)[tiling_index_]->UpdateTileAndTwinPriority(tile_); |
251 // In other cases, the tile we got is a viable candidate, return true. | 237 // In other cases, the tile we got is a viable candidate, return true. |
252 return true; | 238 return true; |
253 } | 239 } |
254 | 240 |
255 // EventuallyTilingIterator | 241 // EventuallyTilingIterator |
256 TilingSetEvictionQueue::EventuallyTilingIterator::EventuallyTilingIterator( | 242 TilingSetEvictionQueue::EventuallyTilingIterator::EventuallyTilingIterator( |
257 std::vector<PictureLayerTiling*>* tilings, | 243 std::vector<PictureLayerTiling*>* tilings, |
258 WhichTree tree, | 244 WhichTree tree) |
259 bool skip_shared_out_of_order_tiles) | |
260 : EvictionRectIterator(tilings, | 245 : EvictionRectIterator(tilings, |
261 tree, | 246 tree, |
262 skip_shared_out_of_order_tiles, | |
263 true /* skip_pending_visible_rect */) { | 247 true /* skip_pending_visible_rect */) { |
264 // Find the first tiling with a tile. | 248 // Find the first tiling with a tile. |
265 while (tiling_index_ < tilings_->size()) { | 249 while (tiling_index_ < tilings_->size()) { |
266 if (!(*tilings_)[tiling_index_]->has_eventually_rect_tiles()) { | 250 if (!(*tilings_)[tiling_index_]->has_eventually_rect_tiles()) { |
267 ++tiling_index_; | 251 ++tiling_index_; |
268 continue; | 252 continue; |
269 } | 253 } |
270 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 254 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
271 (*tilings_)[tiling_index_]->tiling_data(), | 255 (*tilings_)[tiling_index_]->tiling_data(), |
272 (*tilings_)[tiling_index_]->current_eventually_rect(), | 256 (*tilings_)[tiling_index_]->current_eventually_rect(), |
(...skipping 29 matching lines...) Expand all Loading... |
302 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | 286 found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
303 if (!found_tile) | 287 if (!found_tile) |
304 found_tile = AdvanceToNextTile(&iterator_); | 288 found_tile = AdvanceToNextTile(&iterator_); |
305 } | 289 } |
306 return *this; | 290 return *this; |
307 } | 291 } |
308 | 292 |
309 // SoonBorderTilingIterator | 293 // SoonBorderTilingIterator |
310 TilingSetEvictionQueue::SoonBorderTilingIterator::SoonBorderTilingIterator( | 294 TilingSetEvictionQueue::SoonBorderTilingIterator::SoonBorderTilingIterator( |
311 std::vector<PictureLayerTiling*>* tilings, | 295 std::vector<PictureLayerTiling*>* tilings, |
312 WhichTree tree, | 296 WhichTree tree) |
313 bool skip_shared_out_of_order_tiles) | |
314 : EvictionRectIterator(tilings, | 297 : EvictionRectIterator(tilings, |
315 tree, | 298 tree, |
316 skip_shared_out_of_order_tiles, | |
317 true /* skip_pending_visible_rect */) { | 299 true /* skip_pending_visible_rect */) { |
318 // Find the first tiling with a tile. | 300 // Find the first tiling with a tile. |
319 while (tiling_index_ < tilings_->size()) { | 301 while (tiling_index_ < tilings_->size()) { |
320 if (!(*tilings_)[tiling_index_]->has_soon_border_rect_tiles()) { | 302 if (!(*tilings_)[tiling_index_]->has_soon_border_rect_tiles()) { |
321 ++tiling_index_; | 303 ++tiling_index_; |
322 continue; | 304 continue; |
323 } | 305 } |
324 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 306 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
325 (*tilings_)[tiling_index_]->tiling_data(), | 307 (*tilings_)[tiling_index_]->tiling_data(), |
326 (*tilings_)[tiling_index_]->current_soon_border_rect(), | 308 (*tilings_)[tiling_index_]->current_soon_border_rect(), |
(...skipping 29 matching lines...) Expand all Loading... |
356 found_tile = GetFirstTileAndCheckIfValid(&iterator_); | 338 found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
357 if (!found_tile) | 339 if (!found_tile) |
358 found_tile = AdvanceToNextTile(&iterator_); | 340 found_tile = AdvanceToNextTile(&iterator_); |
359 } | 341 } |
360 return *this; | 342 return *this; |
361 } | 343 } |
362 | 344 |
363 // SkewportTilingIterator | 345 // SkewportTilingIterator |
364 TilingSetEvictionQueue::SkewportTilingIterator::SkewportTilingIterator( | 346 TilingSetEvictionQueue::SkewportTilingIterator::SkewportTilingIterator( |
365 std::vector<PictureLayerTiling*>* tilings, | 347 std::vector<PictureLayerTiling*>* tilings, |
366 WhichTree tree, | 348 WhichTree tree) |
367 bool skip_shared_out_of_order_tiles) | |
368 : EvictionRectIterator(tilings, | 349 : EvictionRectIterator(tilings, |
369 tree, | 350 tree, |
370 skip_shared_out_of_order_tiles, | |
371 true /* skip_pending_visible_rect */) { | 351 true /* skip_pending_visible_rect */) { |
372 // Find the first tiling with a tile. | 352 // Find the first tiling with a tile. |
373 while (tiling_index_ < tilings_->size()) { | 353 while (tiling_index_ < tilings_->size()) { |
374 if (!(*tilings_)[tiling_index_]->has_skewport_rect_tiles()) { | 354 if (!(*tilings_)[tiling_index_]->has_skewport_rect_tiles()) { |
375 ++tiling_index_; | 355 ++tiling_index_; |
376 continue; | 356 continue; |
377 } | 357 } |
378 iterator_ = TilingData::ReverseSpiralDifferenceIterator( | 358 iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
379 (*tilings_)[tiling_index_]->tiling_data(), | 359 (*tilings_)[tiling_index_]->tiling_data(), |
380 (*tilings_)[tiling_index_]->current_skewport_rect(), | 360 (*tilings_)[tiling_index_]->current_skewport_rect(), |
(...skipping 30 matching lines...) Expand all Loading... |
411 if (!found_tile) | 391 if (!found_tile) |
412 found_tile = AdvanceToNextTile(&iterator_); | 392 found_tile = AdvanceToNextTile(&iterator_); |
413 } | 393 } |
414 return *this; | 394 return *this; |
415 } | 395 } |
416 | 396 |
417 // PendingVisibleIterator | 397 // PendingVisibleIterator |
418 TilingSetEvictionQueue::PendingVisibleTilingIterator:: | 398 TilingSetEvictionQueue::PendingVisibleTilingIterator:: |
419 PendingVisibleTilingIterator(std::vector<PictureLayerTiling*>* tilings, | 399 PendingVisibleTilingIterator(std::vector<PictureLayerTiling*>* tilings, |
420 WhichTree tree, | 400 WhichTree tree, |
421 bool skip_shared_out_of_order_tiles, | |
422 bool return_required_for_activation_tiles) | 401 bool return_required_for_activation_tiles) |
423 : EvictionRectIterator(tilings, | 402 : EvictionRectIterator(tilings, |
424 tree, | 403 tree, |
425 skip_shared_out_of_order_tiles, | |
426 false /* skip_pending_visible_rect */), | 404 false /* skip_pending_visible_rect */), |
427 return_required_for_activation_tiles_( | 405 return_required_for_activation_tiles_( |
428 return_required_for_activation_tiles) { | 406 return_required_for_activation_tiles) { |
429 // Find the first tiling with a tile. | 407 // Find the first tiling with a tile. |
430 while (tiling_index_ < tilings_->size()) { | 408 while (tiling_index_ < tilings_->size()) { |
431 iterator_ = TilingData::DifferenceIterator( | 409 iterator_ = TilingData::DifferenceIterator( |
432 (*tilings_)[tiling_index_]->tiling_data(), | 410 (*tilings_)[tiling_index_]->tiling_data(), |
433 (*tilings_)[tiling_index_]->pending_visible_rect(), | 411 (*tilings_)[tiling_index_]->pending_visible_rect(), |
434 (*tilings_)[tiling_index_]->current_visible_rect()); | 412 (*tilings_)[tiling_index_]->current_visible_rect()); |
435 if (!iterator_) { | 413 if (!iterator_) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 TileMatchesRequiredFlags(const Tile* tile) const { | 456 TileMatchesRequiredFlags(const Tile* tile) const { |
479 bool activation_flag_matches = | 457 bool activation_flag_matches = |
480 tile->required_for_activation() == return_required_for_activation_tiles_; | 458 tile->required_for_activation() == return_required_for_activation_tiles_; |
481 return activation_flag_matches; | 459 return activation_flag_matches; |
482 } | 460 } |
483 | 461 |
484 // VisibleTilingIterator | 462 // VisibleTilingIterator |
485 TilingSetEvictionQueue::VisibleTilingIterator::VisibleTilingIterator( | 463 TilingSetEvictionQueue::VisibleTilingIterator::VisibleTilingIterator( |
486 std::vector<PictureLayerTiling*>* tilings, | 464 std::vector<PictureLayerTiling*>* tilings, |
487 WhichTree tree, | 465 WhichTree tree, |
488 bool skip_shared_out_of_order_tiles, | |
489 bool return_occluded_tiles, | 466 bool return_occluded_tiles, |
490 bool return_required_for_activation_tiles) | 467 bool return_required_for_activation_tiles) |
491 : EvictionRectIterator(tilings, | 468 : EvictionRectIterator(tilings, |
492 tree, | 469 tree, |
493 skip_shared_out_of_order_tiles, | |
494 false /* skip_pending_visible_rect */), | 470 false /* skip_pending_visible_rect */), |
495 return_occluded_tiles_(return_occluded_tiles), | 471 return_occluded_tiles_(return_occluded_tiles), |
496 return_required_for_activation_tiles_( | 472 return_required_for_activation_tiles_( |
497 return_required_for_activation_tiles) { | 473 return_required_for_activation_tiles) { |
498 // Find the first tiling with a tile. | 474 // Find the first tiling with a tile. |
499 while (tiling_index_ < tilings_->size()) { | 475 while (tiling_index_ < tilings_->size()) { |
500 if (!(*tilings_)[tiling_index_]->has_visible_rect_tiles()) { | 476 if (!(*tilings_)[tiling_index_]->has_visible_rect_tiles()) { |
501 ++tiling_index_; | 477 ++tiling_index_; |
502 continue; | 478 continue; |
503 } | 479 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 525 |
550 bool TilingSetEvictionQueue::VisibleTilingIterator::TileMatchesRequiredFlags( | 526 bool TilingSetEvictionQueue::VisibleTilingIterator::TileMatchesRequiredFlags( |
551 const Tile* tile) const { | 527 const Tile* tile) const { |
552 bool activation_flag_matches = | 528 bool activation_flag_matches = |
553 tile->required_for_activation() == return_required_for_activation_tiles_; | 529 tile->required_for_activation() == return_required_for_activation_tiles_; |
554 bool occluded_flag_matches = tile->is_occluded() == return_occluded_tiles_; | 530 bool occluded_flag_matches = tile->is_occluded() == return_occluded_tiles_; |
555 return activation_flag_matches && occluded_flag_matches; | 531 return activation_flag_matches && occluded_flag_matches; |
556 } | 532 } |
557 | 533 |
558 } // namespace cc | 534 } // namespace cc |
OLD | NEW |