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

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

Powered by Google App Engine
This is Rietveld 408576698