Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: cc/resources/picture_pile_unittest.cc

Issue 672663002: cc: Correct expansion of invalidation for tiles outside of interest rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2171
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture_pile_unittest.cc
diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc
index d28079c0809683d7bd5143203e20475d91e3080c..5143b445ccd26b04de9278495d7487c0183c2811 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));
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698