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