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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 | 1378 |
1371 host_impl_.SetIsLikelyToRequireADraw(true); | 1379 host_impl_.SetIsLikelyToRequireADraw(true); |
1372 | 1380 |
1373 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); | 1381 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); |
1374 host_impl_.tile_manager()->UpdateVisibleTiles(host_impl_.global_tile_state()); | 1382 host_impl_.tile_manager()->UpdateVisibleTiles(host_impl_.global_tile_state()); |
1375 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1383 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
1376 } | 1384 } |
1377 | 1385 |
1378 } // namespace | 1386 } // namespace |
1379 } // namespace cc | 1387 } // namespace cc |
OLD | NEW |