OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/eviction_tile_priority_queue.h" | 5 #include "cc/resources/eviction_tile_priority_queue.h" |
6 #include "cc/resources/raster_tile_priority_queue.h" | 6 #include "cc/resources/raster_tile_priority_queue.h" |
7 #include "cc/resources/resource_pool.h" | 7 #include "cc/resources/resource_pool.h" |
8 #include "cc/resources/tile.h" | 8 #include "cc/resources/tile.h" |
9 #include "cc/resources/tile_priority.h" | 9 #include "cc/resources/tile_priority.h" |
10 #include "cc/resources/tiling_set_raster_queue_all.h" | 10 #include "cc/resources/tiling_set_raster_queue_all.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 | 176 |
177 // Sanity check, all tiles should be visible. | 177 // Sanity check, all tiles should be visible. |
178 std::set<Tile*> smoothness_tiles; | 178 std::set<Tile*> smoothness_tiles; |
179 queue = host_impl_.BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, | 179 queue = host_impl_.BuildRasterQueue(SMOOTHNESS_TAKES_PRIORITY, |
180 RasterTilePriorityQueue::Type::ALL); | 180 RasterTilePriorityQueue::Type::ALL); |
181 bool had_low_res = false; | 181 bool had_low_res = false; |
182 while (!queue->IsEmpty()) { | 182 while (!queue->IsEmpty()) { |
183 Tile* tile = queue->Top(); | 183 Tile* tile = queue->Top(); |
184 EXPECT_TRUE(tile); | 184 EXPECT_TRUE(tile); |
185 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | 185 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); |
186 EXPECT_EQ(TilePriority::NOW, tile->priority(PENDING_TREE).priority_bin); | |
187 if (tile->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) | 186 if (tile->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) |
188 had_low_res = true; | 187 had_low_res = true; |
189 else | 188 else |
190 smoothness_tiles.insert(tile); | 189 smoothness_tiles.insert(tile); |
191 queue->Pop(); | 190 queue->Pop(); |
192 } | 191 } |
193 EXPECT_EQ(all_tiles, smoothness_tiles); | 192 EXPECT_EQ(all_tiles, smoothness_tiles); |
194 EXPECT_TRUE(had_low_res); | 193 EXPECT_TRUE(had_low_res); |
195 | 194 |
196 // Check that everything is required for activation. | 195 // Check that everything is required for activation. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 } | 425 } |
427 | 426 |
428 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) { | 427 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) { |
429 const gfx::Size layer_bounds(1000, 1000); | 428 const gfx::Size layer_bounds(1000, 1000); |
430 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 429 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
431 SetupDefaultTrees(layer_bounds); | 430 SetupDefaultTrees(layer_bounds); |
432 | 431 |
433 // Use a tile's content rect as an invalidation. We should inset it a bit to | 432 // Use a tile's content rect as an invalidation. We should inset it a bit to |
434 // ensure that border math doesn't invalidate neighbouring tiles. | 433 // ensure that border math doesn't invalidate neighbouring tiles. |
435 gfx::Rect invalidation = | 434 gfx::Rect invalidation = |
436 pending_layer_->HighResTiling()->TileAt(1, 0)->content_rect(); | 435 active_layer_->HighResTiling()->TileAt(1, 0)->content_rect(); |
437 invalidation.Inset(2, 2); | 436 invalidation.Inset(2, 2); |
438 | 437 |
439 pending_layer_->set_invalidation(invalidation); | 438 pending_layer_->set_invalidation(invalidation); |
440 pending_layer_->HighResTiling()->Invalidate(invalidation); | 439 pending_layer_->HighResTiling()->Invalidate(invalidation); |
440 pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect(); | |
441 pending_layer_->LowResTiling()->Invalidate(invalidation); | 441 pending_layer_->LowResTiling()->Invalidate(invalidation); |
442 pending_layer_->LowResTiling()->CreateMissingTilesInLiveTilesRect(); | |
442 | 443 |
443 // Sanity checks: Tile at 0, 0 should be the same on both trees, tile at 1, 0 | 444 // Sanity checks: Tile at 0, 0 not exist on the pending tree (it's not |
444 // should be different. | 445 // invalidated). Tile 1, 0 should exist on both. |
445 EXPECT_TRUE(pending_layer_->HighResTiling()->TileAt(0, 0)); | 446 EXPECT_FALSE(pending_layer_->HighResTiling()->TileAt(0, 0)); |
446 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(0, 0)); | 447 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(0, 0)); |
447 EXPECT_EQ(pending_layer_->HighResTiling()->TileAt(0, 0), | |
448 active_layer_->HighResTiling()->TileAt(0, 0)); | |
449 EXPECT_TRUE(pending_layer_->HighResTiling()->TileAt(1, 0)); | 448 EXPECT_TRUE(pending_layer_->HighResTiling()->TileAt(1, 0)); |
450 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(1, 0)); | 449 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(1, 0)); |
451 EXPECT_NE(pending_layer_->HighResTiling()->TileAt(1, 0), | 450 EXPECT_NE(pending_layer_->HighResTiling()->TileAt(1, 0), |
452 active_layer_->HighResTiling()->TileAt(1, 0)); | 451 active_layer_->HighResTiling()->TileAt(1, 0)); |
453 | 452 |
454 std::set<Tile*> expected_now_tiles; | 453 std::set<Tile*> expected_now_tiles; |
455 std::set<Tile*> expected_required_for_draw_tiles; | 454 std::set<Tile*> expected_required_for_draw_tiles; |
456 std::set<Tile*> expected_required_for_activation_tiles; | 455 std::set<Tile*> expected_required_for_activation_tiles; |
457 for (int i = 0; i <= 1; ++i) { | 456 for (int i = 0; i <= 1; ++i) { |
458 for (int j = 0; j <= 1; ++j) { | 457 for (int j = 0; j <= 1; ++j) { |
459 expected_now_tiles.insert(pending_layer_->HighResTiling()->TileAt(i, j)); | 458 bool have_pending_tile = false; |
460 expected_now_tiles.insert(active_layer_->HighResTiling()->TileAt(i, j)); | 459 if (pending_layer_->HighResTiling()->TileAt(i, j)) { |
461 | 460 expected_now_tiles.insert( |
462 expected_required_for_activation_tiles.insert( | 461 pending_layer_->HighResTiling()->TileAt(i, j)); |
463 pending_layer_->HighResTiling()->TileAt(i, j)); | 462 expected_required_for_activation_tiles.insert( |
464 expected_required_for_draw_tiles.insert( | 463 pending_layer_->HighResTiling()->TileAt(i, j)); |
465 active_layer_->HighResTiling()->TileAt(i, j)); | 464 have_pending_tile = true; |
465 } | |
466 Tile* active_tile = active_layer_->HighResTiling()->TileAt(i, j); | |
467 EXPECT_TRUE(active_tile); | |
468 expected_now_tiles.insert(active_tile); | |
469 expected_required_for_draw_tiles.insert(active_tile); | |
470 if (!have_pending_tile) | |
471 expected_required_for_activation_tiles.insert(active_tile); | |
466 } | 472 } |
467 } | 473 } |
468 // Expect 3 shared tiles and 1 unshared tile in total. | 474 // Expect 3 shared tiles and 1 unshared tile in total. |
469 EXPECT_EQ(5u, expected_now_tiles.size()); | 475 EXPECT_EQ(5u, expected_now_tiles.size()); |
470 // Expect 4 tiles for each draw and activation, but not all the same. | 476 // Expect 4 tiles for each draw and activation, but not all the same. |
471 EXPECT_EQ(4u, expected_required_for_activation_tiles.size()); | 477 EXPECT_EQ(4u, expected_required_for_activation_tiles.size()); |
472 EXPECT_EQ(4u, expected_required_for_draw_tiles.size()); | 478 EXPECT_EQ(4u, expected_required_for_draw_tiles.size()); |
473 EXPECT_NE(expected_required_for_draw_tiles, | 479 EXPECT_NE(expected_required_for_draw_tiles, |
474 expected_required_for_activation_tiles); | 480 expected_required_for_activation_tiles); |
475 | 481 |
476 std::set<Tile*> expected_all_tiles; | 482 std::set<Tile*> expected_all_tiles; |
477 for (int i = 0; i <= 3; ++i) { | 483 for (int i = 0; i <= 3; ++i) { |
478 for (int j = 0; j <= 3; ++j) { | 484 for (int j = 0; j <= 3; ++j) { |
479 expected_all_tiles.insert(pending_layer_->HighResTiling()->TileAt(i, j)); | 485 if (pending_layer_->HighResTiling()->TileAt(i, j)) |
486 expected_all_tiles.insert( | |
487 pending_layer_->HighResTiling()->TileAt(i, j)); | |
488 EXPECT_TRUE(active_layer_->HighResTiling()->TileAt(i, j)); | |
480 expected_all_tiles.insert(active_layer_->HighResTiling()->TileAt(i, j)); | 489 expected_all_tiles.insert(active_layer_->HighResTiling()->TileAt(i, j)); |
481 } | 490 } |
482 } | 491 } |
483 // Expect 15 shared tiles and 1 unshared tile. | 492 // Expect 15 shared tiles and 1 unshared tile. |
484 EXPECT_EQ(17u, expected_all_tiles.size()); | 493 EXPECT_EQ(17u, expected_all_tiles.size()); |
485 | 494 |
486 // The actual test will now build different queues and verify that the queues | 495 // The actual test will now build different queues and verify that the queues |
487 // return the same information as computed manually above. | 496 // return the same information as computed manually above. |
488 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 497 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
489 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 498 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 scoped_ptr<EvictionTilePriorityQueue> queue( | 613 scoped_ptr<EvictionTilePriorityQueue> queue( |
605 host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY)); | 614 host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY)); |
606 EXPECT_FALSE(queue->IsEmpty()); | 615 EXPECT_FALSE(queue->IsEmpty()); |
607 | 616 |
608 // Sanity check, all tiles should be visible. | 617 // Sanity check, all tiles should be visible. |
609 std::set<Tile*> smoothness_tiles; | 618 std::set<Tile*> smoothness_tiles; |
610 while (!queue->IsEmpty()) { | 619 while (!queue->IsEmpty()) { |
611 Tile* tile = queue->Top(); | 620 Tile* tile = queue->Top(); |
612 EXPECT_TRUE(tile); | 621 EXPECT_TRUE(tile); |
613 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); | 622 EXPECT_EQ(TilePriority::NOW, tile->priority(ACTIVE_TREE).priority_bin); |
614 EXPECT_EQ(TilePriority::NOW, tile->priority(PENDING_TREE).priority_bin); | |
615 EXPECT_TRUE(tile->HasResource()); | 623 EXPECT_TRUE(tile->HasResource()); |
616 smoothness_tiles.insert(tile); | 624 smoothness_tiles.insert(tile); |
617 queue->Pop(); | 625 queue->Pop(); |
618 } | 626 } |
619 EXPECT_EQ(all_tiles, smoothness_tiles); | 627 EXPECT_EQ(all_tiles, smoothness_tiles); |
620 | 628 |
621 tile_manager()->ReleaseTileResourcesForTesting( | 629 tile_manager()->ReleaseTileResourcesForTesting( |
622 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 630 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
623 | 631 |
624 Region invalidation(gfx::Rect(0, 0, 500, 500)); | 632 Region invalidation(gfx::Rect(0, 0, 500, 500)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 } | 707 } |
700 | 708 |
701 last_tile = tile; | 709 last_tile = tile; |
702 ++tile_count; | 710 ++tile_count; |
703 smoothness_tiles.insert(tile); | 711 smoothness_tiles.insert(tile); |
704 queue->Pop(); | 712 queue->Pop(); |
705 } | 713 } |
706 | 714 |
707 // Ensure that the distance is decreasing many more times than increasing. | 715 // Ensure that the distance is decreasing many more times than increasing. |
708 EXPECT_EQ(3, distance_increasing); | 716 EXPECT_EQ(3, distance_increasing); |
709 EXPECT_EQ(17, distance_decreasing); | 717 EXPECT_EQ(12, distance_decreasing); |
enne (OOO)
2015/04/13 22:36:02
What's up with this change?
vmpstr
2015/04/13 23:52:13
Oops. This was a wrong fix for the test. Changed.
| |
710 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 718 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
711 EXPECT_EQ(all_tiles, smoothness_tiles); | 719 EXPECT_EQ(all_tiles, smoothness_tiles); |
712 | 720 |
713 std::set<Tile*> new_content_tiles; | 721 std::set<Tile*> new_content_tiles; |
714 last_tile = NULL; | 722 last_tile = NULL; |
715 // Again, we expect to get increasing combined priority_bin. | 723 // Again, we expect to get increasing combined priority_bin. |
716 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); | 724 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); |
717 distance_decreasing = 0; | 725 distance_decreasing = 0; |
718 distance_increasing = 0; | 726 distance_increasing = 0; |
719 while (!queue->IsEmpty()) { | 727 while (!queue->IsEmpty()) { |
(...skipping 19 matching lines...) Expand all Loading... | |
739 } | 747 } |
740 } | 748 } |
741 | 749 |
742 last_tile = tile; | 750 last_tile = tile; |
743 new_content_tiles.insert(tile); | 751 new_content_tiles.insert(tile); |
744 queue->Pop(); | 752 queue->Pop(); |
745 } | 753 } |
746 | 754 |
747 // Ensure that the distance is decreasing many more times than increasing. | 755 // Ensure that the distance is decreasing many more times than increasing. |
748 EXPECT_EQ(3, distance_increasing); | 756 EXPECT_EQ(3, distance_increasing); |
749 EXPECT_EQ(17, distance_decreasing); | 757 EXPECT_EQ(12, distance_decreasing); |
750 EXPECT_EQ(tile_count, new_content_tiles.size()); | 758 EXPECT_EQ(tile_count, new_content_tiles.size()); |
751 EXPECT_EQ(all_tiles, new_content_tiles); | 759 EXPECT_EQ(all_tiles, new_content_tiles); |
752 } | 760 } |
753 | 761 |
754 TEST_F(TileManagerTilePriorityQueueTest, | 762 TEST_F(TileManagerTilePriorityQueueTest, |
755 EvictionTilePriorityQueueWithOcclusion) { | 763 EvictionTilePriorityQueueWithOcclusion) { |
756 base::TimeTicks time_ticks; | 764 base::TimeTicks time_ticks; |
757 time_ticks += base::TimeDelta::FromMilliseconds(1); | 765 time_ticks += base::TimeDelta::FromMilliseconds(1); |
758 host_impl_.SetCurrentBeginFrameArgs( | 766 host_impl_.SetCurrentBeginFrameArgs( |
759 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 767 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 RGBA_8888); | 1356 RGBA_8888); |
1349 | 1357 |
1350 host_impl_.tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); | 1358 host_impl_.tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); |
1351 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1359 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
1352 | 1360 |
1353 host_impl_.resource_pool()->ReleaseResource(resource.Pass()); | 1361 host_impl_.resource_pool()->ReleaseResource(resource.Pass()); |
1354 } | 1362 } |
1355 | 1363 |
1356 } // namespace | 1364 } // namespace |
1357 } // namespace cc | 1365 } // namespace cc |
OLD | NEW |