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