Index: cc/resources/picture_layer_tiling_unittest.cc |
diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc |
index a8caf48904b835f7e1c8905379fbedcfe6b1fb85..023e64ea8b569b1fef3bcefc1c9eed3caccef3df 100644 |
--- a/cc/resources/picture_layer_tiling_unittest.cc |
+++ b/cc/resources/picture_layer_tiling_unittest.cc |
@@ -210,6 +210,102 @@ TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
EXPECT_FALSE(tiling_->TileAt(0, 0)); |
} |
+TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverTileBorders) { |
+ // The tiling has three rows and columns. |
+ Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); |
+ EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
+ EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
+ |
+ // The live tiles rect covers the whole tiling. |
+ SetLiveRectAndVerifyTiles(gfx::Rect(250, 250)); |
+ |
+ // Tiles in the right row and column exist. |
+ EXPECT_TRUE(tiling_->TileAt(2, 0)); |
+ EXPECT_TRUE(tiling_->TileAt(2, 1)); |
+ EXPECT_TRUE(tiling_->TileAt(2, 2)); |
+ EXPECT_TRUE(tiling_->TileAt(1, 2)); |
+ EXPECT_TRUE(tiling_->TileAt(0, 2)); |
+ |
+ // Shrink the live tiles rect to the very edge of the right-most and |
+ // bottom-most tiles. Their border pixels would still be inside the live |
+ // tiles rect, but the tiles should not exist just for that. |
+ int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
+ int bottom = tiling_->TilingDataForTesting().TileBounds(2, 2).y(); |
+ |
+ SetLiveRectAndVerifyTiles(gfx::Rect(right, bottom)); |
+ EXPECT_FALSE(tiling_->TileAt(2, 0)); |
+ EXPECT_FALSE(tiling_->TileAt(2, 1)); |
+ EXPECT_FALSE(tiling_->TileAt(2, 2)); |
+ EXPECT_FALSE(tiling_->TileAt(1, 2)); |
+ EXPECT_FALSE(tiling_->TileAt(0, 2)); |
+ |
+ // Including the bottom row and right column again, should create the tiles. |
+ SetLiveRectAndVerifyTiles(gfx::Rect(right + 1, bottom + 1)); |
+ |
+ EXPECT_TRUE(tiling_->TileAt(2, 0)); |
+ EXPECT_TRUE(tiling_->TileAt(2, 1)); |
+ EXPECT_TRUE(tiling_->TileAt(2, 2)); |
+ EXPECT_TRUE(tiling_->TileAt(1, 2)); |
+ EXPECT_TRUE(tiling_->TileAt(0, 2)); |
+ |
+ // Shrink the live tiles rect to the very edge of the left-most and |
+ // top-most tiles. Their border pixels would still be inside the live |
+ // tiles rect, but the tiles should not exist just for that. |
+ int left = tiling_->TilingDataForTesting().TileBounds(0, 0).right(); |
+ int top = tiling_->TilingDataForTesting().TileBounds(0, 0).bottom(); |
+ |
+ SetLiveRectAndVerifyTiles(gfx::Rect(left, top, 250 - left, 250 - top)); |
+ EXPECT_FALSE(tiling_->TileAt(0, 2)); |
+ EXPECT_FALSE(tiling_->TileAt(0, 1)); |
+ EXPECT_FALSE(tiling_->TileAt(0, 0)); |
+ EXPECT_FALSE(tiling_->TileAt(1, 0)); |
+ EXPECT_FALSE(tiling_->TileAt(2, 0)); |
+ |
+ // Including the top row and left column again, should create the tiles. |
+ SetLiveRectAndVerifyTiles( |
+ gfx::Rect(left - 1, top - 1, 250 - left, 250 - top)); |
+ |
+ EXPECT_TRUE(tiling_->TileAt(0, 2)); |
+ EXPECT_TRUE(tiling_->TileAt(0, 1)); |
+ EXPECT_TRUE(tiling_->TileAt(0, 0)); |
+ EXPECT_TRUE(tiling_->TileAt(1, 0)); |
+ EXPECT_TRUE(tiling_->TileAt(2, 0)); |
+} |
+ |
+TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverSameTiles) { |
+ // The tiling has three rows and columns. |
+ Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); |
+ EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
+ EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
+ |
+ // The live tiles rect covers the whole tiling. |
+ SetLiveRectAndVerifyTiles(gfx::Rect(250, 250)); |
+ |
+ // All tiles exist. |
+ for (int i = 0; i < 3; ++i) { |
+ for (int j = 0; j < 3; ++j) |
+ EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
+ } |
+ |
+ // Shrink the live tiles rect, but still cover all the tiles. |
+ SetLiveRectAndVerifyTiles(gfx::Rect(1, 1, 249, 249)); |
+ |
+ // All tiles still exist. |
+ for (int i = 0; i < 3; ++i) { |
+ for (int j = 0; j < 3; ++j) |
+ EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
+ } |
+ |
+ // Grow the live tiles rect, but still cover all the same tiles. |
+ SetLiveRectAndVerifyTiles(gfx::Rect(0, 0, 250, 250)); |
+ |
+ // All tiles still exist. |
+ for (int i = 0; i < 3; ++i) { |
+ for (int j = 0; j < 3; ++j) |
+ EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
+ } |
+} |
+ |
TEST_F(PictureLayerTilingIteratorTest, ResizeOverBorderPixelsDeletesTiles) { |
// Verifies that a resize with invalidation for newly exposed pixels will |
// deletes tiles that intersect that invalidation. |
@@ -513,11 +609,16 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
Tile* tile = tiling->TileAt(i, j); |
TilePriority priority = tile->priority(ACTIVE_TREE); |
- if (viewport_in_content_space.Intersects(tile->content_rect())) { |
+ int borders = tiling->TilingDataForTesting().border_texels(); |
danakj
2014/08/26 20:15:18
This test is the only one affected by the include_
|
+ gfx::Rect tile_content_rect_inside_borders = tile->content_rect(); |
+ tile_content_rect_inside_borders.Inset(borders, borders); |
enne (OOO)
2014/08/26 20:20:27
This is not correct for edge tiles. You should as
danakj
2014/08/26 20:28:46
oh right i was trying to go thru Tile* but no need
|
+ if (viewport_in_content_space.Intersects( |
+ tile_content_rect_inside_borders)) { |
EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
have_now = true; |
- } else if (soon_rect_in_content_space.Intersects(tile->content_rect())) { |
+ } else if (soon_rect_in_content_space.Intersects( |
+ tile_content_rect_inside_borders)) { |
EXPECT_EQ(TilePriority::SOON, priority.priority_bin); |
have_soon = true; |
} else { |
@@ -581,14 +682,19 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
Tile* tile = tiling->TileAt(i, j); |
TilePriority priority = tile->priority(ACTIVE_TREE); |
- if (viewport_in_content_space.Intersects(tile->content_rect())) { |
+ int borders = tiling->TilingDataForTesting().border_texels(); |
+ gfx::Rect tile_content_rect_inside_borders = tile->content_rect(); |
+ tile_content_rect_inside_borders.Inset(borders, borders); |
+ if (viewport_in_content_space.Intersects( |
+ tile_content_rect_inside_borders)) { |
EXPECT_EQ(TilePriority::NOW, priority.priority_bin) << "i: " << i |
<< " j: " << j; |
EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible) << "i: " << i |
<< " j: " << j; |
have_now = true; |
- } else if (skewport.Intersects(tile->content_rect()) || |
- soon_rect_in_content_space.Intersects(tile->content_rect())) { |
+ } else if (skewport.Intersects(tile_content_rect_inside_borders) || |
+ soon_rect_in_content_space.Intersects( |
+ tile_content_rect_inside_borders)) { |
EXPECT_EQ(TilePriority::SOON, priority.priority_bin) << "i: " << i |
<< " j: " << j; |
EXPECT_GT(priority.distance_to_visible, 0.f) << "i: " << i |
@@ -615,7 +721,7 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible); |
priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
- EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
+ EXPECT_FLOAT_EQ(4.f, priority.distance_to_visible); |
// Change the underlying layer scale. |
tiling->UpdateTilePriorities( |
@@ -628,7 +734,7 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
- EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
+ EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
// Test additional scales. |
tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client); |