| Index: cc/resources/picture_pile_unittest.cc
|
| diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc
|
| index d87f92840763978a03ac71b96ae2ece3007bc019..153bcb1a8cd658db2f166ba6731c1a97cef7dd09 100644
|
| --- a/cc/resources/picture_pile_unittest.cc
|
| +++ b/cc/resources/picture_pile_unittest.cc
|
| @@ -18,9 +18,15 @@ namespace {
|
| class TestPicturePile : public PicturePile {
|
| public:
|
| using PicturePile::buffer_pixels;
|
| + using PicturePile::CanRasterSlowTileCheck;
|
| + using PicturePile::Clear;
|
|
|
| PictureMap& picture_map() { return picture_map_; }
|
|
|
| + bool CanRasterLayerRect(const gfx::Rect& layer_rect) {
|
| + return CanRaster(1.f, layer_rect);
|
| + }
|
| +
|
| typedef PicturePile::PictureInfo PictureInfo;
|
| typedef PicturePile::PictureMapKey PictureMapKey;
|
| typedef PicturePile::PictureMap PictureMap;
|
| @@ -229,5 +235,66 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) {
|
| }
|
| }
|
|
|
| +TEST_F(PicturePileTest, ClearingInvalidatesRecordedRect) {
|
| + UpdateWholeLayer();
|
| +
|
| + gfx::Rect rect(0, 0, 5, 5);
|
| + EXPECT_TRUE(pile_->CanRasterLayerRect(rect));
|
| + EXPECT_TRUE(pile_->CanRasterSlowTileCheck(rect));
|
| +
|
| + pile_->Clear();
|
| +
|
| + // Make sure both the cache-aware check (using recorded region) and the normal
|
| + // check are both false after clearing.
|
| + EXPECT_FALSE(pile_->CanRasterLayerRect(rect));
|
| + EXPECT_FALSE(pile_->CanRasterSlowTileCheck(rect));
|
| +}
|
| +
|
| +TEST_F(PicturePileTest, FrequentInvalidationCanRaster) {
|
| + // This test makes sure that if part of the page is frequently invalidated
|
| + // and doesn't get re-recorded, then CanRaster is not true for any
|
| + // tiles touching it, but is true for adjacent tiles, even if it
|
| + // overlaps on borders (edge case).
|
| + gfx::Size layer_size = gfx::ToFlooredSize(gfx::ScaleSize(pile_->size(), 4.f));
|
| + pile_->Resize(layer_size);
|
| +
|
| + gfx::Rect tile01_borders = pile_->tiling().TileBoundsWithBorder(0, 1);
|
| + gfx::Rect tile02_borders = pile_->tiling().TileBoundsWithBorder(0, 2);
|
| + gfx::Rect tile01_noborders = pile_->tiling().TileBounds(0, 1);
|
| + gfx::Rect tile02_noborders = pile_->tiling().TileBounds(0, 2);
|
| +
|
| + // Sanity check these two tiles are overlapping with borders, since this is
|
| + // what the test is trying to repro.
|
| + EXPECT_TRUE(tile01_borders.Intersects(tile02_borders));
|
| + EXPECT_FALSE(tile01_noborders.Intersects(tile02_noborders));
|
| + UpdateWholeLayer();
|
| + EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders));
|
| + EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders));
|
| + EXPECT_TRUE(pile_->CanRasterLayerRect(tile02_noborders));
|
| + EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile02_noborders));
|
| +
|
| + // Update the whole layer until the invalidation frequency is high.
|
| + for (int frame = 0; frame < 33; ++frame) {
|
| + UpdateWholeLayer();
|
| + }
|
| +
|
| + // Update once more with a small viewport.
|
| + gfx::Rect viewport(0, 0, layer_size.width(), 1);
|
| + Update(layer_rect(), viewport);
|
| +
|
| + // Sanity check some pictures exist and others don't.
|
| + EXPECT_TRUE(pile_->picture_map()
|
| + .find(TestPicturePile::PictureMapKey(0, 1))
|
| + ->second.GetPicture());
|
| + EXPECT_FALSE(pile_->picture_map()
|
| + .find(TestPicturePile::PictureMapKey(0, 2))
|
| + ->second.GetPicture());
|
| +
|
| + EXPECT_TRUE(pile_->CanRasterLayerRect(tile01_noborders));
|
| + EXPECT_TRUE(pile_->CanRasterSlowTileCheck(tile01_noborders));
|
| + EXPECT_FALSE(pile_->CanRasterLayerRect(tile02_noborders));
|
| + EXPECT_FALSE(pile_->CanRasterSlowTileCheck(tile02_noborders));
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|