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