Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: cc/tiles/tile_manager_unittest.cc

Issue 2924233002: cc: Move pre-decodes to background worker. (Closed)
Patch Set: export Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/tiles/tile_manager_unittest.cc
diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc
index 5e116400c8feaa614aaa2b6bf294de0d964b3f3e..0c85f4dc50afa6acd20250bc6863cf9633094b59 100644
--- a/cc/tiles/tile_manager_unittest.cc
+++ b/cc/tiles/tile_manager_unittest.cc
@@ -2527,6 +2527,11 @@ TEST_F(CheckerImagingTileManagerTest, BuildsImageDecodeQueueAsExpected) {
gfx::Rect(rect_to_raster)); // Eventually rect.
host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
+ // Finish all raster and dispatch completion callback so that the decode work
+ // for checkered images can be scheduled.
+ static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
+
// Run decode tasks to trigger completion of any pending decodes.
FlushDecodeTasks();
@@ -2564,6 +2569,74 @@ TEST_F(CheckerImagingTileManagerTest, BuildsImageDecodeQueueAsExpected) {
EXPECT_FALSE(host_impl()->client()->did_request_impl_side_invalidation());
}
+TEST_F(CheckerImagingTileManagerTest,
+ TileManagerCorrectlyPrioritizesCheckerImagedDecodes) {
+ gfx::Size layer_bounds(500, 500);
+
+ std::unique_ptr<FakeRecordingSource> recording_source =
+ FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
+ recording_source->set_fill_with_nonsolid_color(true);
+
+ recording_source->Rerecord();
+ scoped_refptr<RasterSource> raster_source =
+ RasterSource::CreateFromRecordingSource(recording_source.get(), false);
+
+ // Required for activation tiles block checker-imaged decodes.
+ SetupPendingTree(raster_source, gfx::Size(100, 100),
+ Region(gfx::Rect(0, 0, 500, 500)));
+ host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
+ EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting());
+ EXPECT_TRUE(host_impl()
+ ->tile_manager()
+ ->checker_image_tracker()
+ .no_decodes_allowed_for_testing());
+ while (!host_impl()->client()->ready_to_activate()) {
+ static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())
+ ->RunSingleTaskForTesting();
+ base::RunLoop().RunUntilIdle();
+ }
+ EXPECT_EQ(host_impl()
+ ->tile_manager()
+ ->checker_image_tracker()
+ .decode_priority_allowed_for_testing(),
+ CheckerImageTracker::DecodeType::kRaster);
+
+ // Finishing all tasks allows pre-decodes.
+ static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(host_impl()
+ ->tile_manager()
+ ->checker_image_tracker()
+ .decode_priority_allowed_for_testing(),
+ CheckerImageTracker::DecodeType::kPreDecode);
+
+ // Required for draw tiles block checker-imaged decodes.
+ // Free all tile resources and perform another PrepareTiles.
+ ActivateTree();
+ EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToDraw());
+ host_impl()->tile_manager()->PrepareTiles(
+ GlobalStateThatImpactsTilePriority());
+ EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToDraw());
+
+ host_impl()->client()->reset_ready_to_draw();
+ host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
+ EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting());
+ EXPECT_TRUE(host_impl()
+ ->tile_manager()
+ ->checker_image_tracker()
+ .no_decodes_allowed_for_testing());
+ while (!host_impl()->client()->ready_to_draw()) {
+ static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())
+ ->RunSingleTaskForTesting();
+ base::RunLoop().RunUntilIdle();
+ }
+ EXPECT_EQ(host_impl()
+ ->tile_manager()
+ ->checker_image_tracker()
+ .decode_priority_allowed_for_testing(),
+ CheckerImageTracker::DecodeType::kRaster);
+}
+
class CheckerImagingTileManagerMemoryTest
: public CheckerImagingTileManagerTest {
public:
@@ -2636,6 +2709,11 @@ TEST_F(CheckerImagingTileManagerMemoryTest, AddsAllNowTilesToImageDecodeQueue) {
complete_tiling_rect); // Eventually rect.
host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
+ // Finish all raster work so the decode work for checkered images can be
+ // scheduled.
+ static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
+
// Flush all decode tasks. The tiles with checkered images should be
// invalidated.
FlushDecodeTasks();

Powered by Google App Engine
This is Rietveld 408576698