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

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

Issue 1196553009: Revert "cc: Make tiling interest rect calc based on viewport." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert extra bools. Created 5 years, 6 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
« no previous file with comments | « cc/tiles/picture_layer_tiling_set_unittest.cc ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/fake_output_surface.h" 9 #include "cc/test/fake_output_surface.h"
10 #include "cc/test/fake_output_surface_client.h" 10 #include "cc/test/fake_output_surface_client.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 using PictureLayerTiling::TileAt; 42 using PictureLayerTiling::TileAt;
43 43
44 static scoped_ptr<TestablePictureLayerTiling> Create( 44 static scoped_ptr<TestablePictureLayerTiling> Create(
45 WhichTree tree, 45 WhichTree tree,
46 float contents_scale, 46 float contents_scale,
47 scoped_refptr<RasterSource> raster_source, 47 scoped_refptr<RasterSource> raster_source,
48 PictureLayerTilingClient* client, 48 PictureLayerTilingClient* client,
49 const LayerTreeSettings& settings) { 49 const LayerTreeSettings& settings) {
50 return make_scoped_ptr(new TestablePictureLayerTiling( 50 return make_scoped_ptr(new TestablePictureLayerTiling(
51 tree, contents_scale, raster_source, client, 51 tree, contents_scale, raster_source, client,
52 settings.tiling_interest_area_viewport_multiplier, 52 settings.max_tiles_for_interest_area,
53 settings.skewport_target_time_in_seconds, 53 settings.skewport_target_time_in_seconds,
54 settings.skewport_extrapolation_limit_in_content_pixels)); 54 settings.skewport_extrapolation_limit_in_content_pixels));
55 } 55 }
56 56
57 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 57 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
58 58
59 using PictureLayerTiling::ComputeSkewport; 59 using PictureLayerTiling::ComputeSkewport;
60 using PictureLayerTiling::RemoveTileAt; 60 using PictureLayerTiling::RemoveTileAt;
61 61
62 protected: 62 protected:
63 TestablePictureLayerTiling(WhichTree tree, 63 TestablePictureLayerTiling(WhichTree tree,
64 float contents_scale, 64 float contents_scale,
65 scoped_refptr<RasterSource> raster_source, 65 scoped_refptr<RasterSource> raster_source,
66 PictureLayerTilingClient* client, 66 PictureLayerTilingClient* client,
67 float tiling_interest_area_viewport_multiplier, 67 size_t max_tiles_for_interest_area,
68 float skewport_target_time, 68 float skewport_target_time,
69 int skewport_extrapolation_limit) 69 int skewport_extrapolation_limit)
70 : PictureLayerTiling(tree, 70 : PictureLayerTiling(tree,
71 contents_scale, 71 contents_scale,
72 raster_source, 72 raster_source,
73 client, 73 client,
74 tiling_interest_area_viewport_multiplier, 74 max_tiles_for_interest_area,
75 skewport_target_time, 75 skewport_target_time,
76 skewport_extrapolation_limit) {} 76 skewport_extrapolation_limit) {}
77 }; 77 };
78 78
79 class PictureLayerTilingIteratorTest : public testing::Test { 79 class PictureLayerTilingIteratorTest : public testing::Test {
80 public: 80 public:
81 PictureLayerTilingIteratorTest() {} 81 PictureLayerTilingIteratorTest() {}
82 ~PictureLayerTilingIteratorTest() override {} 82 ~PictureLayerTilingIteratorTest() override {}
83 83
84 void Initialize(const gfx::Size& tile_size, 84 void Initialize(const gfx::Size& tile_size,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 543 }
544 544
545 TEST(PictureLayerTilingTest, SkewportLimits) { 545 TEST(PictureLayerTilingTest, SkewportLimits) {
546 FakePictureLayerTilingClient client; 546 FakePictureLayerTilingClient client;
547 547
548 gfx::Rect viewport(0, 0, 100, 100); 548 gfx::Rect viewport(0, 0, 100, 100);
549 gfx::Size layer_bounds(200, 200); 549 gfx::Size layer_bounds(200, 200);
550 550
551 client.SetTileSize(gfx::Size(100, 100)); 551 client.SetTileSize(gfx::Size(100, 100));
552 LayerTreeSettings settings; 552 LayerTreeSettings settings;
553 settings.max_tiles_for_interest_area = 10000;
553 settings.skewport_extrapolation_limit_in_content_pixels = 75; 554 settings.skewport_extrapolation_limit_in_content_pixels = 75;
554 555
555 scoped_refptr<FakePicturePileImpl> pile = 556 scoped_refptr<FakePicturePileImpl> pile =
556 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); 557 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds);
557 scoped_ptr<TestablePictureLayerTiling> tiling = 558 scoped_ptr<TestablePictureLayerTiling> tiling =
558 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, 559 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client,
559 settings); 560 settings);
560 561
561 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); 562 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion());
562 563
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 786 }
786 787
787 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { 788 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) {
788 FakePictureLayerTilingClient client; 789 FakePictureLayerTilingClient client;
789 790
790 gfx::Rect viewport(0, 0, 100, 100); 791 gfx::Rect viewport(0, 0, 100, 100);
791 gfx::Size layer_bounds(1500, 1500); 792 gfx::Size layer_bounds(1500, 1500);
792 793
793 client.SetTileSize(gfx::Size(10, 10)); 794 client.SetTileSize(gfx::Size(10, 10));
794 LayerTreeSettings settings; 795 LayerTreeSettings settings;
795 settings.tiling_interest_area_viewport_multiplier = 10000; 796 settings.max_tiles_for_interest_area = 10000;
796 797
797 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. 798 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10.
798 // The reason is that each tile has a one pixel border, so tile at (1, 2) 799 // The reason is that each tile has a one pixel border, so tile at (1, 2)
799 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at 800 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at
800 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the 801 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the
801 // tiling. 802 // tiling.
802 scoped_refptr<FakePicturePileImpl> pile = 803 scoped_refptr<FakePicturePileImpl> pile =
803 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); 804 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds);
804 scoped_ptr<TestablePictureLayerTiling> tiling = 805 scoped_ptr<TestablePictureLayerTiling> tiling =
805 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, pile, &client, 806 TestablePictureLayerTiling::Create(ACTIVE_TREE, 0.25f, pile, &client,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 EXPECT_EQ(expected_exists, tile != NULL) 1286 EXPECT_EQ(expected_exists, tile != NULL)
1286 << "Rects intersecting " << rect.ToString() << " should exist. " 1287 << "Rects intersecting " << rect.ToString() << " should exist. "
1287 << "Current tile rect is " << geometry_rect.ToString(); 1288 << "Current tile rect is " << geometry_rect.ToString();
1288 } 1289 }
1289 1290
1290 TEST_F(PictureLayerTilingIteratorTest, 1291 TEST_F(PictureLayerTilingIteratorTest,
1291 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { 1292 TilesExistLargeViewportAndLayerWithSmallVisibleArea) {
1292 gfx::Size layer_bounds(10000, 10000); 1293 gfx::Size layer_bounds(10000, 10000);
1293 client_.SetTileSize(gfx::Size(100, 100)); 1294 client_.SetTileSize(gfx::Size(100, 100));
1294 LayerTreeSettings settings; 1295 LayerTreeSettings settings;
1295 settings.tiling_interest_area_viewport_multiplier = 1; 1296 settings.max_tiles_for_interest_area = 1;
1296 1297
1297 scoped_refptr<FakePicturePileImpl> pile = 1298 scoped_refptr<FakePicturePileImpl> pile =
1298 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); 1299 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds);
1299 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, pile, 1300 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, 1.f, pile,
1300 &client_, settings); 1301 &client_, settings);
1301 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); 1302 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds));
1302 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); 1303 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false));
1303 1304
1304 gfx::Rect visible_rect(8000, 8000, 50, 50); 1305 gfx::Rect visible_rect(8000, 8000, 50, 50);
1305 1306
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 1743
1743 // Offscreen layer is coming closer to viewport at 1000 pixels per second. 1744 // Offscreen layer is coming closer to viewport at 1000 pixels per second.
1744 current_screen_transform.Translate(1800, 0); 1745 current_screen_transform.Translate(1800, 0);
1745 last_screen_transform.Translate(2800, 0); 1746 last_screen_transform.Translate(2800, 0);
1746 1747
1747 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( 1748 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace(
1748 current_screen_transform, device_viewport); 1749 current_screen_transform, device_viewport);
1749 1750
1750 client.SetTileSize(gfx::Size(100, 100)); 1751 client.SetTileSize(gfx::Size(100, 100));
1751 LayerTreeSettings settings; 1752 LayerTreeSettings settings;
1752 settings.tiling_interest_area_viewport_multiplier = 10000; 1753 settings.max_tiles_for_interest_area = 10000;
1753 1754
1754 scoped_refptr<FakePicturePileImpl> pile = 1755 scoped_refptr<FakePicturePileImpl> pile =
1755 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( 1756 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
1756 current_layer_bounds); 1757 current_layer_bounds);
1757 scoped_ptr<TestablePictureLayerTiling> tiling = 1758 scoped_ptr<TestablePictureLayerTiling> tiling =
1758 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client, 1759 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, &client,
1759 settings); 1760 settings);
1760 1761
1761 // previous ("last") frame 1762 // previous ("last") frame
1762 tiling->ComputeTilePriorityRects(viewport_in_layer_space, 1763 tiling->ComputeTilePriorityRects(viewport_in_layer_space,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 // - Viewport moves somewhere far away and active tiling clears tiles. 1873 // - Viewport moves somewhere far away and active tiling clears tiles.
1873 // - Viewport moves back and a new active tiling tile is created. 1874 // - Viewport moves back and a new active tiling tile is created.
1874 // Result: 1875 // Result:
1875 // - Recycle tiling does _not_ have the tile in the same location (thus it 1876 // - Recycle tiling does _not_ have the tile in the same location (thus it
1876 // will be shared next time a pending tiling is created). 1877 // will be shared next time a pending tiling is created).
1877 1878
1878 FakePictureLayerTilingClient active_client; 1879 FakePictureLayerTilingClient active_client;
1879 1880
1880 active_client.SetTileSize(gfx::Size(100, 100)); 1881 active_client.SetTileSize(gfx::Size(100, 100));
1881 LayerTreeSettings settings; 1882 LayerTreeSettings settings;
1883 settings.max_tiles_for_interest_area = 10;
1882 1884
1883 scoped_refptr<FakePicturePileImpl> pile = 1885 scoped_refptr<FakePicturePileImpl> pile =
1884 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( 1886 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
1885 gfx::Size(10000, 10000)); 1887 gfx::Size(10000, 10000));
1886 scoped_ptr<TestablePictureLayerTiling> active_tiling = 1888 scoped_ptr<TestablePictureLayerTiling> active_tiling =
1887 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile, 1889 TestablePictureLayerTiling::Create(ACTIVE_TREE, 1.0f, pile,
1888 &active_client, settings); 1890 &active_client, settings);
1889 // Create all tiles on this tiling. 1891 // Create all tiles on this tiling.
1890 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, 1892 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f,
1891 Occlusion()); 1893 Occlusion());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 &active_client, LayerTreeSettings()); 1941 &active_client, LayerTreeSettings());
1940 // Create all tiles on this tiling. 1942 // Create all tiles on this tiling.
1941 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, 1943 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f,
1942 Occlusion()); 1944 Occlusion());
1943 1945
1944 FakePictureLayerTilingClient recycle_client; 1946 FakePictureLayerTilingClient recycle_client;
1945 recycle_client.SetTileSize(gfx::Size(100, 100)); 1947 recycle_client.SetTileSize(gfx::Size(100, 100));
1946 recycle_client.set_twin_tiling(active_tiling.get()); 1948 recycle_client.set_twin_tiling(active_tiling.get());
1947 1949
1948 LayerTreeSettings settings; 1950 LayerTreeSettings settings;
1951 settings.max_tiles_for_interest_area = 10;
1949 1952
1950 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( 1953 pile = FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
1951 gfx::Size(100, 100)); 1954 gfx::Size(100, 100));
1952 scoped_ptr<TestablePictureLayerTiling> recycle_tiling = 1955 scoped_ptr<TestablePictureLayerTiling> recycle_tiling =
1953 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile, 1956 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, pile,
1954 &recycle_client, settings); 1957 &recycle_client, settings);
1955 1958
1956 // Create all tiles on the recycle tiling. All tiles should be shared. 1959 // Create all tiles on the recycle tiling. All tiles should be shared.
1957 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1960 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f,
1958 1.0f, Occlusion()); 1961 1.0f, Occlusion());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 tiling_->SetRasterSourceAndResize(pile); 1994 tiling_->SetRasterSourceAndResize(pile);
1992 1995
1993 // Tile size in the tiling should be resized to 250x200. 1996 // Tile size in the tiling should be resized to 250x200.
1994 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); 1997 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
1995 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); 1998 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
1996 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); 1999 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size());
1997 } 2000 }
1998 2001
1999 } // namespace 2002 } // namespace
2000 } // namespace cc 2003 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling_set_unittest.cc ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698