Chromium Code Reviews

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: DCHECK cleanups Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« 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...)
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 we do not have both layers (active and pending), we do not care about
166 // shared tiles because we do not encounter them twice.
167 // We do not encounter shared tile twice in that case, because in that case
168 // shared tiles are either shared between an active and a recycled layer
169 // (and we do not have nor want an iterator for a recycled layer) or shared
170 // between an active and a pending layer either of which do not have
171 // valid tile priorities (and we do not have nor want an iterator for
172 // a layer without valid tile priorities because such layers will not be
173 // displayed).
174 if (!has_both_layers)
175 break;
176
177 Tile* tile = **next_iterator;
reveman 2014/09/08 14:38:42 Consider adding a helper function for the rest of
USE eero AT chromium.org 2014/09/09 17:22:18 I am bit hesitated to do that, because the code do
178 if (!tile->is_shared())
179 break;
180
181 switch (tree_priority) {
182 case SMOOTHNESS_TAKES_PRIORITY:
183 // If we reach a pending tile, all shared tiles have been returned once
184 // as active tiles and should not be returned again.
185 if (next_tree != ACTIVE_TREE)
186 continue;
187 break;
188 case NEW_CONTENT_TAKES_PRIORITY:
189 // If we reach an active tile, all shared tiles have been returned once
190 // as pending tiles and should not be returned again.
191 if (next_tree != PENDING_TREE)
192 continue;
193 break;
194 case SAME_PRIORITY_FOR_BOTH_TREES: {
195 // Skip the shared tile if its local priority in the next tree is lower
196 // than its local priority in the other tree in order to skip it on
197 // the second time but not on the first time it is encountered.
198 const TilePriority& active_priority = tile->priority(ACTIVE_TREE);
199 const TilePriority& pending_priority = tile->priority(PENDING_TREE);
200 WhichTree higher_priority_tree =
201 pending_priority.IsHigherPriorityThan(active_priority)
202 ? PENDING_TREE
203 : ACTIVE_TREE;
204 if (next_tree != higher_priority_tree)
205 continue;
206 break;
207 }
208 default:
209 NOTREACHED();
210 }
211
212 break;
176 } 213 }
214
215 DCHECK(!*next_iterator ||
216 returned_tiles_for_debug.find(**next_iterator) ==
217 returned_tiles_for_debug.end());
177 } 218 }
178 219
179 WhichTree 220 WhichTree
180 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( 221 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
181 TreePriority tree_priority) const { 222 TreePriority tree_priority) const {
182 DCHECK(!IsEmpty()); 223 DCHECK(!IsEmpty());
183 224
184 // If we only have one iterator with tiles, return it. 225 // If we only have one iterator with tiles, return it.
185 if (!active_iterator) 226 if (!active_iterator)
186 return PENDING_TREE; 227 return PENDING_TREE;
(...skipping 23 matching lines...)
210 default: 251 default:
211 NOTREACHED(); 252 NOTREACHED();
212 } 253 }
213 254
214 NOTREACHED(); 255 NOTREACHED();
215 // Keep the compiler happy. 256 // Keep the compiler happy.
216 return ACTIVE_TREE; 257 return ACTIVE_TREE;
217 } 258 }
218 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