Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: cc/resources/picture_layer_tiling.cc

Issue 428533008: cc: Remove vectors from tiling eviction tile iterator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unused var Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 cache->previous_result = result; 838 cache->previous_result = result;
839 return result; 839 return result;
840 } 840 }
841 841
842 void PictureLayerTiling::UpdateEvictionCacheIfNeeded( 842 void PictureLayerTiling::UpdateEvictionCacheIfNeeded(
843 TreePriority tree_priority) { 843 TreePriority tree_priority) {
844 if (eviction_tiles_cache_valid_ && 844 if (eviction_tiles_cache_valid_ &&
845 eviction_cache_tree_priority_ == tree_priority) 845 eviction_cache_tree_priority_ == tree_priority)
846 return; 846 return;
847 847
848 eviction_tiles_cache_.clear(); 848 eventually_eviction_tiles_.clear();
849 eviction_tiles_cache_.reserve(tiles_.size()); 849 soon_eviction_tiles_.clear();
850 now_required_for_activation_eviction_tiles_.clear();
851 now_not_required_for_activation_eviction_tiles_.clear();
852
850 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 853 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
851 // TODO(vmpstr): This should update the priority if UpdateTilePriorities 854 // TODO(vmpstr): This should update the priority if UpdateTilePriorities
852 // changes not to do this. 855 // changes not to do this.
853 eviction_tiles_cache_.push_back(it->second); 856 Tile* tile = it->second;
857 const TilePriority& priority =
858 tile->priority_for_tree_priority(tree_priority);
859 switch (priority.priority_bin) {
860 case TilePriority::EVENTUALLY:
861 eventually_eviction_tiles_.push_back(tile);
862 break;
863 case TilePriority::SOON:
864 soon_eviction_tiles_.push_back(tile);
865 break;
866 case TilePriority::NOW:
867 if (tile->required_for_activation())
868 now_required_for_activation_eviction_tiles_.push_back(tile);
869 else
870 now_not_required_for_activation_eviction_tiles_.push_back(tile);
871 break;
872 }
854 } 873 }
855 874
856 std::sort(eviction_tiles_cache_.begin(), 875 // TODO(vmpstr): Do this lazily. One option is to have a "sorted" flag that
857 eviction_tiles_cache_.end(), 876 // can be updated for each of the queues.
858 TileEvictionOrder(tree_priority)); 877 TileEvictionOrder sort_order(tree_priority);
878 std::sort(eventually_eviction_tiles_.begin(),
879 eventually_eviction_tiles_.end(),
880 sort_order);
881 std::sort(
882 soon_eviction_tiles_.begin(), soon_eviction_tiles_.end(), sort_order);
883 std::sort(now_required_for_activation_eviction_tiles_.begin(),
884 now_required_for_activation_eviction_tiles_.end(),
885 sort_order);
886 std::sort(now_not_required_for_activation_eviction_tiles_.begin(),
887 now_not_required_for_activation_eviction_tiles_.end(),
888 sort_order);
889
859 eviction_tiles_cache_valid_ = true; 890 eviction_tiles_cache_valid_ = true;
860 eviction_cache_tree_priority_ = tree_priority; 891 eviction_cache_tree_priority_ = tree_priority;
861 } 892 }
862 893
863 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator() 894 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator()
864 : tiling_(NULL), current_tile_(NULL) {} 895 : tiling_(NULL), current_tile_(NULL) {}
865 896
866 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator( 897 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator(
867 PictureLayerTiling* tiling, 898 PictureLayerTiling* tiling,
868 WhichTree tree) 899 WhichTree tree)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 1009 }
979 next_index = spiral_iterator_.index(); 1010 next_index = spiral_iterator_.index();
980 break; 1011 break;
981 } 1012 }
982 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); 1013 current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
983 } 1014 }
984 return *this; 1015 return *this;
985 } 1016 }
986 1017
987 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator() 1018 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator()
988 : tiling_(NULL) { 1019 : tiling_(NULL), eviction_tiles_(NULL) {
989 } 1020 }
990 1021
991 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator( 1022 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator(
992 PictureLayerTiling* tiling, 1023 PictureLayerTiling* tiling,
993 TreePriority tree_priority) 1024 TreePriority tree_priority,
994 : tiling_(tiling), tree_priority_(tree_priority) { 1025 TilePriority::PriorityBin type,
1026 bool required_for_activation)
1027 : tiling_(tiling), tree_priority_(tree_priority), eviction_tiles_(NULL) {
1028 if (required_for_activation && type != TilePriority::NOW)
1029 return;
1030
995 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); 1031 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_);
996 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); 1032 switch (type) {
997 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && 1033 case TilePriority::EVENTUALLY:
1034 eviction_tiles_ = &tiling_->eventually_eviction_tiles_;
1035 break;
1036 case TilePriority::SOON:
1037 eviction_tiles_ = &tiling_->soon_eviction_tiles_;
1038 break;
1039 case TilePriority::NOW:
1040 if (required_for_activation)
1041 eviction_tiles_ = &tiling_->now_required_for_activation_eviction_tiles_;
1042 else
1043 eviction_tiles_ =
1044 &tiling_->now_not_required_for_activation_eviction_tiles_;
1045 break;
1046 }
1047 DCHECK(eviction_tiles_);
1048 tile_iterator_ = eviction_tiles_->begin();
1049 if (tile_iterator_ != eviction_tiles_->end() &&
998 !(*tile_iterator_)->HasResources()) { 1050 !(*tile_iterator_)->HasResources()) {
999 ++(*this); 1051 ++(*this);
1000 } 1052 }
1001 } 1053 }
1002 1054
1003 PictureLayerTiling::TilingEvictionTileIterator::~TilingEvictionTileIterator() {} 1055 PictureLayerTiling::TilingEvictionTileIterator::~TilingEvictionTileIterator() {}
1004 1056
1005 PictureLayerTiling::TilingEvictionTileIterator::operator bool() const { 1057 PictureLayerTiling::TilingEvictionTileIterator::operator bool() const {
1006 return tiling_ && tile_iterator_ != tiling_->eviction_tiles_cache_.end(); 1058 return eviction_tiles_ && tile_iterator_ != eviction_tiles_->end();
1007 } 1059 }
1008 1060
1009 Tile* PictureLayerTiling::TilingEvictionTileIterator::operator*() { 1061 Tile* PictureLayerTiling::TilingEvictionTileIterator::operator*() {
1010 DCHECK(*this); 1062 DCHECK(*this);
1011 return *tile_iterator_; 1063 return *tile_iterator_;
1012 } 1064 }
1013 1065
1014 const Tile* PictureLayerTiling::TilingEvictionTileIterator::operator*() const { 1066 const Tile* PictureLayerTiling::TilingEvictionTileIterator::operator*() const {
1015 DCHECK(*this); 1067 DCHECK(*this);
1016 return *tile_iterator_; 1068 return *tile_iterator_;
1017 } 1069 }
1018 1070
1019 PictureLayerTiling::TilingEvictionTileIterator& 1071 PictureLayerTiling::TilingEvictionTileIterator&
1020 PictureLayerTiling::TilingEvictionTileIterator:: 1072 PictureLayerTiling::TilingEvictionTileIterator::
1021 operator++() { 1073 operator++() {
1022 DCHECK(*this); 1074 DCHECK(*this);
1023 do { 1075 do {
1024 ++tile_iterator_; 1076 ++tile_iterator_;
1025 } while (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && 1077 } while (tile_iterator_ != eviction_tiles_->end() &&
1026 (!(*tile_iterator_)->HasResources())); 1078 (!(*tile_iterator_)->HasResources()));
1027 1079
1028 return *this; 1080 return *this;
1029 } 1081 }
1030 1082
1031 } // namespace cc 1083 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698