Commit a98b1eab authored by enne@chromium.org's avatar enne@chromium.org

cc: Fix invalid tiling state after lost context

After a lost context, it used to be the case that a tree wouldn't need
update draw properties (implying no ManageTilings prior to AppendQuads
or MarkVisibleResourcesAsRequired).  This meant that if one layer added
a tiling and synced it to its twin, that the tiling state would not be
valid.  This synced tiling would be the first tiling, but the resolution
wouldn't be set, causing the tiling state to be bogus.

The way to fix this is to simply set_needs_update_draw_properties when a
PictureLayerImpl loses its resources.  This will force tilings to be
created and resolutions set correctly.

BUG=358350

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262756 0039d316-1c4b-4281-b951-d872f2087c98
parent 5bec78d3
......@@ -411,6 +411,11 @@ void PictureLayerImpl::ReleaseResources() {
RemoveAllTilings();
ResetRasterScale();
// To avoid an edge case after lost context where the tree is up to date but
// the tilings have not been managed, request an update draw properties
// to force tilings to get managed.
layer_tree_impl()->set_needs_update_draw_properties();
}
void PictureLayerImpl::CalculateContentsScale(
......@@ -668,6 +673,16 @@ void PictureLayerImpl::SyncTiling(
return;
tilings_->AddTiling(tiling->contents_scale());
if (!layer_tree_impl()->needs_update_draw_properties()) {
// When the tree is up to date, the set of tilings must either be empty or
// contain at least one high resolution tiling. (If it is up to date,
// then it would be invalid to sync a tiling if it is the first tiling
// on the layer, since there would be no high resolution tiling.)
SanityCheckTilingState();
// TODO(enne): temporary sanity CHECK for http://crbug.com/358350
CHECK_GT(tilings_->num_tilings(), 1u);
}
// If this tree needs update draw properties, then the tiling will
// get updated prior to drawing or activation. If this tree does not
// need update draw properties, then its transforms are up to date and
......
......@@ -1615,11 +1615,23 @@ TEST_F(PictureLayerImplTest, SyncTilingAfterReleaseResource) {
// Contrived unit test of a real crash. A layer is transparent during a
// context loss, and later becomes opaque, causing active layer SyncTiling to
// be called.
const float tile_scale = 2.f;
float new_scale = 1.f;
active_layer_->ReleaseResources();
EXPECT_FALSE(active_layer_->tilings()->TilingAtScale(tile_scale));
pending_layer_->AddTiling(2.f);
EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(tile_scale));
pending_layer_->ReleaseResources();
EXPECT_FALSE(active_layer_->tilings()->TilingAtScale(new_scale));
pending_layer_->AddTiling(new_scale);
EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(new_scale));
// UpdateDrawProperties early-outs if the tree doesn't need it. It is also
// responsible for calling ManageTilings. These checks verify that
// ReleaseResources has set needs update draw properties so that the
// new tiling gets the appropriate resolution set in ManageTilings.
EXPECT_TRUE(host_impl_.active_tree()->needs_update_draw_properties());
host_impl_.active_tree()->UpdateDrawProperties();
PictureLayerTiling* high_res =
active_layer_->tilings()->TilingAtScale(new_scale);
ASSERT_TRUE(!!high_res);
EXPECT_EQ(HIGH_RESOLUTION, high_res->resolution());
}
TEST_F(PictureLayerImplTest, TilingWithoutGpuRasterization) {
......
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