Index: cc/resources/picture_pile_unittest.cc |
diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc |
index 8d798d9792fa7ed2f0ebd79296aa3662d9dfc4ba..de3845f12042c209e14d9c639485372d6925608e 100644 |
--- a/cc/resources/picture_pile_unittest.cc |
+++ b/cc/resources/picture_pile_unittest.cc |
@@ -99,6 +99,58 @@ class PicturePileTest : public PicturePileTestBase, public testing::Test { |
virtual void SetUp() override { InitializeData(); } |
}; |
+TEST_F(PicturePileTest, InvalidationOnTileBorderOutsideInterestRect) { |
+ // Don't expand the interest rect past what we invalidate. |
+ pile_->SetPixelRecordDistanceForTesting(0); |
+ |
+ gfx::Size tile_size(100, 100); |
+ pile_->tiling().SetMaxTextureSize(tile_size); |
+ |
+ gfx::Size pile_size(400, 400); |
+ SetTilingSize(pile_size); |
+ |
+ // We have multiple tiles. |
vmpstr
2014/10/15 19:00:20
Can you explain in the comment why 5 not 4?
danakj
2014/10/15 19:06:27
Cuz borders :D I could just > 1 instead.. maybe th
|
+ EXPECT_EQ(5, pile_->tiling().num_tiles_x()); |
+ EXPECT_EQ(5, pile_->tiling().num_tiles_y()); |
+ |
+ // Record everything. |
+ Region invalidation(tiling_rect()); |
+ UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); |
+ |
+ // The interest rect will be entirely inside 1,0 and not touch the border of |
+ // 1,1. |
+ gfx::Rect interest_rect( |
+ pile_->tiling().TilePositionX(1) + pile_->tiling().border_texels(), |
+ 0, |
+ 10, |
+ pile_->tiling().TileSizeY(0) - pile_->tiling().border_texels()); |
+ |
+ // Invalidate tile 1,0 only. This is a rect that avoids the borders of any |
+ // other tiles. |
+ gfx::Rect invalidate_tile = interest_rect; |
+ // This should cause the tile 1,0 to be invalidated and re-recorded. The |
+ // invalidation did not need to be expanded. |
+ invalidation = invalidate_tile; |
+ UpdateAndExpandInvalidation(&invalidation, tiling_size(), interest_rect); |
+ EXPECT_EQ(invalidate_tile, invalidation); |
+ |
+ // Invalidate tile 1,0 and 1,1 by invalidating something that only touches the |
+ // border of 1,1 (and is inside the tile bounds of 1,0). This is a 10px wide |
+ // strip from the top of the tiling onto the border pixels of tile 1,1 that |
+ // avoids border pixels of any other tiles. |
+ gfx::Rect invalidate_border(pile_->tiling().TilePositionX(1) + 10, |
+ 0, |
+ 10, |
+ pile_->tiling().TileSizeY(0)); |
vmpstr
2014/10/15 19:00:20
Can you assert somewhere that pile_->tiling().bord
danakj
2014/10/15 19:06:27
It's not 1. The recording border pixels are more.
|
+ // This should cause the tile 1,0 and 1,1 to be invalidated, and 1,1 will not |
vmpstr
2014/10/15 19:00:20
"and 1,1 will not be re-recorded" Can you elaborat
danakj
2014/10/15 19:06:27
It's because the interest rect doesn't touch it. I
|
+ // be re-recorded. So the invalidation should be expanded to cover all of 1,1. |
+ invalidation = invalidate_border; |
+ UpdateAndExpandInvalidation(&invalidation, tiling_size(), interest_rect); |
+ Region expected_invalidation = invalidate_border; |
+ expected_invalidation.Union(pile_->tiling().TileBounds(1, 1)); |
+ EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
+} |
+ |
TEST_F(PicturePileTest, SmallInvalidateInflated) { |
// Invalidate something inside a tile. |
Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); |