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

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

Issue 690063002: cc: Do not ignore layers without valid priorities during eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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 #include <set> 10 #include <set>
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 Tile* twin_tile = 735 Tile* twin_tile =
736 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); 736 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index());
737 // If twin tile is missing, it might not have a recording, so we don't need 737 // If twin tile is missing, it might not have a recording, so we don't need
738 // this tile to be required for activation. 738 // this tile to be required for activation.
739 if (!twin_tile) 739 if (!twin_tile)
740 return false; 740 return false;
741 741
742 return true; 742 return true;
743 } 743 }
744 744
745 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { 745 void PictureLayerTiling::UpdateTileAndTwinPriority(
746 UpdateTilePriority(tile); 746 Tile* tile,
747 bool use_tile_priority_rects,
748 bool use_twin_tile_priority_rects) const {
749 if (use_tile_priority_rects) {
vmpstr 2014/10/31 15:35:49 How about we add a client_->GetMaxBinForTilePriori
USE eero AT chromium.org 2014/11/04 17:47:57 Done.
750 UpdateTilePriority(tile);
751 } else {
752 WhichTree tree = client_->GetTree();
753 tile->SetPriority(tree, TilePriority());
754 tile->set_is_occluded(tree, false);
755 if (tree == PENDING_TREE)
756 tile->set_required_for_activation(false);
757 }
747 758
748 const PictureLayerTiling* twin_tiling = 759 const PictureLayerTiling* twin_tiling =
749 client_->GetPendingOrActiveTwinTiling(this); 760 client_->GetPendingOrActiveTwinTiling(this);
750 if (!tile->is_shared() || !twin_tiling) { 761 if (use_twin_tile_priority_rects && tile->is_shared() && twin_tiling) {
762 twin_tiling->UpdateTilePriority(tile);
763 } else {
751 WhichTree tree = client_->GetTree(); 764 WhichTree tree = client_->GetTree();
752 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; 765 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE;
753 tile->SetPriority(twin_tree, TilePriority()); 766 tile->SetPriority(twin_tree, TilePriority());
754 tile->set_is_occluded(twin_tree, false); 767 tile->set_is_occluded(twin_tree, false);
755 if (twin_tree == PENDING_TREE) 768 if (twin_tree == PENDING_TREE)
756 tile->set_required_for_activation(false); 769 tile->set_required_for_activation(false);
757 return;
758 } 770 }
759
760 twin_tiling->UpdateTilePriority(tile);
761 } 771 }
762 772
763 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { 773 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const {
764 // TODO(vmpstr): This code should return the priority instead of setting it on 774 // TODO(vmpstr): This code should return the priority instead of setting it on
765 // the tile. This should be a part of the change to move tile priority from 775 // the tile. This should be a part of the change to move tile priority from
766 // tiles into iterators. 776 // tiles into iterators.
767 WhichTree tree = client_->GetTree(); 777 WhichTree tree = client_->GetTree();
768 778
769 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); 779 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile);
770 gfx::Rect tile_bounds = 780 gfx::Rect tile_bounds =
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 break; 978 break;
969 } 979 }
970 980
971 gfx::Rect result(origin_x, origin_y, width, height); 981 gfx::Rect result(origin_x, origin_y, width, height);
972 if (cache) 982 if (cache)
973 cache->previous_result = result; 983 cache->previous_result = result;
974 return result; 984 return result;
975 } 985 }
976 986
977 void PictureLayerTiling::UpdateEvictionCacheIfNeeded( 987 void PictureLayerTiling::UpdateEvictionCacheIfNeeded(
978 TreePriority tree_priority) { 988 TreePriority tree_priority,
989 bool use_tile_priority_rects,
990 bool use_twin_tile_priority_rects) {
979 if (eviction_tiles_cache_valid_ && 991 if (eviction_tiles_cache_valid_ &&
980 eviction_cache_tree_priority_ == tree_priority) 992 eviction_cache_tree_priority_ == tree_priority)
981 return; 993 return;
982 994
983 eviction_tiles_now_.clear(); 995 eviction_tiles_now_.clear();
984 eviction_tiles_now_and_required_for_activation_.clear(); 996 eviction_tiles_now_and_required_for_activation_.clear();
985 eviction_tiles_soon_.clear(); 997 eviction_tiles_soon_.clear();
986 eviction_tiles_soon_and_required_for_activation_.clear(); 998 eviction_tiles_soon_and_required_for_activation_.clear();
987 eviction_tiles_eventually_.clear(); 999 eviction_tiles_eventually_.clear();
988 eviction_tiles_eventually_and_required_for_activation_.clear(); 1000 eviction_tiles_eventually_and_required_for_activation_.clear();
989 1001
990 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 1002 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
991 Tile* tile = it->second.get(); 1003 Tile* tile = it->second.get();
992 UpdateTileAndTwinPriority(tile); 1004 UpdateTileAndTwinPriority(
1005 tile, use_tile_priority_rects, use_twin_tile_priority_rects);
993 const TilePriority& priority = 1006 const TilePriority& priority =
994 tile->priority_for_tree_priority(tree_priority); 1007 tile->priority_for_tree_priority(tree_priority);
995 switch (priority.priority_bin) { 1008 switch (priority.priority_bin) {
996 case TilePriority::EVENTUALLY: 1009 case TilePriority::EVENTUALLY:
997 if (tile->required_for_activation()) 1010 if (tile->required_for_activation())
998 eviction_tiles_eventually_and_required_for_activation_.push_back( 1011 eviction_tiles_eventually_and_required_for_activation_.push_back(
999 tile); 1012 tile);
1000 else 1013 else
1001 eviction_tiles_eventually_.push_back(tile); 1014 eviction_tiles_eventually_.push_back(tile);
1002 break; 1015 break;
(...skipping 30 matching lines...) Expand all
1033 std::sort(eviction_tiles_eventually_and_required_for_activation_.begin(), 1046 std::sort(eviction_tiles_eventually_and_required_for_activation_.begin(),
1034 eviction_tiles_eventually_and_required_for_activation_.end(), 1047 eviction_tiles_eventually_and_required_for_activation_.end(),
1035 sort_order); 1048 sort_order);
1036 1049
1037 eviction_tiles_cache_valid_ = true; 1050 eviction_tiles_cache_valid_ = true;
1038 eviction_cache_tree_priority_ = tree_priority; 1051 eviction_cache_tree_priority_ = tree_priority;
1039 } 1052 }
1040 1053
1041 const std::vector<Tile*>* PictureLayerTiling::GetEvictionTiles( 1054 const std::vector<Tile*>* PictureLayerTiling::GetEvictionTiles(
1042 TreePriority tree_priority, 1055 TreePriority tree_priority,
1043 EvictionCategory category) { 1056 EvictionCategory category,
1044 UpdateEvictionCacheIfNeeded(tree_priority); 1057 bool use_tile_priority_rects,
1058 bool use_twin_tile_priority_rects) {
1059 UpdateEvictionCacheIfNeeded(
1060 tree_priority, use_tile_priority_rects, use_twin_tile_priority_rects);
1045 switch (category) { 1061 switch (category) {
1046 case EVENTUALLY: 1062 case EVENTUALLY:
1047 return &eviction_tiles_eventually_; 1063 return &eviction_tiles_eventually_;
1048 case EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION: 1064 case EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION:
1049 return &eviction_tiles_eventually_and_required_for_activation_; 1065 return &eviction_tiles_eventually_and_required_for_activation_;
1050 case SOON: 1066 case SOON:
1051 return &eviction_tiles_soon_; 1067 return &eviction_tiles_soon_;
1052 case SOON_AND_REQUIRED_FOR_ACTIVATION: 1068 case SOON_AND_REQUIRED_FOR_ACTIVATION:
1053 return &eviction_tiles_soon_and_required_for_activation_; 1069 return &eviction_tiles_soon_and_required_for_activation_;
1054 case NOW: 1070 case NOW:
(...skipping 23 matching lines...) Expand all
1078 AdvancePhase(); 1094 AdvancePhase();
1079 return; 1095 return;
1080 } 1096 }
1081 1097
1082 current_tile_ = 1098 current_tile_ =
1083 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); 1099 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y());
1084 if (!current_tile_ || !TileNeedsRaster(current_tile_)) { 1100 if (!current_tile_ || !TileNeedsRaster(current_tile_)) {
1085 ++(*this); 1101 ++(*this);
1086 return; 1102 return;
1087 } 1103 }
1088 tiling_->UpdateTileAndTwinPriority(current_tile_); 1104 tiling_->UpdateTileAndTwinPriority(current_tile_, true, true);
1089 } 1105 }
1090 1106
1091 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} 1107 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {}
1092 1108
1093 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { 1109 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() {
1094 DCHECK_LT(phase_, EVENTUALLY_RECT); 1110 DCHECK_LT(phase_, EVENTUALLY_RECT);
1095 1111
1096 do { 1112 do {
1097 phase_ = static_cast<Phase>(phase_ + 1); 1113 phase_ = static_cast<Phase>(phase_ + 1);
1098 switch (phase_) { 1114 switch (phase_) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 ++spiral_iterator_; 1157 ++spiral_iterator_;
1142 } 1158 }
1143 1159
1144 if (!spiral_iterator_ && phase_ == EVENTUALLY_RECT) { 1160 if (!spiral_iterator_ && phase_ == EVENTUALLY_RECT) {
1145 current_tile_ = NULL; 1161 current_tile_ = NULL;
1146 break; 1162 break;
1147 } 1163 }
1148 } while (!spiral_iterator_); 1164 } while (!spiral_iterator_);
1149 1165
1150 if (current_tile_) 1166 if (current_tile_)
1151 tiling_->UpdateTileAndTwinPriority(current_tile_); 1167 tiling_->UpdateTileAndTwinPriority(current_tile_, true, true);
1152 } 1168 }
1153 1169
1154 PictureLayerTiling::TilingRasterTileIterator& 1170 PictureLayerTiling::TilingRasterTileIterator&
1155 PictureLayerTiling::TilingRasterTileIterator:: 1171 PictureLayerTiling::TilingRasterTileIterator::
1156 operator++() { 1172 operator++() {
1157 current_tile_ = NULL; 1173 current_tile_ = NULL;
1158 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { 1174 while (!current_tile_ || !TileNeedsRaster(current_tile_)) {
1159 std::pair<int, int> next_index; 1175 std::pair<int, int> next_index;
1160 switch (phase_) { 1176 switch (phase_) {
1161 case VISIBLE_RECT: 1177 case VISIBLE_RECT:
(...skipping 19 matching lines...) Expand all
1181 current_tile_ = NULL; 1197 current_tile_ = NULL;
1182 return *this; 1198 return *this;
1183 } 1199 }
1184 next_index = spiral_iterator_.index(); 1200 next_index = spiral_iterator_.index();
1185 break; 1201 break;
1186 } 1202 }
1187 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); 1203 current_tile_ = tiling_->TileAt(next_index.first, next_index.second);
1188 } 1204 }
1189 1205
1190 if (current_tile_) 1206 if (current_tile_)
1191 tiling_->UpdateTileAndTwinPriority(current_tile_); 1207 tiling_->UpdateTileAndTwinPriority(current_tile_, true, true);
1192 return *this; 1208 return *this;
1193 } 1209 }
1194 1210
1195 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator() 1211 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator()
1196 : eviction_tiles_(NULL), current_eviction_tiles_index_(0u) { 1212 : eviction_tiles_(NULL), current_eviction_tiles_index_(0u) {
1197 } 1213 }
1198 1214
1199 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator( 1215 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator(
1200 PictureLayerTiling* tiling, 1216 PictureLayerTiling* tiling,
1201 TreePriority tree_priority, 1217 TreePriority tree_priority,
1202 EvictionCategory category) 1218 EvictionCategory category,
1203 : eviction_tiles_(tiling->GetEvictionTiles(tree_priority, category)), 1219 bool use_tile_priority_rects,
1220 bool use_twin_tile_priority_rects)
1221 : eviction_tiles_(tiling->GetEvictionTiles(tree_priority,
1222 category,
1223 use_tile_priority_rects,
1224 use_twin_tile_priority_rects)),
1204 // Note: initializing to "0 - 1" works as overflow is well defined for 1225 // Note: initializing to "0 - 1" works as overflow is well defined for
1205 // unsigned integers. 1226 // unsigned integers.
1206 current_eviction_tiles_index_(static_cast<size_t>(0) - 1) { 1227 current_eviction_tiles_index_(static_cast<size_t>(0) - 1) {
1207 DCHECK(eviction_tiles_); 1228 DCHECK(eviction_tiles_);
1208 ++(*this); 1229 ++(*this);
1209 } 1230 }
1210 1231
1211 PictureLayerTiling::TilingEvictionTileIterator::~TilingEvictionTileIterator() { 1232 PictureLayerTiling::TilingEvictionTileIterator::~TilingEvictionTileIterator() {
1212 } 1233 }
1213 1234
(...skipping 18 matching lines...) Expand all
1232 DCHECK(*this); 1253 DCHECK(*this);
1233 do { 1254 do {
1234 ++current_eviction_tiles_index_; 1255 ++current_eviction_tiles_index_;
1235 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && 1256 } while (current_eviction_tiles_index_ != eviction_tiles_->size() &&
1236 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); 1257 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources());
1237 1258
1238 return *this; 1259 return *this;
1239 } 1260 }
1240 1261
1241 } // namespace cc 1262 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698