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 "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "cc/layers/recording_source.h" | 14 #include "cc/layers/recording_source.h" |
15 #include "cc/raster/raster_buffer.h" | 15 #include "cc/raster/raster_buffer.h" |
16 #include "cc/raster/raster_source.h" | 16 #include "cc/raster/raster_source.h" |
17 #include "cc/raster/synchronous_task_graph_runner.h" | 17 #include "cc/raster/synchronous_task_graph_runner.h" |
18 #include "cc/resources/resource_pool.h" | 18 #include "cc/resources/resource_pool.h" |
19 #include "cc/test/begin_frame_args_test.h" | 19 #include "cc/test/begin_frame_args_test.h" |
20 #include "cc/test/fake_compositor_frame_sink.h" | 20 #include "cc/test/fake_compositor_frame_sink.h" |
21 #include "cc/test/fake_compositor_frame_sink_client.h" | 21 #include "cc/test/fake_compositor_frame_sink_client.h" |
22 #include "cc/test/fake_impl_task_runner_provider.h" | 22 #include "cc/test/fake_impl_task_runner_provider.h" |
23 #include "cc/test/fake_layer_tree_host_impl.h" | 23 #include "cc/test/fake_layer_tree_host_impl.h" |
24 #include "cc/test/fake_picture_layer_impl.h" | 24 #include "cc/test/fake_picture_layer_impl.h" |
25 #include "cc/test/fake_picture_layer_tiling_client.h" | 25 #include "cc/test/fake_picture_layer_tiling_client.h" |
26 #include "cc/test/fake_raster_source.h" | 26 #include "cc/test/fake_raster_source.h" |
27 #include "cc/test/fake_recording_source.h" | 27 #include "cc/test/fake_recording_source.h" |
28 #include "cc/test/fake_tile_manager.h" | 28 #include "cc/test/fake_tile_manager.h" |
29 #include "cc/test/fake_tile_task_manager.h" | 29 #include "cc/test/fake_tile_task_manager.h" |
30 #include "cc/test/layer_tree_settings_for_testing.h" | |
31 #include "cc/test/test_layer_tree_host_base.h" | 30 #include "cc/test/test_layer_tree_host_base.h" |
32 #include "cc/test/test_task_graph_runner.h" | 31 #include "cc/test/test_task_graph_runner.h" |
33 #include "cc/test/test_tile_priorities.h" | 32 #include "cc/test/test_tile_priorities.h" |
34 #include "cc/tiles/eviction_tile_priority_queue.h" | 33 #include "cc/tiles/eviction_tile_priority_queue.h" |
35 #include "cc/tiles/raster_tile_priority_queue.h" | 34 #include "cc/tiles/raster_tile_priority_queue.h" |
36 #include "cc/tiles/tile.h" | 35 #include "cc/tiles/tile.h" |
37 #include "cc/tiles/tile_priority.h" | 36 #include "cc/tiles/tile_priority.h" |
38 #include "cc/tiles/tiling_set_raster_queue_all.h" | 37 #include "cc/tiles/tiling_set_raster_queue_all.h" |
39 #include "cc/trees/layer_tree_impl.h" | 38 #include "cc/trees/layer_tree_impl.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 75 |
77 protected: | 76 protected: |
78 ~SynchronousSimpleTaskRunner() override = default; | 77 ~SynchronousSimpleTaskRunner() override = default; |
79 | 78 |
80 bool run_tasks_synchronously_ = false; | 79 bool run_tasks_synchronously_ = false; |
81 }; | 80 }; |
82 | 81 |
83 class TileManagerTilePriorityQueueTest : public TestLayerTreeHostBase { | 82 class TileManagerTilePriorityQueueTest : public TestLayerTreeHostBase { |
84 public: | 83 public: |
85 LayerTreeSettings CreateSettings() override { | 84 LayerTreeSettings CreateSettings() override { |
86 LayerTreeSettingsForTesting settings; | 85 LayerTreeSettings settings; |
87 settings.create_low_res_tiling = true; | 86 settings.create_low_res_tiling = true; |
88 settings.renderer_settings.buffer_to_texture_target_map = | 87 settings.renderer_settings.buffer_to_texture_target_map = |
89 DefaultBufferToTextureTargetMapForTesting(); | 88 DefaultBufferToTextureTargetMapForTesting(); |
90 return settings; | 89 return settings; |
91 } | 90 } |
92 | 91 |
93 TileManager* tile_manager() { return host_impl()->tile_manager(); } | 92 TileManager* tile_manager() { return host_impl()->tile_manager(); } |
94 }; | 93 }; |
95 | 94 |
96 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { | 95 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1117 |
1119 gfx::Rect viewport(50, 50, 500, 500); | 1118 gfx::Rect viewport(50, 50, 500, 500); |
1120 gfx::Size layer_bounds(1600, 1600); | 1119 gfx::Size layer_bounds(1600, 1600); |
1121 | 1120 |
1122 const int soon_border_outset = 312; | 1121 const int soon_border_outset = 312; |
1123 gfx::Rect soon_rect = viewport; | 1122 gfx::Rect soon_rect = viewport; |
1124 soon_rect.Inset(-soon_border_outset, -soon_border_outset); | 1123 soon_rect.Inset(-soon_border_outset, -soon_border_outset); |
1125 | 1124 |
1126 client.SetTileSize(gfx::Size(30, 30)); | 1125 client.SetTileSize(gfx::Size(30, 30)); |
1127 LayerTreeSettings settings; | 1126 LayerTreeSettings settings; |
1128 settings.verify_clip_tree_calculations = true; | |
1129 | 1127 |
1130 std::unique_ptr<PictureLayerTilingSet> tiling_set = | 1128 std::unique_ptr<PictureLayerTilingSet> tiling_set = |
1131 PictureLayerTilingSet::Create( | 1129 PictureLayerTilingSet::Create( |
1132 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, | 1130 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, |
1133 settings.skewport_target_time_in_seconds, | 1131 settings.skewport_target_time_in_seconds, |
1134 settings.skewport_extrapolation_limit_in_screen_pixels, | 1132 settings.skewport_extrapolation_limit_in_screen_pixels, |
1135 settings.max_preraster_distance_in_screen_pixels); | 1133 settings.max_preraster_distance_in_screen_pixels); |
1136 | 1134 |
1137 scoped_refptr<FakeRasterSource> raster_source = | 1135 scoped_refptr<FakeRasterSource> raster_source = |
1138 FakeRasterSource::CreateFilled(layer_bounds); | 1136 FakeRasterSource::CreateFilled(layer_bounds); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 TEST_F(TileManagerTilePriorityQueueTest, | 1228 TEST_F(TileManagerTilePriorityQueueTest, |
1231 RasterTilePriorityQueueMovingViewport) { | 1229 RasterTilePriorityQueueMovingViewport) { |
1232 FakePictureLayerTilingClient client; | 1230 FakePictureLayerTilingClient client; |
1233 | 1231 |
1234 gfx::Rect viewport(50, 0, 100, 100); | 1232 gfx::Rect viewport(50, 0, 100, 100); |
1235 gfx::Rect moved_viewport(50, 0, 100, 500); | 1233 gfx::Rect moved_viewport(50, 0, 100, 500); |
1236 gfx::Size layer_bounds(1000, 1000); | 1234 gfx::Size layer_bounds(1000, 1000); |
1237 | 1235 |
1238 client.SetTileSize(gfx::Size(30, 30)); | 1236 client.SetTileSize(gfx::Size(30, 30)); |
1239 LayerTreeSettings settings; | 1237 LayerTreeSettings settings; |
1240 settings.verify_clip_tree_calculations = true; | |
1241 | 1238 |
1242 std::unique_ptr<PictureLayerTilingSet> tiling_set = | 1239 std::unique_ptr<PictureLayerTilingSet> tiling_set = |
1243 PictureLayerTilingSet::Create( | 1240 PictureLayerTilingSet::Create( |
1244 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, | 1241 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, |
1245 settings.skewport_target_time_in_seconds, | 1242 settings.skewport_target_time_in_seconds, |
1246 settings.skewport_extrapolation_limit_in_screen_pixels, | 1243 settings.skewport_extrapolation_limit_in_screen_pixels, |
1247 settings.max_preraster_distance_in_screen_pixels); | 1244 settings.max_preraster_distance_in_screen_pixels); |
1248 | 1245 |
1249 scoped_refptr<FakeRasterSource> raster_source = | 1246 scoped_refptr<FakeRasterSource> raster_source = |
1250 FakeRasterSource::CreateFilled(layer_bounds); | 1247 FakeRasterSource::CreateFilled(layer_bounds); |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 for (int i = 0; i < 100; ++i) { | 2026 for (int i = 0; i < 100; ++i) { |
2030 for (int j = 0; j < 100; ++j) { | 2027 for (int j = 0; j < 100; ++j) { |
2031 recording_source_->add_draw_rect_with_flags( | 2028 recording_source_->add_draw_rect_with_flags( |
2032 gfx::Rect(10 * i, 10 * j, 5, 5), non_solid_flags); | 2029 gfx::Rect(10 * i, 10 * j, 5, 5), non_solid_flags); |
2033 } | 2030 } |
2034 } | 2031 } |
2035 recording_source_->Rerecord(); | 2032 recording_source_->Rerecord(); |
2036 } | 2033 } |
2037 | 2034 |
2038 LayerTreeSettings CreateSettings() override { | 2035 LayerTreeSettings CreateSettings() override { |
2039 LayerTreeSettingsForTesting settings; | 2036 LayerTreeSettings settings; |
2040 settings.renderer_settings.buffer_to_texture_target_map = | 2037 settings.renderer_settings.buffer_to_texture_target_map = |
2041 DefaultBufferToTextureTargetMapForTesting(); | 2038 DefaultBufferToTextureTargetMapForTesting(); |
2042 return settings; | 2039 return settings; |
2043 } | 2040 } |
2044 | 2041 |
2045 void SetupTreesWithActiveTreeTiles() { | 2042 void SetupTreesWithActiveTreeTiles() { |
2046 scoped_refptr<RasterSource> active_tree_raster_source = | 2043 scoped_refptr<RasterSource> active_tree_raster_source = |
2047 RasterSource::CreateFromRecordingSource(recording_source_.get(), false); | 2044 RasterSource::CreateFromRecordingSource(recording_source_.get(), false); |
2048 scoped_refptr<RasterSource> pending_tree_raster_source = | 2045 scoped_refptr<RasterSource> pending_tree_raster_source = |
2049 RasterSource::CreateFromRecordingSource( | 2046 RasterSource::CreateFromRecordingSource( |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 // a part of raster tasks, the test should fail. | 2376 // a part of raster tasks, the test should fail. |
2380 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 2377 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
2381 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 2378 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); |
2382 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle(); | 2379 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle(); |
2383 base::RunLoop().RunUntilIdle(); | 2380 base::RunLoop().RunUntilIdle(); |
2384 EXPECT_FALSE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); | 2381 EXPECT_FALSE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); |
2385 } | 2382 } |
2386 | 2383 |
2387 } // namespace | 2384 } // namespace |
2388 } // namespace cc | 2385 } // namespace cc |
OLD | NEW |