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/resources/raster_tile_priority_queue_all.h" | 5 #include "cc/resources/raster_tile_priority_queue_all.h" |
6 | 6 |
7 #include "base/containers/hash_tables.h" | |
7 #include "cc/resources/tiling_set_raster_queue_all.h" | 8 #include "cc/resources/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) {} |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 return ACTIVE_TREE; | 121 return ACTIVE_TREE; |
121 return PENDING_TREE; | 122 return PENDING_TREE; |
122 } | 123 } |
123 default: | 124 default: |
124 NOTREACHED(); | 125 NOTREACHED(); |
125 return ACTIVE_TREE; | 126 return ACTIVE_TREE; |
126 } | 127 } |
127 } | 128 } |
128 | 129 |
129 scoped_ptr<TilingSetRasterQueueAll> CreateTilingSetRasterQueue( | 130 scoped_ptr<TilingSetRasterQueueAll> CreateTilingSetRasterQueue( |
130 PictureLayerImpl* layer, | 131 PictureLayerTilingSet* tiling_set, |
131 TreePriority tree_priority) { | 132 TreePriority tree_priority) { |
132 if (!layer) | 133 if (!tiling_set) |
133 return nullptr; | 134 return nullptr; |
134 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); | |
135 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; | 135 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; |
136 return make_scoped_ptr( | 136 return make_scoped_ptr( |
137 new TilingSetRasterQueueAll(tiling_set, prioritize_low_res)); | 137 new TilingSetRasterQueueAll(tiling_set, prioritize_low_res)); |
138 } | 138 } |
139 | 139 |
140 } // namespace | 140 } // namespace |
141 | 141 |
142 RasterTilePriorityQueueAll::RasterTilePriorityQueueAll() { | 142 RasterTilePriorityQueueAll::RasterTilePriorityQueueAll() { |
143 } | 143 } |
144 | 144 |
145 RasterTilePriorityQueueAll::~RasterTilePriorityQueueAll() { | 145 RasterTilePriorityQueueAll::~RasterTilePriorityQueueAll() { |
146 } | 146 } |
147 | 147 |
148 void RasterTilePriorityQueueAll::Build( | 148 void RasterTilePriorityQueueAll::Build( |
149 const std::vector<PictureLayerImpl::Pair>& paired_layers, | 149 const base::hash_map<int, PictureLayerTilingSet::Pair>& |
150 paired_picture_layer_tiling_sets, | |
151 bool has_pending_tree, | |
150 TreePriority tree_priority) { | 152 TreePriority tree_priority) { |
151 tree_priority_ = tree_priority; | 153 tree_priority_ = tree_priority; |
152 for (std::vector<PictureLayerImpl::Pair>::const_iterator it = | 154 for (const auto& paired_tiling_set_pair : paired_picture_layer_tiling_sets) { |
153 paired_layers.begin(); | 155 const auto& paired_tiling_set = paired_tiling_set_pair.second; |
154 it != paired_layers.end(); ++it) { | 156 PictureLayerTilingSet* active = paired_tiling_set.active; |
155 paired_queues_.push_back( | 157 // Reset |active| if it doesn't have valid tile priorities. |
156 make_scoped_ptr(new PairedTilingSetQueue(*it, tree_priority_))); | 158 if (active && !active->HasValidTilePriorities()) |
enne (OOO)
2015/02/10 21:28:31
Would it make sense to unregister/register when th
vmpstr
2015/02/11 21:37:16
We process non-valid-tile-priority layers in evict
enne (OOO)
2015/02/11 21:46:16
Aha, ok! That makes sense.
| |
159 active = nullptr; | |
160 | |
161 PictureLayerTilingSet* pending = | |
162 has_pending_tree ? paired_tiling_set.pending : nullptr; | |
163 // Reset |pending| if it doesn't have valid tile priorities. | |
164 if (pending && !pending->HasValidTilePriorities()) | |
165 pending = nullptr; | |
166 | |
167 paired_queues_.push_back(make_scoped_ptr( | |
168 new PairedTilingSetQueue(active, pending, tree_priority_))); | |
157 } | 169 } |
158 paired_queues_.make_heap(RasterOrderComparator(tree_priority_)); | 170 paired_queues_.make_heap(RasterOrderComparator(tree_priority_)); |
159 } | 171 } |
160 | 172 |
161 bool RasterTilePriorityQueueAll::IsEmpty() const { | 173 bool RasterTilePriorityQueueAll::IsEmpty() const { |
162 return paired_queues_.empty() || paired_queues_.front()->IsEmpty(); | 174 return paired_queues_.empty() || paired_queues_.front()->IsEmpty(); |
163 } | 175 } |
164 | 176 |
165 Tile* RasterTilePriorityQueueAll::Top() { | 177 Tile* RasterTilePriorityQueueAll::Top() { |
166 DCHECK(!IsEmpty()); | 178 DCHECK(!IsEmpty()); |
167 return paired_queues_.front()->Top(tree_priority_); | 179 return paired_queues_.front()->Top(tree_priority_); |
168 } | 180 } |
169 | 181 |
170 void RasterTilePriorityQueueAll::Pop() { | 182 void RasterTilePriorityQueueAll::Pop() { |
171 DCHECK(!IsEmpty()); | 183 DCHECK(!IsEmpty()); |
172 | 184 |
173 paired_queues_.pop_heap(RasterOrderComparator(tree_priority_)); | 185 paired_queues_.pop_heap(RasterOrderComparator(tree_priority_)); |
174 PairedTilingSetQueue* paired_queue = paired_queues_.back(); | 186 PairedTilingSetQueue* paired_queue = paired_queues_.back(); |
175 paired_queue->Pop(tree_priority_); | 187 paired_queue->Pop(tree_priority_); |
176 paired_queues_.push_heap(RasterOrderComparator(tree_priority_)); | 188 paired_queues_.push_heap(RasterOrderComparator(tree_priority_)); |
177 } | 189 } |
178 | 190 |
179 RasterTilePriorityQueueAll::PairedTilingSetQueue::PairedTilingSetQueue() { | 191 RasterTilePriorityQueueAll::PairedTilingSetQueue::PairedTilingSetQueue() { |
180 } | 192 } |
181 | 193 |
182 RasterTilePriorityQueueAll::PairedTilingSetQueue::PairedTilingSetQueue( | 194 RasterTilePriorityQueueAll::PairedTilingSetQueue::PairedTilingSetQueue( |
183 const PictureLayerImpl::Pair& layer_pair, | 195 PictureLayerTilingSet* active_set, |
196 PictureLayerTilingSet* pending_set, | |
184 TreePriority tree_priority) | 197 TreePriority tree_priority) |
185 : active_queue_( | 198 : active_queue_(CreateTilingSetRasterQueue(active_set, tree_priority)), |
186 CreateTilingSetRasterQueue(layer_pair.active, tree_priority)), | 199 pending_queue_(CreateTilingSetRasterQueue(pending_set, tree_priority)), |
187 pending_queue_( | 200 has_both_tiling_sets_(active_set && pending_set) { |
188 CreateTilingSetRasterQueue(layer_pair.pending, tree_priority)), | |
189 has_both_layers_(layer_pair.active && layer_pair.pending) { | |
190 SkipTilesReturnedByTwin(tree_priority); | 201 SkipTilesReturnedByTwin(tree_priority); |
191 | 202 |
192 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 203 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
193 "PairedTilingSetQueue::PairedTilingSetQueue", | 204 "PairedTilingSetQueue::PairedTilingSetQueue", |
194 TRACE_EVENT_SCOPE_THREAD, "state", StateAsValue()); | 205 TRACE_EVENT_SCOPE_THREAD, "state", StateAsValue()); |
195 } | 206 } |
196 | 207 |
197 RasterTilePriorityQueueAll::PairedTilingSetQueue::~PairedTilingSetQueue() { | 208 RasterTilePriorityQueueAll::PairedTilingSetQueue::~PairedTilingSetQueue() { |
198 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 209 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
199 "PairedTilingSetQueue::~PairedTilingSetQueue", | 210 "PairedTilingSetQueue::~PairedTilingSetQueue", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 next_queue->Pop(); | 242 next_queue->Pop(); |
232 | 243 |
233 SkipTilesReturnedByTwin(tree_priority); | 244 SkipTilesReturnedByTwin(tree_priority); |
234 | 245 |
235 // If no empty, use Top to do DCHECK the next iterator. | 246 // If no empty, use Top to do DCHECK the next iterator. |
236 DCHECK(IsEmpty() || Top(tree_priority)); | 247 DCHECK(IsEmpty() || Top(tree_priority)); |
237 } | 248 } |
238 | 249 |
239 void RasterTilePriorityQueueAll::PairedTilingSetQueue::SkipTilesReturnedByTwin( | 250 void RasterTilePriorityQueueAll::PairedTilingSetQueue::SkipTilesReturnedByTwin( |
240 TreePriority tree_priority) { | 251 TreePriority tree_priority) { |
241 if (!has_both_layers_) | 252 if (!has_both_tiling_sets_) |
242 return; | 253 return; |
243 | 254 |
244 // We have both layers (active and pending) thus we can encounter shared | 255 // We have both layers (active and pending) thus we can encounter shared |
245 // tiles twice (from the active iterator and from the pending iterator). | 256 // tiles twice (from the active iterator and from the pending iterator). |
246 while (!IsEmpty()) { | 257 while (!IsEmpty()) { |
247 WhichTree next_tree = NextTileIteratorTree(tree_priority); | 258 WhichTree next_tree = NextTileIteratorTree(tree_priority); |
248 TilingSetRasterQueueAll* next_queue = | 259 TilingSetRasterQueueAll* next_queue = |
249 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get(); | 260 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get(); |
250 DCHECK(next_queue && !next_queue->IsEmpty()); | 261 DCHECK(next_queue && !next_queue->IsEmpty()); |
251 | 262 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 | 324 |
314 state->BeginDictionary("pending_queue"); | 325 state->BeginDictionary("pending_queue"); |
315 state->SetBoolean("has_tile", active_queue_has_tile); | 326 state->SetBoolean("has_tile", active_queue_has_tile); |
316 state->SetInteger("active_priority_bin", active_priority_bin); | 327 state->SetInteger("active_priority_bin", active_priority_bin); |
317 state->SetInteger("pending_priority_bin", pending_priority_bin); | 328 state->SetInteger("pending_priority_bin", pending_priority_bin); |
318 state->EndDictionary(); | 329 state->EndDictionary(); |
319 return state; | 330 return state; |
320 } | 331 } |
321 | 332 |
322 } // namespace cc | 333 } // namespace cc |
OLD | NEW |