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