Chromium Code Reviews| 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/resources/picture_layer_tiling.h" | 9 #include "cc/resources/picture_layer_tiling.h" |
| 10 #include "cc/resources/picture_layer_tiling_set.h" | 10 #include "cc/resources/picture_layer_tiling_set.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 using PictureLayerTiling::TileAt; | 41 using PictureLayerTiling::TileAt; |
| 42 | 42 |
| 43 static scoped_ptr<TestablePictureLayerTiling> Create( | 43 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 44 WhichTree tree, | 44 WhichTree tree, |
| 45 float contents_scale, | 45 float contents_scale, |
| 46 scoped_refptr<RasterSource> raster_source, | 46 scoped_refptr<RasterSource> raster_source, |
| 47 PictureLayerTilingClient* client, | 47 PictureLayerTilingClient* client, |
| 48 const LayerTreeSettings& settings) { | 48 const LayerTreeSettings& settings) { |
| 49 return make_scoped_ptr(new TestablePictureLayerTiling( | 49 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 50 tree, contents_scale, raster_source, client, | 50 tree, contents_scale, raster_source, client, |
| 51 settings.max_tiles_for_interest_area, | 51 settings.tiling_interest_area_viewport_multiplier, |
| 52 settings.skewport_target_time_in_seconds, | 52 settings.skewport_target_time_in_seconds, |
| 53 settings.skewport_extrapolation_limit_in_content_pixels)); | 53 settings.skewport_extrapolation_limit_in_content_pixels)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 56 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 57 | 57 |
| 58 using PictureLayerTiling::ComputeSkewport; | 58 using PictureLayerTiling::ComputeSkewport; |
| 59 using PictureLayerTiling::RemoveTileAt; | 59 using PictureLayerTiling::RemoveTileAt; |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 TestablePictureLayerTiling(WhichTree tree, | 62 TestablePictureLayerTiling(WhichTree tree, |
| 63 float contents_scale, | 63 float contents_scale, |
| 64 scoped_refptr<RasterSource> raster_source, | 64 scoped_refptr<RasterSource> raster_source, |
| 65 PictureLayerTilingClient* client, | 65 PictureLayerTilingClient* client, |
| 66 size_t max_tiles_for_interest_area, | 66 float tiling_interest_area_viewport_multiplier, |
| 67 float skewport_target_time, | 67 float skewport_target_time, |
| 68 int skewport_extrapolation_limit) | 68 int skewport_extrapolation_limit) |
| 69 : PictureLayerTiling(tree, | 69 : PictureLayerTiling(tree, |
| 70 contents_scale, | 70 contents_scale, |
| 71 raster_source, | 71 raster_source, |
| 72 client, | 72 client, |
| 73 max_tiles_for_interest_area, | 73 tiling_interest_area_viewport_multiplier, |
| 74 skewport_target_time, | 74 skewport_target_time, |
| 75 skewport_extrapolation_limit) {} | 75 skewport_extrapolation_limit) {} |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 class PictureLayerTilingIteratorTest : public testing::Test { | 78 class PictureLayerTilingIteratorTest : public testing::Test { |
| 79 public: | 79 public: |
| 80 PictureLayerTilingIteratorTest() {} | 80 PictureLayerTilingIteratorTest() {} |
| 81 ~PictureLayerTilingIteratorTest() override {} | 81 ~PictureLayerTilingIteratorTest() override {} |
| 82 | 82 |
| 83 void Initialize(const gfx::Size& tile_size, | 83 void Initialize(const gfx::Size& tile_size, |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 } | 542 } |
| 543 | 543 |
| 544 TEST(PictureLayerTilingTest, SkewportLimits) { | 544 TEST(PictureLayerTilingTest, SkewportLimits) { |
| 545 FakePictureLayerTilingClient client; | 545 FakePictureLayerTilingClient client; |
| 546 | 546 |
| 547 gfx::Rect viewport(0, 0, 100, 100); | 547 gfx::Rect viewport(0, 0, 100, 100); |
| 548 gfx::Size layer_bounds(200, 200); | 548 gfx::Size layer_bounds(200, 200); |
| 549 | 549 |
| 550 client.SetTileSize(gfx::Size(100, 100)); | 550 client.SetTileSize(gfx::Size(100, 100)); |
| 551 LayerTreeSettings settings; | 551 LayerTreeSettings settings; |
| 552 settings.max_tiles_for_interest_area = 10000; | |
| 553 settings.skewport_extrapolation_limit_in_content_pixels = 75; | 552 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
| 554 | 553 |
| 555 scoped_refptr<FakePicturePileImpl> pile = | 554 scoped_refptr<FakePicturePileImpl> pile = |
| 556 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 555 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 557 scoped_ptr<TestablePictureLayerTiling> tiling = | 556 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 558 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 557 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, |
| 559 settings); | 558 settings); |
| 560 | 559 |
| 561 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 560 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 562 | 561 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 } | 760 } |
| 762 | 761 |
| 763 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { | 762 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
| 764 FakePictureLayerTilingClient client; | 763 FakePictureLayerTilingClient client; |
| 765 | 764 |
| 766 gfx::Rect viewport(0, 0, 100, 100); | 765 gfx::Rect viewport(0, 0, 100, 100); |
| 767 gfx::Size layer_bounds(1500, 1500); | 766 gfx::Size layer_bounds(1500, 1500); |
| 768 | 767 |
| 769 client.SetTileSize(gfx::Size(10, 10)); | 768 client.SetTileSize(gfx::Size(10, 10)); |
| 770 LayerTreeSettings settings; | 769 LayerTreeSettings settings; |
| 771 settings.max_tiles_for_interest_area = 10000; | 770 settings.tiling_interest_area_viewport_multiplier = 1600; |
|
vmpstr
2015/05/07 17:21:39
Why 1600?
sohanjg
2015/05/08 13:26:10
Done.
I tried to keep the same interest rect as b
| |
| 772 | 771 |
| 773 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 772 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
| 774 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 773 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
| 775 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 774 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
| 776 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 775 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
| 777 // tiling. | 776 // tiling. |
| 778 scoped_refptr<FakePicturePileImpl> pile = | 777 scoped_refptr<FakePicturePileImpl> pile = |
| 779 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 778 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 780 scoped_ptr<TestablePictureLayerTiling> tiling = | 779 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 781 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, pile, &client, | 780 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, pile, &client, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1260 EXPECT_EQ(expected_exists, tile != NULL) | 1259 EXPECT_EQ(expected_exists, tile != NULL) |
| 1261 << "Rects intersecting " << rect.ToString() << " should exist. " | 1260 << "Rects intersecting " << rect.ToString() << " should exist. " |
| 1262 << "Current tile rect is " << geometry_rect.ToString(); | 1261 << "Current tile rect is " << geometry_rect.ToString(); |
| 1263 } | 1262 } |
| 1264 | 1263 |
| 1265 TEST_F(PictureLayerTilingIteratorTest, | 1264 TEST_F(PictureLayerTilingIteratorTest, |
| 1266 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1265 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
| 1267 gfx::Size layer_bounds(10000, 10000); | 1266 gfx::Size layer_bounds(10000, 10000); |
| 1268 client_.SetTileSize(gfx::Size(100, 100)); | 1267 client_.SetTileSize(gfx::Size(100, 100)); |
| 1269 LayerTreeSettings settings; | 1268 LayerTreeSettings settings; |
| 1270 settings.max_tiles_for_interest_area = 1; | 1269 settings.tiling_interest_area_viewport_multiplier = 4; |
|
vmpstr
2015/05/07 17:21:39
Why 4?
sohanjg
2015/05/08 13:26:09
Done.
same.
| |
| 1271 | 1270 |
| 1272 scoped_refptr<FakePicturePileImpl> pile = | 1271 scoped_refptr<FakePicturePileImpl> pile = |
| 1273 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1272 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1274 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, pile, | 1273 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, pile, |
| 1275 &client_, settings); | 1274 &client_, settings); |
| 1276 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1275 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1277 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1276 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1278 | 1277 |
| 1279 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1278 gfx::Rect visible_rect(8000, 8000, 50, 50); |
| 1280 | 1279 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 | 1714 |
| 1716 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1715 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
| 1717 current_screen_transform.Translate(1800, 0); | 1716 current_screen_transform.Translate(1800, 0); |
| 1718 last_screen_transform.Translate(2800, 0); | 1717 last_screen_transform.Translate(2800, 0); |
| 1719 | 1718 |
| 1720 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1719 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1721 current_screen_transform, device_viewport); | 1720 current_screen_transform, device_viewport); |
| 1722 | 1721 |
| 1723 client.SetTileSize(gfx::Size(100, 100)); | 1722 client.SetTileSize(gfx::Size(100, 100)); |
| 1724 LayerTreeSettings settings; | 1723 LayerTreeSettings settings; |
| 1725 settings.max_tiles_for_interest_area = 10000; | 1724 settings.tiling_interest_area_viewport_multiplier = 200; |
|
vmpstr
2015/05/07 17:21:39
Why 200?
sohanjg
2015/05/08 13:26:09
Done.
same.
| |
| 1726 | 1725 |
| 1727 scoped_refptr<FakePicturePileImpl> pile = | 1726 scoped_refptr<FakePicturePileImpl> pile = |
| 1728 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1727 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1729 current_layer_bounds); | 1728 current_layer_bounds); |
| 1730 scoped_ptr<TestablePictureLayerTiling> tiling = | 1729 scoped_ptr<TestablePictureLayerTiling> tiling = |
| 1731 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, | 1730 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, |
| 1732 settings); | 1731 settings); |
| 1733 | 1732 |
| 1734 // previous ("last") frame | 1733 // previous ("last") frame |
| 1735 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1734 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1845 // - Viewport moves somewhere far away and active tiling clears tiles. | 1844 // - Viewport moves somewhere far away and active tiling clears tiles. |
| 1846 // - Viewport moves back and a new active tiling tile is created. | 1845 // - Viewport moves back and a new active tiling tile is created. |
| 1847 // Result: | 1846 // Result: |
| 1848 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1847 // - Recycle tiling does _not_ have the tile in the same location (thus it |
| 1849 // will be shared next time a pending tiling is created). | 1848 // will be shared next time a pending tiling is created). |
| 1850 | 1849 |
| 1851 FakePictureLayerTilingClient active_client; | 1850 FakePictureLayerTilingClient active_client; |
| 1852 | 1851 |
| 1853 active_client.SetTileSize(gfx::Size(100, 100)); | 1852 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1854 LayerTreeSettings settings; | 1853 LayerTreeSettings settings; |
| 1855 settings.max_tiles_for_interest_area = 10; | 1854 settings.tiling_interest_area_viewport_multiplier = 10; |
|
vmpstr
2015/05/07 17:21:39
Is this line required at all? 10 is close to 9 whi
sohanjg
2015/05/08 13:26:09
Done.
Not reqd :)
| |
| 1856 | 1855 |
| 1857 scoped_refptr<FakePicturePileImpl> pile = | 1856 scoped_refptr<FakePicturePileImpl> pile = |
| 1858 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1857 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1859 gfx::Size(10000, 10000)); | 1858 gfx::Size(10000, 10000)); |
| 1860 scoped_ptr<TestablePictureLayerTiling> active_tiling = | 1859 scoped_ptr<TestablePictureLayerTiling> active_tiling = |
| 1861 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, | 1860 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, |
| 1862 &active_client, settings); | 1861 &active_client, settings); |
| 1863 // Create all tiles on this tiling. | 1862 // Create all tiles on this tiling. |
| 1864 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1863 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1865 Occlusion()); | 1864 Occlusion()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1913 &active_client, LayerTreeSettings()); | 1912 &active_client, LayerTreeSettings()); |
| 1914 // Create all tiles on this tiling. | 1913 // Create all tiles on this tiling. |
| 1915 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1914 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1916 Occlusion()); | 1915 Occlusion()); |
| 1917 | 1916 |
| 1918 FakePictureLayerTilingClient recycle_client; | 1917 FakePictureLayerTilingClient recycle_client; |
| 1919 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1918 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1920 recycle_client.set_twin_tiling(active_tiling.get()); | 1919 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1921 | 1920 |
| 1922 LayerTreeSettings settings; | 1921 LayerTreeSettings settings; |
| 1923 settings.max_tiles_for_interest_area = 10; | 1922 settings.tiling_interest_area_viewport_multiplier = 10; |
|
vmpstr
2015/05/07 17:21:39
Is this line required at all? 10 is close to 9 whi
sohanjg
2015/05/08 13:26:09
Done.
| |
| 1924 | 1923 |
| 1925 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1924 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
| 1926 gfx::Size(100, 100)); | 1925 gfx::Size(100, 100)); |
| 1927 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = | 1926 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = |
| 1928 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile, | 1927 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile, |
| 1929 &recycle_client, settings); | 1928 &recycle_client, settings); |
| 1930 | 1929 |
| 1931 // Create all tiles on the recycle tiling. All tiles should be shared. | 1930 // Create all tiles on the recycle tiling. All tiles should be shared. |
| 1932 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1931 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1933 1.0f, Occlusion()); | 1932 1.0f, Occlusion()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1966 tiling_->SetRasterSourceAndResize(pile); | 1965 tiling_->SetRasterSourceAndResize(pile); |
| 1967 | 1966 |
| 1968 // Tile size in the tiling should be resized to 250x200. | 1967 // Tile size in the tiling should be resized to 250x200. |
| 1969 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 1968 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 1970 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 1969 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 1971 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 1970 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 1972 } | 1971 } |
| 1973 | 1972 |
| 1974 } // namespace | 1973 } // namespace |
| 1975 } // namespace cc | 1974 } // namespace cc |
| OLD | NEW |