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/raster/raster_buffer.h" | 9 #include "cc/raster/raster_buffer.h" |
10 #include "cc/resources/resource_pool.h" | 10 #include "cc/resources/resource_pool.h" |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 non_intersecting_rect, // Soon rect. | 1416 non_intersecting_rect, // Soon rect. |
1417 intersecting_rect); // Eventually rect. | 1417 intersecting_rect); // Eventually rect. |
1418 scoped_ptr<TilingSetRasterQueueAll> queue( | 1418 scoped_ptr<TilingSetRasterQueueAll> queue( |
1419 new TilingSetRasterQueueAll(tiling_set.get(), false)); | 1419 new TilingSetRasterQueueAll(tiling_set.get(), false)); |
1420 EXPECT_FALSE(queue->IsEmpty()); | 1420 EXPECT_FALSE(queue->IsEmpty()); |
1421 } | 1421 } |
1422 } | 1422 } |
1423 | 1423 |
1424 class TileManagerTest : public testing::Test { | 1424 class TileManagerTest : public testing::Test { |
1425 public: | 1425 public: |
1426 TileManagerTest() | 1426 void SetUp() override { |
1427 : output_surface_(FakeOutputSurface::CreateSoftware( | 1427 output_surface_ = FakeOutputSurface::CreateSoftware( |
1428 make_scoped_ptr(new SoftwareOutputDevice))), | 1428 make_scoped_ptr(new SoftwareOutputDevice)); |
1429 host_impl_(new MockLayerTreeHostImpl(&proxy_, | 1429 LayerTreeSettings settings; |
1430 &shared_bitmap_manager_, | 1430 CustomizeSettings(&settings); |
1431 &task_graph_runner_)) { | 1431 host_impl_.reset(new MockLayerTreeHostImpl( |
| 1432 settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_)); |
1432 host_impl_->InitializeRenderer(output_surface_.get()); | 1433 host_impl_->InitializeRenderer(output_surface_.get()); |
1433 } | 1434 } |
1434 | 1435 |
1435 protected: | 1436 protected: |
1436 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. | 1437 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. |
1437 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { | 1438 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { |
1438 public: | 1439 public: |
1439 MockLayerTreeHostImpl(Proxy* proxy, | 1440 MockLayerTreeHostImpl(const LayerTreeSettings& settings, |
| 1441 Proxy* proxy, |
1440 SharedBitmapManager* manager, | 1442 SharedBitmapManager* manager, |
1441 TaskGraphRunner* task_graph_runner) | 1443 TaskGraphRunner* task_graph_runner) |
1442 : FakeLayerTreeHostImpl(proxy, manager, task_graph_runner) {} | 1444 : FakeLayerTreeHostImpl(settings, proxy, manager, task_graph_runner) {} |
1443 | 1445 |
1444 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); | 1446 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); |
1445 }; | 1447 }; |
1446 | 1448 |
| 1449 // By default do no customization. |
| 1450 virtual void CustomizeSettings(LayerTreeSettings* settings) {} |
| 1451 |
1447 TestSharedBitmapManager shared_bitmap_manager_; | 1452 TestSharedBitmapManager shared_bitmap_manager_; |
1448 TestTaskGraphRunner task_graph_runner_; | 1453 TestTaskGraphRunner task_graph_runner_; |
1449 FakeImplProxy proxy_; | 1454 FakeImplProxy proxy_; |
1450 scoped_ptr<OutputSurface> output_surface_; | 1455 scoped_ptr<OutputSurface> output_surface_; |
1451 scoped_ptr<MockLayerTreeHostImpl> host_impl_; | 1456 scoped_ptr<MockLayerTreeHostImpl> host_impl_; |
1452 }; | 1457 }; |
1453 | 1458 |
1454 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is | 1459 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is |
1455 // called. | 1460 // called. |
1456 TEST_F(TileManagerTest, AllWorkFinishedTest) { | 1461 TEST_F(TileManagerTest, AllWorkFinishedTest) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 uint64_t resource_content_id, | 1599 uint64_t resource_content_id, |
1595 uint64_t previous_content_id) override { | 1600 uint64_t previous_content_id) override { |
1596 NOTREACHED(); | 1601 NOTREACHED(); |
1597 return nullptr; | 1602 return nullptr; |
1598 } | 1603 } |
1599 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} | 1604 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} |
1600 | 1605 |
1601 ~CancellingTileTaskRunner() override {} | 1606 ~CancellingTileTaskRunner() override {} |
1602 }; | 1607 }; |
1603 | 1608 |
| 1609 class PartialRasterTileManagerTest : public TileManagerTest { |
| 1610 public: |
| 1611 void CustomizeSettings(LayerTreeSettings* settings) override { |
| 1612 settings->enable_partial_raster = true; |
| 1613 } |
| 1614 }; |
| 1615 |
1604 // Ensures that if a raster task is cancelled, it gets returned to the resource | 1616 // Ensures that if a raster task is cancelled, it gets returned to the resource |
1605 // pool with an invalid content ID, not with its invalidated content ID. | 1617 // pool with an invalid content ID, not with its invalidated content ID. |
1606 TEST_F(TileManagerTest, CancelledTasksHaveNoContentId) { | 1618 TEST_F(PartialRasterTileManagerTest, CancelledTasksHaveNoContentId) { |
1607 // Create a CancellingTaskRunner and set it on the tile manager so that all | 1619 // Create a CancellingTaskRunner and set it on the tile manager so that all |
1608 // scheduled work is immediately cancelled. | 1620 // scheduled work is immediately cancelled. |
1609 CancellingTileTaskRunner cancelling_runner; | 1621 CancellingTileTaskRunner cancelling_runner; |
1610 host_impl_->tile_manager()->SetTileTaskRunnerForTesting(&cancelling_runner); | 1622 host_impl_->tile_manager()->SetTileTaskRunnerForTesting(&cancelling_runner); |
1611 | 1623 |
1612 // Pick arbitrary IDs - they don't really matter as long as they're constant. | 1624 // Pick arbitrary IDs - they don't really matter as long as they're constant. |
1613 int layer_id = 7; | 1625 int layer_id = 7; |
1614 int invalidated_id = 43; | 1626 int invalidated_id = 43; |
1615 | 1627 |
1616 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 1628 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 EXPECT_FALSE(host_impl_->resource_pool()->TryAcquireResourceWithContentId( | 1660 EXPECT_FALSE(host_impl_->resource_pool()->TryAcquireResourceWithContentId( |
1649 invalidated_id)); | 1661 invalidated_id)); |
1650 | 1662 |
1651 // Free our host_impl_ before the cancelling_runner we passed it, as it will | 1663 // Free our host_impl_ before the cancelling_runner we passed it, as it will |
1652 // use that class in clean up. | 1664 // use that class in clean up. |
1653 host_impl_ = nullptr; | 1665 host_impl_ = nullptr; |
1654 } | 1666 } |
1655 | 1667 |
1656 } // namespace | 1668 } // namespace |
1657 } // namespace cc | 1669 } // namespace cc |
OLD | NEW |