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

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: update 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
« 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 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 SkipTilesReturnedByTwin(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 SkipTilesReturnedByTwin(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::SkipTilesReturnedByTwin(
198 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 while (!IsEmpty()) {
202 WhichTree next_tree = NextTileIteratorTree(tree_priority);
203 PictureLayerImpl::LayerRasterTileIterator* next_iterator =
204 next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
205
206 // Accept all non-shared tiles.
207 const Tile* tile = **next_iterator;
208 if (!tile->is_shared())
209 break;
210
211 // Accept a shared tile if the next tree is the higher priority one
212 // corresponding the iterator (active or pending) which usually (but due
213 // to spiral iterators not always) returns the shared tile first.
214 if (next_tree == HigherPriorityTree(tree_priority, nullptr, nullptr, tile))
215 break;
216
217 ++(*next_iterator);
reveman 2014/10/10 15:30:40 ah, we're advancing the iterator we decided to use
vmpstr 2014/10/10 15:36:18 Same here :)
218 }
219 }
220
213 WhichTree 221 WhichTree
214 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( 222 RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
215 TreePriority tree_priority) const { 223 TreePriority tree_priority) const {
216 DCHECK(!IsEmpty()); 224 DCHECK(!IsEmpty());
217 225
218 // If we only have one iterator with tiles, return it. 226 // If we only have one iterator with tiles, return it.
219 if (!active_iterator) 227 if (!active_iterator)
220 return PENDING_TREE; 228 return PENDING_TREE;
221 if (!pending_iterator) 229 if (!pending_iterator)
222 return ACTIVE_TREE; 230 return ACTIVE_TREE;
223 231
224 // Now both iterators have tiles, so we have to decide based on tree priority. 232 // Now both iterators have tiles, so we have to decide based on tree priority.
225 return HigherPriorityTree( 233 return HigherPriorityTree(
226 tree_priority, &active_iterator, &pending_iterator, NULL); 234 tree_priority, &active_iterator, &pending_iterator, nullptr);
227 } 235 }
228 236
229 } // namespace cc 237 } // 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