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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1324 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); |
1325 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1325 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
1326 EXPECT_TRUE(host_impl()->is_likely_to_require_a_draw()); | 1326 EXPECT_TRUE(host_impl()->is_likely_to_require_a_draw()); |
1327 | 1327 |
1328 Resource* resource = host_impl()->resource_pool()->AcquireResource( | 1328 Resource* resource = host_impl()->resource_pool()->AcquireResource( |
1329 gfx::Size(256, 256), RGBA_8888); | 1329 gfx::Size(256, 256), RGBA_8888); |
1330 | 1330 |
1331 host_impl()->tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); | 1331 host_impl()->tile_manager()->CheckIfMoreTilesNeedToBePreparedForTesting(); |
1332 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); | 1332 EXPECT_FALSE(host_impl()->is_likely_to_require_a_draw()); |
1333 | 1333 |
1334 host_impl()->resource_pool()->ReleaseResource(resource, 0); | 1334 host_impl()->resource_pool()->ReleaseResource(resource); |
1335 } | 1335 } |
1336 | 1336 |
1337 TEST_F(TileManagerTilePriorityQueueTest, DefaultMemoryPolicy) { | 1337 TEST_F(TileManagerTilePriorityQueueTest, DefaultMemoryPolicy) { |
1338 const gfx::Size layer_bounds(1000, 1000); | 1338 const gfx::Size layer_bounds(1000, 1000); |
1339 host_impl()->SetViewportSize(layer_bounds); | 1339 host_impl()->SetViewportSize(layer_bounds); |
1340 SetupDefaultTrees(layer_bounds); | 1340 SetupDefaultTrees(layer_bounds); |
1341 | 1341 |
1342 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1342 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
1343 | 1343 |
1344 // 64MB is the default mem limit. | 1344 // 64MB is the default mem limit. |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 EXPECT_FALSE(queue->IsEmpty()); | 1776 EXPECT_FALSE(queue->IsEmpty()); |
1777 queue->Top().tile()->SetInvalidated(gfx::Rect(), kInvalidatedId); | 1777 queue->Top().tile()->SetInvalidated(gfx::Rect(), kInvalidatedId); |
1778 | 1778 |
1779 // PrepareTiles to schedule tasks. Due to the FakeTileTaskManagerImpl, | 1779 // PrepareTiles to schedule tasks. Due to the FakeTileTaskManagerImpl, |
1780 // these tasks will immediately be canceled. | 1780 // these tasks will immediately be canceled. |
1781 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | 1781 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
1782 | 1782 |
1783 // Make sure that the tile we invalidated above was not returned to the pool | 1783 // Make sure that the tile we invalidated above was not returned to the pool |
1784 // with its invalidated resource ID. | 1784 // with its invalidated resource ID. |
1785 host_impl()->resource_pool()->CheckBusyResources(); | 1785 host_impl()->resource_pool()->CheckBusyResources(); |
1786 EXPECT_FALSE(host_impl()->resource_pool()->TryAcquireResourceWithContentId( | 1786 gfx::Rect total_invalidated_rect; |
1787 kInvalidatedId)); | 1787 EXPECT_FALSE(host_impl()->resource_pool()->TryAcquireResourceForPartialRaster( |
| 1788 kInvalidatedId + 1, gfx::Rect(), kInvalidatedId, |
| 1789 &total_invalidated_rect)); |
| 1790 EXPECT_EQ(gfx::Rect(), total_invalidated_rect); |
1788 | 1791 |
1789 // Free our host_impl_ before the tile_task_manager we passed it, as it | 1792 // Free our host_impl_ before the tile_task_manager we passed it, as it |
1790 // will use that class in clean up. | 1793 // will use that class in clean up. |
1791 TakeHostImpl(); | 1794 TakeHostImpl(); |
1792 } | 1795 } |
1793 | 1796 |
1794 // FakeRasterBufferProviderImpl that verifies the resource content ID of raster | 1797 // FakeRasterBufferProviderImpl that verifies the resource content ID of raster |
1795 // tasks. | 1798 // tasks. |
1796 class VerifyResourceContentIdRasterBufferProvider | 1799 class VerifyResourceContentIdRasterBufferProvider |
1797 : public FakeRasterBufferProviderImpl { | 1800 : public FakeRasterBufferProviderImpl { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 // raster task we see is created with |kExpectedId|. | 1832 // raster task we see is created with |kExpectedId|. |
1830 FakeTileTaskManagerImpl tile_task_manager; | 1833 FakeTileTaskManagerImpl tile_task_manager; |
1831 host_impl->tile_manager()->SetTileTaskManagerForTesting(&tile_task_manager); | 1834 host_impl->tile_manager()->SetTileTaskManagerForTesting(&tile_task_manager); |
1832 | 1835 |
1833 VerifyResourceContentIdRasterBufferProvider raster_buffer_provider( | 1836 VerifyResourceContentIdRasterBufferProvider raster_buffer_provider( |
1834 kExpectedId); | 1837 kExpectedId); |
1835 host_impl->tile_manager()->SetRasterBufferProviderForTesting( | 1838 host_impl->tile_manager()->SetRasterBufferProviderForTesting( |
1836 &raster_buffer_provider); | 1839 &raster_buffer_provider); |
1837 | 1840 |
1838 // Ensure there's a resource with our |kInvalidatedId| in the resource pool. | 1841 // Ensure there's a resource with our |kInvalidatedId| in the resource pool. |
1839 host_impl->resource_pool()->ReleaseResource( | 1842 auto* resource = |
1840 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888), | 1843 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888); |
1841 kInvalidatedId); | 1844 host_impl->resource_pool()->OnContentReplaced(resource->id(), kInvalidatedId); |
| 1845 host_impl->resource_pool()->ReleaseResource(resource); |
1842 host_impl->resource_pool()->CheckBusyResources(); | 1846 host_impl->resource_pool()->CheckBusyResources(); |
1843 | 1847 |
1844 scoped_refptr<FakeRasterSource> pending_raster_source = | 1848 scoped_refptr<FakeRasterSource> pending_raster_source = |
1845 FakeRasterSource::CreateFilled(kTileSize); | 1849 FakeRasterSource::CreateFilled(kTileSize); |
1846 host_impl->CreatePendingTree(); | 1850 host_impl->CreatePendingTree(); |
1847 LayerTreeImpl* pending_tree = host_impl->pending_tree(); | 1851 LayerTreeImpl* pending_tree = host_impl->pending_tree(); |
1848 | 1852 |
1849 // Steal from the recycled tree. | 1853 // Steal from the recycled tree. |
1850 std::unique_ptr<FakePictureLayerImpl> pending_layer = | 1854 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
1851 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId, | 1855 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, kLayerId, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 } | 1888 } |
1885 | 1889 |
1886 // Ensures that the tile manager does not attempt to reuse tiles when partial | 1890 // Ensures that the tile manager does not attempt to reuse tiles when partial |
1887 // raster is disabled. | 1891 // raster is disabled. |
1888 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 1892 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
1889 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); | 1893 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); |
1890 } | 1894 } |
1891 | 1895 |
1892 } // namespace | 1896 } // namespace |
1893 } // namespace cc | 1897 } // namespace cc |
OLD | NEW |