| 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/thread_task_runner_handle.h" | 6 #include "base/thread_task_runner_handle.h" |
| 7 #include "cc/playback/display_list_raster_source.h" | 7 #include "cc/playback/display_list_raster_source.h" |
| 8 #include "cc/playback/display_list_recording_source.h" | 8 #include "cc/playback/display_list_recording_source.h" |
| 9 #include "cc/resources/resource_pool.h" | 9 #include "cc/resources/resource_pool.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 class TileManagerTilePriorityQueueTest : public testing::Test { | 41 class TileManagerTilePriorityQueueTest : public testing::Test { |
| 42 public: | 42 public: |
| 43 TileManagerTilePriorityQueueTest() | 43 TileManagerTilePriorityQueueTest() |
| 44 : memory_limit_policy_(ALLOW_ANYTHING), | 44 : memory_limit_policy_(ALLOW_ANYTHING), |
| 45 max_tiles_(10000), | 45 max_tiles_(10000), |
| 46 ready_to_activate_(false), | 46 ready_to_activate_(false), |
| 47 id_(7), | 47 id_(7), |
| 48 proxy_(base::ThreadTaskRunnerHandle::Get()), | 48 proxy_(base::ThreadTaskRunnerHandle::Get()), |
| 49 output_surface_(FakeOutputSurface::Create3d()), |
| 49 host_impl_(LowResTilingsSettings(), | 50 host_impl_(LowResTilingsSettings(), |
| 50 &proxy_, | 51 &proxy_, |
| 51 &shared_bitmap_manager_, | 52 &shared_bitmap_manager_, |
| 52 &task_graph_runner_) {} | 53 &task_graph_runner_) {} |
| 53 | 54 |
| 54 void SetTreePriority(TreePriority tree_priority) { | 55 void SetTreePriority(TreePriority tree_priority) { |
| 55 GlobalStateThatImpactsTilePriority state; | 56 GlobalStateThatImpactsTilePriority state; |
| 56 gfx::Size tile_size(256, 256); | 57 gfx::Size tile_size(256, 256); |
| 57 | 58 |
| 58 state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; | 59 state.soft_memory_limit_in_bytes = 100 * 1000 * 1000; |
| 59 state.num_resources_limit = max_tiles_; | 60 state.num_resources_limit = max_tiles_; |
| 60 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; | 61 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; |
| 61 state.memory_limit_policy = memory_limit_policy_; | 62 state.memory_limit_policy = memory_limit_policy_; |
| 62 state.tree_priority = tree_priority; | 63 state.tree_priority = tree_priority; |
| 63 | 64 |
| 64 global_state_ = state; | 65 global_state_ = state; |
| 65 host_impl_.resource_pool()->SetResourceUsageLimits( | 66 host_impl_.resource_pool()->SetResourceUsageLimits( |
| 66 state.soft_memory_limit_in_bytes, | 67 state.soft_memory_limit_in_bytes, |
| 67 state.num_resources_limit); | 68 state.num_resources_limit); |
| 68 host_impl_.tile_manager()->SetGlobalStateForTesting(state); | 69 host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void SetUp() override { | 72 void SetUp() override { |
| 72 InitializeRenderer(); | 73 InitializeRenderer(); |
| 73 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 74 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 74 } | 75 } |
| 75 | 76 |
| 76 virtual void InitializeRenderer() { | 77 virtual void InitializeRenderer() { |
| 77 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 78 host_impl_.InitializeRenderer(output_surface_.get()); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 81 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 81 gfx::Size tile_size(100, 100); | 82 gfx::Size tile_size(100, 100); |
| 82 | 83 |
| 83 scoped_refptr<FakePicturePileImpl> pending_pile = | 84 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 84 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 85 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 85 scoped_refptr<FakePicturePileImpl> active_pile = | 86 scoped_refptr<FakePicturePileImpl> active_pile = |
| 86 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 87 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 87 | 88 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 protected: | 150 protected: |
| 150 GlobalStateThatImpactsTilePriority global_state_; | 151 GlobalStateThatImpactsTilePriority global_state_; |
| 151 | 152 |
| 152 TestSharedBitmapManager shared_bitmap_manager_; | 153 TestSharedBitmapManager shared_bitmap_manager_; |
| 153 TestTaskGraphRunner task_graph_runner_; | 154 TestTaskGraphRunner task_graph_runner_; |
| 154 TileMemoryLimitPolicy memory_limit_policy_; | 155 TileMemoryLimitPolicy memory_limit_policy_; |
| 155 int max_tiles_; | 156 int max_tiles_; |
| 156 bool ready_to_activate_; | 157 bool ready_to_activate_; |
| 157 int id_; | 158 int id_; |
| 158 FakeImplProxy proxy_; | 159 FakeImplProxy proxy_; |
| 160 scoped_ptr<OutputSurface> output_surface_; |
| 159 FakeLayerTreeHostImpl host_impl_; | 161 FakeLayerTreeHostImpl host_impl_; |
| 160 FakePictureLayerImpl* pending_layer_; | 162 FakePictureLayerImpl* pending_layer_; |
| 161 FakePictureLayerImpl* active_layer_; | 163 FakePictureLayerImpl* active_layer_; |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { | 166 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) { |
| 165 const gfx::Size layer_bounds(1000, 1000); | 167 const gfx::Size layer_bounds(1000, 1000); |
| 166 host_impl_.SetViewportSize(layer_bounds); | 168 host_impl_.SetViewportSize(layer_bounds); |
| 167 SetupDefaultTrees(layer_bounds); | 169 SetupDefaultTrees(layer_bounds); |
| 168 | 170 |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 intersecting_rect); // Eventually rect. | 1418 intersecting_rect); // Eventually rect. |
| 1417 scoped_ptr<TilingSetRasterQueueAll> queue( | 1419 scoped_ptr<TilingSetRasterQueueAll> queue( |
| 1418 new TilingSetRasterQueueAll(tiling_set.get(), false)); | 1420 new TilingSetRasterQueueAll(tiling_set.get(), false)); |
| 1419 EXPECT_FALSE(queue->IsEmpty()); | 1421 EXPECT_FALSE(queue->IsEmpty()); |
| 1420 } | 1422 } |
| 1421 } | 1423 } |
| 1422 | 1424 |
| 1423 class TileManagerTest : public testing::Test { | 1425 class TileManagerTest : public testing::Test { |
| 1424 public: | 1426 public: |
| 1425 TileManagerTest() | 1427 TileManagerTest() |
| 1426 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} | 1428 : output_surface_(FakeOutputSurface::CreateSoftware( |
| 1429 make_scoped_ptr(new SoftwareOutputDevice))), |
| 1430 host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) { |
| 1431 host_impl_.InitializeRenderer(output_surface_.get()); |
| 1432 } |
| 1427 | 1433 |
| 1428 protected: | 1434 protected: |
| 1429 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. | 1435 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. |
| 1430 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { | 1436 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { |
| 1431 public: | 1437 public: |
| 1432 MockLayerTreeHostImpl(Proxy* proxy, | 1438 MockLayerTreeHostImpl(Proxy* proxy, |
| 1433 SharedBitmapManager* manager, | 1439 SharedBitmapManager* manager, |
| 1434 TaskGraphRunner* task_graph_runner) | 1440 TaskGraphRunner* task_graph_runner) |
| 1435 : FakeLayerTreeHostImpl(proxy, manager, task_graph_runner) { | 1441 : FakeLayerTreeHostImpl(proxy, manager, task_graph_runner) {} |
| 1436 InitializeRenderer(FakeOutputSurface::CreateSoftware( | |
| 1437 make_scoped_ptr(new SoftwareOutputDevice))); | |
| 1438 } | |
| 1439 | 1442 |
| 1440 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); | 1443 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); |
| 1441 }; | 1444 }; |
| 1442 | 1445 |
| 1443 TestSharedBitmapManager shared_bitmap_manager_; | 1446 TestSharedBitmapManager shared_bitmap_manager_; |
| 1444 TestTaskGraphRunner task_graph_runner_; | 1447 TestTaskGraphRunner task_graph_runner_; |
| 1445 FakeImplProxy proxy_; | 1448 FakeImplProxy proxy_; |
| 1449 scoped_ptr<OutputSurface> output_surface_; |
| 1446 MockLayerTreeHostImpl host_impl_; | 1450 MockLayerTreeHostImpl host_impl_; |
| 1447 }; | 1451 }; |
| 1448 | 1452 |
| 1449 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is | 1453 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is |
| 1450 // called. | 1454 // called. |
| 1451 TEST_F(TileManagerTest, AllWorkFinishedTest) { | 1455 TEST_F(TileManagerTest, AllWorkFinishedTest) { |
| 1452 // Check with no tile work enqueued. | 1456 // Check with no tile work enqueued. |
| 1453 { | 1457 { |
| 1454 base::RunLoop run_loop; | 1458 base::RunLoop run_loop; |
| 1455 EXPECT_FALSE(host_impl_.tile_manager()->HasScheduledTileTasksForTesting()); | 1459 EXPECT_FALSE(host_impl_.tile_manager()->HasScheduledTileTasksForTesting()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 // background is not visible. | 1558 // background is not visible. |
| 1555 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); | 1559 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); |
| 1556 } | 1560 } |
| 1557 } | 1561 } |
| 1558 } | 1562 } |
| 1559 } | 1563 } |
| 1560 } | 1564 } |
| 1561 | 1565 |
| 1562 } // namespace | 1566 } // namespace |
| 1563 } // namespace cc | 1567 } // namespace cc |
| OLD | NEW |