Chromium Code Reviews| Index: cc/resources/tile_manager_unittest.cc |
| diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc |
| index 113cd7212aa766043cb34fd3fabf459750f6163e..f8c67e21167f20a24f9dbfa038299010af6495a1 100644 |
| --- a/cc/resources/tile_manager_unittest.cc |
| +++ b/cc/resources/tile_manager_unittest.cc |
| @@ -6,6 +6,7 @@ |
| #include "cc/resources/raster_tile_priority_queue.h" |
| #include "cc/resources/tile.h" |
| #include "cc/resources/tile_priority.h" |
| +#include "cc/resources/tiling_set_raster_queue_all.h" |
| #include "cc/test/begin_frame_args_test.h" |
| #include "cc/test/fake_impl_proxy.h" |
| #include "cc/test/fake_layer_tree_host_impl.h" |
| @@ -151,7 +152,8 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| SetupDefaultTrees(layer_bounds); |
| RasterTilePriorityQueue queue; |
| - host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| + host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| + RasterTilePriorityQueue::Type::ALL); |
| EXPECT_FALSE(queue.IsEmpty()); |
| size_t tile_count = 0; |
| @@ -169,7 +171,8 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| // Sanity check, all tiles should be visible. |
| std::set<Tile*> smoothness_tiles; |
| queue.Reset(); |
| - host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); |
| + host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::ALL); |
| bool had_low_res = false; |
| while (!queue.IsEmpty()) { |
| Tile* tile = queue.Top(); |
| @@ -185,6 +188,33 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| EXPECT_EQ(all_tiles, smoothness_tiles); |
| EXPECT_TRUE(had_low_res); |
| + // Check that everything is required for activation. |
| + queue.Reset(); |
| + host_impl_.BuildRasterQueue( |
| + &queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| + std::set<Tile*> required_for_activation_tiles; |
| + while (!queue.IsEmpty()) { |
| + Tile* tile = queue.Top(); |
| + EXPECT_TRUE(tile->required_for_activation()); |
| + required_for_activation_tiles.insert(tile); |
| + queue.Pop(); |
| + } |
| + EXPECT_EQ(all_tiles, required_for_activation_tiles); |
|
danakj
2015/01/08 23:24:41
this test is just checking that all tiles are requ
vmpstr
2015/01/09 20:21:40
Well it's testing that these tiles are all shared
|
| + |
| + // Check that everything is required for draw. |
| + queue.Reset(); |
| + host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| + std::set<Tile*> required_for_draw_tiles; |
| + while (!queue.IsEmpty()) { |
| + Tile* tile = queue.Top(); |
| + EXPECT_TRUE(tile->required_for_draw()); |
| + required_for_draw_tiles.insert(tile); |
| + queue.Pop(); |
| + } |
| + EXPECT_EQ(all_tiles, required_for_draw_tiles); |
|
danakj
2015/01/08 23:24:40
ditto?
vmpstr
2015/01/09 20:21:40
Ditto!
|
| + |
| Region invalidation(gfx::Rect(0, 0, 500, 500)); |
| // Invalidate the pending tree. |
| @@ -239,7 +269,10 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| size_t correct_order_tiles = 0u; |
| // Here we expect to get increasing ACTIVE_TREE priority_bin. |
| queue.Reset(); |
| - host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); |
| + host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::ALL); |
| + std::set<Tile*> actual_required_for_draw_tiles; |
| + std::set<Tile*> actual_required_for_activation_tiles; |
| while (!queue.IsEmpty()) { |
| Tile* tile = queue.Top(); |
| EXPECT_TRUE(tile); |
| @@ -275,6 +308,10 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| last_tile = tile; |
| ++tile_count; |
| smoothness_tiles.insert(tile); |
| + if (tile->required_for_draw()) |
| + actual_required_for_draw_tiles.insert(tile); |
| + if (tile->required_for_activation()) |
| + actual_required_for_activation_tiles.insert(tile); |
| queue.Pop(); |
| } |
| @@ -284,12 +321,41 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| // should check that we're _mostly_ right. |
| EXPECT_GT(correct_order_tiles, 3 * tile_count / 4); |
| + // Check that we have consistent required_for_activation tiles. |
| + queue.Reset(); |
| + host_impl_.BuildRasterQueue( |
| + &queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| + required_for_activation_tiles.clear(); |
| + while (!queue.IsEmpty()) { |
| + Tile* tile = queue.Top(); |
| + EXPECT_TRUE(tile->required_for_activation()); |
| + required_for_activation_tiles.insert(tile); |
| + queue.Pop(); |
| + } |
| + EXPECT_EQ(actual_required_for_activation_tiles, |
|
danakj
2015/01/08 23:24:41
Can you EXPECT_NE(required_for_activation, all_til
vmpstr
2015/01/09 20:21:40
Done.
|
| + required_for_activation_tiles); |
| + |
| + // Check that we have consistent required_for_draw tiles. |
| + queue.Reset(); |
| + host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| + required_for_draw_tiles.clear(); |
| + while (!queue.IsEmpty()) { |
| + Tile* tile = queue.Top(); |
| + EXPECT_TRUE(tile->required_for_draw()); |
| + required_for_draw_tiles.insert(tile); |
| + queue.Pop(); |
| + } |
| + EXPECT_EQ(actual_required_for_draw_tiles, required_for_draw_tiles); |
|
danakj
2015/01/08 23:24:41
Can you EXPECT_NE(required_for_draw, all_tiles) ?
vmpstr
2015/01/09 20:21:40
Done.
|
| + |
| std::set<Tile*> new_content_tiles; |
| last_tile = NULL; |
| size_t increasing_distance_tiles = 0u; |
| // Here we expect to get increasing PENDING_TREE priority_bin. |
| queue.Reset(); |
| - host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY); |
| + host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::ALL); |
| tile_count = 0; |
| while (!queue.IsEmpty()) { |
| Tile* tile = queue.Top(); |
| @@ -325,6 +391,34 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| // Since we don't guarantee increasing distance due to spiral iterator, we |
| // should check that we're _mostly_ right. |
| EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); |
| + |
| + // Check that we have consistent required_for_activation tiles. |
| + queue.Reset(); |
| + host_impl_.BuildRasterQueue( |
| + &queue, NEW_CONTENT_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| + required_for_activation_tiles.clear(); |
| + while (!queue.IsEmpty()) { |
| + Tile* tile = queue.Top(); |
| + EXPECT_TRUE(tile->required_for_activation()); |
| + required_for_activation_tiles.insert(tile); |
| + queue.Pop(); |
| + } |
| + EXPECT_EQ(actual_required_for_activation_tiles, |
| + required_for_activation_tiles); |
|
danakj
2015/01/08 23:24:40
ditto?
vmpstr
2015/01/09 20:21:40
Done.
|
| + |
| + // Check that we have consistent required_for_draw tiles. |
| + queue.Reset(); |
| + host_impl_.BuildRasterQueue(&queue, NEW_CONTENT_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| + required_for_draw_tiles.clear(); |
| + while (!queue.IsEmpty()) { |
| + Tile* tile = queue.Top(); |
| + EXPECT_TRUE(tile->required_for_draw()); |
| + required_for_draw_tiles.insert(tile); |
| + queue.Pop(); |
| + } |
| + EXPECT_EQ(actual_required_for_draw_tiles, required_for_draw_tiles); |
|
danakj
2015/01/08 23:24:40
moar ditto?
vmpstr
2015/01/09 20:21:40
Done.
|
| } |
| TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { |
| @@ -356,7 +450,8 @@ TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { |
| RasterTilePriorityQueue queue; |
| host_impl_.SetRequiresHighResToDraw(); |
| - host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY); |
| + host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY, |
| + RasterTilePriorityQueue::Type::ALL); |
| EXPECT_FALSE(queue.IsEmpty()); |
| // Get all the tiles that are NOW or SOON and make sure they are ready to |
| @@ -391,7 +486,8 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) { |
| size_t tile_count = 0; |
| RasterTilePriorityQueue raster_queue; |
| - host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| + host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| + RasterTilePriorityQueue::Type::ALL); |
| while (!raster_queue.IsEmpty()) { |
| ++tile_count; |
| EXPECT_TRUE(raster_queue.Top()); |
| @@ -588,7 +684,8 @@ TEST_F(TileManagerTilePriorityQueueTest, |
| std::set<Tile*> all_tiles; |
| size_t tile_count = 0; |
| RasterTilePriorityQueue raster_queue; |
| - host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| + host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| + RasterTilePriorityQueue::Type::ALL); |
| while (!raster_queue.IsEmpty()) { |
| ++tile_count; |
| EXPECT_TRUE(raster_queue.Top()); |
| @@ -793,7 +890,8 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { |
| SetupDefaultTrees(layer_bounds); |
| RasterTilePriorityQueue queue; |
| - host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| + host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| + RasterTilePriorityQueue::Type::ALL); |
| EXPECT_FALSE(queue.IsEmpty()); |
| size_t tile_count = 0; |
| @@ -817,7 +915,8 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { |
| pending_layer_->AddChild(pending_layer.Pass()); |
| } |
| - host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| + host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| + RasterTilePriorityQueue::Type::ALL); |
| EXPECT_FALSE(queue.IsEmpty()); |
| tile_count = 0; |
| @@ -838,7 +937,8 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueueEmptyLayers) { |
| SetupDefaultTrees(layer_bounds); |
| RasterTilePriorityQueue raster_queue; |
| - host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES); |
| + host_impl_.BuildRasterQueue(&raster_queue, SAME_PRIORITY_FOR_BOTH_TREES, |
| + RasterTilePriorityQueue::Type::ALL); |
| EXPECT_FALSE(raster_queue.IsEmpty()); |
| size_t tile_count = 0; |
| @@ -905,12 +1005,7 @@ TEST_F(TileManagerTilePriorityQueueTest, |
| tiling->set_resolution(HIGH_RESOLUTION); |
| tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); |
| - |
| - TilingSetRasterQueue empty_queue; |
| - EXPECT_TRUE(empty_queue.IsEmpty()); |
| - |
| std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| - |
| // Sanity check. |
| EXPECT_EQ(841u, all_tiles.size()); |
| @@ -922,7 +1017,8 @@ TEST_F(TileManagerTilePriorityQueueTest, |
| // 3. Third iteration ensures that no tiles are returned, since they were all |
| // marked as ready to draw. |
| for (int i = 0; i < 3; ++i) { |
| - TilingSetRasterQueue queue(tiling_set.get(), false); |
| + scoped_ptr<TilingSetRasterQueue> queue( |
| + new TilingSetRasterQueueAll(tiling_set.get(), false)); |
| // There are 3 bins in TilePriority. |
| bool have_tiles[3] = {}; |
| @@ -930,14 +1026,14 @@ TEST_F(TileManagerTilePriorityQueueTest, |
| // On the third iteration, we should get no tiles since everything was |
| // marked as ready to draw. |
| if (i == 2) { |
| - EXPECT_TRUE(queue.IsEmpty()); |
| + EXPECT_TRUE(queue->IsEmpty()); |
| continue; |
| } |
| - EXPECT_FALSE(queue.IsEmpty()); |
| + EXPECT_FALSE(queue->IsEmpty()); |
| std::set<Tile*> unique_tiles; |
| - unique_tiles.insert(queue.Top()); |
| - Tile* last_tile = queue.Top(); |
| + unique_tiles.insert(queue->Top()); |
| + Tile* last_tile = queue->Top(); |
| have_tiles[last_tile->priority(ACTIVE_TREE).priority_bin] = true; |
| // On the second iteration, mark everything as ready to draw (solid color). |
| @@ -945,12 +1041,12 @@ TEST_F(TileManagerTilePriorityQueueTest, |
| TileDrawInfo& draw_info = last_tile->draw_info(); |
| draw_info.SetSolidColorForTesting(SK_ColorRED); |
| } |
| - queue.Pop(); |
| + queue->Pop(); |
| int eventually_bin_order_correct_count = 0; |
| int eventually_bin_order_incorrect_count = 0; |
| - while (!queue.IsEmpty()) { |
| - Tile* new_tile = queue.Top(); |
| - queue.Pop(); |
| + while (!queue->IsEmpty()) { |
| + Tile* new_tile = queue->Top(); |
| + queue->Pop(); |
| unique_tiles.insert(new_tile); |
| TilePriority last_priority = last_tile->priority(ACTIVE_TREE); |
| @@ -1031,12 +1127,13 @@ TEST_F(TileManagerTilePriorityQueueTest, |
| Tile* last_tile = NULL; |
| int eventually_bin_order_correct_count = 0; |
| int eventually_bin_order_incorrect_count = 0; |
| - for (TilingSetRasterQueue queue(tiling_set.get(), false); !queue.IsEmpty(); |
| - queue.Pop()) { |
| + scoped_ptr<TilingSetRasterQueue> queue( |
| + new TilingSetRasterQueueAll(tiling_set.get(), false)); |
| + for (; !queue->IsEmpty(); queue->Pop()) { |
| if (!last_tile) |
| - last_tile = queue.Top(); |
| + last_tile = queue->Top(); |
| - Tile* new_tile = queue.Top(); |
| + Tile* new_tile = queue->Top(); |
| TilePriority last_priority = last_tile->priority(ACTIVE_TREE); |
| TilePriority new_priority = new_tile->priority(ACTIVE_TREE); |