Chromium Code Reviews| Index: cc/resources/tiling_set_eviction_queue.cc |
| diff --git a/cc/resources/tiling_set_eviction_queue.cc b/cc/resources/tiling_set_eviction_queue.cc |
| index 43d085b629f7047e09ce1d8b22748115b0df8ccf..4a6fb8755a720d68014ff10ea50d1e358454f1ad 100644 |
| --- a/cc/resources/tiling_set_eviction_queue.cc |
| +++ b/cc/resources/tiling_set_eviction_queue.cc |
| @@ -10,27 +10,9 @@ namespace cc { |
| namespace { |
| bool IsSharedOutOfOrderTile(WhichTree tree, const Tile* tile) { |
| - if (!tile->is_shared()) |
| - return false; |
| - |
| - // The priority for tile priority of a shared tile will be a combined |
| - // priority thus return shared tiles from a higher priority tree as |
| - // it is out of order for a lower priority tree. |
| - WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
| - const TilePriority& priority = tile->priority(tree); |
| - const TilePriority& twin_priority = tile->priority(twin_tree); |
| - if (priority.priority_bin != twin_priority.priority_bin) |
| - return priority.priority_bin > twin_priority.priority_bin; |
| - const bool occluded = tile->is_occluded(tree); |
| - const bool twin_occluded = tile->is_occluded(twin_tree); |
| - if (occluded != twin_occluded) |
| - return occluded; |
| - if (priority.distance_to_visible != twin_priority.distance_to_visible) |
| - return priority.distance_to_visible > twin_priority.distance_to_visible; |
| - |
| - // If priorities are the same, it does not matter which tree returns |
| - // the tile. Let's pick the pending tree. |
| - return tree != PENDING_TREE; |
| + // TODO(vmpstr): Clean up is_shared usage. |
| + DCHECK(!tile->is_shared()); |
| + return false; |
| } |
| } // namespace |
| @@ -108,6 +90,20 @@ void TilingSetEvictionQueue::AdvancePhase() { |
| if (!skewport_iterator_.done()) |
| current_tile_ = *skewport_iterator_; |
| break; |
| + case PENDING_VISIBLE_RECT: |
| + pending_visible_iterator_ = PendingVisibleTilingIterator( |
| + &tilings_, tree_, skip_shared_out_of_order_tiles_, |
| + false /* return required for activation tiles */); |
| + if (!pending_visible_iterator_.done()) |
| + current_tile_ = *pending_visible_iterator_; |
| + break; |
| + case PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION: |
| + pending_visible_iterator_ = PendingVisibleTilingIterator( |
| + &tilings_, tree_, skip_shared_out_of_order_tiles_, |
| + true /* return required for activation tiles */); |
| + if (!pending_visible_iterator_.done()) |
| + current_tile_ = *pending_visible_iterator_; |
| + break; |
| case VISIBLE_RECT_OCCLUDED: |
| visible_iterator_ = VisibleTilingIterator( |
| &tilings_, tree_, skip_shared_out_of_order_tiles_, |
| @@ -177,6 +173,12 @@ void TilingSetEvictionQueue::Pop() { |
| if (!skewport_iterator_.done()) |
| current_tile_ = *skewport_iterator_; |
| break; |
| + case PENDING_VISIBLE_RECT: |
| + case PENDING_VISIBLE_RECT_REQUIRED_FOR_ACTIVATION: |
| + ++pending_visible_iterator_; |
| + if (!pending_visible_iterator_.done()) |
| + current_tile_ = *pending_visible_iterator_; |
| + break; |
| case VISIBLE_RECT_OCCLUDED: |
| case VISIBLE_RECT_UNOCCLUDED: |
| case VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED: |
| @@ -202,11 +204,13 @@ TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator() |
| TilingSetEvictionQueue::EvictionRectIterator::EvictionRectIterator( |
| std::vector<PictureLayerTiling*>* tilings, |
| WhichTree tree, |
| - bool skip_shared_out_of_order_tiles) |
| + bool skip_shared_out_of_order_tiles, |
| + bool skip_pending_visible_rect) |
| : tile_(nullptr), |
| tilings_(tilings), |
| tree_(tree), |
| skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), |
| + skip_pending_visible_rect_(skip_pending_visible_rect), |
| tiling_index_(0) { |
| } |
| @@ -228,11 +232,15 @@ bool TilingSetEvictionQueue::EvictionRectIterator::AdvanceToNextTile( |
| template <typename TilingIteratorType> |
| bool TilingSetEvictionQueue::EvictionRectIterator::GetFirstTileAndCheckIfValid( |
| TilingIteratorType* iterator) { |
| - tile_ = (*tilings_)[tiling_index_]->TileAt(iterator->index_x(), |
| - iterator->index_y()); |
| + PictureLayerTiling* tiling = (*tilings_)[tiling_index_]; |
| + tile_ = tiling->TileAt(iterator->index_x(), iterator->index_y()); |
| // If there's nothing to evict, return false. |
| if (!tile_ || !tile_->HasResource()) |
| return false; |
| + if (skip_pending_visible_rect_ && |
| + tiling->pending_visible_rect().Intersects(tile_->content_rect())) { |
| + return false; |
| + } |
| (*tilings_)[tiling_index_]->UpdateTileAndTwinPriority(tile_); |
| // If the tile is out of order, return false. |
| if (skip_shared_out_of_order_tiles_ && IsSharedOutOfOrderTile(tree_, tile_)) |
| @@ -246,18 +254,21 @@ TilingSetEvictionQueue::EventuallyTilingIterator::EventuallyTilingIterator( |
| std::vector<PictureLayerTiling*>* tilings, |
| WhichTree tree, |
| bool skip_shared_out_of_order_tiles) |
| - : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles) { |
| + : EvictionRectIterator(tilings, |
| + tree, |
| + skip_shared_out_of_order_tiles, |
| + true /* skip_pending_visible_rect */) { |
| // Find the first tiling with a tile. |
| while (tiling_index_ < tilings_->size()) { |
| - if (!((*tilings_))[tiling_index_]->has_eventually_rect_tiles()) { |
| + if (!(*tilings_)[tiling_index_]->has_eventually_rect_tiles()) { |
|
enne (OOO)
2015/04/13 22:36:03
How about a temporary variable for (*tilings)[tili
vmpstr
2015/04/13 23:52:13
Are you OK with this being a follow-up (since I ha
|
| ++tiling_index_; |
| continue; |
| } |
| iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_eventually_rect(), |
| - ((*tilings_))[tiling_index_]->current_skewport_rect(), |
| - ((*tilings_))[tiling_index_]->current_soon_border_rect()); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_eventually_rect(), |
| + (*tilings_)[tiling_index_]->current_skewport_rect(), |
| + (*tilings_)[tiling_index_]->current_soon_border_rect()); |
| if (!iterator_) { |
| ++tiling_index_; |
| continue; |
| @@ -276,13 +287,13 @@ TilingSetEvictionQueue::EventuallyTilingIterator& |
| bool found_tile = AdvanceToNextTile(&iterator_); |
| while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
| ++tiling_index_; |
| - if (!((*tilings_))[tiling_index_]->has_eventually_rect_tiles()) |
| + if (!(*tilings_)[tiling_index_]->has_eventually_rect_tiles()) |
| continue; |
| iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_eventually_rect(), |
| - ((*tilings_))[tiling_index_]->current_skewport_rect(), |
| - ((*tilings_))[tiling_index_]->current_soon_border_rect()); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_eventually_rect(), |
| + (*tilings_)[tiling_index_]->current_skewport_rect(), |
| + (*tilings_)[tiling_index_]->current_soon_border_rect()); |
| if (!iterator_) |
| continue; |
| found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
| @@ -297,18 +308,21 @@ TilingSetEvictionQueue::SoonBorderTilingIterator::SoonBorderTilingIterator( |
| std::vector<PictureLayerTiling*>* tilings, |
| WhichTree tree, |
| bool skip_shared_out_of_order_tiles) |
| - : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles) { |
| + : EvictionRectIterator(tilings, |
| + tree, |
| + skip_shared_out_of_order_tiles, |
| + true /* skip_pending_visible_rect */) { |
| // Find the first tiling with a tile. |
| while (tiling_index_ < tilings_->size()) { |
| - if (!((*tilings_))[tiling_index_]->has_soon_border_rect_tiles()) { |
| + if (!(*tilings_)[tiling_index_]->has_soon_border_rect_tiles()) { |
| ++tiling_index_; |
| continue; |
| } |
| iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_soon_border_rect(), |
| - ((*tilings_))[tiling_index_]->current_skewport_rect(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect()); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_soon_border_rect(), |
| + (*tilings_)[tiling_index_]->current_skewport_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect()); |
| if (!iterator_) { |
| ++tiling_index_; |
| continue; |
| @@ -327,13 +341,13 @@ TilingSetEvictionQueue::SoonBorderTilingIterator& |
| bool found_tile = AdvanceToNextTile(&iterator_); |
| while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
| ++tiling_index_; |
| - if (!((*tilings_))[tiling_index_]->has_soon_border_rect_tiles()) |
| + if (!(*tilings_)[tiling_index_]->has_soon_border_rect_tiles()) |
| continue; |
| iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_soon_border_rect(), |
| - ((*tilings_))[tiling_index_]->current_skewport_rect(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect()); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_soon_border_rect(), |
| + (*tilings_)[tiling_index_]->current_skewport_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect()); |
| if (!iterator_) |
| continue; |
| found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
| @@ -348,18 +362,21 @@ TilingSetEvictionQueue::SkewportTilingIterator::SkewportTilingIterator( |
| std::vector<PictureLayerTiling*>* tilings, |
| WhichTree tree, |
| bool skip_shared_out_of_order_tiles) |
| - : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles) { |
| + : EvictionRectIterator(tilings, |
| + tree, |
| + skip_shared_out_of_order_tiles, |
| + true /* skip_pending_visible_rect */) { |
| // Find the first tiling with a tile. |
| while (tiling_index_ < tilings_->size()) { |
| - if (!((*tilings_))[tiling_index_]->has_skewport_rect_tiles()) { |
| + if (!(*tilings_)[tiling_index_]->has_skewport_rect_tiles()) { |
| ++tiling_index_; |
| continue; |
| } |
| iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_skewport_rect(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect()); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_skewport_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect()); |
| if (!iterator_) { |
| ++tiling_index_; |
| continue; |
| @@ -378,13 +395,13 @@ TilingSetEvictionQueue::SkewportTilingIterator& |
| bool found_tile = AdvanceToNextTile(&iterator_); |
| while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
| ++tiling_index_; |
| - if (!((*tilings_))[tiling_index_]->has_skewport_rect_tiles()) |
| + if (!(*tilings_)[tiling_index_]->has_skewport_rect_tiles()) |
| continue; |
| iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_skewport_rect(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect()); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_skewport_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect()); |
| if (!iterator_) |
| continue; |
| found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
| @@ -394,6 +411,73 @@ TilingSetEvictionQueue::SkewportTilingIterator& |
| return *this; |
| } |
| +// PendingVisibleIterator |
| +TilingSetEvictionQueue::PendingVisibleTilingIterator:: |
| + PendingVisibleTilingIterator(std::vector<PictureLayerTiling*>* tilings, |
| + WhichTree tree, |
| + bool skip_shared_out_of_order_tiles, |
| + bool return_required_for_activation_tiles) |
| + : EvictionRectIterator(tilings, |
| + tree, |
| + skip_shared_out_of_order_tiles, |
| + false /* skip_pending_visible_rect */), |
| + return_required_for_activation_tiles_( |
| + return_required_for_activation_tiles) { |
| + // Find the first tiling with a tile. |
| + while (tiling_index_ < tilings_->size()) { |
| + iterator_ = TilingData::DifferenceIterator( |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->pending_visible_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect()); |
| + if (!iterator_) { |
| + ++tiling_index_; |
| + continue; |
| + } |
| + break; |
| + } |
| + if (tiling_index_ >= tilings_->size()) |
| + return; |
| + if (!GetFirstTileAndCheckIfValid(&iterator_)) { |
| + ++(*this); |
| + return; |
| + } |
| + if (!TileMatchesRequiredFlags(tile_)) { |
| + ++(*this); |
| + return; |
| + } |
| +} |
| + |
| +TilingSetEvictionQueue::PendingVisibleTilingIterator& |
| + TilingSetEvictionQueue::PendingVisibleTilingIterator:: |
| + operator++() { |
| + bool found_tile = AdvanceToNextTile(&iterator_); |
| + while (found_tile && !TileMatchesRequiredFlags(tile_)) |
| + found_tile = AdvanceToNextTile(&iterator_); |
| + |
| + while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
| + ++tiling_index_; |
| + iterator_ = TilingData::DifferenceIterator( |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->pending_visible_rect(), |
| + (*tilings_)[tiling_index_]->current_visible_rect()); |
| + if (!iterator_) |
| + continue; |
| + found_tile = GetFirstTileAndCheckIfValid(&iterator_); |
| + if (!found_tile) |
| + found_tile = AdvanceToNextTile(&iterator_); |
| + while (found_tile && !TileMatchesRequiredFlags(tile_)) |
| + found_tile = AdvanceToNextTile(&iterator_); |
| + } |
| + return *this; |
| +} |
| + |
| +bool TilingSetEvictionQueue::PendingVisibleTilingIterator:: |
| + TileMatchesRequiredFlags(const Tile* tile) const { |
| + bool activation_flag_matches = |
| + tile->required_for_activation() == return_required_for_activation_tiles_; |
| + return activation_flag_matches; |
| +} |
| + |
| // VisibleTilingIterator |
| TilingSetEvictionQueue::VisibleTilingIterator::VisibleTilingIterator( |
| std::vector<PictureLayerTiling*>* tilings, |
| @@ -401,19 +485,22 @@ TilingSetEvictionQueue::VisibleTilingIterator::VisibleTilingIterator( |
| bool skip_shared_out_of_order_tiles, |
| bool return_occluded_tiles, |
| bool return_required_for_activation_tiles) |
| - : EvictionRectIterator(tilings, tree, skip_shared_out_of_order_tiles), |
| + : EvictionRectIterator(tilings, |
| + tree, |
| + skip_shared_out_of_order_tiles, |
| + false /* skip_pending_visible_rect */), |
| return_occluded_tiles_(return_occluded_tiles), |
| return_required_for_activation_tiles_( |
| return_required_for_activation_tiles) { |
| // Find the first tiling with a tile. |
| while (tiling_index_ < tilings_->size()) { |
| - if (!((*tilings_))[tiling_index_]->has_visible_rect_tiles()) { |
| + if (!(*tilings_)[tiling_index_]->has_visible_rect_tiles()) { |
| ++tiling_index_; |
| continue; |
| } |
| iterator_ = TilingData::Iterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect(), false); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_visible_rect(), false); |
| if (!iterator_) { |
| ++tiling_index_; |
| continue; |
| @@ -441,11 +528,11 @@ TilingSetEvictionQueue::VisibleTilingIterator& |
| while (!found_tile && (tiling_index_ + 1) < tilings_->size()) { |
| ++tiling_index_; |
| - if (!((*tilings_))[tiling_index_]->has_visible_rect_tiles()) |
| + if (!(*tilings_)[tiling_index_]->has_visible_rect_tiles()) |
| continue; |
| iterator_ = TilingData::Iterator( |
| - ((*tilings_))[tiling_index_]->tiling_data(), |
| - ((*tilings_))[tiling_index_]->current_visible_rect(), false); |
| + (*tilings_)[tiling_index_]->tiling_data(), |
| + (*tilings_)[tiling_index_]->current_visible_rect(), false); |
| if (!iterator_) |
| continue; |
| found_tile = GetFirstTileAndCheckIfValid(&iterator_); |