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

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: Restored dropped final break. 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
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) {
vmpstr 2014/09/05 16:54:34 nit: member variables should end with _
vmpstr 2014/09/05 17:12:57 Disregard this, I forgot that it's a struct with p
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);
reveman 2014/09/05 17:08:31 If returned_shared_tiles is a std::set then you co
USE eero AT chromium.org 2014/09/08 14:08:17 It needs a .second. Without that it errors with .i
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
171 // If we do not have both layers (active and pending), we do not care about
172 // shared tiles because we do not encounter them twice.
173 // We do not encounter shared twice in that case, because in that case
174 // shared tiles are either shared between an active and a recycled layer
175 // (and we do not have nor want an iterator for a recycled layer) or shared
176 // between an active and a pending layer either of which do not have
177 // valid tile priorities (and we do not have nor want an iterator for
178 // a layer without valid tile priorities because such layers will not be
179 // displayed).
180 if (!has_both_layers)
181 break;
182
183 Tile* tile = **next_iterator;
184 if (!tile->is_shared())
185 break;
186
187 switch (tree_priority) {
188 case SMOOTHNESS_TAKES_PRIORITY:
189 // If we reach a pending tile, all shared tiles have been returned once
190 // as active tiles and should not be returned again.
191 if (next_tree != ACTIVE_TREE)
192 continue;
193 break;
194 case NEW_CONTENT_TAKES_PRIORITY:
195 // If we reach an active tile, all shared tiles have been returned once
196 // as pending tiles and should not be returned again.
197 if (next_tree != PENDING_TREE)
198 continue;
199 break;
200 case SAME_PRIORITY_FOR_BOTH_TREES: {
201 // Skip the shared tile if its local priority in the next tree is lower
202 // than its local priority in the other tree in order to skip it on
203 // the second time but not on the first time it is encountered.
204 const TilePriority& active_priority = tile->priority(ACTIVE_TREE);
205 const TilePriority& pending_priority = tile->priority(PENDING_TREE);
206 WhichTree higher_priority_tree =
207 pending_priority.IsHigherPriorityThan(active_priority)
208 ? PENDING_TREE
209 : ACTIVE_TREE;
210 if (next_tree != higher_priority_tree)
211 continue;
212 break;
213 }
214 default:
215 NOTREACHED();
216 }
217
218 break;
176 } 219 }
220
221 #if DCHECK_IS_ON
222 if (!IsEmpty()) {
reveman 2014/09/05 17:08:31 is this check necessary?
USE eero AT chromium.org 2014/09/08 14:08:17 Yes, although it can be put inside DCHECK. If the
223 DCHECK(std::find(returned_shared_tiles.begin(),
224 returned_shared_tiles.end(),
225 **next_iterator) == returned_shared_tiles.end());
226 }
227 #endif
177 } 228 }
178 229
179 WhichTree 230 WhichTree
180 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( 231 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
181 TreePriority tree_priority) const { 232 TreePriority tree_priority) const {
182 DCHECK(!IsEmpty()); 233 DCHECK(!IsEmpty());
183 234
184 // If we only have one iterator with tiles, return it. 235 // If we only have one iterator with tiles, return it.
185 if (!active_iterator) 236 if (!active_iterator)
186 return PENDING_TREE; 237 return PENDING_TREE;
(...skipping 23 matching lines...) Expand all
210 default: 261 default:
211 NOTREACHED(); 262 NOTREACHED();
212 } 263 }
213 264
214 NOTREACHED(); 265 NOTREACHED();
215 // Keep the compiler happy. 266 // Keep the compiler happy.
216 return ACTIVE_TREE; 267 return ACTIVE_TREE;
217 } 268 }
218 269
219 } // namespace cc 270 } // namespace cc
OLDNEW
« cc/resources/raster_tile_priority_queue.h ('K') | « 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