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