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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 // Set the tile priority rects such that only the tile with the second image | 2520 // Set the tile priority rects such that only the tile with the second image |
2521 // is scheduled for decodes, since it is checker-imaged. | 2521 // is scheduled for decodes, since it is checker-imaged. |
2522 gfx::Rect rect_to_raster(600, 0, 300, 900); | 2522 gfx::Rect rect_to_raster(600, 0, 300, 900); |
2523 active_tiling->SetTilePriorityRectsForTesting( | 2523 active_tiling->SetTilePriorityRectsForTesting( |
2524 gfx::Rect(rect_to_raster), // Visible rect. | 2524 gfx::Rect(rect_to_raster), // Visible rect. |
2525 gfx::Rect(rect_to_raster), // Skewport rect. | 2525 gfx::Rect(rect_to_raster), // Skewport rect. |
2526 gfx::Rect(rect_to_raster), // Soon rect. | 2526 gfx::Rect(rect_to_raster), // Soon rect. |
2527 gfx::Rect(rect_to_raster)); // Eventually rect. | 2527 gfx::Rect(rect_to_raster)); // Eventually rect. |
2528 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 2528 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
2529 | 2529 |
| 2530 // Finish all raster and dispatch completion callback so that the decode work |
| 2531 // for checkered images can be scheduled. |
| 2532 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle(); |
| 2533 base::RunLoop().RunUntilIdle(); |
| 2534 |
2530 // Run decode tasks to trigger completion of any pending decodes. | 2535 // Run decode tasks to trigger completion of any pending decodes. |
2531 FlushDecodeTasks(); | 2536 FlushDecodeTasks(); |
2532 | 2537 |
2533 // Create a new pending tree to invalidate tiles for decoded images and verify | 2538 // Create a new pending tree to invalidate tiles for decoded images and verify |
2534 // that only tiles for |image2| are invalidated. | 2539 // that only tiles for |image2| are invalidated. |
2535 EXPECT_TRUE(host_impl()->client()->did_request_impl_side_invalidation()); | 2540 EXPECT_TRUE(host_impl()->client()->did_request_impl_side_invalidation()); |
2536 PerformImplSideInvalidation(); | 2541 PerformImplSideInvalidation(); |
2537 for (int i = 0; i < 2; i++) { | 2542 for (int i = 0; i < 2; i++) { |
2538 for (int j = 0; j < 2; j++) { | 2543 for (int j = 0; j < 2; j++) { |
2539 const Tile* tile = pending_tiling->TileAt(i, j); | 2544 const Tile* tile = pending_tiling->TileAt(i, j); |
(...skipping 17 matching lines...) Expand all Loading... |
2557 gfx::Rect(layer_bounds), // Visible rect. | 2562 gfx::Rect(layer_bounds), // Visible rect. |
2558 gfx::Rect(layer_bounds), // Skewport rect. | 2563 gfx::Rect(layer_bounds), // Skewport rect. |
2559 gfx::Rect(layer_bounds), // Soon rect. | 2564 gfx::Rect(layer_bounds), // Soon rect. |
2560 gfx::Rect(layer_bounds)); // Eventually rect. | 2565 gfx::Rect(layer_bounds)); // Eventually rect. |
2561 host_impl()->SetVisible(false); | 2566 host_impl()->SetVisible(false); |
2562 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 2567 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
2563 FlushDecodeTasks(); | 2568 FlushDecodeTasks(); |
2564 EXPECT_FALSE(host_impl()->client()->did_request_impl_side_invalidation()); | 2569 EXPECT_FALSE(host_impl()->client()->did_request_impl_side_invalidation()); |
2565 } | 2570 } |
2566 | 2571 |
| 2572 TEST_F(CheckerImagingTileManagerTest, |
| 2573 TileManagerCorrectlyPrioritizesCheckerImagedDecodes) { |
| 2574 gfx::Size layer_bounds(500, 500); |
| 2575 |
| 2576 std::unique_ptr<FakeRecordingSource> recording_source = |
| 2577 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); |
| 2578 recording_source->set_fill_with_nonsolid_color(true); |
| 2579 |
| 2580 recording_source->Rerecord(); |
| 2581 scoped_refptr<RasterSource> raster_source = |
| 2582 RasterSource::CreateFromRecordingSource(recording_source.get(), false); |
| 2583 |
| 2584 // Required for activation tiles block checker-imaged decodes. |
| 2585 SetupPendingTree(raster_source, gfx::Size(100, 100), |
| 2586 Region(gfx::Rect(0, 0, 500, 500))); |
| 2587 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
| 2588 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); |
| 2589 EXPECT_TRUE(host_impl() |
| 2590 ->tile_manager() |
| 2591 ->checker_image_tracker() |
| 2592 .no_decodes_allowed_for_testing()); |
| 2593 while (!host_impl()->client()->ready_to_activate()) { |
| 2594 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner()) |
| 2595 ->RunSingleTaskForTesting(); |
| 2596 base::RunLoop().RunUntilIdle(); |
| 2597 } |
| 2598 EXPECT_EQ(host_impl() |
| 2599 ->tile_manager() |
| 2600 ->checker_image_tracker() |
| 2601 .decode_priority_allowed_for_testing(), |
| 2602 CheckerImageTracker::DecodeType::kRaster); |
| 2603 |
| 2604 // Finishing all tasks allows pre-decodes. |
| 2605 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle(); |
| 2606 base::RunLoop().RunUntilIdle(); |
| 2607 EXPECT_EQ(host_impl() |
| 2608 ->tile_manager() |
| 2609 ->checker_image_tracker() |
| 2610 .decode_priority_allowed_for_testing(), |
| 2611 CheckerImageTracker::DecodeType::kPreDecode); |
| 2612 |
| 2613 // Required for draw tiles block checker-imaged decodes. |
| 2614 // Free all tile resources and perform another PrepareTiles. |
| 2615 ActivateTree(); |
| 2616 EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToDraw()); |
| 2617 host_impl()->tile_manager()->PrepareTiles( |
| 2618 GlobalStateThatImpactsTilePriority()); |
| 2619 EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToDraw()); |
| 2620 |
| 2621 host_impl()->client()->reset_ready_to_draw(); |
| 2622 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
| 2623 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); |
| 2624 EXPECT_TRUE(host_impl() |
| 2625 ->tile_manager() |
| 2626 ->checker_image_tracker() |
| 2627 .no_decodes_allowed_for_testing()); |
| 2628 while (!host_impl()->client()->ready_to_draw()) { |
| 2629 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner()) |
| 2630 ->RunSingleTaskForTesting(); |
| 2631 base::RunLoop().RunUntilIdle(); |
| 2632 } |
| 2633 EXPECT_EQ(host_impl() |
| 2634 ->tile_manager() |
| 2635 ->checker_image_tracker() |
| 2636 .decode_priority_allowed_for_testing(), |
| 2637 CheckerImageTracker::DecodeType::kRaster); |
| 2638 } |
| 2639 |
2567 class CheckerImagingTileManagerMemoryTest | 2640 class CheckerImagingTileManagerMemoryTest |
2568 : public CheckerImagingTileManagerTest { | 2641 : public CheckerImagingTileManagerTest { |
2569 public: | 2642 public: |
2570 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( | 2643 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( |
2571 const LayerTreeSettings& settings, | 2644 const LayerTreeSettings& settings, |
2572 TaskRunnerProvider* task_runner_provider, | 2645 TaskRunnerProvider* task_runner_provider, |
2573 TaskGraphRunner* task_graph_runner) override { | 2646 TaskGraphRunner* task_graph_runner) override { |
2574 LayerTreeSettings new_settings = settings; | 2647 LayerTreeSettings new_settings = settings; |
2575 new_settings.gpu_memory_policy.num_resources_limit = 4; | 2648 new_settings.gpu_memory_policy.num_resources_limit = 4; |
2576 return CheckerImagingTileManagerTest::CreateHostImpl( | 2649 return CheckerImagingTileManagerTest::CreateHostImpl( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2629 gfx::Rect complete_tiling_rect(layer_bounds); | 2702 gfx::Rect complete_tiling_rect(layer_bounds); |
2630 PictureLayerTiling* active_tiling = | 2703 PictureLayerTiling* active_tiling = |
2631 active_layer()->picture_layer_tiling_set()->tiling_at(0); | 2704 active_layer()->picture_layer_tiling_set()->tiling_at(0); |
2632 active_tiling->SetTilePriorityRectsForTesting( | 2705 active_tiling->SetTilePriorityRectsForTesting( |
2633 complete_tiling_rect, // Visible rect. | 2706 complete_tiling_rect, // Visible rect. |
2634 complete_tiling_rect, // Skewport rect. | 2707 complete_tiling_rect, // Skewport rect. |
2635 complete_tiling_rect, // Soon rect. | 2708 complete_tiling_rect, // Soon rect. |
2636 complete_tiling_rect); // Eventually rect. | 2709 complete_tiling_rect); // Eventually rect. |
2637 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 2710 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
2638 | 2711 |
| 2712 // Finish all raster work so the decode work for checkered images can be |
| 2713 // scheduled. |
| 2714 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle(); |
| 2715 base::RunLoop().RunUntilIdle(); |
| 2716 |
2639 // Flush all decode tasks. The tiles with checkered images should be | 2717 // Flush all decode tasks. The tiles with checkered images should be |
2640 // invalidated. | 2718 // invalidated. |
2641 FlushDecodeTasks(); | 2719 FlushDecodeTasks(); |
2642 EXPECT_TRUE(host_impl()->client()->did_request_impl_side_invalidation()); | 2720 EXPECT_TRUE(host_impl()->client()->did_request_impl_side_invalidation()); |
2643 PerformImplSideInvalidation(); | 2721 PerformImplSideInvalidation(); |
2644 for (int i = 0; i < 2; i++) { | 2722 for (int i = 0; i < 2; i++) { |
2645 for (int j = 0; j < 3; j++) { | 2723 for (int j = 0; j < 3; j++) { |
2646 const Tile* tile = pending_tiling->TileAt(i, j); | 2724 const Tile* tile = pending_tiling->TileAt(i, j); |
2647 if (j == 1) | 2725 if (j == 1) |
2648 EXPECT_TRUE(tile); | 2726 EXPECT_TRUE(tile); |
2649 else | 2727 else |
2650 EXPECT_FALSE(tile); | 2728 EXPECT_FALSE(tile); |
2651 } | 2729 } |
2652 } | 2730 } |
2653 host_impl()->client()->reset_did_request_impl_side_invalidation(); | 2731 host_impl()->client()->reset_did_request_impl_side_invalidation(); |
2654 } | 2732 } |
2655 | 2733 |
2656 } // namespace | 2734 } // namespace |
2657 } // namespace cc | 2735 } // namespace cc |
OLD | NEW |