Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1638)

Side by Side Diff: cc/resources/raster_tile_priority_queue.cc

Issue 541843002: cc: Optimise shared raster tile handling in raster tile priority queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop special casing the same tile case. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/raster_tile_priority_queue.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
144 DCHECK(std::find(returned_shared_tiles.begin(), 145 DCHECK(returned_tiles_for_debug.find(tile) == returned_tiles_for_debug.end());
145 returned_shared_tiles.end(),
146 tile) == returned_shared_tiles.end());
147 return tile; 146 return tile;
148 } 147 }
149 148
150 void RasterTilePriorityQueue::PairedPictureLayerQueue::Pop( 149 void RasterTilePriorityQueue::PairedPictureLayerQueue::Pop(
151 TreePriority tree_priority) { 150 TreePriority tree_priority) {
152 DCHECK(!IsEmpty()); 151 DCHECK(!IsEmpty());
153 152
154 WhichTree next_tree = NextTileIteratorTree(tree_priority); 153 WhichTree next_tree = NextTileIteratorTree(tree_priority);
155 PictureLayerImpl::LayerRasterTileIterator* next_iterator = 154 PictureLayerImpl::LayerRasterTileIterator* next_iterator =
156 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; 155 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
157 DCHECK(*next_iterator); 156 DCHECK(*next_iterator);
158 returned_shared_tiles.push_back(**next_iterator); 157 DCHECK(returned_tiles_for_debug.insert(**next_iterator).second);
159 ++(*next_iterator); 158 ++(*next_iterator);
160 159
161 if (IsEmpty()) 160 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); 161 next_tree = NextTileIteratorTree(tree_priority);
174 next_iterator = 162 next_iterator =
175 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; 163 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
164
165 if (has_both_layers) {
reveman 2014/09/09 18:26:47 doesn't seem to make sense to enter this loop unle
USE eero AT chromium.org 2014/09/10 07:38:23 Yes, that could be done. It is just that the DCHEC
USE eero AT chromium.org 2014/09/10 14:08:26 It turned out to be quite easy to work-a-round tha
166 // We have both layers (active and pending) thus we can encounter shared
167 // tiles twice (from the active iterator and from the pending iterator).
168 // Skip a shared tile if the tree is not the primary one corresponding
169 // the iterator (active or pending) which usually (but due to spiral
170 // iterators not always) returns the shared tile first.
171 const Tile* tile = **next_iterator;
172 if (tile->is_shared() &&
173 next_tree != PrimarySharedTileTree(tree_priority, tile))
174 continue;
175 }
176
177 break;
reveman 2014/09/09 18:26:47 I think it would be less awkward to keep iterating
USE eero AT chromium.org 2014/09/10 07:38:24 Done.
176 } 178 }
179
180 DCHECK(!*next_iterator ||
181 returned_tiles_for_debug.find(**next_iterator) ==
182 returned_tiles_for_debug.end());
177 } 183 }
178 184
179 WhichTree 185 WhichTree
180 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( 186 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
181 TreePriority tree_priority) const { 187 TreePriority tree_priority) const {
182 DCHECK(!IsEmpty()); 188 DCHECK(!IsEmpty());
183 189
184 // If we only have one iterator with tiles, return it. 190 // If we only have one iterator with tiles, return it.
185 if (!active_iterator) 191 if (!active_iterator)
186 return PENDING_TREE; 192 return PENDING_TREE;
187 if (!pending_iterator) 193 if (!pending_iterator)
188 return ACTIVE_TREE; 194 return ACTIVE_TREE;
189 195
190 // Now both iterators have tiles, so we have to decide based on tree priority. 196 // Now both iterators have tiles, so we have to decide based on tree priority.
197 // Keep in sync with PrimarySharedTileTree.
191 switch (tree_priority) { 198 switch (tree_priority) {
192 case SMOOTHNESS_TAKES_PRIORITY: 199 case SMOOTHNESS_TAKES_PRIORITY:
193 return ACTIVE_TREE; 200 return ACTIVE_TREE;
194 case NEW_CONTENT_TAKES_PRIORITY: 201 case NEW_CONTENT_TAKES_PRIORITY:
195 return PENDING_TREE; 202 return PENDING_TREE;
196 case SAME_PRIORITY_FOR_BOTH_TREES: { 203 case SAME_PRIORITY_FOR_BOTH_TREES: {
197 const Tile* active_tile = *active_iterator; 204 const Tile* active_tile = *active_iterator;
198 const Tile* pending_tile = *pending_iterator; 205 const Tile* pending_tile = *pending_iterator;
199 if (active_tile == pending_tile)
200 return ACTIVE_TREE;
201 206
202 const TilePriority& active_priority = active_tile->priority(ACTIVE_TREE); 207 const TilePriority& active_priority = active_tile->priority(ACTIVE_TREE);
203 const TilePriority& pending_priority = 208 const TilePriority& pending_priority =
204 pending_tile->priority(PENDING_TREE); 209 pending_tile->priority(PENDING_TREE);
205 210
206 if (active_priority.IsHigherPriorityThan(pending_priority)) 211 if (active_priority.IsHigherPriorityThan(pending_priority))
207 return ACTIVE_TREE; 212 return ACTIVE_TREE;
208 return PENDING_TREE; 213 return PENDING_TREE;
209 } 214 }
210 default: 215 default:
211 NOTREACHED(); 216 NOTREACHED();
212 } 217 }
213 218
214 NOTREACHED(); 219 NOTREACHED();
215 // Keep the compiler happy. 220 // Keep the compiler happy.
216 return ACTIVE_TREE; 221 return ACTIVE_TREE;
217 } 222 }
218 223
224 WhichTree
225 RasterTilePriorityQueue::PairedPictureLayerQueue::PrimarySharedTileTree(
reveman 2014/09/09 18:26:47 PrimaryTreeForSharedTile?
USE eero AT chromium.org 2014/09/10 07:38:23 Done.
226 TreePriority tree_priority,
227 const Tile* tile) const {
228 DCHECK(has_both_layers && tile->is_shared());
229
230 // Keep in sync with NextTileIteratorTree.
reveman 2014/09/09 18:26:47 Instead of having to keep these functions in sync,
USE eero AT chromium.org 2014/09/10 07:38:23 The only but is that for the first two cases there
USE eero AT chromium.org 2014/09/10 14:08:26 It does have a major impact. Half of the improveme
reveman 2014/09/10 18:53:35 I'm not sure I understand the reasoning here. I'm
231 switch (tree_priority) {
232 case SMOOTHNESS_TAKES_PRIORITY:
233 // Return shared tiles as active tiles as we return all active tiles
234 // before the first pending tile.
235 return ACTIVE_TREE;
236 case NEW_CONTENT_TAKES_PRIORITY:
237 // Return shared tiles as pending tiles as we return all pending tiles
238 // before the first active tile.
239 return PENDING_TREE;
240 case SAME_PRIORITY_FOR_BOTH_TREES: {
241 // Return shared tiles as either active or pending tiles based on their
242 // active and pending priorities order to return them on the first time
243 // they are encountered and to skip them on the second time.
244 const TilePriority& active_priority = tile->priority(ACTIVE_TREE);
245 const TilePriority& pending_priority = tile->priority(PENDING_TREE);
246
247 if (active_priority.IsHigherPriorityThan(pending_priority))
248 return ACTIVE_TREE;
249 return PENDING_TREE;
250 }
251 default:
252 NOTREACHED();
253 }
254
255 NOTREACHED();
reveman 2014/09/09 18:26:47 You're just being consistent here and that's good
USE eero AT chromium.org 2014/09/10 07:38:24 Done.
256 // Keep the compiler happy.
257 return ACTIVE_TREE;
258 }
259
219 } // namespace cc 260 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/raster_tile_priority_queue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698