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/raster_tile_priority_queue.h" | 5 #include "cc/resources/raster_tile_priority_queue.h" |
6 | 6 |
7 namespace cc { | 7 namespace cc { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 TreePriority tree_priority) | 115 TreePriority tree_priority) |
116 : active_iterator(layer_pair.active | 116 : active_iterator(layer_pair.active |
117 ? PictureLayerImpl::LayerRasterTileIterator( | 117 ? PictureLayerImpl::LayerRasterTileIterator( |
118 layer_pair.active, | 118 layer_pair.active, |
119 tree_priority == SMOOTHNESS_TAKES_PRIORITY) | 119 tree_priority == SMOOTHNESS_TAKES_PRIORITY) |
120 : PictureLayerImpl::LayerRasterTileIterator()), | 120 : PictureLayerImpl::LayerRasterTileIterator()), |
121 pending_iterator(layer_pair.pending | 121 pending_iterator(layer_pair.pending |
122 ? PictureLayerImpl::LayerRasterTileIterator( | 122 ? PictureLayerImpl::LayerRasterTileIterator( |
123 layer_pair.pending, | 123 layer_pair.pending, |
124 tree_priority == SMOOTHNESS_TAKES_PRIORITY) | 124 tree_priority == SMOOTHNESS_TAKES_PRIORITY) |
125 : PictureLayerImpl::LayerRasterTileIterator()) { | 125 : PictureLayerImpl::LayerRasterTileIterator()), |
126 has_both_layers(layer_pair.active && layer_pair.pending) { | |
126 } | 127 } |
127 | 128 |
128 RasterTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() { | 129 RasterTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() { |
129 } | 130 } |
130 | 131 |
131 bool RasterTilePriorityQueue::PairedPictureLayerQueue::IsEmpty() const { | 132 bool RasterTilePriorityQueue::PairedPictureLayerQueue::IsEmpty() const { |
132 return !active_iterator && !pending_iterator; | 133 return !active_iterator && !pending_iterator; |
133 } | 134 } |
134 | 135 |
135 Tile* RasterTilePriorityQueue::PairedPictureLayerQueue::Top( | 136 Tile* RasterTilePriorityQueue::PairedPictureLayerQueue::Top( |
136 TreePriority tree_priority) { | 137 TreePriority tree_priority) { |
137 DCHECK(!IsEmpty()); | 138 DCHECK(!IsEmpty()); |
138 | 139 |
139 WhichTree next_tree = NextTileIteratorTree(tree_priority); | 140 WhichTree next_tree = NextTileIteratorTree(tree_priority); |
140 PictureLayerImpl::LayerRasterTileIterator* next_iterator = | 141 PictureLayerImpl::LayerRasterTileIterator* next_iterator = |
141 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; | 142 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; |
142 DCHECK(*next_iterator); | 143 DCHECK(*next_iterator); |
143 Tile* tile = **next_iterator; | 144 Tile* tile = **next_iterator; |
145 #if DCHECK_IS_ON | |
144 DCHECK(std::find(returned_shared_tiles.begin(), | 146 DCHECK(std::find(returned_shared_tiles.begin(), |
145 returned_shared_tiles.end(), | 147 returned_shared_tiles.end(), |
146 tile) == returned_shared_tiles.end()); | 148 tile) == returned_shared_tiles.end()); |
149 #endif | |
147 return tile; | 150 return tile; |
148 } | 151 } |
149 | 152 |
150 void RasterTilePriorityQueue::PairedPictureLayerQueue::Pop( | 153 void RasterTilePriorityQueue::PairedPictureLayerQueue::Pop( |
151 TreePriority tree_priority) { | 154 TreePriority tree_priority) { |
152 DCHECK(!IsEmpty()); | 155 DCHECK(!IsEmpty()); |
153 | 156 |
154 WhichTree next_tree = NextTileIteratorTree(tree_priority); | 157 WhichTree next_tree = NextTileIteratorTree(tree_priority); |
155 PictureLayerImpl::LayerRasterTileIterator* next_iterator = | 158 PictureLayerImpl::LayerRasterTileIterator* next_iterator = |
156 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; | 159 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; |
157 DCHECK(*next_iterator); | 160 DCHECK(*next_iterator); |
161 #if DCHECK_IS_ON | |
158 returned_shared_tiles.push_back(**next_iterator); | 162 returned_shared_tiles.push_back(**next_iterator); |
163 #endif | |
159 ++(*next_iterator); | 164 ++(*next_iterator); |
160 | 165 |
161 if (IsEmpty()) | 166 for (; !IsEmpty(); ++(*next_iterator)) { |
162 return; | |
163 | |
164 next_tree = NextTileIteratorTree(tree_priority); | |
165 next_iterator = | |
166 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; | |
167 while (std::find(returned_shared_tiles.begin(), | |
168 returned_shared_tiles.end(), | |
169 **next_iterator) != returned_shared_tiles.end()) { | |
170 ++(*next_iterator); | |
171 if (IsEmpty()) | |
172 break; | |
173 next_tree = NextTileIteratorTree(tree_priority); | 167 next_tree = NextTileIteratorTree(tree_priority); |
174 next_iterator = | 168 next_iterator = |
175 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; | 169 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; |
170 if (has_both_layers) { | |
vmpstr
2014/09/04 18:26:01
nit: do
if (!has_both_layers)
break;
Tile* til
USE eero AT chromium.org
2014/09/05 07:51:26
Done. In addition, it is possible that a shared ti
| |
171 Tile* tile = **next_iterator; | |
172 if (tile->is_shared()) { | |
173 switch (tree_priority) { | |
174 case SMOOTHNESS_TAKES_PRIORITY: | |
175 // If we reach a pending tile, all shared tiles have been returned | |
176 // once as active tiles and should not be returned again. | |
177 if (next_tree != ACTIVE_TREE) | |
178 continue; | |
179 break; | |
180 case NEW_CONTENT_TAKES_PRIORITY: | |
181 // If we reach an active tile, all shared tiles have been returned | |
182 // once as pending tiles and should not be returned again. | |
183 if (next_tree != PENDING_TREE) | |
184 continue; | |
185 break; | |
186 case SAME_PRIORITY_FOR_BOTH_TREES: { | |
187 // Skip the shared tile if its local priority in the next tree is | |
188 // lower than its local priority in the other tree in order to | |
189 // skip it on the second time but not on the first time it is | |
190 // encountered. | |
191 const TilePriority& active_priority = tile->priority(ACTIVE_TREE); | |
192 const TilePriority& pending_priority = tile->priority(PENDING_TREE); | |
193 WhichTree main_tree = | |
vmpstr
2014/09/04 18:26:01
nit: Name this something like "higher_priority_tre
USE eero AT chromium.org
2014/09/05 07:51:25
Done.
| |
194 pending_priority.IsHigherPriorityThan(active_priority) | |
195 ? PENDING_TREE | |
196 : ACTIVE_TREE; | |
197 if (next_tree != main_tree) | |
198 continue; | |
199 break; | |
200 } | |
201 default: | |
202 NOTREACHED(); | |
203 } | |
204 } | |
205 } | |
206 #if DCHECK_IS_ON | |
207 DCHECK(std::find(returned_shared_tiles.begin(), | |
208 returned_shared_tiles.end(), | |
209 **next_iterator) == returned_shared_tiles.end()); | |
210 #endif | |
211 break; | |
176 } | 212 } |
177 } | 213 } |
178 | 214 |
179 WhichTree | 215 WhichTree |
180 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( | 216 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( |
181 TreePriority tree_priority) const { | 217 TreePriority tree_priority) const { |
182 DCHECK(!IsEmpty()); | 218 DCHECK(!IsEmpty()); |
183 | 219 |
184 // If we only have one iterator with tiles, return it. | 220 // If we only have one iterator with tiles, return it. |
185 if (!active_iterator) | 221 if (!active_iterator) |
(...skipping 24 matching lines...) Expand all Loading... | |
210 default: | 246 default: |
211 NOTREACHED(); | 247 NOTREACHED(); |
212 } | 248 } |
213 | 249 |
214 NOTREACHED(); | 250 NOTREACHED(); |
215 // Keep the compiler happy. | 251 // Keep the compiler happy. |
216 return ACTIVE_TREE; | 252 return ACTIVE_TREE; |
217 } | 253 } |
218 | 254 |
219 } // namespace cc | 255 } // namespace cc |
OLD | NEW |