Chromium Code Reviews| 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> | |
| 6 | |
| 5 #include "cc/resources/tiling_set_eviction_queue.h" | 7 #include "cc/resources/tiling_set_eviction_queue.h" |
| 6 | 8 |
| 7 namespace cc { | 9 namespace cc { |
| 8 | 10 |
| 11 namespace { | |
| 12 const size_t kNullTilingIndex = ~static_cast<size_t>(0u); | |
| 13 } | |
| 14 | |
| 9 TilingSetEvictionQueue::TilingSetEvictionQueue() | 15 TilingSetEvictionQueue::TilingSetEvictionQueue() |
| 10 : tiling_set_(nullptr), | 16 : tiling_set_(nullptr), |
| 17 tree_(ACTIVE_TREE), | |
| 11 tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES), | 18 tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES), |
| 12 current_category_(PictureLayerTiling::EVENTUALLY), | 19 skip_all_shared_tiles_(false), |
| 20 skip_shared_out_of_order_tiles_(false), | |
| 21 processing_required_for_activation_tiling_(false), | |
| 22 processing_soon_border_rect_(false), | |
| 23 current_priority_bin_(TilePriority::EVENTUALLY), | |
| 13 current_tiling_index_(0u), | 24 current_tiling_index_(0u), |
| 25 current_required_for_activation_tiling_index_(kNullTilingIndex), | |
| 14 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), | 26 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), |
| 15 current_eviction_tile_(nullptr), | 27 current_eviction_tile_(nullptr), |
| 16 eviction_tiles_(nullptr), | 28 next_unoccluded_now_tile_index_(0u) { |
| 17 next_eviction_tile_index_(0u) { | |
| 18 } | 29 } |
| 19 | 30 |
| 20 TilingSetEvictionQueue::TilingSetEvictionQueue( | 31 TilingSetEvictionQueue::TilingSetEvictionQueue( |
| 21 PictureLayerTilingSet* tiling_set, | 32 PictureLayerTilingSet* tiling_set, |
| 22 TreePriority tree_priority) | 33 TreePriority tree_priority, |
| 34 bool skip_shared_out_of_order_tiles) | |
| 23 : tiling_set_(tiling_set), | 35 : tiling_set_(tiling_set), |
| 36 tree_(ACTIVE_TREE), | |
| 24 tree_priority_(tree_priority), | 37 tree_priority_(tree_priority), |
| 25 current_category_(PictureLayerTiling::EVENTUALLY), | 38 skip_all_shared_tiles_(false), |
| 39 skip_shared_out_of_order_tiles_(skip_shared_out_of_order_tiles), | |
| 40 processing_required_for_activation_tiling_(false), | |
| 41 processing_soon_border_rect_(false), | |
| 42 current_priority_bin_(TilePriority::EVENTUALLY), | |
| 26 current_tiling_index_(0u), | 43 current_tiling_index_(0u), |
| 44 current_required_for_activation_tiling_index_(kNullTilingIndex), | |
| 27 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), | 45 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), |
| 28 current_eviction_tile_(nullptr), | 46 current_eviction_tile_(nullptr), |
| 29 eviction_tiles_(nullptr), | 47 next_unoccluded_now_tile_index_(0u) { |
| 30 next_eviction_tile_index_(0u) { | |
| 31 DCHECK(tiling_set_); | 48 DCHECK(tiling_set_); |
| 32 | 49 |
| 33 // Early out if the layer has no tilings. | 50 // Early out if the layer has no tilings. |
| 34 if (!tiling_set_->num_tilings()) | 51 if (!tiling_set_->num_tilings()) |
| 35 return; | 52 return; |
| 36 | 53 |
| 54 const PictureLayerTilingClient* client = tiling_set_->tiling_at(0)->client_; | |
|
vmpstr
2014/12/09 19:47:56
tiling_set has a client as well (and it's the same
USE eero AT chromium.org
2014/12/10 12:35:46
Done.
| |
| 55 tree_ = client->GetTree(); | |
| 56 skip_all_shared_tiles_ = | |
| 57 skip_shared_out_of_order_tiles_ && | |
| 58 tree_priority_ == (tree_ == ACTIVE_TREE ? NEW_CONTENT_TAKES_PRIORITY | |
| 59 : SMOOTHNESS_TAKES_PRIORITY); | |
| 60 | |
| 37 current_tiling_index_ = CurrentTilingRange().start - 1u; | 61 current_tiling_index_ = CurrentTilingRange().start - 1u; |
| 38 AdvanceToNextValidTiling(); | 62 AdvanceToNextValidTiling(); |
| 39 } | 63 } |
| 40 | 64 |
| 41 TilingSetEvictionQueue::~TilingSetEvictionQueue() { | 65 TilingSetEvictionQueue::~TilingSetEvictionQueue() { |
| 42 } | 66 } |
| 43 | 67 |
| 44 bool TilingSetEvictionQueue::IsEmpty() const { | 68 bool TilingSetEvictionQueue::IsEmpty() const { |
| 45 return !current_eviction_tile_; | 69 return !current_eviction_tile_; |
| 46 } | 70 } |
| 47 | 71 |
| 48 void TilingSetEvictionQueue::Pop() { | 72 void TilingSetEvictionQueue::Pop() { |
| 49 DCHECK(!IsEmpty()); | 73 DCHECK(!IsEmpty()); |
| 50 | 74 |
| 51 if (!AdvanceToNextEvictionTile()) | 75 if (!AdvanceToNextEvictionTile()) |
| 52 AdvanceToNextValidTiling(); | 76 AdvanceToNextValidTiling(); |
| 53 } | 77 } |
| 54 | 78 |
| 55 Tile* TilingSetEvictionQueue::Top() { | 79 Tile* TilingSetEvictionQueue::Top() { |
| 56 DCHECK(!IsEmpty()); | 80 DCHECK(!IsEmpty()); |
| 57 return current_eviction_tile_; | 81 return current_eviction_tile_; |
| 58 } | 82 } |
| 59 | 83 |
| 60 const Tile* TilingSetEvictionQueue::Top() const { | 84 const Tile* TilingSetEvictionQueue::Top() const { |
| 61 DCHECK(!IsEmpty()); | 85 DCHECK(!IsEmpty()); |
| 62 return current_eviction_tile_; | 86 return current_eviction_tile_; |
| 63 } | 87 } |
| 64 | 88 |
| 65 bool TilingSetEvictionQueue::AdvanceToNextCategory() { | 89 bool TilingSetEvictionQueue::AdvanceToNextEvictionTile() { |
| 66 // Advance to the next category. This is done only after all tiling range | 90 // Advance to the next eviction tile within the current priority bin and |
| 67 // types within the previous category have been gone through. | 91 // tiling. This is done while advancing to a new tiling and while popping |
| 92 // the current tile. | |
| 93 | |
| 94 bool required_for_activation = processing_required_for_activation_tiling_; | |
| 95 | |
| 96 for (;;) { | |
| 97 while (spiral_iterator_) { | |
| 98 std::pair<int, int> next_index = spiral_iterator_.index(); | |
| 99 Tile* tile = current_tiling_->TileAt(next_index.first, next_index.second); | |
| 100 ++spiral_iterator_; | |
| 101 if (!tile || !tile->HasResources()) | |
| 102 continue; | |
| 103 if (skip_all_shared_tiles_ && tile->is_shared()) | |
| 104 continue; | |
| 105 current_tiling_->UpdateTileAndTwinPriority(tile); | |
| 106 if (skip_shared_out_of_order_tiles_ && IsSharedOutOfOrderTile(tile)) | |
| 107 continue; | |
| 108 if (tile->required_for_activation() == required_for_activation) { | |
| 109 current_eviction_tile_ = tile; | |
| 110 return true; | |
| 111 } | |
| 112 SetCurrentRequiredForActivationTilingIndex(current_tiling_index_); | |
|
vmpstr
2014/12/09 19:47:56
This is the part that is confusing to me. I think
USE eero AT chromium.org
2014/12/10 12:35:46
Done.
| |
| 113 } | |
| 114 if (processing_soon_border_rect_) { | |
| 115 // Advance from soon border rect to skewport rect. | |
| 116 processing_soon_border_rect_ = false; | |
| 117 if (current_tiling_->has_skewport_rect_tiles_) { | |
| 118 spiral_iterator_ = TilingData::ReverseSpiralDifferenceIterator( | |
| 119 ¤t_tiling_->tiling_data_, | |
| 120 current_tiling_->current_skewport_rect_, | |
| 121 current_tiling_->current_visible_rect_, | |
| 122 current_tiling_->current_visible_rect_); | |
| 123 continue; | |
| 124 } | |
| 125 } | |
| 126 break; | |
| 127 } | |
| 128 | |
| 129 if (visible_iterator_) { | |
| 130 TilePriority::PriorityBin max_tile_priority_bin = | |
| 131 current_tiling_->client_->GetMaxTilePriorityBin(); | |
| 132 do { | |
| 133 std::pair<int, int> next_index = visible_iterator_.index(); | |
| 134 Tile* tile = current_tiling_->TileAt(next_index.first, next_index.second); | |
| 135 ++visible_iterator_; | |
| 136 if (!tile || !tile->HasResources()) | |
| 137 continue; | |
| 138 if (skip_all_shared_tiles_ && tile->is_shared()) | |
| 139 continue; | |
| 140 if (max_tile_priority_bin <= TilePriority::NOW) { | |
| 141 if (tree_ == PENDING_TREE && | |
| 142 current_tiling_->IsTileRequiredForActivationIfVisible(tile) != | |
| 143 required_for_activation) { | |
| 144 SetCurrentRequiredForActivationTilingIndex(current_tiling_index_); | |
| 145 continue; | |
| 146 } | |
| 147 if (!current_tiling_->IsTileOccluded(tile)) { | |
| 148 unoccluded_now_tiles_.push_back(tile); | |
| 149 continue; | |
| 150 } | |
| 151 } | |
| 152 current_tiling_->UpdateTileAndTwinPriority(tile); | |
| 153 if (skip_shared_out_of_order_tiles_ && IsSharedOutOfOrderTile(tile)) | |
| 154 continue; | |
| 155 if (tile->required_for_activation() == required_for_activation) { | |
| 156 current_eviction_tile_ = tile; | |
| 157 return true; | |
| 158 } | |
| 159 SetCurrentRequiredForActivationTilingIndex(current_tiling_index_); | |
| 160 } while (visible_iterator_); | |
| 161 } | |
| 162 | |
| 163 if (!unoccluded_now_tiles_.empty()) { | |
| 164 while (next_unoccluded_now_tile_index_ < unoccluded_now_tiles_.size()) { | |
| 165 Tile* tile = unoccluded_now_tiles_[next_unoccluded_now_tile_index_]; | |
| 166 ++next_unoccluded_now_tile_index_; | |
| 167 DCHECK(tile); | |
| 168 if (!tile->HasResources()) | |
| 169 continue; | |
| 170 current_tiling_->UpdateTileAndTwinPriority(tile); | |
| 171 if (skip_shared_out_of_order_tiles_ && IsSharedOutOfOrderTile(tile)) | |
| 172 continue; | |
| 173 if (tile->required_for_activation() == required_for_activation) { | |
| 174 current_eviction_tile_ = tile; | |
| 175 return true; | |
| 176 } | |
| 177 SetCurrentRequiredForActivationTilingIndex(current_tiling_index_); | |
| 178 } | |
| 179 unoccluded_now_tiles_.clear(); | |
| 180 next_unoccluded_now_tile_index_ = 0u; | |
| 181 } | |
| 182 | |
| 183 current_eviction_tile_ = nullptr; | |
| 184 return false; | |
| 185 } | |
| 186 | |
| 187 bool TilingSetEvictionQueue::AdvanceToNextPriorityBin() { | |
| 188 // Advance to the next priority bin. This is done only after all tiling range | |
| 189 // types (including the required for activation tiling) within the previous | |
| 190 // priority bin have been gone through. | |
| 68 DCHECK_EQ(current_tiling_range_type_, PictureLayerTilingSet::HIGH_RES); | 191 DCHECK_EQ(current_tiling_range_type_, PictureLayerTilingSet::HIGH_RES); |
| 192 DCHECK_EQ(current_required_for_activation_tiling_index_, kNullTilingIndex); | |
| 69 | 193 |
| 70 switch (current_category_) { | 194 switch (current_priority_bin_) { |
| 71 case PictureLayerTiling::EVENTUALLY: | 195 case TilePriority::EVENTUALLY: |
| 72 current_category_ = | 196 current_priority_bin_ = TilePriority::SOON; |
| 73 PictureLayerTiling::EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION; | |
| 74 return true; | 197 return true; |
| 75 case PictureLayerTiling::EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION: | 198 case TilePriority::SOON: |
| 76 current_category_ = PictureLayerTiling::SOON; | 199 current_priority_bin_ = TilePriority::NOW; |
| 77 return true; | 200 return true; |
| 78 case PictureLayerTiling::SOON: | 201 case TilePriority::NOW: |
| 79 current_category_ = PictureLayerTiling::SOON_AND_REQUIRED_FOR_ACTIVATION; | |
| 80 return true; | |
| 81 case PictureLayerTiling::SOON_AND_REQUIRED_FOR_ACTIVATION: | |
| 82 current_category_ = PictureLayerTiling::NOW; | |
| 83 return true; | |
| 84 case PictureLayerTiling::NOW: | |
| 85 current_category_ = PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION; | |
| 86 return true; | |
| 87 case PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION: | |
| 88 return false; | 202 return false; |
| 89 } | 203 } |
| 90 NOTREACHED(); | 204 NOTREACHED(); |
| 91 return false; | 205 return false; |
| 92 } | 206 } |
| 93 | 207 |
| 94 bool TilingSetEvictionQueue::AdvanceToNextEvictionTile() { | |
| 95 // Advance to the next eviction tile within the current category and tiling. | |
| 96 // This is done while advancing to a new tiling (in which case the next | |
| 97 // eviction tile index is 0) and while popping the current tile (in which | |
| 98 // case the next eviction tile index is greater than 0). | |
| 99 DCHECK_EQ(next_eviction_tile_index_ > 0, current_eviction_tile_ != nullptr); | |
| 100 | |
| 101 while (next_eviction_tile_index_ < eviction_tiles_->size()) { | |
| 102 Tile* tile = (*eviction_tiles_)[next_eviction_tile_index_]; | |
| 103 ++next_eviction_tile_index_; | |
| 104 if (tile->HasResources()) { | |
| 105 current_eviction_tile_ = tile; | |
| 106 return true; | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 current_eviction_tile_ = nullptr; | |
| 111 return false; | |
| 112 } | |
| 113 | |
| 114 bool TilingSetEvictionQueue::AdvanceToNextTilingRangeType() { | 208 bool TilingSetEvictionQueue::AdvanceToNextTilingRangeType() { |
| 115 // Advance to the next tiling range type within the current category or to | 209 // Advance to the next tiling range type within the current priority bin, to |
| 116 // the first tiling range type within the next category. This is done only | 210 // the required for activation tiling range type within the current priority |
| 117 // after all tilings within the previous tiling range type have been gone | 211 // bin or to the first tiling range type within the next priority bin. This |
| 118 // through. | 212 // is done only after all tilings within the previous tiling range type have |
| 213 // been gone through. | |
| 119 DCHECK_EQ(current_tiling_index_, CurrentTilingRange().end); | 214 DCHECK_EQ(current_tiling_index_, CurrentTilingRange().end); |
| 120 | 215 |
| 121 switch (current_tiling_range_type_) { | 216 switch (current_tiling_range_type_) { |
| 122 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES: | 217 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES: |
| 123 current_tiling_range_type_ = PictureLayerTilingSet::LOWER_THAN_LOW_RES; | 218 current_tiling_range_type_ = PictureLayerTilingSet::LOWER_THAN_LOW_RES; |
| 124 return true; | 219 return true; |
| 125 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: | 220 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: |
| 126 current_tiling_range_type_ = | 221 current_tiling_range_type_ = |
| 127 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES; | 222 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES; |
| 128 return true; | 223 return true; |
| 129 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES: | 224 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES: |
| 130 current_tiling_range_type_ = PictureLayerTilingSet::LOW_RES; | 225 current_tiling_range_type_ = PictureLayerTilingSet::LOW_RES; |
| 131 return true; | 226 return true; |
| 132 case PictureLayerTilingSet::LOW_RES: | 227 case PictureLayerTilingSet::LOW_RES: |
| 133 current_tiling_range_type_ = PictureLayerTilingSet::HIGH_RES; | 228 current_tiling_range_type_ = PictureLayerTilingSet::HIGH_RES; |
| 134 return true; | 229 return true; |
| 135 case PictureLayerTilingSet::HIGH_RES: | 230 case PictureLayerTilingSet::HIGH_RES: |
| 136 if (!AdvanceToNextCategory()) | 231 if (!processing_required_for_activation_tiling_ && |
| 232 current_required_for_activation_tiling_index_ != kNullTilingIndex) { | |
| 233 processing_required_for_activation_tiling_ = true; | |
| 234 return true; | |
| 235 } | |
| 236 SetCurrentRequiredForActivationTilingIndex(kNullTilingIndex); | |
| 237 processing_required_for_activation_tiling_ = false; | |
| 238 | |
| 239 if (!AdvanceToNextPriorityBin()) | |
| 137 return false; | 240 return false; |
| 138 | 241 |
| 139 current_tiling_range_type_ = PictureLayerTilingSet::HIGHER_THAN_HIGH_RES; | 242 current_tiling_range_type_ = PictureLayerTilingSet::HIGHER_THAN_HIGH_RES; |
| 140 return true; | 243 return true; |
| 141 } | 244 } |
| 142 NOTREACHED(); | 245 NOTREACHED(); |
| 143 return false; | 246 return false; |
| 144 } | 247 } |
| 145 | 248 |
| 146 bool TilingSetEvictionQueue::AdvanceToNextValidTiling() { | 249 bool TilingSetEvictionQueue::AdvanceToNextValidTiling() { |
| 147 // Advance to the next tiling within current tiling range type or to | 250 // Advance to the next tiling within current tiling range type or to |
| 148 // the first tiling within the next tiling range type or category until | 251 // the first tiling within the next tiling range type or priority bin until |
| 149 // the next eviction tile is found. This is done only after all eviction | 252 // the next eviction tile is found. This is done only after all eviction |
| 150 // tiles within the previous tiling within the current category and tiling | 253 // tiles within the previous tiling within the current priority bin and |
| 151 // range type have been gone through. | 254 // tiling range type have been gone through. |
| 152 DCHECK(!current_eviction_tile_); | 255 DCHECK(!current_eviction_tile_); |
| 153 DCHECK_NE(current_tiling_index_, CurrentTilingRange().end); | 256 DCHECK_NE(current_tiling_index_, CurrentTilingRange().end); |
| 154 | 257 |
| 155 for (;;) { | 258 for (;;) { |
| 156 ++current_tiling_index_; | 259 ++current_tiling_index_; |
| 157 while (current_tiling_index_ == CurrentTilingRange().end) { | 260 while (current_tiling_index_ == CurrentTilingRange().end) { |
| 158 if (!AdvanceToNextTilingRangeType()) | 261 if (!AdvanceToNextTilingRangeType()) |
| 159 return false; | 262 return false; |
| 160 current_tiling_index_ = CurrentTilingRange().start; | 263 current_tiling_index_ = CurrentTilingRange().start; |
| 161 } | 264 } |
| 265 current_tiling_ = tiling_set_->tiling_at(CurrentTilingIndex()); | |
| 162 | 266 |
| 163 PictureLayerTiling* tiling = tiling_set_->tiling_at(CurrentTilingIndex()); | 267 switch (current_priority_bin_) { |
| 164 eviction_tiles_ = | 268 case TilePriority::EVENTUALLY: |
| 165 tiling->GetEvictionTiles(tree_priority_, current_category_); | 269 if (current_tiling_->has_eventually_rect_tiles_) { |
| 166 next_eviction_tile_index_ = 0u; | 270 spiral_iterator_ = TilingData::ReverseSpiralDifferenceIterator( |
| 167 if (AdvanceToNextEvictionTile()) | 271 ¤t_tiling_->tiling_data_, |
| 168 return true; | 272 current_tiling_->current_eventually_rect_, |
| 273 current_tiling_->current_skewport_rect_, | |
| 274 current_tiling_->current_soon_border_rect_); | |
| 275 if (AdvanceToNextEvictionTile()) | |
| 276 return true; | |
| 277 } | |
| 278 break; | |
| 279 case TilePriority::SOON: | |
| 280 if (current_tiling_->has_skewport_rect_tiles_ || | |
| 281 current_tiling_->has_soon_border_rect_tiles_) { | |
| 282 processing_soon_border_rect_ = true; | |
| 283 if (current_tiling_->has_soon_border_rect_tiles_) | |
| 284 spiral_iterator_ = TilingData::ReverseSpiralDifferenceIterator( | |
| 285 ¤t_tiling_->tiling_data_, | |
| 286 current_tiling_->current_soon_border_rect_, | |
| 287 current_tiling_->current_skewport_rect_, | |
| 288 current_tiling_->current_visible_rect_); | |
| 289 if (AdvanceToNextEvictionTile()) | |
| 290 return true; | |
| 291 } | |
| 292 break; | |
| 293 case TilePriority::NOW: | |
| 294 if (current_tiling_->has_visible_rect_tiles_) { | |
| 295 visible_iterator_ = | |
| 296 TilingData::Iterator(¤t_tiling_->tiling_data_, | |
| 297 current_tiling_->current_visible_rect_, | |
| 298 false /* include_borders */); | |
| 299 if (AdvanceToNextEvictionTile()) | |
| 300 return true; | |
| 301 } | |
| 302 break; | |
| 303 } | |
| 169 } | 304 } |
| 170 } | 305 } |
| 171 | 306 |
| 172 PictureLayerTilingSet::TilingRange | 307 PictureLayerTilingSet::TilingRange |
| 173 TilingSetEvictionQueue::CurrentTilingRange() const { | 308 TilingSetEvictionQueue::CurrentTilingRange() const { |
| 309 if (processing_required_for_activation_tiling_) | |
| 310 return PictureLayerTilingSet::TilingRange( | |
| 311 current_required_for_activation_tiling_index_, | |
| 312 current_required_for_activation_tiling_index_ + 1); | |
| 174 return tiling_set_->GetTilingRange(current_tiling_range_type_); | 313 return tiling_set_->GetTilingRange(current_tiling_range_type_); |
| 175 } | 314 } |
| 176 | 315 |
| 177 size_t TilingSetEvictionQueue::CurrentTilingIndex() const { | 316 size_t TilingSetEvictionQueue::CurrentTilingIndex() const { |
| 178 DCHECK_NE(current_tiling_index_, CurrentTilingRange().end); | 317 DCHECK_NE(current_tiling_index_, CurrentTilingRange().end); |
| 179 switch (current_tiling_range_type_) { | 318 switch (current_tiling_range_type_) { |
| 180 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES: | 319 case PictureLayerTilingSet::HIGHER_THAN_HIGH_RES: |
| 181 case PictureLayerTilingSet::LOW_RES: | 320 case PictureLayerTilingSet::LOW_RES: |
| 182 case PictureLayerTilingSet::HIGH_RES: | 321 case PictureLayerTilingSet::HIGH_RES: |
| 183 return current_tiling_index_; | 322 return current_tiling_index_; |
| 184 // Tilings in the following ranges are accessed in reverse order. | 323 // Tilings in the following ranges are accessed in reverse order. |
| 185 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES: | 324 case PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES: |
| 186 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: { | 325 case PictureLayerTilingSet::LOWER_THAN_LOW_RES: { |
| 187 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 326 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 188 size_t current_tiling_range_offset = | 327 size_t current_tiling_range_offset = |
| 189 current_tiling_index_ - tiling_range.start; | 328 current_tiling_index_ - tiling_range.start; |
| 190 return tiling_range.end - 1 - current_tiling_range_offset; | 329 return tiling_range.end - 1 - current_tiling_range_offset; |
| 191 } | 330 } |
| 192 } | 331 } |
| 193 NOTREACHED(); | 332 NOTREACHED(); |
| 194 return 0; | 333 return 0; |
| 195 } | 334 } |
| 196 | 335 |
| 336 bool TilingSetEvictionQueue::IsSharedOutOfOrderTile(const Tile* tile) const { | |
| 337 if (!tile->is_shared()) | |
| 338 return false; | |
| 339 | |
| 340 switch (tree_priority_) { | |
| 341 case SMOOTHNESS_TAKES_PRIORITY: | |
| 342 DCHECK_EQ(ACTIVE_TREE, tree_); | |
| 343 return false; | |
| 344 case NEW_CONTENT_TAKES_PRIORITY: | |
| 345 DCHECK_EQ(PENDING_TREE, tree_); | |
| 346 return false; | |
| 347 case SAME_PRIORITY_FOR_BOTH_TREES: | |
| 348 break; | |
| 349 default: | |
|
vmpstr
2014/12/09 19:47:56
Don't put a default case (if a new case is added,
USE eero AT chromium.org
2014/12/10 12:35:46
Done. Had to add case for NUM_TREE_PRIORITIES, tho
vmpstr
2014/12/10 18:01:15
Ok, that's fine. We can remove NUM_TREE_PRIORITIES
| |
| 350 NOTREACHED(); | |
| 351 } | |
| 352 | |
| 353 // The priority for tile priority of a shared tile will be a combined | |
| 354 // priority thus return shared tiles from a higher priority tree. | |
| 355 WhichTree other_tree = tree_ == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | |
| 356 const TilePriority& priority = tile->priority(tree_); | |
| 357 const TilePriority& other_priority = tile->priority(other_tree); | |
|
vmpstr
2014/12/09 19:47:56
nit: twin_tree/twin_priority
USE eero AT chromium.org
2014/12/10 12:35:46
Done.
| |
| 358 if (priority.priority_bin != other_priority.priority_bin) | |
| 359 return priority.priority_bin < other_priority.priority_bin; | |
| 360 const bool occluded = tile->is_occluded(tree_); | |
| 361 const bool other_occluded = tile->is_occluded(other_tree); | |
| 362 if (occluded != other_occluded) | |
| 363 return !occluded; | |
| 364 if (priority.distance_to_visible != other_priority.distance_to_visible) | |
| 365 return priority.distance_to_visible < other_priority.distance_to_visible; | |
| 366 | |
| 367 // If priorities are the same, it does not matter which tree returns | |
| 368 // the tile. Let's pick the pending tree. | |
| 369 return tree_ == PENDING_TREE; | |
| 197 } | 370 } |
| 371 | |
| 372 void TilingSetEvictionQueue::SetCurrentRequiredForActivationTilingIndex( | |
| 373 size_t index) { | |
| 374 // A tiling can have required for activation tiles only if the tiling is | |
| 375 // pending high-res tiling or its twin tiling. There can thus be at most one | |
| 376 // such tiling in a tiling set. | |
| 377 DCHECK(current_required_for_activation_tiling_index_ == index || | |
| 378 current_required_for_activation_tiling_index_ == kNullTilingIndex || | |
| 379 index == kNullTilingIndex); | |
| 380 current_required_for_activation_tiling_index_ = index; | |
| 381 } | |
| 382 | |
| 383 } // namespace cc | |
| OLD | NEW |