| 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 "cc/tiles/eviction_tile_priority_queue.h" | 5 #include "cc/tiles/eviction_tile_priority_queue.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 class EvictionOrderComparator { | 13 class EvictionOrderComparator { |
| 14 public: | 14 public: |
| 15 explicit EvictionOrderComparator(TreePriority tree_priority) | 15 explicit EvictionOrderComparator(TreePriority tree_priority) |
| 16 : tree_priority_(tree_priority) {} | 16 : tree_priority_(tree_priority) {} |
| 17 | 17 |
| 18 // Note that in this function, we have to return true if and only if |
| 19 // b is strictly lower priority than a. |
| 18 bool operator()( | 20 bool operator()( |
| 19 const std::unique_ptr<TilingSetEvictionQueue>& a_queue, | 21 const std::unique_ptr<TilingSetEvictionQueue>& a_queue, |
| 20 const std::unique_ptr<TilingSetEvictionQueue>& b_queue) const { | 22 const std::unique_ptr<TilingSetEvictionQueue>& b_queue) const { |
| 21 // Note that in this function, we have to return true if and only if | |
| 22 // b is strictly lower priority than a. | |
| 23 const PrioritizedTile& a_tile = a_queue->Top(); | 23 const PrioritizedTile& a_tile = a_queue->Top(); |
| 24 const PrioritizedTile& b_tile = b_queue->Top(); | 24 const PrioritizedTile& b_tile = b_queue->Top(); |
| 25 | 25 |
| 26 const TilePriority& a_priority = a_tile.priority(); | 26 const TilePriority& a_priority = a_tile.priority(); |
| 27 const TilePriority& b_priority = b_tile.priority(); | 27 const TilePriority& b_priority = b_tile.priority(); |
| 28 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; | 28 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; |
| 29 | 29 |
| 30 // If the priority bin is the same but one of the tiles is from a |
| 31 // non-drawing layer, then the drawing layer has a higher priority. |
| 32 if (b_priority.priority_bin == a_priority.priority_bin && |
| 33 b_queue->is_drawing_layer() != a_queue->is_drawing_layer()) { |
| 34 return a_queue->is_drawing_layer(); |
| 35 } |
| 36 |
| 30 // If the priority bin differs, b is lower priority if it has the higher | 37 // If the priority bin differs, b is lower priority if it has the higher |
| 31 // priority bin. | 38 // priority bin. |
| 32 if (a_priority.priority_bin != b_priority.priority_bin) | 39 if (a_priority.priority_bin != b_priority.priority_bin) |
| 33 return b_priority.priority_bin > a_priority.priority_bin; | 40 return b_priority.priority_bin > a_priority.priority_bin; |
| 34 | 41 |
| 35 // Otherwise if the resolution differs, then the order will be determined by | 42 // Otherwise if the resolution differs, then the order will be determined by |
| 36 // whether we prioritize low res or not. | 43 // whether we prioritize low res or not. |
| 37 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile | 44 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile |
| 38 // class but instead produced by the iterators. | 45 // class but instead produced by the iterators. |
| 39 if (b_priority.resolution != a_priority.resolution) { | 46 if (b_priority.resolution != a_priority.resolution) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 66 | 73 |
| 67 void CreateTilingSetEvictionQueues( | 74 void CreateTilingSetEvictionQueues( |
| 68 const std::vector<PictureLayerImpl*>& layers, | 75 const std::vector<PictureLayerImpl*>& layers, |
| 69 TreePriority tree_priority, | 76 TreePriority tree_priority, |
| 70 std::vector<std::unique_ptr<TilingSetEvictionQueue>>* queues) { | 77 std::vector<std::unique_ptr<TilingSetEvictionQueue>>* queues) { |
| 71 DCHECK(queues->empty()); | 78 DCHECK(queues->empty()); |
| 72 | 79 |
| 73 for (auto* layer : layers) { | 80 for (auto* layer : layers) { |
| 74 std::unique_ptr<TilingSetEvictionQueue> tiling_set_queue = | 81 std::unique_ptr<TilingSetEvictionQueue> tiling_set_queue = |
| 75 base::MakeUnique<TilingSetEvictionQueue>( | 82 base::MakeUnique<TilingSetEvictionQueue>( |
| 76 layer->picture_layer_tiling_set()); | 83 layer->picture_layer_tiling_set(), |
| 84 layer->contributes_to_drawn_render_surface()); |
| 77 // Queues will only contain non empty tiling sets. | 85 // Queues will only contain non empty tiling sets. |
| 78 if (!tiling_set_queue->IsEmpty()) | 86 if (!tiling_set_queue->IsEmpty()) |
| 79 queues->push_back(std::move(tiling_set_queue)); | 87 queues->push_back(std::move(tiling_set_queue)); |
| 80 } | 88 } |
| 81 std::make_heap(queues->begin(), queues->end(), | 89 std::make_heap(queues->begin(), queues->end(), |
| 82 EvictionOrderComparator(tree_priority)); | 90 EvictionOrderComparator(tree_priority)); |
| 83 } | 91 } |
| 84 | 92 |
| 85 } // namespace | 93 } // namespace |
| 86 | 94 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 : active_queues_; | 171 : active_queues_; |
| 164 } | 172 } |
| 165 | 173 |
| 166 // Return tile with a lower priority. | 174 // Return tile with a lower priority. |
| 167 if (pending_priority.IsHigherPriorityThan(active_priority)) | 175 if (pending_priority.IsHigherPriorityThan(active_priority)) |
| 168 return active_queues_; | 176 return active_queues_; |
| 169 return pending_queues_; | 177 return pending_queues_; |
| 170 } | 178 } |
| 171 | 179 |
| 172 } // namespace cc | 180 } // namespace cc |
| OLD | NEW |