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/resources/eviction_tile_priority_queue.h" | 5 #include "cc/resources/eviction_tile_priority_queue.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 Tile* EvictionTilePriorityQueue::PairedTilingSetQueue::Top( | 145 Tile* EvictionTilePriorityQueue::PairedTilingSetQueue::Top( |
146 TreePriority tree_priority) { | 146 TreePriority tree_priority) { |
147 DCHECK(!IsEmpty()); | 147 DCHECK(!IsEmpty()); |
148 | 148 |
149 WhichTree next_tree = NextTileIteratorTree(tree_priority); | 149 WhichTree next_tree = NextTileIteratorTree(tree_priority); |
150 TilingSetEvictionQueue* next_queue = | 150 TilingSetEvictionQueue* next_queue = |
151 next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get(); | 151 next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get(); |
152 DCHECK(next_queue && !next_queue->IsEmpty()); | 152 DCHECK(next_queue && !next_queue->IsEmpty()); |
153 | 153 |
154 Tile* tile = next_queue->Top(); | 154 Tile* tile = next_queue->Top(); |
155 DCHECK(std::find(returned_shared_tiles.begin(), | 155 DCHECK(returned_tiles_for_debug.find(tile) == returned_tiles_for_debug.end()); |
156 returned_shared_tiles.end(), | |
157 tile) == returned_shared_tiles.end()); | |
158 return tile; | 156 return tile; |
159 } | 157 } |
160 | 158 |
161 void EvictionTilePriorityQueue::PairedTilingSetQueue::Pop( | 159 void EvictionTilePriorityQueue::PairedTilingSetQueue::Pop( |
162 TreePriority tree_priority) { | 160 TreePriority tree_priority) { |
163 DCHECK(!IsEmpty()); | 161 DCHECK(!IsEmpty()); |
164 | 162 |
165 WhichTree next_tree = NextTileIteratorTree(tree_priority); | 163 WhichTree next_tree = NextTileIteratorTree(tree_priority); |
166 TilingSetEvictionQueue* next_queue = | 164 TilingSetEvictionQueue* next_queue = |
167 next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get(); | 165 next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get(); |
168 DCHECK(next_queue && !next_queue->IsEmpty()); | 166 DCHECK(next_queue && !next_queue->IsEmpty()); |
169 returned_shared_tiles.push_back(next_queue->Top()); | 167 DCHECK(returned_tiles_for_debug.insert(next_queue->Top()).second); |
170 next_queue->Pop(); | 168 next_queue->Pop(); |
171 | 169 |
172 if (IsEmpty()) | 170 // If no empty, use Top to do DCHECK the next iterator. |
vmpstr
2014/12/15 17:33:31
nit: If not empty
USE eero AT chromium.org
2014/12/16 08:50:31
Done.
| |
173 return; | 171 DCHECK(IsEmpty() || Top(tree_priority)); |
vmpstr
2014/12/15 17:33:31
nit: DCHECK_IMPLIES(!IsEmpty(), Top(tree_priority)
USE eero AT chromium.org
2014/12/16 08:50:31
Done.
| |
174 | |
175 next_tree = NextTileIteratorTree(tree_priority); | |
176 next_queue = | |
177 next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get(); | |
178 while (std::find(returned_shared_tiles.begin(), | |
179 returned_shared_tiles.end(), | |
180 next_queue->Top()) != returned_shared_tiles.end()) { | |
181 next_queue->Pop(); | |
182 if (IsEmpty()) | |
183 break; | |
184 next_tree = NextTileIteratorTree(tree_priority); | |
185 next_queue = | |
186 next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get(); | |
187 } | |
188 } | 172 } |
189 | 173 |
190 WhichTree | 174 WhichTree |
191 EvictionTilePriorityQueue::PairedTilingSetQueue::NextTileIteratorTree( | 175 EvictionTilePriorityQueue::PairedTilingSetQueue::NextTileIteratorTree( |
192 TreePriority tree_priority) const { | 176 TreePriority tree_priority) const { |
193 DCHECK(!IsEmpty()); | 177 DCHECK(!IsEmpty()); |
194 | 178 |
195 // If we only have one iterator with tiles, return it. | 179 // If we only have one iterator with tiles, return it. |
196 if (!active_queue || active_queue->IsEmpty()) | 180 if (!active_queue || active_queue->IsEmpty()) |
197 return PENDING_TREE; | 181 return PENDING_TREE; |
(...skipping 20 matching lines...) Expand all Loading... | |
218 return active_tile->required_for_activation() ? PENDING_TREE : ACTIVE_TREE; | 202 return active_tile->required_for_activation() ? PENDING_TREE : ACTIVE_TREE; |
219 } | 203 } |
220 | 204 |
221 // Return tile with a lower priority. | 205 // Return tile with a lower priority. |
222 if (pending_priority.IsHigherPriorityThan(active_priority)) | 206 if (pending_priority.IsHigherPriorityThan(active_priority)) |
223 return ACTIVE_TREE; | 207 return ACTIVE_TREE; |
224 return PENDING_TREE; | 208 return PENDING_TREE; |
225 } | 209 } |
226 | 210 |
227 } // namespace cc | 211 } // namespace cc |
OLD | NEW |