Commit 94ad9cde authored by enne@chromium.org's avatar enne@chromium.org

cc: Ignore offscreen tiles for activation

Remove the overenthusiastic DCHECK from PictureLayerImpl to make sure
that every tile that intersects the visible content rect also has a
distance to the viewport of zero.  Because the projection of the
viewport is done more precisely than the enclosing rect for the visible
content rect, it may be possible for a tile to be outside the viewport
but inside the visible content rect.

Therefore, the current DCHECKS are bogus.  Instead, skip these tiles
because they're not truly required for activation.

R=reveman@chromium.org
BUG=243437

Review URL: https://chromiumcodereview.appspot.com/16160005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203063 0039d316-1c4b-4281-b951-d872f2087c98
parent 21c1e00e
......@@ -684,11 +684,15 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const {
++iter) {
if (!*iter || !iter->tile_version().IsReadyToDraw())
continue;
// This iteration is over the visible content rect which is potentially
// less conservative than projecting the viewport into the layer.
// Ignore tiles that are know to be outside the viewport.
if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0)
continue;
missing_region.Subtract(iter.geometry_rect());
iter->mark_required_for_activation();
DCHECK_EQ(iter->priority(PENDING_TREE).distance_to_visible_in_pixels, 0);
DCHECK_EQ(iter->priority(PENDING_TREE).time_to_visible_in_seconds, 0);
}
}
......@@ -699,15 +703,21 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const {
iter;
++iter) {
// A null tile (i.e. missing recording) can just be skipped.
if (!*iter)
continue;
// This iteration is over the visible content rect which is potentially
// less conservative than projecting the viewport into the layer.
// Ignore tiles that are know to be outside the viewport.
if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0)
continue;
// If the missing region doesn't cover it, this tile is fully
// covered by acceptable tiles at other scales.
if (!*iter || !missing_region.Intersects(iter.geometry_rect()))
if (!missing_region.Intersects(iter.geometry_rect()))
continue;
iter->mark_required_for_activation();
// These must be true for this tile to end up in the NOW_BIN in TileManager.
DCHECK_EQ(iter->priority(PENDING_TREE).distance_to_visible_in_pixels, 0);
DCHECK_EQ(iter->priority(PENDING_TREE).time_to_visible_in_seconds, 0);
iter->mark_required_for_activation();
}
}
......
......@@ -825,6 +825,71 @@ TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) {
// It should be safe to call this (and MarkVisibleResourcesAsRequired)
// on a layer with no recordings.
host_impl_.pending_tree()->UpdateDrawProperties();
pending_layer_->MarkVisibleResourcesAsRequired();
}
TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) {
gfx::Size tile_size(100, 100);
gfx::Size layer_bounds(200, 100);
scoped_refptr<FakePicturePileImpl> pending_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
SetupPendingTree(pending_pile);
pending_layer_->set_fixed_tile_size(tile_size);
ASSERT_TRUE(pending_layer_->CanHaveTilings());
PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
host_impl_.pending_tree()->UpdateDrawProperties();
EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION);
// Fake set priorities.
int tile_count = 0;
for (PictureLayerTiling::CoverageIterator iter(
tiling,
pending_layer_->contents_scale_x(),
gfx::Rect(pending_layer_->visible_content_rect()));
iter;
++iter) {
if (!*iter)
continue;
Tile* tile = *iter;
TilePriority priority;
priority.resolution = HIGH_RESOLUTION;
if (++tile_count % 2) {
priority.time_to_visible_in_seconds = 0.f;
priority.distance_to_visible_in_pixels = 0.f;
} else {
priority.time_to_visible_in_seconds = 1.f;
priority.distance_to_visible_in_pixels = 1.f;
}
tile->SetPriority(PENDING_TREE, priority);
}
pending_layer_->MarkVisibleResourcesAsRequired();
int num_visible = 0;
int num_offscreen = 0;
for (PictureLayerTiling::CoverageIterator iter(
tiling,
pending_layer_->contents_scale_x(),
gfx::Rect(pending_layer_->visible_content_rect()));
iter;
++iter) {
if (!*iter)
continue;
const Tile* tile = *iter;
if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels == 0.f) {
EXPECT_TRUE(tile->required_for_activation());
num_visible++;
} else {
EXPECT_FALSE(tile->required_for_activation());
num_offscreen++;
}
}
EXPECT_GT(num_visible, 0);
EXPECT_GT(num_offscreen, 0);
}
} // namespace
......
......@@ -29,6 +29,7 @@ class FakePictureLayerImpl : public PictureLayerImpl {
using PictureLayerImpl::AddTiling;
using PictureLayerImpl::CleanUpTilingsOnActiveLayer;
using PictureLayerImpl::CanHaveTilings;
using PictureLayerImpl::MarkVisibleResourcesAsRequired;
PictureLayerImpl* twin_layer() { return twin_layer_; }
PictureLayerTilingSet* tilings() { return tilings_.get(); }
......
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