Commit 2451de62 authored by e.hakkinen's avatar e.hakkinen Committed by Commit bot

cc: Fix layer raster tile iterator not to skip a tile erroneously.

Fix the constructor of the layer raster tile iterator to never advance
a tiling raster tile iterator. This fixes the iterator not to skip the
first tile returned by a tiling raster tile iterator even if there are
no NOW tiles but only SOON and/or EVENTUALLY tiles.

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

Cr-Commit-Position: refs/heads/master@{#294188}
parent a80fc361
......@@ -1568,7 +1568,7 @@ PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator(
IteratorType index = stages_[current_stage_].iterator_type;
TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
if (!iterators_[index] || iterators_[index].get_type() != tile_type)
++(*this);
AdvanceToNextStage();
}
PictureLayerImpl::LayerRasterTileIterator::~LayerRasterTileIterator() {}
......@@ -1584,22 +1584,13 @@ operator++() {
TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
// First advance the iterator.
if (iterators_[index])
++iterators_[index];
if (iterators_[index] && iterators_[index].get_type() == tile_type)
return *this;
DCHECK(iterators_[index]);
DCHECK(iterators_[index].get_type() == tile_type);
++iterators_[index];
// Next, advance the stage.
++current_stage_;
while (current_stage_ < arraysize(stages_)) {
index = stages_[current_stage_].iterator_type;
tile_type = stages_[current_stage_].tile_type;
if (!iterators_[index] || iterators_[index].get_type() != tile_type)
AdvanceToNextStage();
if (iterators_[index] && iterators_[index].get_type() == tile_type)
break;
++current_stage_;
}
return *this;
}
......@@ -1623,6 +1614,19 @@ const Tile* PictureLayerImpl::LayerRasterTileIterator::operator*() const {
return *iterators_[index];
}
void PictureLayerImpl::LayerRasterTileIterator::AdvanceToNextStage() {
DCHECK_LT(current_stage_, arraysize(stages_));
++current_stage_;
while (current_stage_ < arraysize(stages_)) {
IteratorType index = stages_[current_stage_].iterator_type;
TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
if (iterators_[index] && iterators_[index].get_type() == tile_type)
break;
++current_stage_;
}
}
PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator()
: layer_(NULL),
tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES),
......
......@@ -51,6 +51,8 @@ class CC_EXPORT PictureLayerImpl
private:
enum IteratorType { LOW_RES, HIGH_RES, NUM_ITERATORS };
void AdvanceToNextStage();
PictureLayerImpl* layer_;
struct IterationStage {
......
......@@ -2498,6 +2498,11 @@ TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForGpuRasterization) {
}
TEST_F(PictureLayerImplTest, LayerRasterTileIterator) {
base::TimeTicks time_ticks;
time_ticks += base::TimeDelta::FromMilliseconds(1);
host_impl_.SetCurrentBeginFrameArgs(
CreateBeginFrameArgsForTesting(time_ticks));
gfx::Size tile_size(100, 100);
gfx::Size layer_bounds(1000, 1000);
......@@ -2563,6 +2568,45 @@ TEST_F(PictureLayerImplTest, LayerRasterTileIterator) {
EXPECT_EQ(low_res_tile_count + high_res_tile_count + non_ideal_tile_count,
unique_tiles.size());
// No NOW tiles.
time_ticks += base::TimeDelta::FromMilliseconds(200);
host_impl_.SetCurrentBeginFrameArgs(
CreateBeginFrameArgsForTesting(time_ticks));
pending_layer_->draw_properties().visible_content_rect =
gfx::Rect(1100, 1100, 500, 500);
pending_layer_->UpdateTiles(NULL);
unique_tiles.clear();
high_res_tile_count = 0u;
for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false);
it;
++it) {
Tile* tile = *it;
TilePriority priority = tile->priority(PENDING_TREE);
EXPECT_TRUE(tile);
// Non-high res tiles only get visible tiles.
EXPECT_EQ(HIGH_RESOLUTION, priority.resolution);
EXPECT_NE(TilePriority::NOW, priority.priority_bin);
high_res_tile_count += priority.resolution == HIGH_RESOLUTION;
unique_tiles.insert(tile);
}
EXPECT_EQ(16u, high_res_tile_count);
EXPECT_EQ(high_res_tile_count, unique_tiles.size());
time_ticks += base::TimeDelta::FromMilliseconds(200);
host_impl_.SetCurrentBeginFrameArgs(
CreateBeginFrameArgsForTesting(time_ticks));
pending_layer_->draw_properties().visible_content_rect =
gfx::Rect(0, 0, 500, 500);
pending_layer_->UpdateTiles(NULL);
std::vector<Tile*> high_res_tiles = high_res_tiling->AllTilesForTesting();
for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin();
tile_it != high_res_tiles.end();
......
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