OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 | 769 |
770 void PictureLayerTiling::UpdateEvictionCacheIfNeeded( | 770 void PictureLayerTiling::UpdateEvictionCacheIfNeeded( |
771 TreePriority tree_priority) { | 771 TreePriority tree_priority) { |
772 if (eviction_tiles_cache_valid_ && | 772 if (eviction_tiles_cache_valid_ && |
773 eviction_cache_tree_priority_ == tree_priority) | 773 eviction_cache_tree_priority_ == tree_priority) |
774 return; | 774 return; |
775 | 775 |
776 eviction_tiles_cache_.clear(); | 776 eviction_tiles_cache_.clear(); |
777 eviction_tiles_cache_.reserve(tiles_.size()); | 777 eviction_tiles_cache_.reserve(tiles_.size()); |
778 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 778 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 779 DCHECK(it->second); |
| 780 |
779 // TODO(vmpstr): This should update the priority if UpdateTilePriorities | 781 // TODO(vmpstr): This should update the priority if UpdateTilePriorities |
780 // changes not to do this. | 782 // changes not to do this. |
781 eviction_tiles_cache_.push_back(it->second); | 783 eviction_tiles_cache_.push_back(it->second); |
782 } | 784 } |
783 | 785 |
784 std::sort(eviction_tiles_cache_.begin(), | 786 std::sort(eviction_tiles_cache_.begin(), |
785 eviction_tiles_cache_.end(), | 787 eviction_tiles_cache_.end(), |
786 TileEvictionOrder(tree_priority)); | 788 TileEvictionOrder(tree_priority)); |
787 eviction_tiles_cache_valid_ = true; | 789 eviction_tiles_cache_valid_ = true; |
788 eviction_cache_tree_priority_ = tree_priority; | 790 eviction_cache_tree_priority_ = tree_priority; |
(...skipping 26 matching lines...) Expand all Loading... |
815 } | 817 } |
816 | 818 |
817 current_tile_ = | 819 current_tile_ = |
818 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | 820 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); |
819 if (!current_tile_ || !TileNeedsRaster(current_tile_)) | 821 if (!current_tile_ || !TileNeedsRaster(current_tile_)) |
820 ++(*this); | 822 ++(*this); |
821 } | 823 } |
822 | 824 |
823 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} | 825 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} |
824 | 826 |
| 827 bool |
| 828 PictureLayerTiling::TilingRasterTileIterator::HasTilesRequiredForActivation() |
| 829 const { |
| 830 if (!*this || get_type() != TilePriority::NOW) |
| 831 return false; |
| 832 |
| 833 for (TilingData::Iterator it = visible_iterator_; it; ++it) { |
| 834 std::pair<int, int> next_index = visible_iterator_.index(); |
| 835 Tile* tile = tiling_->TileAt(next_index.first, next_index.second); |
| 836 if (tile && tile->required_for_activation()) |
| 837 return true; |
| 838 } |
| 839 return false; |
| 840 } |
| 841 |
825 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { | 842 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { |
826 DCHECK_LT(type_, TilePriority::EVENTUALLY); | 843 DCHECK_LT(type_, TilePriority::EVENTUALLY); |
827 | 844 |
828 do { | 845 do { |
829 type_ = static_cast<TilePriority::PriorityBin>(type_ + 1); | 846 type_ = static_cast<TilePriority::PriorityBin>(type_ + 1); |
830 if (type_ == TilePriority::EVENTUALLY) { | 847 if (type_ == TilePriority::EVENTUALLY) { |
831 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | 848 spiral_iterator_ = TilingData::SpiralDifferenceIterator( |
832 &tiling_->tiling_data_, | 849 &tiling_->tiling_data_, |
833 eventually_rect_in_content_space_, | 850 eventually_rect_in_content_space_, |
834 skewport_in_content_space_, | 851 skewport_in_content_space_, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 944 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
928 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 945 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
929 is_valid_ = true; | 946 is_valid_ = true; |
930 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 947 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
931 !(*tile_iterator_)->HasResources()) { | 948 !(*tile_iterator_)->HasResources()) { |
932 ++(*this); | 949 ++(*this); |
933 } | 950 } |
934 } | 951 } |
935 | 952 |
936 } // namespace cc | 953 } // namespace cc |
OLD | NEW |