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

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

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: cleanup tasks if ordering barrier fails Created 4 years, 6 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
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 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 uint64_t resource_content_id, 1802 uint64_t resource_content_id,
1803 uint64_t previous_content_id) override { 1803 uint64_t previous_content_id) override {
1804 EXPECT_EQ(expected_resource_id_, resource_content_id); 1804 EXPECT_EQ(expected_resource_id_, resource_content_id);
1805 return nullptr; 1805 return nullptr;
1806 } 1806 }
1807 1807
1808 private: 1808 private:
1809 uint64_t expected_resource_id_; 1809 uint64_t expected_resource_id_;
1810 }; 1810 };
1811 1811
1812 class VerifyResourceContentIdTileTaskManager : public FakeTileTaskManagerImpl {
1813 public:
1814 explicit VerifyResourceContentIdTileTaskManager(uint64_t expected_resource_id)
1815 : FakeTileTaskManagerImpl(base::WrapUnique<RasterBufferProvider>(
1816 new VerifyResourceContentIdRasterBufferProvider(
1817 expected_resource_id))) {}
1818 ~VerifyResourceContentIdTileTaskManager() override {}
1819 };
1820
1821 // Runs a test to ensure that partial raster is either enabled or disabled, 1812 // Runs a test to ensure that partial raster is either enabled or disabled,
1822 // depending on |partial_raster_enabled|'s value. Takes ownership of host_impl 1813 // depending on |partial_raster_enabled|'s value. Takes ownership of host_impl
1823 // so that cleanup order can be controlled. 1814 // so that cleanup order can be controlled.
1824 void RunPartialRasterCheck(std::unique_ptr<LayerTreeHostImpl> host_impl, 1815 void RunPartialRasterCheck(std::unique_ptr<LayerTreeHostImpl> host_impl,
1825 bool partial_raster_enabled) { 1816 bool partial_raster_enabled) {
1826 // Pick arbitrary IDs - they don't really matter as long as they're constant. 1817 // Pick arbitrary IDs - they don't really matter as long as they're constant.
1827 const int kLayerId = 7; 1818 const int kLayerId = 7;
1828 const uint64_t kInvalidatedId = 43; 1819 const uint64_t kInvalidatedId = 43;
1829 const uint64_t kExpectedId = partial_raster_enabled ? kInvalidatedId : 0u; 1820 const uint64_t kExpectedId = partial_raster_enabled ? kInvalidatedId : 0u;
1830 const gfx::Size kTileSize(128, 128); 1821 const gfx::Size kTileSize(128, 128);
1831 1822
1832 // Create a VerifyResourceContentIdTileTaskManager to ensure that the 1823 // Create a VerifyResourceContentIdTileTaskManager to ensure that the
1833 // raster task we see is created with |kExpectedId|. 1824 // raster task we see is created with |kExpectedId|.
1834 VerifyResourceContentIdTileTaskManager verifying_task_manager(kExpectedId); 1825 FakeTileTaskManagerImpl tile_task_manager;
1835 host_impl->tile_manager()->SetTileTaskManagerForTesting( 1826 host_impl->tile_manager()->SetTileTaskManagerForTesting(&tile_task_manager);
1836 &verifying_task_manager); 1827
1828 VerifyResourceContentIdRasterBufferProvider raster_buffer_provider(
1829 kExpectedId);
1830 host_impl->tile_manager()->SetRasterBufferProviderForTesting(
1831 &raster_buffer_provider);
1837 1832
1838 // Ensure there's a resource with our |kInvalidatedId| in the resource pool. 1833 // Ensure there's a resource with our |kInvalidatedId| in the resource pool.
1839 host_impl->resource_pool()->ReleaseResource( 1834 host_impl->resource_pool()->ReleaseResource(
1840 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888), 1835 host_impl->resource_pool()->AcquireResource(kTileSize, RGBA_8888),
1841 kInvalidatedId); 1836 kInvalidatedId);
1842 host_impl->resource_pool()->CheckBusyResources(); 1837 host_impl->resource_pool()->CheckBusyResources();
1843 1838
1844 scoped_refptr<FakeRasterSource> pending_raster_source = 1839 scoped_refptr<FakeRasterSource> pending_raster_source =
1845 FakeRasterSource::CreateFilled(kTileSize); 1840 FakeRasterSource::CreateFilled(kTileSize);
1846 host_impl->CreatePendingTree(); 1841 host_impl->CreatePendingTree();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 } 1879 }
1885 1880
1886 // Ensures that the tile manager does not attempt to reuse tiles when partial 1881 // Ensures that the tile manager does not attempt to reuse tiles when partial
1887 // raster is disabled. 1882 // raster is disabled.
1888 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 1883 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
1889 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); 1884 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */);
1890 } 1885 }
1891 1886
1892 } // namespace 1887 } // namespace
1893 } // namespace cc 1888 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698