Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: cc/tiles/tile_manager_unittest.cc

Issue 2101043002: Reland of cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_sync_tokens_revert
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager.cc ('k') | cc/tiles/tile_task_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 uint64_t resource_content_id, 1804 uint64_t resource_content_id,
1805 uint64_t previous_content_id) override { 1805 uint64_t previous_content_id) override {
1806 EXPECT_EQ(expected_resource_id_, resource_content_id); 1806 EXPECT_EQ(expected_resource_id_, resource_content_id);
1807 return nullptr; 1807 return nullptr;
1808 } 1808 }
1809 1809
1810 private: 1810 private:
1811 uint64_t expected_resource_id_; 1811 uint64_t expected_resource_id_;
1812 }; 1812 };
1813 1813
1814 class VerifyResourceContentIdTileTaskManager : public FakeTileTaskManagerImpl {
1815 public:
1816 explicit VerifyResourceContentIdTileTaskManager(uint64_t expected_resource_id)
1817 : FakeTileTaskManagerImpl(base::WrapUnique<RasterBufferProvider>(
1818 new VerifyResourceContentIdRasterBufferProvider(
1819 expected_resource_id))) {}
1820 ~VerifyResourceContentIdTileTaskManager() override {}
1821 };
1822
1823 // Runs a test to ensure that partial raster is either enabled or disabled, 1814 // Runs a test to ensure that partial raster is either enabled or disabled,
1824 // depending on |partial_raster_enabled|'s value. Takes ownership of host_impl 1815 // depending on |partial_raster_enabled|'s value. Takes ownership of host_impl
1825 // so that cleanup order can be controlled. 1816 // so that cleanup order can be controlled.
1826 void RunPartialRasterCheck(std::unique_ptr<LayerTreeHostImpl> host_impl, 1817 void RunPartialRasterCheck(std::unique_ptr<LayerTreeHostImpl> host_impl,
1827 bool partial_raster_enabled) { 1818 bool partial_raster_enabled) {
1828 // Pick arbitrary IDs - they don't really matter as long as they're constant. 1819 // Pick arbitrary IDs - they don't really matter as long as they're constant.
1829 const int kLayerId = 7; 1820 const int kLayerId = 7;
1830 const uint64_t kInvalidatedId = 43; 1821 const uint64_t kInvalidatedId = 43;
1831 const uint64_t kExpectedId = partial_raster_enabled ? kInvalidatedId : 0u; 1822 const uint64_t kExpectedId = partial_raster_enabled ? kInvalidatedId : 0u;
1832 const gfx::Size kTileSize(128, 128); 1823 const gfx::Size kTileSize(128, 128);
1833 1824
1834 // Create a VerifyResourceContentIdTileTaskManager to ensure that the 1825 // Create a VerifyResourceContentIdTileTaskManager to ensure that the
1835 // raster task we see is created with |kExpectedId|. 1826 // raster task we see is created with |kExpectedId|.
1836 VerifyResourceContentIdTileTaskManager verifying_task_manager(kExpectedId); 1827 FakeTileTaskManagerImpl tile_task_manager;
1837 host_impl->tile_manager()->SetTileTaskManagerForTesting( 1828 host_impl->tile_manager()->SetTileTaskManagerForTesting(&tile_task_manager);
1838 &verifying_task_manager); 1829
1830 VerifyResourceContentIdRasterBufferProvider raster_buffer_provider(
1831 kExpectedId);
1832 host_impl->tile_manager()->SetRasterBufferProviderForTesting(
1833 &raster_buffer_provider);
1839 1834
1840 // Ensure there's a resource with our |kInvalidatedId| in the resource pool. 1835 // Ensure there's a resource with our |kInvalidatedId| in the resource pool.
1841 host_impl->resource_pool()->ReleaseResource( 1836 host_impl->resource_pool()->ReleaseResource(
1842 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888), 1837 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888),
1843 kInvalidatedId); 1838 kInvalidatedId);
1844 host_impl->resource_pool()->CheckBusyResources(); 1839 host_impl->resource_pool()->CheckBusyResources();
1845 1840
1846 scoped_refptr<FakeRasterSource> pending_raster_source = 1841 scoped_refptr<FakeRasterSource> pending_raster_source =
1847 FakeRasterSource::CreateFilled(kTileSize); 1842 FakeRasterSource::CreateFilled(kTileSize);
1848 host_impl->CreatePendingTree(); 1843 host_impl->CreatePendingTree();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 } 1881 }
1887 1882
1888 // Ensures that the tile manager does not attempt to reuse tiles when partial 1883 // Ensures that the tile manager does not attempt to reuse tiles when partial
1889 // raster is disabled. 1884 // raster is disabled.
1890 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 1885 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
1891 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); 1886 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */);
1892 } 1887 }
1893 1888
1894 } // namespace 1889 } // namespace
1895 } // namespace cc 1890 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.cc ('k') | cc/tiles/tile_task_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698