diff options
author | danakj <danakj@chromium.org> | 2014-10-15 13:11:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-15 20:12:10 +0000 |
commit | 04a24ab064c9e19d17d481b7649387a2ed2402ff (patch) | |
tree | 8a78af95a86bd5e41dcee03f05fb0138135b8a14 /cc/resources/picture_pile_unittest.cc | |
parent | 55721c1fd3bb640d29491407572c7dbb56975ca5 (diff) | |
download | chromium_src-04a24ab064c9e19d17d481b7649387a2ed2402ff.zip chromium_src-04a24ab064c9e19d17d481b7649387a2ed2402ff.tar.gz chromium_src-04a24ab064c9e19d17d481b7649387a2ed2402ff.tar.bz2 |
cc: Correct expansion of invalidation for tiles outside of interest rect
Previously we subtracted the interest_rect_over_tiles from the
invalid_rect when looking to see what invalidation would not be recorded
but this computation is wrong.
Instead, we need to expand the invalidation to the bounds of the tiles
it touches (including tiles it touches on borders). Then we can subtract
the interest rect expanded to the bounds of tiles it touches (including
tiles it touches on borders). This makes each expansion match the
iteration of the given rect where we include borders.
If a tile is touched only on the border by invalidation, but the tile is
not touched even on a border by the interest rect, we want to expand the
invalidation to cover that tile.
R=enne, vmpstr
BUG=421729
Review URL: https://codereview.chromium.org/657913002
Cr-Commit-Position: refs/heads/master@{#299750}
Diffstat (limited to 'cc/resources/picture_pile_unittest.cc')
-rw-r--r-- | cc/resources/picture_pile_unittest.cc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc index 8d798d9..338d5a6 100644 --- a/cc/resources/picture_pile_unittest.cc +++ b/cc/resources/picture_pile_unittest.cc @@ -99,6 +99,82 @@ 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. + EXPECT_GT(pile_->tiling().num_tiles_x(), 2); + EXPECT_GT(pile_->tiling().num_tiles_y(), 2); + + // Record everything. + Region invalidation(tiling_rect()); + UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); + + // +----------+-----------------+-----------+ + // | | VVVV 1,0| | + // | | VVVV | | + // | | VVVV | | + // | ...|.................|... | + // | ...|.................|... | + // +----------+-----------------+-----------+ + // | ...| |... | + // | ...| |... | + // | ...| |... | + // | ...| |... | + // | ...| 1,1|... | + // +----------+-----------------+-----------+ + // | ...|.................|... | + // | ...|.................|... | + // +----------+-----------------+-----------+ + // + // .. = border pixels for tile 1,1 + // VV = interest rect (what we will record) + // + // The first invalidation is inside VV, so it does not touch border pixels of + // tile 1,1. + // + // The second invalidation goes below VV into the .. border pixels of 1,1. + + // This is the VV interest rect which 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 = interest_rect; + invalidate_border.Inset(0, 0, 0, -1); + // This should cause the tile 1,0 and 1,1 to be invalidated. The 1,1 tile will + // not be re-recorded since it does not touch the interest rect, 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)); |