OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <limits> | 5 #include <limits> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/test/fake_display_list_raster_source.h" | 9 #include "cc/test/fake_display_list_raster_source.h" |
10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 scoped_refptr<FakeDisplayListRasterSource> raster_source = | 1789 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
1790 FakeDisplayListRasterSource::CreateEmpty(layer_size); | 1790 FakeDisplayListRasterSource::CreateEmpty(layer_size); |
1791 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, | 1791 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
1792 raster_source, &client_, | 1792 raster_source, &client_, |
1793 LayerTreeSettings()); | 1793 LayerTreeSettings()); |
1794 | 1794 |
1795 gfx::Rect content_rect(25554432, 25554432, 950, 860); | 1795 gfx::Rect content_rect(25554432, 25554432, 950, 860); |
1796 VerifyTilesExactlyCoverRect(contents_scale, content_rect); | 1796 VerifyTilesExactlyCoverRect(contents_scale, content_rect); |
1797 } | 1797 } |
1798 | 1798 |
| 1799 // Invalidates a tiling and ensures that if partial raster is enabled, the |
| 1800 // tiling provides tiles with an invalidated id. |
| 1801 TEST_F(PictureLayerTilingIteratorTest, InvalidateRespectsEnabledPartialRaster) { |
| 1802 gfx::Size tile_size(100, 100); |
| 1803 gfx::Size original_layer_size(10, 10); |
| 1804 client_.SetTileSize(tile_size); |
| 1805 client_.set_partial_raster_enabled(true); |
| 1806 LayerTreeSettings settings; |
| 1807 settings.use_partial_raster = true; |
| 1808 |
| 1809 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
| 1810 FakeDisplayListRasterSource::CreateFilled(original_layer_size); |
| 1811 tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, raster_source, |
| 1812 &client_, settings); |
| 1813 tiling_->set_resolution(HIGH_RESOLUTION); |
| 1814 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 1815 |
| 1816 // Tiling only has one tile, since its total size is less than one. |
| 1817 Tile::Id original_id = tiling_->TileAt(0, 0)->id(); |
| 1818 EXPECT_NE(0u, original_id); |
| 1819 EXPECT_EQ(0u, tiling_->TileAt(0, 0)->invalidated_id()); |
| 1820 |
| 1821 Region invalidation = |
| 1822 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 1823 tiling_->Invalidate(invalidation); |
| 1824 EXPECT_EQ(original_id, tiling_->TileAt(0, 0)->invalidated_id()); |
| 1825 } |
| 1826 |
| 1827 // Invalidates a tiling and ensures that if partial raster is disabled, the |
| 1828 // tiling does not provide tiles with an invalidated id. |
| 1829 TEST_F(PictureLayerTilingIteratorTest, |
| 1830 InvalidateRespectsDisabledPartialRaster) { |
| 1831 gfx::Size tile_size(100, 100); |
| 1832 gfx::Size original_layer_size(10, 10); |
| 1833 client_.SetTileSize(tile_size); |
| 1834 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
| 1835 FakeDisplayListRasterSource::CreateFilled(original_layer_size); |
| 1836 tiling_ = TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, raster_source, |
| 1837 &client_, LayerTreeSettings()); |
| 1838 tiling_->set_resolution(HIGH_RESOLUTION); |
| 1839 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 1840 |
| 1841 // Tiling only has one tile, since its total size is less than one. |
| 1842 EXPECT_NE(0u, tiling_->TileAt(0, 0)->id()); |
| 1843 EXPECT_EQ(0u, tiling_->TileAt(0, 0)->invalidated_id()); |
| 1844 |
| 1845 Region invalidation = |
| 1846 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 1847 tiling_->Invalidate(invalidation); |
| 1848 EXPECT_EQ(0u, tiling_->TileAt(0, 0)->invalidated_id()); |
| 1849 } |
| 1850 |
| 1851 // Ensures that if partial raster is enabled, we copy the tile ids from the |
| 1852 // active tiling to the invalidated ids of any new tiles created by |
| 1853 // CreateMissingTilesInLiveTilesRect. |
| 1854 TEST_F(PictureLayerTilingIteratorTest, |
| 1855 CreateMissingRespectsEnabledPartialRaster) { |
| 1856 gfx::Size tile_size(100, 100); |
| 1857 gfx::Size original_layer_size(10, 10); |
| 1858 LayerTreeSettings settings; |
| 1859 settings.use_partial_raster = true; |
| 1860 Region invalidation = |
| 1861 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 1862 scoped_refptr<FakeDisplayListRasterSource> empty_raster_source = |
| 1863 FakeDisplayListRasterSource::CreatePartiallyFilled(original_layer_size, |
| 1864 gfx::Rect()); |
| 1865 scoped_refptr<FakeDisplayListRasterSource> filled_raster_source = |
| 1866 FakeDisplayListRasterSource::CreateFilled(original_layer_size); |
| 1867 |
| 1868 // Set up the client. |
| 1869 client_.SetTileSize(tile_size); |
| 1870 client_.set_partial_raster_enabled(settings.use_partial_raster); |
| 1871 client_.set_invalidation(invalidation); |
| 1872 |
| 1873 // Create a twin tiling based on the filled raster source and set it to the |
| 1874 // client. |
| 1875 scoped_ptr<TestablePictureLayerTiling> twin_tiling = |
| 1876 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, filled_raster_source, |
| 1877 &client_, settings); |
| 1878 twin_tiling->set_resolution(HIGH_RESOLUTION); |
| 1879 twin_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size)); |
| 1880 client_.set_twin_tiling(twin_tiling.get()); |
| 1881 |
| 1882 // The twin tiling should have a valid tile at 0,0. |
| 1883 Tile::Id original_tile_id = twin_tiling->TileAt(0, 0)->id(); |
| 1884 DCHECK_NE(0u, original_tile_id); |
| 1885 |
| 1886 // Crate an empty tiling which will have CreateMissingTilesInLiveTilesRect |
| 1887 // called on it. |
| 1888 scoped_ptr<TestablePictureLayerTiling> empty_tiling = |
| 1889 TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, empty_raster_source, |
| 1890 &client_, settings); |
| 1891 empty_tiling->set_resolution(HIGH_RESOLUTION); |
| 1892 empty_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size)); |
| 1893 EXPECT_EQ(nullptr, empty_tiling->TileAt(0, 0)); |
| 1894 |
| 1895 // Now update the |empty_tiling|'s raster source to the filled source, so |
| 1896 // that it will attempt to create tiles when CreateMissingTilesInLiveTilesRect |
| 1897 // is called. |
| 1898 empty_tiling->SetRasterSourceAndResize(filled_raster_source); |
| 1899 |
| 1900 empty_tiling->CreateMissingTilesInLiveTilesRect(); |
| 1901 EXPECT_EQ(original_tile_id, empty_tiling->TileAt(0, 0)->invalidated_id()); |
| 1902 } |
| 1903 |
| 1904 // Ensures that if partial raster is disavbled, we do not set invalidated ids on |
| 1905 // any new tiles created by CreateMissingTilesInLiveTilesRect. |
| 1906 TEST_F(PictureLayerTilingIteratorTest, |
| 1907 CreateMissingRespectsDisabledPartialRaster) { |
| 1908 gfx::Size tile_size(100, 100); |
| 1909 gfx::Size original_layer_size(10, 10); |
| 1910 LayerTreeSettings settings; |
| 1911 settings.use_partial_raster = false; |
| 1912 Region invalidation = |
| 1913 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 1914 scoped_refptr<FakeDisplayListRasterSource> empty_raster_source = |
| 1915 FakeDisplayListRasterSource::CreatePartiallyFilled(original_layer_size, |
| 1916 gfx::Rect()); |
| 1917 scoped_refptr<FakeDisplayListRasterSource> filled_raster_source = |
| 1918 FakeDisplayListRasterSource::CreateFilled(original_layer_size); |
| 1919 |
| 1920 // Set up the client. |
| 1921 client_.SetTileSize(tile_size); |
| 1922 client_.set_partial_raster_enabled(settings.use_partial_raster); |
| 1923 client_.set_invalidation(invalidation); |
| 1924 |
| 1925 // Create a twin tiling based on the filled raster source and set it to the |
| 1926 // client. |
| 1927 scoped_ptr<TestablePictureLayerTiling> twin_tiling = |
| 1928 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.f, filled_raster_source, |
| 1929 &client_, settings); |
| 1930 twin_tiling->set_resolution(HIGH_RESOLUTION); |
| 1931 twin_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size)); |
| 1932 client_.set_twin_tiling(twin_tiling.get()); |
| 1933 |
| 1934 // The twin tiling should have a valid tile at 0,0. |
| 1935 DCHECK_NE(0u, twin_tiling->TileAt(0, 0)->id()); |
| 1936 |
| 1937 // Crate an empty tiling which will have CreateMissingTilesInLiveTilesRect |
| 1938 // called on it. |
| 1939 scoped_ptr<TestablePictureLayerTiling> empty_tiling = |
| 1940 TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, empty_raster_source, |
| 1941 &client_, settings); |
| 1942 empty_tiling->set_resolution(HIGH_RESOLUTION); |
| 1943 empty_tiling->SetLiveTilesRect(gfx::Rect(original_layer_size)); |
| 1944 EXPECT_EQ(nullptr, empty_tiling->TileAt(0, 0)); |
| 1945 |
| 1946 // Now update the |empty_tiling|'s raster source to the filled source, so |
| 1947 // that it will attempt to create tiles when CreateMissingTilesInLiveTilesRect |
| 1948 // is called. |
| 1949 empty_tiling->SetRasterSourceAndResize(filled_raster_source); |
| 1950 |
| 1951 empty_tiling->CreateMissingTilesInLiveTilesRect(); |
| 1952 EXPECT_EQ(0u, empty_tiling->TileAt(0, 0)->invalidated_id()); |
| 1953 } |
| 1954 |
1799 } // namespace | 1955 } // namespace |
1800 } // namespace cc | 1956 } // namespace cc |
OLD | NEW |