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/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "cc/playback/display_list_raster_source.h" | 10 #include "cc/playback/display_list_raster_source.h" |
(...skipping 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 // Since it's high res, the bitmap (blue) was drawn, and the | 1815 // Since it's high res, the bitmap (blue) was drawn, and the |
1816 // background is not visible. | 1816 // background is not visible. |
1817 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); | 1817 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); |
1818 } | 1818 } |
1819 } | 1819 } |
1820 } | 1820 } |
1821 } | 1821 } |
1822 } | 1822 } |
1823 | 1823 |
1824 // Fake TileTaskRunner that just no-ops all calls. | 1824 // Fake TileTaskRunner that just no-ops all calls. |
1825 class FakeTileTaskRunner : public TileTaskRunner, public TileTaskClient { | 1825 class FakeTileTaskRunner : public TileTaskRunner, public DependencyTaskClient { |
1826 public: | 1826 public: |
1827 FakeTileTaskRunner() {} | 1827 FakeTileTaskRunner() {} |
1828 ~FakeTileTaskRunner() override {} | 1828 ~FakeTileTaskRunner() override {} |
1829 | 1829 |
1830 // TileTaskRunner methods. | 1830 // TileTaskRunner methods. |
1831 void Shutdown() override {} | 1831 void Shutdown() override {} |
1832 void CheckForCompletedTasks() override {} | 1832 void CheckForCompletedTasks() override {} |
1833 ResourceFormat GetResourceFormat(bool must_support_alpha) const override { | 1833 ResourceFormat GetResourceFormat(bool must_support_alpha) const override { |
1834 return ResourceFormat::RGBA_8888; | 1834 return ResourceFormat::RGBA_8888; |
1835 } | 1835 } |
1836 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override { | 1836 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override { |
1837 return false; | 1837 return false; |
1838 } | 1838 } |
1839 | 1839 |
1840 void ScheduleTasks(TaskGraph* graph) override {} | 1840 void ScheduleTasks(TaskGraph* graph) override {} |
1841 | 1841 |
1842 // TileTaskClient methods. | 1842 // DependencyTaskClient methods. |
1843 scoped_ptr<RasterBuffer> AcquireBufferForRaster( | 1843 scoped_ptr<RasterBuffer> AcquireBufferForRaster( |
1844 const Resource* resource, | 1844 const Resource* resource, |
1845 uint64_t resource_content_id, | 1845 uint64_t resource_content_id, |
1846 uint64_t previous_content_id) override { | 1846 uint64_t previous_content_id) override { |
1847 NOTREACHED(); | 1847 NOTREACHED(); |
1848 return nullptr; | 1848 return nullptr; |
1849 } | 1849 } |
1850 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} | 1850 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} |
1851 }; | 1851 }; |
1852 | 1852 |
1853 // Fake TileTaskRunner that just cancels all scheduled tasks immediately. | 1853 // Fake TileTaskRunner that just cancels all scheduled tasks immediately. |
1854 class CancellingTileTaskRunner : public FakeTileTaskRunner { | 1854 class CancellingTileTaskRunner : public FakeTileTaskRunner { |
1855 public: | 1855 public: |
1856 CancellingTileTaskRunner() {} | 1856 CancellingTileTaskRunner() {} |
1857 ~CancellingTileTaskRunner() override {} | 1857 ~CancellingTileTaskRunner() override {} |
1858 | 1858 |
1859 void ScheduleTasks(TaskGraph* graph) override { | 1859 void ScheduleTasks(TaskGraph* graph) override { |
1860 // Just call CompleteOnOriginThread on each item in the queue. As none of | 1860 // Just call CompleteOnOriginThread on each item in the queue. As none of |
1861 // these items have run yet, they will be treated as cancelled tasks. | 1861 // these items have run yet, they will be treated as cancelled tasks. |
1862 for (const auto& node : graph->nodes) { | 1862 for (const auto& node : graph->nodes) { |
1863 static_cast<TileTask*>(node.task)->CompleteOnOriginThread(this); | 1863 node.task->CompleteOnOriginThread(this); |
1864 } | 1864 } |
1865 } | 1865 } |
1866 }; | 1866 }; |
1867 | 1867 |
1868 class PartialRasterTileManagerTest : public TileManagerTest { | 1868 class PartialRasterTileManagerTest : public TileManagerTest { |
1869 public: | 1869 public: |
1870 void CustomizeSettings(LayerTreeSettings* settings) override { | 1870 void CustomizeSettings(LayerTreeSettings* settings) override { |
1871 settings->use_partial_raster = true; | 1871 settings->use_partial_raster = true; |
1872 } | 1872 } |
1873 }; | 1873 }; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 | 1928 |
1929 // Fake TileTaskRunner that verifies the resource content ID of raster tasks. | 1929 // Fake TileTaskRunner that verifies the resource content ID of raster tasks. |
1930 class VerifyResourceContentIdTileTaskRunner : public FakeTileTaskRunner { | 1930 class VerifyResourceContentIdTileTaskRunner : public FakeTileTaskRunner { |
1931 public: | 1931 public: |
1932 explicit VerifyResourceContentIdTileTaskRunner(uint64_t expected_resource_id) | 1932 explicit VerifyResourceContentIdTileTaskRunner(uint64_t expected_resource_id) |
1933 : expected_resource_id_(expected_resource_id) {} | 1933 : expected_resource_id_(expected_resource_id) {} |
1934 ~VerifyResourceContentIdTileTaskRunner() override {} | 1934 ~VerifyResourceContentIdTileTaskRunner() override {} |
1935 | 1935 |
1936 void ScheduleTasks(TaskGraph* graph) override { | 1936 void ScheduleTasks(TaskGraph* graph) override { |
1937 for (const auto& node : graph->nodes) { | 1937 for (const auto& node : graph->nodes) { |
1938 TileTask* task = static_cast<TileTask*>(node.task); | 1938 DependencyTask* task = node.task; |
1939 // Triggers a call to AcquireBufferForRaster. | 1939 // Triggers a call to AcquireBufferForRaster. |
1940 task->ScheduleOnOriginThread(this); | 1940 task->ScheduleOnOriginThread(this); |
1941 // Calls TileManager as though task was cancelled. | 1941 // Calls TileManager as though task was cancelled. |
1942 task->CompleteOnOriginThread(this); | 1942 task->CompleteOnOriginThread(this); |
1943 } | 1943 } |
1944 } | 1944 } |
1945 | 1945 |
1946 // TileTaskClient methods. | 1946 // DependencyTaskClient methods. |
1947 scoped_ptr<RasterBuffer> AcquireBufferForRaster( | 1947 scoped_ptr<RasterBuffer> AcquireBufferForRaster( |
1948 const Resource* resource, | 1948 const Resource* resource, |
1949 uint64_t resource_content_id, | 1949 uint64_t resource_content_id, |
1950 uint64_t previous_content_id) override { | 1950 uint64_t previous_content_id) override { |
1951 EXPECT_EQ(expected_resource_id_, resource_content_id); | 1951 EXPECT_EQ(expected_resource_id_, resource_content_id); |
1952 return nullptr; | 1952 return nullptr; |
1953 } | 1953 } |
1954 | 1954 |
1955 private: | 1955 private: |
1956 uint64_t expected_resource_id_; | 1956 uint64_t expected_resource_id_; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 | 2023 |
2024 // Ensures that the tile manager does not attempt to reuse tiles when partial | 2024 // Ensures that the tile manager does not attempt to reuse tiles when partial |
2025 // raster is disabled. | 2025 // raster is disabled. |
2026 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 2026 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
2027 RunPartialRasterCheck(std::move(host_impl_), | 2027 RunPartialRasterCheck(std::move(host_impl_), |
2028 false /* partial_raster_enabled */); | 2028 false /* partial_raster_enabled */); |
2029 } | 2029 } |
2030 | 2030 |
2031 } // namespace | 2031 } // namespace |
2032 } // namespace cc | 2032 } // namespace cc |
OLD | NEW |