OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/raster_tile_priority_queue_all.h" | 5 #include "cc/tiles/raster_tile_priority_queue_all.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "cc/tiles/tiling_set_raster_queue_all.h" | 8 #include "cc/tiles/tiling_set_raster_queue_all.h" |
8 | 9 |
9 namespace cc { | 10 namespace cc { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 class RasterOrderComparator { | 14 class RasterOrderComparator { |
14 public: | 15 public: |
15 explicit RasterOrderComparator(TreePriority tree_priority) | 16 explicit RasterOrderComparator(TreePriority tree_priority) |
16 : tree_priority_(tree_priority) {} | 17 : tree_priority_(tree_priority) {} |
17 | 18 |
18 bool operator()(const scoped_ptr<TilingSetRasterQueueAll>& a_queue, | 19 bool operator()( |
19 const scoped_ptr<TilingSetRasterQueueAll>& b_queue) const { | 20 const std::unique_ptr<TilingSetRasterQueueAll>& a_queue, |
| 21 const std::unique_ptr<TilingSetRasterQueueAll>& b_queue) const { |
20 // Note that in this function, we have to return true if and only if | 22 // Note that in this function, we have to return true if and only if |
21 // a is strictly lower priority than b. | 23 // a is strictly lower priority than b. |
22 const TilePriority& a_priority = a_queue->Top().priority(); | 24 const TilePriority& a_priority = a_queue->Top().priority(); |
23 const TilePriority& b_priority = b_queue->Top().priority(); | 25 const TilePriority& b_priority = b_queue->Top().priority(); |
24 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; | 26 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; |
25 | 27 |
26 // If the bin is the same but the resolution is not, then the order will be | 28 // If the bin is the same but the resolution is not, then the order will be |
27 // determined by whether we prioritize low res or not. | 29 // determined by whether we prioritize low res or not. |
28 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile | 30 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile |
29 // class but instead produced by the iterators. | 31 // class but instead produced by the iterators. |
(...skipping 14 matching lines...) Expand all Loading... |
44 return b_priority.IsHigherPriorityThan(a_priority); | 46 return b_priority.IsHigherPriorityThan(a_priority); |
45 } | 47 } |
46 | 48 |
47 private: | 49 private: |
48 TreePriority tree_priority_; | 50 TreePriority tree_priority_; |
49 }; | 51 }; |
50 | 52 |
51 void CreateTilingSetRasterQueues( | 53 void CreateTilingSetRasterQueues( |
52 const std::vector<PictureLayerImpl*>& layers, | 54 const std::vector<PictureLayerImpl*>& layers, |
53 TreePriority tree_priority, | 55 TreePriority tree_priority, |
54 std::vector<scoped_ptr<TilingSetRasterQueueAll>>* queues) { | 56 std::vector<std::unique_ptr<TilingSetRasterQueueAll>>* queues) { |
55 DCHECK(queues->empty()); | 57 DCHECK(queues->empty()); |
56 | 58 |
57 for (auto* layer : layers) { | 59 for (auto* layer : layers) { |
58 if (!layer->HasValidTilePriorities()) | 60 if (!layer->HasValidTilePriorities()) |
59 continue; | 61 continue; |
60 | 62 |
61 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); | 63 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); |
62 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; | 64 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; |
63 scoped_ptr<TilingSetRasterQueueAll> tiling_set_queue = make_scoped_ptr( | 65 std::unique_ptr<TilingSetRasterQueueAll> tiling_set_queue = |
64 new TilingSetRasterQueueAll(tiling_set, prioritize_low_res)); | 66 base::WrapUnique( |
| 67 new TilingSetRasterQueueAll(tiling_set, prioritize_low_res)); |
65 // Queues will only contain non empty tiling sets. | 68 // Queues will only contain non empty tiling sets. |
66 if (!tiling_set_queue->IsEmpty()) | 69 if (!tiling_set_queue->IsEmpty()) |
67 queues->push_back(std::move(tiling_set_queue)); | 70 queues->push_back(std::move(tiling_set_queue)); |
68 } | 71 } |
69 std::make_heap(queues->begin(), queues->end(), | 72 std::make_heap(queues->begin(), queues->end(), |
70 RasterOrderComparator(tree_priority)); | 73 RasterOrderComparator(tree_priority)); |
71 } | 74 } |
72 | 75 |
73 } // namespace | 76 } // namespace |
74 | 77 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 112 |
110 // Remove empty queues. | 113 // Remove empty queues. |
111 if (queue->IsEmpty()) { | 114 if (queue->IsEmpty()) { |
112 next_queues.pop_back(); | 115 next_queues.pop_back(); |
113 } else { | 116 } else { |
114 std::push_heap(next_queues.begin(), next_queues.end(), | 117 std::push_heap(next_queues.begin(), next_queues.end(), |
115 RasterOrderComparator(tree_priority_)); | 118 RasterOrderComparator(tree_priority_)); |
116 } | 119 } |
117 } | 120 } |
118 | 121 |
119 std::vector<scoped_ptr<TilingSetRasterQueueAll>>& | 122 std::vector<std::unique_ptr<TilingSetRasterQueueAll>>& |
120 RasterTilePriorityQueueAll::GetNextQueues() { | 123 RasterTilePriorityQueueAll::GetNextQueues() { |
121 const auto* const_this = static_cast<const RasterTilePriorityQueueAll*>(this); | 124 const auto* const_this = static_cast<const RasterTilePriorityQueueAll*>(this); |
122 const auto& const_queues = const_this->GetNextQueues(); | 125 const auto& const_queues = const_this->GetNextQueues(); |
123 return const_cast<std::vector<scoped_ptr<TilingSetRasterQueueAll>>&>( | 126 return const_cast<std::vector<std::unique_ptr<TilingSetRasterQueueAll>>&>( |
124 const_queues); | 127 const_queues); |
125 } | 128 } |
126 | 129 |
127 const std::vector<scoped_ptr<TilingSetRasterQueueAll>>& | 130 const std::vector<std::unique_ptr<TilingSetRasterQueueAll>>& |
128 RasterTilePriorityQueueAll::GetNextQueues() const { | 131 RasterTilePriorityQueueAll::GetNextQueues() const { |
129 DCHECK(!IsEmpty()); | 132 DCHECK(!IsEmpty()); |
130 | 133 |
131 // If we only have one queue with tiles, return it. | 134 // If we only have one queue with tiles, return it. |
132 if (active_queues_.empty()) | 135 if (active_queues_.empty()) |
133 return pending_queues_; | 136 return pending_queues_; |
134 if (pending_queues_.empty()) | 137 if (pending_queues_.empty()) |
135 return active_queues_; | 138 return active_queues_; |
136 | 139 |
137 const PrioritizedTile& active_tile = active_queues_.front()->Top(); | 140 const PrioritizedTile& active_tile = active_queues_.front()->Top(); |
(...skipping 30 matching lines...) Expand all Loading... |
168 return active_queues_; | 171 return active_queues_; |
169 return pending_queues_; | 172 return pending_queues_; |
170 } | 173 } |
171 default: | 174 default: |
172 NOTREACHED(); | 175 NOTREACHED(); |
173 return active_queues_; | 176 return active_queues_; |
174 } | 177 } |
175 } | 178 } |
176 | 179 |
177 } // namespace cc | 180 } // namespace cc |
OLD | NEW |