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