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

Side by Side Diff: cc/resources/picture_layer_tiling_unittest.cc

Issue 1126793002: cc: Make tiling interest rect calc based on viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove switch entry from chromeos cmdline. Created 5 years, 7 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 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
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
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
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 = 10000;
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
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 = 1;
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
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 = 10000;
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
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;
1856 1854
1857 scoped_refptr<FakePicturePileImpl> pile = 1855 scoped_refptr<FakePicturePileImpl> pile =
1858 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( 1856 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
1859 gfx::Size(10000, 10000)); 1857 gfx::Size(10000, 10000));
1860 scoped_ptr<TestablePictureLayerTiling> active_tiling = 1858 scoped_ptr<TestablePictureLayerTiling> active_tiling =
1861 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, 1859 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile,
1862 &active_client, settings); 1860 &active_client, settings);
1863 // Create all tiles on this tiling. 1861 // Create all tiles on this tiling.
1864 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, 1862 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f,
1865 Occlusion()); 1863 Occlusion());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 &active_client, LayerTreeSettings()); 1911 &active_client, LayerTreeSettings());
1914 // Create all tiles on this tiling. 1912 // Create all tiles on this tiling.
1915 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, 1913 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f,
1916 Occlusion()); 1914 Occlusion());
1917 1915
1918 FakePictureLayerTilingClient recycle_client; 1916 FakePictureLayerTilingClient recycle_client;
1919 recycle_client.SetTileSize(gfx::Size(100, 100)); 1917 recycle_client.SetTileSize(gfx::Size(100, 100));
1920 recycle_client.set_twin_tiling(active_tiling.get()); 1918 recycle_client.set_twin_tiling(active_tiling.get());
1921 1919
1922 LayerTreeSettings settings; 1920 LayerTreeSettings settings;
1923 settings.max_tiles_for_interest_area = 10;
1924 1921
1925 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( 1922 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
1926 gfx::Size(100, 100)); 1923 gfx::Size(100, 100));
1927 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = 1924 scoped_ptr<TestablePictureLayerTiling> recycle_tiling =
1928 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile, 1925 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile,
1929 &recycle_client, settings); 1926 &recycle_client, settings);
1930 1927
1931 // Create all tiles on the recycle tiling. All tiles should be shared. 1928 // Create all tiles on the recycle tiling. All tiles should be shared.
1932 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1929 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f,
1933 1.0f, Occlusion()); 1930 1.0f, Occlusion());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 tiling_->SetRasterSourceAndResize(pile); 1963 tiling_->SetRasterSourceAndResize(pile);
1967 1964
1968 // Tile size in the tiling should be resized to 250x200. 1965 // Tile size in the tiling should be resized to 250x200.
1969 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); 1966 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
1970 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); 1967 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
1971 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); 1968 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size());
1972 } 1969 }
1973 1970
1974 } // namespace 1971 } // namespace
1975 } // namespace cc 1972 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set_unittest.cc ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698