Commit bee8d3d4 authored by vmpstr's avatar vmpstr Committed by Commit bot

cc: Ensure to skip the first tile that would be returned by twin.

Since we're using a spiral iterator, we run into a situations where
a shared tile is visited by an iterator, but it is meant to be returned
by the twin (since it has higher priority). We already skip these types
of tiles in the Pop function. However, it could be the case that
the very first tile is of this kind. The fix is to ensure we skip these
types of tiles in the constructor as well.

BUG=422178
R=reveman

Review URL: https://codereview.chromium.org/647683002

Cr-Commit-Position: refs/heads/master@{#299135}
parent 84d03b89
...@@ -152,6 +152,8 @@ RasterTilePriorityQueue::PairedPictureLayerQueue::PairedPictureLayerQueue( ...@@ -152,6 +152,8 @@ RasterTilePriorityQueue::PairedPictureLayerQueue::PairedPictureLayerQueue(
tree_priority == SMOOTHNESS_TAKES_PRIORITY) tree_priority == SMOOTHNESS_TAKES_PRIORITY)
: PictureLayerImpl::LayerRasterTileIterator()), : PictureLayerImpl::LayerRasterTileIterator()),
has_both_layers(layer_pair.active && layer_pair.pending) { has_both_layers(layer_pair.active && layer_pair.pending) {
if (has_both_layers)
SkipTilesReturnedByTwin(tree_priority);
} }
RasterTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() { RasterTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() {
...@@ -185,31 +187,37 @@ void RasterTilePriorityQueue::PairedPictureLayerQueue::Pop( ...@@ -185,31 +187,37 @@ void RasterTilePriorityQueue::PairedPictureLayerQueue::Pop(
DCHECK(returned_tiles_for_debug.insert(**next_iterator).second); DCHECK(returned_tiles_for_debug.insert(**next_iterator).second);
++(*next_iterator); ++(*next_iterator);
if (has_both_layers) { if (has_both_layers)
// We have both layers (active and pending) thus we can encounter shared SkipTilesReturnedByTwin(tree_priority);
// tiles twice (from the active iterator and from the pending iterator).
for (; !IsEmpty(); ++(*next_iterator)) {
next_tree = NextTileIteratorTree(tree_priority);
next_iterator =
next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
// Accept all non-shared tiles.
const Tile* tile = **next_iterator;
if (!tile->is_shared())
break;
// Accept a shared tile if the next tree is the higher priority one
// corresponding the iterator (active or pending) which usually (but due
// to spiral iterators not always) returns the shared tile first.
if (next_tree == HigherPriorityTree(tree_priority, NULL, NULL, tile))
break;
}
}
// If no empty, use Top to do DCHECK the next iterator. // If no empty, use Top to do DCHECK the next iterator.
DCHECK(IsEmpty() || Top(tree_priority)); DCHECK(IsEmpty() || Top(tree_priority));
} }
void RasterTilePriorityQueue::PairedPictureLayerQueue::SkipTilesReturnedByTwin(
TreePriority tree_priority) {
// We have both layers (active and pending) thus we can encounter shared
// tiles twice (from the active iterator and from the pending iterator).
while (!IsEmpty()) {
WhichTree next_tree = NextTileIteratorTree(tree_priority);
PictureLayerImpl::LayerRasterTileIterator* next_iterator =
next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
// Accept all non-shared tiles.
const Tile* tile = **next_iterator;
if (!tile->is_shared())
break;
// Accept a shared tile if the next tree is the higher priority one
// corresponding the iterator (active or pending) which usually (but due
// to spiral iterators not always) returns the shared tile first.
if (next_tree == HigherPriorityTree(tree_priority, nullptr, nullptr, tile))
break;
++(*next_iterator);
}
}
WhichTree WhichTree
RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
TreePriority tree_priority) const { TreePriority tree_priority) const {
...@@ -223,7 +231,7 @@ RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree( ...@@ -223,7 +231,7 @@ RasterTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
// Now both iterators have tiles, so we have to decide based on tree priority. // Now both iterators have tiles, so we have to decide based on tree priority.
return HigherPriorityTree( return HigherPriorityTree(
tree_priority, &active_iterator, &pending_iterator, NULL); tree_priority, &active_iterator, &pending_iterator, nullptr);
} }
} // namespace cc } // namespace cc
...@@ -28,6 +28,7 @@ class CC_EXPORT RasterTilePriorityQueue { ...@@ -28,6 +28,7 @@ class CC_EXPORT RasterTilePriorityQueue {
void Pop(TreePriority tree_priority); void Pop(TreePriority tree_priority);
WhichTree NextTileIteratorTree(TreePriority tree_priority) const; WhichTree NextTileIteratorTree(TreePriority tree_priority) const;
void SkipTilesReturnedByTwin(TreePriority tree_priority);
PictureLayerImpl::LayerRasterTileIterator active_iterator; PictureLayerImpl::LayerRasterTileIterator active_iterator;
PictureLayerImpl::LayerRasterTileIterator pending_iterator; PictureLayerImpl::LayerRasterTileIterator pending_iterator;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment