| Index: cc/tiles/picture_layer_tiling_unittest.cc
|
| diff --git a/cc/tiles/picture_layer_tiling_unittest.cc b/cc/tiles/picture_layer_tiling_unittest.cc
|
| index ec3b87024d78931c0df77bd8fef84c3b76646fd1..2c0cf7b8d6a8d6494670fc2dce35428f551c11a2 100644
|
| --- a/cc/tiles/picture_layer_tiling_unittest.cc
|
| +++ b/cc/tiles/picture_layer_tiling_unittest.cc
|
| @@ -1796,5 +1796,161 @@ TEST_F(PictureLayerTilingIteratorTest, GiantRect) {
|
| VerifyTilesExactlyCoverRect(contents_scale, content_rect);
|
| }
|
|
|
| +// Invalidates a tiling and ensures that if partial raster is enabled, the
|
| +// tiling provides tiles with an invalidated id.
|
| +TEST_F(PictureLayerTilingIteratorTest, InvalidateRespectsEnabledPartialRaster) {
|
| + gfx::Size tile_size(100, 100);
|
| + gfx::Size original_layer_size(10, 10);
|
| + client_.SetTileSize(tile_size);
|
| + client_.set_partial_raster_enabled(true);
|
| + LayerTreeSettings settings;
|
| + settings.use_partial_raster = true;
|
| +
|
| + scoped_refptr<FakeDisplayListRasterSource> raster_source =
|
| + FakeDisplayListRasterSource::CreateFilled(original_layer_size);
|
| + tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, raster_source,
|
| + &client_, settings);
|
| + tiling_->set_resolution(HIGH_RESOLUTION);
|
| + SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size));
|
| +
|
| + // Tiling only has one tile, since its total size is less than one.
|
| + Tile::Id original_id = tiling_->TileAt(0, 0)->id();
|
| + EXPECT_NE(0u, original_id);
|
| + EXPECT_EQ(0u, tiling_->TileAt(0, 0)->invalidated_id());
|
| +
|
| + Region invalidation =
|
| + SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
|
| + tiling_->Invalidate(invalidation);
|
| + EXPECT_EQ(original_id, tiling_->TileAt(0, 0)->invalidated_id());
|
| +}
|
| +
|
| +// Invalidates a tiling and ensures that if partial raster is disabled, the
|
| +// tiling does not provide tiles with an invalidated id.
|
| +TEST_F(PictureLayerTilingIteratorTest,
|
| + InvalidateRespectsDisabledPartialRaster) {
|
| + gfx::Size tile_size(100, 100);
|
| + gfx::Size original_layer_size(10, 10);
|
| + client_.SetTileSize(tile_size);
|
| + scoped_refptr<FakeDisplayListRasterSource> raster_source =
|
| + FakeDisplayListRasterSource::CreateFilled(original_layer_size);
|
| + tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, raster_source,
|
| + &client_, LayerTreeSettings());
|
| + tiling_->set_resolution(HIGH_RESOLUTION);
|
| + SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size));
|
| +
|
| + // Tiling only has one tile, since its total size is less than one.
|
| + EXPECT_NE(0u, tiling_->TileAt(0, 0)->id());
|
| + EXPECT_EQ(0u, tiling_->TileAt(0, 0)->invalidated_id());
|
| +
|
| + Region invalidation =
|
| + SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
|
| + tiling_->Invalidate(invalidation);
|
| + EXPECT_EQ(0u, tiling_->TileAt(0, 0)->invalidated_id());
|
| +}
|
| +
|
| +// Ensures that if partial raster is enabled, we copy the tile ids from the
|
| +// active tiling to the invalidated ids of any new tiles created by
|
| +// CreateMissingTilesInLiveTilesRect.
|
| +TEST_F(PictureLayerTilingIteratorTest,
|
| + CreateMissingRespectsEnabledPartialRaster) {
|
| + gfx::Size tile_size(100, 100);
|
| + gfx::Size original_layer_size(10, 10);
|
| + LayerTreeSettings settings;
|
| + settings.use_partial_raster = true;
|
| + Region invalidation =
|
| + SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
|
| + scoped_refptr<FakeDisplayListRasterSource> empty_raster_source =
|
| + FakeDisplayListRasterSource::CreatePartiallyFilled(original_layer_size,
|
| + gfx::Rect());
|
| + scoped_refptr<FakeDisplayListRasterSource> filled_raster_source =
|
| + FakeDisplayListRasterSource::CreateFilled(original_layer_size);
|
| +
|
| + // Set up the client.
|
| + client_.SetTileSize(tile_size);
|
| + client_.set_partial_raster_enabled(settings.use_partial_raster);
|
| + client_.set_invalidation(invalidation);
|
| +
|
| + // Create a twin tiling based on the filled raster source and set it to the
|
| + // client.
|
| + scoped_ptr<TestablePictureLayerTiling> twin_tiling =
|
| + TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, filled_raster_source,
|
| + &client_, settings);
|
| + twin_tiling->set_resolution(HIGH_RESOLUTION);
|
| + twin_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size));
|
| + client_.set_twin_tiling(twin_tiling.get());
|
| +
|
| + // The twin tiling should have a valid tile at 0,0.
|
| + Tile::Id original_tile_id = twin_tiling->TileAt(0, 0)->id();
|
| + DCHECK_NE(0u, original_tile_id);
|
| +
|
| + // Crate an empty tiling which will have CreateMissingTilesInLiveTilesRect
|
| + // called on it.
|
| + scoped_ptr<TestablePictureLayerTiling> empty_tiling =
|
| + TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, empty_raster_source,
|
| + &client_, settings);
|
| + empty_tiling->set_resolution(HIGH_RESOLUTION);
|
| + empty_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size));
|
| + EXPECT_EQ(nullptr, empty_tiling->TileAt(0, 0));
|
| +
|
| + // Now update the |empty_tiling|'s raster source to the filled source, so
|
| + // that it will attempt to create tiles when CreateMissingTilesInLiveTilesRect
|
| + // is called.
|
| + empty_tiling->SetRasterSourceAndResize(filled_raster_source);
|
| +
|
| + empty_tiling->CreateMissingTilesInLiveTilesRect();
|
| + EXPECT_EQ(original_tile_id, empty_tiling->TileAt(0, 0)->invalidated_id());
|
| +}
|
| +
|
| +// Ensures that if partial raster is disavbled, we do not set invalidated ids on
|
| +// any new tiles created by CreateMissingTilesInLiveTilesRect.
|
| +TEST_F(PictureLayerTilingIteratorTest,
|
| + CreateMissingRespectsDisabledPartialRaster) {
|
| + gfx::Size tile_size(100, 100);
|
| + gfx::Size original_layer_size(10, 10);
|
| + LayerTreeSettings settings;
|
| + settings.use_partial_raster = false;
|
| + Region invalidation =
|
| + SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
|
| + scoped_refptr<FakeDisplayListRasterSource> empty_raster_source =
|
| + FakeDisplayListRasterSource::CreatePartiallyFilled(original_layer_size,
|
| + gfx::Rect());
|
| + scoped_refptr<FakeDisplayListRasterSource> filled_raster_source =
|
| + FakeDisplayListRasterSource::CreateFilled(original_layer_size);
|
| +
|
| + // Set up the client.
|
| + client_.SetTileSize(tile_size);
|
| + client_.set_partial_raster_enabled(settings.use_partial_raster);
|
| + client_.set_invalidation(invalidation);
|
| +
|
| + // Create a twin tiling based on the filled raster source and set it to the
|
| + // client.
|
| + scoped_ptr<TestablePictureLayerTiling> twin_tiling =
|
| + TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, filled_raster_source,
|
| + &client_, settings);
|
| + twin_tiling->set_resolution(HIGH_RESOLUTION);
|
| + twin_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size));
|
| + client_.set_twin_tiling(twin_tiling.get());
|
| +
|
| + // The twin tiling should have a valid tile at 0,0.
|
| + DCHECK_NE(0u, twin_tiling->TileAt(0, 0)->id());
|
| +
|
| + // Crate an empty tiling which will have CreateMissingTilesInLiveTilesRect
|
| + // called on it.
|
| + scoped_ptr<TestablePictureLayerTiling> empty_tiling =
|
| + TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, empty_raster_source,
|
| + &client_, settings);
|
| + empty_tiling->set_resolution(HIGH_RESOLUTION);
|
| + empty_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size));
|
| + EXPECT_EQ(nullptr, empty_tiling->TileAt(0, 0));
|
| +
|
| + // Now update the |empty_tiling|'s raster source to the filled source, so
|
| + // that it will attempt to create tiles when CreateMissingTilesInLiveTilesRect
|
| + // is called.
|
| + empty_tiling->SetRasterSourceAndResize(filled_raster_source);
|
| +
|
| + empty_tiling->CreateMissingTilesInLiveTilesRect();
|
| + EXPECT_EQ(0u, empty_tiling->TileAt(0, 0)->invalidated_id());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|