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

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

Issue 647683002: cc: Ensure to skip the first tile that would be returned by twin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 ? PictureLayerImpl::LayerRasterTileIterator( 145 ? PictureLayerImpl::LayerRasterTileIterator(
146 layer_pair.active, 146 layer_pair.active,
147 tree_priority == SMOOTHNESS_TAKES_PRIORITY) 147 tree_priority == SMOOTHNESS_TAKES_PRIORITY)
148 : PictureLayerImpl::LayerRasterTileIterator()), 148 : PictureLayerImpl::LayerRasterTileIterator()),
149 pending_iterator(layer_pair.pending 149 pending_iterator(layer_pair.pending
150 ? PictureLayerImpl::LayerRasterTileIterator( 150 ? PictureLayerImpl::LayerRasterTileIterator(
151 layer_pair.pending, 151 layer_pair.pending,
152 tree_priority == SMOOTHNESS_TAKES_PRIORITY) 152 tree_priority == SMOOTHNESS_TAKES_PRIORITY)
153 : PictureLayerImpl::LayerRasterTileIterator()), 153 : PictureLayerImpl::LayerRasterTileIterator()),
154 has_both_layers(layer_pair.active && layer_pair.pending) { 154 has_both_layers(layer_pair.active && layer_pair.pending) {
155 if (has_both_layers)
156 SkipNextSharedTileReturnedByTwin(tree_priority);
155 } 157 }
156 158
157 RasterTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() { 159 RasterTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() {
158 } 160 }
159 161
160 bool RasterTilePriorityQueue::PairedPictureLayerQueue::IsEmpty() const { 162 bool RasterTilePriorityQueue::PairedPictureLayerQueue::IsEmpty() const {
161 return !active_iterator && !pending_iterator; 163 return !active_iterator && !pending_iterator;
162 } 164 }
163 165
164 Tile* RasterTilePriorityQueue::PairedPictureLayerQueue::Top( 166 Tile* RasterTilePriorityQueue::PairedPictureLayerQueue::Top(
(...skipping 13 matching lines...) Expand all
178 TreePriority tree_priority) { 180 TreePriority tree_priority) {
179 DCHECK(!IsEmpty()); 181 DCHECK(!IsEmpty());
180 182
181 WhichTree next_tree = NextTileIteratorTree(tree_priority); 183 WhichTree next_tree = NextTileIteratorTree(tree_priority);
182 PictureLayerImpl::LayerRasterTileIterator* next_iterator = 184 PictureLayerImpl::LayerRasterTileIterator* next_iterator =
183 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator; 185 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
184 DCHECK(*next_iterator); 186 DCHECK(*next_iterator);
185 DCHECK(returned_tiles_for_debug.insert(**next_iterator).second); 187 DCHECK(returned_tiles_for_debug.insert(**next_iterator).second);
186 ++(*next_iterator); 188 ++(*next_iterator);
187 189
188 if (has_both_layers) { 190 if (has_both_layers)
189 // We have both layers (active and pending) thus we can encounter shared 191 SkipNextSharedTileReturnedByTwin(tree_priority);
190 // tiles twice (from the active iterator and from the pending iterator).
191 for (; !IsEmpty(); ++(*next_iterator)) {
192 next_tree = NextTileIteratorTree(tree_priority);
193 next_iterator =
194 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
195
196 // Accept all non-shared tiles.
197 const Tile* tile = **next_iterator;
198 if (!tile->is_shared())
199 break;
200
201 // Accept a shared tile if the next tree is the higher priority one
202 // corresponding the iterator (active or pending) which usually (but due
203 // to spiral iterators not always) returns the shared tile first.
204 if (next_tree == HigherPriorityTree(tree_priority, NULL, NULL, tile))
205 break;
206 }
207 }
208 192
209 // If no empty, use Top to do DCHECK the next iterator. 193 // If no empty, use Top to do DCHECK the next iterator.
210 DCHECK(IsEmpty() || Top(tree_priority)); 194 DCHECK(IsEmpty() || Top(tree_priority));
211 } 195 }
212 196
197 void RasterTilePriorityQueue::PairedPictureLayerQueue::
198 SkipNextSharedTileReturnedByTwin(TreePriority tree_priority) {
199 // We have both layers (active and pending) thus we can encounter shared
200 // tiles twice (from the active iterator and from the pending iterator).
201 PictureLayerImpl::LayerRasterTileIterator* next_iterator = NULL;
reveman 2014/10/10 14:27:22 I find the use of next_iterator confusing. it's in
reveman 2014/10/10 14:40:47 s/NULL/nullptr/
vmpstr 2014/10/10 15:24:05 I made this into a while loop. FWIW, I just moved
202 for (; !IsEmpty(); ++(*next_iterator)) {
203 WhichTree next_tree = NextTileIteratorTree(tree_priority);
204 next_iterator =
205 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
206
207 // Accept all non-shared tiles.
208 const Tile* tile = **next_iterator;
209 if (!tile->is_shared())
210 break;
211
212 // Accept a shared tile if the next tree is the higher priority one
213 // corresponding the iterator (active or pending) which usually (but due
214 // to spiral iterators not always) returns the shared tile first.
215 if (next_tree == HigherPriorityTree(tree_priority, NULL, NULL, tile))
216 break;
217 }
218 }
219
213 WhichTree 220 WhichTree
214 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( 221 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
215 TreePriority tree_priority) const { 222 TreePriority tree_priority) const {
216 DCHECK(!IsEmpty()); 223 DCHECK(!IsEmpty());
217 224
218 // If we only have one iterator with tiles, return it. 225 // If we only have one iterator with tiles, return it.
219 if (!active_iterator) 226 if (!active_iterator)
220 return PENDING_TREE; 227 return PENDING_TREE;
221 if (!pending_iterator) 228 if (!pending_iterator)
222 return ACTIVE_TREE; 229 return ACTIVE_TREE;
223 230
224 // Now both iterators have tiles, so we have to decide based on tree priority. 231 // Now both iterators have tiles, so we have to decide based on tree priority.
225 return HigherPriorityTree( 232 return HigherPriorityTree(
226 tree_priority, &active_iterator, &pending_iterator, NULL); 233 tree_priority, &active_iterator, &pending_iterator, NULL);
227 } 234 }
228 235
229 } // namespace cc 236 } // 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