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 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 non_intersecting_rect, // Soon rect. | 1432 non_intersecting_rect, // Soon rect. |
1433 intersecting_rect); // Eventually rect. | 1433 intersecting_rect); // Eventually rect. |
1434 scoped_ptr<TilingSetRasterQueueAll> queue( | 1434 scoped_ptr<TilingSetRasterQueueAll> queue( |
1435 new TilingSetRasterQueueAll(tiling_set.get(), false)); | 1435 new TilingSetRasterQueueAll(tiling_set.get(), false)); |
1436 EXPECT_FALSE(queue->IsEmpty()); | 1436 EXPECT_FALSE(queue->IsEmpty()); |
1437 } | 1437 } |
1438 } | 1438 } |
1439 | 1439 |
1440 class TileManagerTest : public testing::Test { | 1440 class TileManagerTest : public testing::Test { |
1441 public: | 1441 public: |
1442 TileManagerTest() | 1442 void SetUp() override { |
1443 : output_surface_(FakeOutputSurface::CreateSoftware( | 1443 output_surface_ = FakeOutputSurface::CreateSoftware( |
1444 make_scoped_ptr(new SoftwareOutputDevice))), | 1444 make_scoped_ptr(new SoftwareOutputDevice)); |
1445 host_impl_(new MockLayerTreeHostImpl(&proxy_, | 1445 LayerTreeSettings settings; |
1446 &shared_bitmap_manager_, | 1446 CustomizeSettings(&settings); |
1447 &task_graph_runner_)) { | 1447 host_impl_.reset(new MockLayerTreeHostImpl( |
| 1448 settings, &proxy_, &shared_bitmap_manager_, &task_graph_runner_)); |
1448 host_impl_->InitializeRenderer(output_surface_.get()); | 1449 host_impl_->InitializeRenderer(output_surface_.get()); |
1449 } | 1450 } |
1450 | 1451 |
1451 protected: | 1452 protected: |
1452 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. | 1453 // MockLayerTreeHostImpl allows us to intercept tile manager callbacks. |
1453 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { | 1454 class MockLayerTreeHostImpl : public FakeLayerTreeHostImpl { |
1454 public: | 1455 public: |
1455 MockLayerTreeHostImpl(Proxy* proxy, | 1456 MockLayerTreeHostImpl(const LayerTreeSettings& settings, |
| 1457 Proxy* proxy, |
1456 SharedBitmapManager* manager, | 1458 SharedBitmapManager* manager, |
1457 TaskGraphRunner* task_graph_runner) | 1459 TaskGraphRunner* task_graph_runner) |
1458 : FakeLayerTreeHostImpl(proxy, manager, task_graph_runner) {} | 1460 : FakeLayerTreeHostImpl(settings, proxy, manager, task_graph_runner) {} |
1459 | 1461 |
1460 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); | 1462 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); |
1461 }; | 1463 }; |
1462 | 1464 |
| 1465 // By default do no customization. |
| 1466 virtual void CustomizeSettings(LayerTreeSettings* settings) {} |
| 1467 |
1463 TestSharedBitmapManager shared_bitmap_manager_; | 1468 TestSharedBitmapManager shared_bitmap_manager_; |
1464 TestTaskGraphRunner task_graph_runner_; | 1469 TestTaskGraphRunner task_graph_runner_; |
1465 FakeImplProxy proxy_; | 1470 FakeImplProxy proxy_; |
1466 scoped_ptr<OutputSurface> output_surface_; | 1471 scoped_ptr<OutputSurface> output_surface_; |
1467 scoped_ptr<MockLayerTreeHostImpl> host_impl_; | 1472 scoped_ptr<MockLayerTreeHostImpl> host_impl_; |
1468 }; | 1473 }; |
1469 | 1474 |
1470 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is | 1475 // Test to ensure that we call NotifyAllTileTasksCompleted when PrepareTiles is |
1471 // called. | 1476 // called. |
1472 TEST_F(TileManagerTest, AllWorkFinishedTest) { | 1477 TEST_F(TileManagerTest, AllWorkFinishedTest) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 uint64_t resource_content_id, | 1615 uint64_t resource_content_id, |
1611 uint64_t previous_content_id) override { | 1616 uint64_t previous_content_id) override { |
1612 NOTREACHED(); | 1617 NOTREACHED(); |
1613 return nullptr; | 1618 return nullptr; |
1614 } | 1619 } |
1615 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} | 1620 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} |
1616 | 1621 |
1617 ~CancellingTileTaskRunner() override {} | 1622 ~CancellingTileTaskRunner() override {} |
1618 }; | 1623 }; |
1619 | 1624 |
| 1625 class PartialRasterTileManagerTest : public TileManagerTest { |
| 1626 public: |
| 1627 void CustomizeSettings(LayerTreeSettings* settings) override { |
| 1628 settings->use_partial_raster = true; |
| 1629 } |
| 1630 }; |
| 1631 |
1620 // Ensures that if a raster task is cancelled, it gets returned to the resource | 1632 // Ensures that if a raster task is cancelled, it gets returned to the resource |
1621 // pool with an invalid content ID, not with its invalidated content ID. | 1633 // pool with an invalid content ID, not with its invalidated content ID. |
1622 TEST_F(TileManagerTest, CancelledTasksHaveNoContentId) { | 1634 TEST_F(PartialRasterTileManagerTest, CancelledTasksHaveNoContentId) { |
1623 // Create a CancellingTaskRunner and set it on the tile manager so that all | 1635 // Create a CancellingTaskRunner and set it on the tile manager so that all |
1624 // scheduled work is immediately cancelled. | 1636 // scheduled work is immediately cancelled. |
1625 CancellingTileTaskRunner cancelling_runner; | 1637 CancellingTileTaskRunner cancelling_runner; |
1626 host_impl_->tile_manager()->SetTileTaskRunnerForTesting(&cancelling_runner); | 1638 host_impl_->tile_manager()->SetTileTaskRunnerForTesting(&cancelling_runner); |
1627 | 1639 |
1628 // Pick arbitrary IDs - they don't really matter as long as they're constant. | 1640 // Pick arbitrary IDs - they don't really matter as long as they're constant. |
1629 int layer_id = 7; | 1641 int layer_id = 7; |
1630 int invalidated_id = 43; | 1642 int invalidated_id = 43; |
1631 | 1643 |
1632 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = | 1644 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 EXPECT_FALSE(host_impl_->resource_pool()->TryAcquireResourceWithContentId( | 1676 EXPECT_FALSE(host_impl_->resource_pool()->TryAcquireResourceWithContentId( |
1665 invalidated_id)); | 1677 invalidated_id)); |
1666 | 1678 |
1667 // Free our host_impl_ before the cancelling_runner we passed it, as it will | 1679 // Free our host_impl_ before the cancelling_runner we passed it, as it will |
1668 // use that class in clean up. | 1680 // use that class in clean up. |
1669 host_impl_ = nullptr; | 1681 host_impl_ = nullptr; |
1670 } | 1682 } |
1671 | 1683 |
1672 } // namespace | 1684 } // namespace |
1673 } // namespace cc | 1685 } // namespace cc |
OLD | NEW |