Commit b24b256a authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

cc: Always create pending tree tiles when LCD or raster transform change

This patch ensures that when we consider whether or not to create
pending tree tiles, we always do so if the LCD state or the raster
transform change. This is required since if any of those change, then
we remove the whole active tree tiling before activating the pending
one. This means that if the pending tree tiling does not have the
tile (because it thought the active tree one would remain), we
can encounter flickering due to missing tiles.

R=wangxianzhu@chromium.org

Bug: 1127803
Change-Id: I45ad2c591de7c215f73f7081ad2e2e5be9d68925
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411492Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807016}
parent aaedfc4c
...@@ -75,9 +75,9 @@ std::unique_ptr<FakeLayerTreeHostImpl> TestLayerTreeHostBase::TakeHostImpl() { ...@@ -75,9 +75,9 @@ std::unique_ptr<FakeLayerTreeHostImpl> TestLayerTreeHostBase::TakeHostImpl() {
void TestLayerTreeHostBase::SetupDefaultTrees(const gfx::Size& layer_bounds) { void TestLayerTreeHostBase::SetupDefaultTrees(const gfx::Size& layer_bounds) {
scoped_refptr<FakeRasterSource> pending_raster_source = scoped_refptr<FakeRasterSource> pending_raster_source =
FakeRasterSource::CreateFilled(layer_bounds); FakeRasterSource::CreateFilledWithText(layer_bounds);
scoped_refptr<FakeRasterSource> active_raster_source = scoped_refptr<FakeRasterSource> active_raster_source =
FakeRasterSource::CreateFilled(layer_bounds); FakeRasterSource::CreateFilledWithText(layer_bounds);
SetupTrees(std::move(pending_raster_source), std::move(active_raster_source)); SetupTrees(std::move(pending_raster_source), std::move(active_raster_source));
} }
......
...@@ -345,6 +345,14 @@ bool PictureLayerTiling::ShouldCreateTileAt( ...@@ -345,6 +345,14 @@ bool PictureLayerTiling::ShouldCreateTileAt(
if (!TilingMatchesTileIndices(active_twin)) if (!TilingMatchesTileIndices(active_twin))
return true; return true;
// If our settings don't match the active twin, it means that the active
// tiles will all be removed when we activate. So we need all the tiles on the
// pending tree to be created. See
// PictureLayerTilingSet::CopyTilingsAndPropertiesFromPendingTwin.
if (can_use_lcd_text() != active_twin->can_use_lcd_text() ||
raster_transform() != active_twin->raster_transform())
return true;
// If the active tree can't create a tile, because of its raster source, then // If the active tree can't create a tile, because of its raster source, then
// the pending tree should create one. // the pending tree should create one.
if (!active_twin->raster_source()->CoversRect(info.enclosing_layer_rect, if (!active_twin->raster_source()->CoversRect(info.enclosing_layer_rect,
......
...@@ -1106,5 +1106,58 @@ TEST(PictureLayerTilingSetTest, TilingTranslationChanges) { ...@@ -1106,5 +1106,58 @@ TEST(PictureLayerTilingSetTest, TilingTranslationChanges) {
EXPECT_EQ(1u, active_set->tiling_at(0)->AllTilesForTesting().size()); EXPECT_EQ(1u, active_set->tiling_at(0)->AllTilesForTesting().size());
} }
TEST(PictureLayerTilingSetTest, LcdChanges) {
gfx::Size tile_size(64, 64);
FakePictureLayerTilingClient pending_client;
FakePictureLayerTilingClient active_client;
pending_client.SetTileSize(tile_size);
active_client.SetTileSize(tile_size);
std::unique_ptr<PictureLayerTilingSet> pending_set =
PictureLayerTilingSet::Create(PENDING_TREE, &pending_client, 0, 1.f, 0,
0.f);
std::unique_ptr<PictureLayerTilingSet> active_set =
PictureLayerTilingSet::Create(ACTIVE_TREE, &active_client, 0, 1.f, 0,
0.f);
active_client.set_twin_tiling_set(pending_set.get());
pending_client.set_twin_tiling_set(active_set.get());
gfx::Size layer_bounds(100, 100);
scoped_refptr<FakeRasterSource> raster_source =
FakeRasterSource::CreateFilled(layer_bounds);
const bool with_lcd_text = true;
const bool without_lcd_text = false;
gfx::AxisTransform2d raster_transform(1.f, gfx::Vector2dF());
pending_set->AddTiling(raster_transform, raster_source, with_lcd_text);
pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
// Set a priority rect so we get tiles.
pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0,
Occlusion(), false);
// Make sure all tiles are generated.
EXPECT_EQ(4u, pending_set->tiling_at(0)->AllTilesForTesting().size());
// Clone from the pending to the active tree.
active_set->UpdateTilingsToCurrentRasterSourceForActivation(
raster_source.get(), pending_set.get(), Region(), 1.f, 1.f);
// Verifies active tree cloned the tiling correctly.
ASSERT_EQ(1u, active_set->num_tilings());
EXPECT_EQ(4u, active_set->tiling_at(0)->AllTilesForTesting().size());
// Change LCD state on the pending tree
pending_set->RemoveAllTilings();
pending_set->AddTiling(raster_transform, raster_source, without_lcd_text);
pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
// Set a priority rect so we get tiles.
pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0,
Occlusion(), false);
// We should have created all tiles because lcd state changed.
EXPECT_EQ(4u, pending_set->tiling_at(0)->AllTilesForTesting().size());
}
} // namespace } // namespace
} // namespace cc } // namespace cc
...@@ -843,7 +843,7 @@ TEST_F(TileManagerTilePriorityQueueTest, ...@@ -843,7 +843,7 @@ TEST_F(TileManagerTilePriorityQueueTest,
host_impl()->active_tree()->SetDeviceViewportRect(gfx::Rect(layer_bounds)); host_impl()->active_tree()->SetDeviceViewportRect(gfx::Rect(layer_bounds));
scoped_refptr<FakeRasterSource> pending_raster_source = scoped_refptr<FakeRasterSource> pending_raster_source =
FakeRasterSource::CreateFilled(layer_bounds); FakeRasterSource::CreateFilledWithText(layer_bounds);
SetupPendingTree(pending_raster_source); SetupPendingTree(pending_raster_source);
auto* pending_child_layer = AddLayer<FakePictureLayerImpl>( auto* pending_child_layer = AddLayer<FakePictureLayerImpl>(
......
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