| 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/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 | 1901 |
| 1902 // The first task to run should be ReadyToDraw (this should not be blocked by | 1902 // The first task to run should be ReadyToDraw (this should not be blocked by |
| 1903 // the tasks required for activation). | 1903 // the tasks required for activation). |
| 1904 base::RunLoop run_loop; | 1904 base::RunLoop run_loop; |
| 1905 EXPECT_CALL(*host_impl_, NotifyReadyToDraw()) | 1905 EXPECT_CALL(*host_impl_, NotifyReadyToDraw()) |
| 1906 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | 1906 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| 1907 GetSynchronousTaskGraphRunner()->RunSingleTaskForTesting(); | 1907 GetSynchronousTaskGraphRunner()->RunSingleTaskForTesting(); |
| 1908 run_loop.Run(); | 1908 run_loop.Run(); |
| 1909 } | 1909 } |
| 1910 | 1910 |
| 1911 // Fake TileTaskManager that just cancels all scheduled tasks immediately. | 1911 using CancellingTileTaskManager = FakeTileTaskManagerImpl; |
| 1912 class CancellingTileTaskManager : public FakeTileTaskManagerImpl { | |
| 1913 public: | |
| 1914 CancellingTileTaskManager() {} | |
| 1915 ~CancellingTileTaskManager() override {} | |
| 1916 | |
| 1917 void ScheduleTasks(TaskGraph* graph) override { | |
| 1918 // Just call CompleteOnOriginThread on each item in the queue. As none of | |
| 1919 // these items have run yet, they will be treated as cancelled tasks. | |
| 1920 for (const auto& node : graph->nodes) { | |
| 1921 static_cast<TileTask*>(node.task)->CompleteOnOriginThread( | |
| 1922 raster_buffer_provider_.get()); | |
| 1923 } | |
| 1924 } | |
| 1925 void CheckForCompletedTasks() override {} | |
| 1926 }; | |
| 1927 | 1912 |
| 1928 class PartialRasterTileManagerTest : public TileManagerTest { | 1913 class PartialRasterTileManagerTest : public TileManagerTest { |
| 1929 public: | 1914 public: |
| 1930 void CustomizeSettings(LayerTreeSettings* settings) override { | 1915 void CustomizeSettings(LayerTreeSettings* settings) override { |
| 1931 settings->use_partial_raster = true; | 1916 settings->use_partial_raster = true; |
| 1932 } | 1917 } |
| 1933 }; | 1918 }; |
| 1934 | 1919 |
| 1935 // Ensures that if a raster task is cancelled, it gets returned to the resource | 1920 // Ensures that if a raster task is cancelled, it gets returned to the resource |
| 1936 // pool with an invalid content ID, not with its invalidated content ID. | 1921 // pool with an invalid content ID, not with its invalidated content ID. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 uint64_t expected_resource_id_; | 1995 uint64_t expected_resource_id_; |
| 2011 }; | 1996 }; |
| 2012 | 1997 |
| 2013 class VerifyResourceContentIdTileTaskManager : public FakeTileTaskManagerImpl { | 1998 class VerifyResourceContentIdTileTaskManager : public FakeTileTaskManagerImpl { |
| 2014 public: | 1999 public: |
| 2015 explicit VerifyResourceContentIdTileTaskManager(uint64_t expected_resource_id) | 2000 explicit VerifyResourceContentIdTileTaskManager(uint64_t expected_resource_id) |
| 2016 : FakeTileTaskManagerImpl(base::WrapUnique<RasterBufferProvider>( | 2001 : FakeTileTaskManagerImpl(base::WrapUnique<RasterBufferProvider>( |
| 2017 new VerifyResourceContentIdRasterBufferProvider( | 2002 new VerifyResourceContentIdRasterBufferProvider( |
| 2018 expected_resource_id))) {} | 2003 expected_resource_id))) {} |
| 2019 ~VerifyResourceContentIdTileTaskManager() override {} | 2004 ~VerifyResourceContentIdTileTaskManager() override {} |
| 2020 | |
| 2021 void ScheduleTasks(TaskGraph* graph) override { | |
| 2022 for (const auto& node : graph->nodes) { | |
| 2023 TileTask* task = static_cast<TileTask*>(node.task); | |
| 2024 // Triggers a call to AcquireBufferForRaster. | |
| 2025 task->ScheduleOnOriginThread(raster_buffer_provider_.get()); | |
| 2026 // Calls TileManager as though task was cancelled. | |
| 2027 task->CompleteOnOriginThread(raster_buffer_provider_.get()); | |
| 2028 } | |
| 2029 } | |
| 2030 void CheckForCompletedTasks() override {} | |
| 2031 }; | 2005 }; |
| 2032 | 2006 |
| 2033 // Runs a test to ensure that partial raster is either enabled or disabled, | 2007 // Runs a test to ensure that partial raster is either enabled or disabled, |
| 2034 // depending on |partial_raster_enabled|'s value. Takes ownership of host_impl | 2008 // depending on |partial_raster_enabled|'s value. Takes ownership of host_impl |
| 2035 // so that cleanup order can be controlled. | 2009 // so that cleanup order can be controlled. |
| 2036 void RunPartialRasterCheck(std::unique_ptr<LayerTreeHostImpl> host_impl, | 2010 void RunPartialRasterCheck(std::unique_ptr<LayerTreeHostImpl> host_impl, |
| 2037 bool partial_raster_enabled) { | 2011 bool partial_raster_enabled) { |
| 2038 // Pick arbitrary IDs - they don't really matter as long as they're constant. | 2012 // Pick arbitrary IDs - they don't really matter as long as they're constant. |
| 2039 const int kLayerId = 7; | 2013 const int kLayerId = 7; |
| 2040 const uint64_t kInvalidatedId = 43; | 2014 const uint64_t kInvalidatedId = 43; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2072 |
| 2099 // Ensures that the tile manager does not attempt to reuse tiles when partial | 2073 // Ensures that the tile manager does not attempt to reuse tiles when partial |
| 2100 // raster is disabled. | 2074 // raster is disabled. |
| 2101 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 2075 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
| 2102 RunPartialRasterCheck(std::move(host_impl_), | 2076 RunPartialRasterCheck(std::move(host_impl_), |
| 2103 false /* partial_raster_enabled */); | 2077 false /* partial_raster_enabled */); |
| 2104 } | 2078 } |
| 2105 | 2079 |
| 2106 } // namespace | 2080 } // namespace |
| 2107 } // namespace cc | 2081 } // namespace cc |
| OLD | NEW |