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 "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 } | 47 } |
48 | 48 |
49 class TestablePictureLayerTiling : public PictureLayerTiling { | 49 class TestablePictureLayerTiling : public PictureLayerTiling { |
50 public: | 50 public: |
51 using PictureLayerTiling::SetLiveTilesRect; | 51 using PictureLayerTiling::SetLiveTilesRect; |
52 using PictureLayerTiling::TileAt; | 52 using PictureLayerTiling::TileAt; |
53 | 53 |
54 static scoped_ptr<TestablePictureLayerTiling> Create( | 54 static scoped_ptr<TestablePictureLayerTiling> Create( |
55 float contents_scale, | 55 float contents_scale, |
56 const gfx::Size& layer_bounds, | 56 const gfx::Size& layer_bounds, |
57 PictureLayerTilingClient* client, | |
58 size_t max_tiles_for_interest_area, | |
59 float skewport_target_time, | |
60 int skewport_extrapolation_limit) { | |
61 return make_scoped_ptr(new TestablePictureLayerTiling( | |
62 contents_scale, layer_bounds, client, max_tiles_for_interest_area, | |
63 skewport_target_time, skewport_extrapolation_limit)); | |
64 } | |
65 | |
66 static scoped_ptr<TestablePictureLayerTiling> CreateDefault( | |
67 float contents_scale, | |
68 const gfx::Size& layer_bounds, | |
57 PictureLayerTilingClient* client) { | 69 PictureLayerTilingClient* client) { |
58 return make_scoped_ptr(new TestablePictureLayerTiling( | 70 LayerTreeSettings defaults; |
59 contents_scale, | 71 return Create(contents_scale, layer_bounds, client, 10000, |
danakj
2014/12/10 22:23:25
did you mean to use 10000 here?
vmpstr
2014/12/11 00:14:17
I changed this a bit. I removed CreateDefault, and
| |
60 layer_bounds, | 72 defaults.skewport_target_time_in_seconds, |
61 client)); | 73 defaults.skewport_extrapolation_limit_in_content_pixels); |
62 } | 74 } |
63 | 75 |
64 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 76 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
65 bool eviction_tiles_cache_valid() const { | 77 bool eviction_tiles_cache_valid() const { |
66 return eviction_tiles_cache_valid_; | 78 return eviction_tiles_cache_valid_; |
67 } | 79 } |
68 | 80 |
69 using PictureLayerTiling::ComputeSkewport; | 81 using PictureLayerTiling::ComputeSkewport; |
70 using PictureLayerTiling::RemoveTileAt; | 82 using PictureLayerTiling::RemoveTileAt; |
71 | 83 |
72 protected: | 84 protected: |
73 TestablePictureLayerTiling(float contents_scale, | 85 TestablePictureLayerTiling(float contents_scale, |
74 const gfx::Size& layer_bounds, | 86 const gfx::Size& layer_bounds, |
75 PictureLayerTilingClient* client) | 87 PictureLayerTilingClient* client, |
76 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 88 size_t max_tiles_for_interest_area, |
89 float skewport_target_time, | |
90 int skewport_extrapolation_limit) | |
91 : PictureLayerTiling(contents_scale, | |
92 layer_bounds, | |
93 client, | |
94 max_tiles_for_interest_area, | |
95 skewport_target_time, | |
96 skewport_extrapolation_limit) {} | |
77 }; | 97 }; |
78 | 98 |
79 class PictureLayerTilingIteratorTest : public testing::Test { | 99 class PictureLayerTilingIteratorTest : public testing::Test { |
80 public: | 100 public: |
81 PictureLayerTilingIteratorTest() {} | 101 PictureLayerTilingIteratorTest() {} |
82 virtual ~PictureLayerTilingIteratorTest() {} | 102 virtual ~PictureLayerTilingIteratorTest() {} |
83 | 103 |
84 void Initialize(const gfx::Size& tile_size, | 104 void Initialize(const gfx::Size& tile_size, |
85 float contents_scale, | 105 float contents_scale, |
86 const gfx::Size& layer_bounds) { | 106 const gfx::Size& layer_bounds) { |
87 client_.SetTileSize(tile_size); | 107 client_.SetTileSize(tile_size); |
88 client_.set_tree(PENDING_TREE); | 108 client_.set_tree(PENDING_TREE); |
89 tiling_ = TestablePictureLayerTiling::Create(contents_scale, | 109 LayerTreeSettings defaults; |
90 layer_bounds, | 110 tiling_ = TestablePictureLayerTiling::Create( |
danakj
2014/12/10 22:23:25
or else this can just call CreateDefault?
vmpstr
2014/12/11 00:14:17
Done.
| |
91 &client_); | 111 contents_scale, layer_bounds, &client_, 10000, |
112 defaults.skewport_target_time_in_seconds, | |
113 defaults.skewport_extrapolation_limit_in_content_pixels); | |
92 } | 114 } |
93 | 115 |
94 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 116 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
95 tiling_->SetLiveTilesRect(live_tiles_rect); | 117 tiling_->SetLiveTilesRect(live_tiles_rect); |
96 | 118 |
97 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 119 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
98 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 120 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
99 iter != tiles.end(); | 121 iter != tiles.end(); |
100 ++iter) { | 122 ++iter) { |
101 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); | 123 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 195 |
174 void VerifyTilesCoverNonContainedRect(float rect_scale, | 196 void VerifyTilesCoverNonContainedRect(float rect_scale, |
175 const gfx::Rect& dest_rect) { | 197 const gfx::Rect& dest_rect) { |
176 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; | 198 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; |
177 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( | 199 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( |
178 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); | 200 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); |
179 clamped_rect.Intersect(dest_rect); | 201 clamped_rect.Intersect(dest_rect); |
180 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); | 202 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); |
181 } | 203 } |
182 | 204 |
183 void set_max_tiles_for_interest_area(size_t area) { | |
184 client_.set_max_tiles_for_interest_area(area); | |
185 } | |
186 | |
187 protected: | 205 protected: |
188 FakePictureLayerTilingClient client_; | 206 FakePictureLayerTilingClient client_; |
189 scoped_ptr<TestablePictureLayerTiling> tiling_; | 207 scoped_ptr<TestablePictureLayerTiling> tiling_; |
190 | 208 |
191 private: | 209 private: |
192 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); | 210 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
193 }; | 211 }; |
194 | 212 |
195 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { | 213 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
196 // Verifies that a resize with invalidation for newly exposed pixels will | 214 // Verifies that a resize with invalidation for newly exposed pixels will |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | 543 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); |
526 | 544 |
527 // Partially covering content, but too large | 545 // Partially covering content, but too large |
528 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 546 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
529 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 547 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
530 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | 548 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); |
531 } | 549 } |
532 | 550 |
533 TEST(PictureLayerTilingTest, SkewportLimits) { | 551 TEST(PictureLayerTilingTest, SkewportLimits) { |
534 FakePictureLayerTilingClient client; | 552 FakePictureLayerTilingClient client; |
535 client.set_skewport_extrapolation_limit_in_content_pixels(75); | 553 LayerTreeSettings defaults; |
536 client.set_tree(ACTIVE_TREE); | 554 client.set_tree(ACTIVE_TREE); |
537 scoped_ptr<TestablePictureLayerTiling> tiling; | 555 scoped_ptr<TestablePictureLayerTiling> tiling; |
538 | 556 |
539 gfx::Rect viewport(0, 0, 100, 100); | 557 gfx::Rect viewport(0, 0, 100, 100); |
540 gfx::Size layer_bounds(200, 200); | 558 gfx::Size layer_bounds(200, 200); |
541 | 559 |
542 client.SetTileSize(gfx::Size(100, 100)); | 560 client.SetTileSize(gfx::Size(100, 100)); |
543 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 561 tiling = TestablePictureLayerTiling::Create( |
562 1.0f, layer_bounds, &client, 10000, | |
563 defaults.skewport_target_time_in_seconds, 75); | |
544 | 564 |
545 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 565 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
546 | 566 |
547 // Move viewport down 50 pixels in 0.5 seconds. | 567 // Move viewport down 50 pixels in 0.5 seconds. |
548 gfx::Rect down_skewport = | 568 gfx::Rect down_skewport = |
549 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 569 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
550 | 570 |
551 EXPECT_EQ(0, down_skewport.x()); | 571 EXPECT_EQ(0, down_skewport.x()); |
552 EXPECT_EQ(50, down_skewport.y()); | 572 EXPECT_EQ(50, down_skewport.y()); |
553 EXPECT_EQ(100, down_skewport.width()); | 573 EXPECT_EQ(100, down_skewport.width()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 | 619 |
600 TEST(PictureLayerTilingTest, ComputeSkewport) { | 620 TEST(PictureLayerTilingTest, ComputeSkewport) { |
601 FakePictureLayerTilingClient client; | 621 FakePictureLayerTilingClient client; |
602 scoped_ptr<TestablePictureLayerTiling> tiling; | 622 scoped_ptr<TestablePictureLayerTiling> tiling; |
603 | 623 |
604 gfx::Rect viewport(0, 0, 100, 100); | 624 gfx::Rect viewport(0, 0, 100, 100); |
605 gfx::Size layer_bounds(200, 200); | 625 gfx::Size layer_bounds(200, 200); |
606 | 626 |
607 client.SetTileSize(gfx::Size(100, 100)); | 627 client.SetTileSize(gfx::Size(100, 100)); |
608 client.set_tree(ACTIVE_TREE); | 628 client.set_tree(ACTIVE_TREE); |
609 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 629 tiling = |
630 TestablePictureLayerTiling::CreateDefault(1.0f, layer_bounds, &client); | |
610 | 631 |
611 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 632 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
612 | 633 |
613 // Move viewport down 50 pixels in 0.5 seconds. | 634 // Move viewport down 50 pixels in 0.5 seconds. |
614 gfx::Rect down_skewport = | 635 gfx::Rect down_skewport = |
615 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 636 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
616 | 637 |
617 EXPECT_EQ(0, down_skewport.x()); | 638 EXPECT_EQ(0, down_skewport.x()); |
618 EXPECT_EQ(50, down_skewport.y()); | 639 EXPECT_EQ(50, down_skewport.y()); |
619 EXPECT_EQ(100, down_skewport.width()); | 640 EXPECT_EQ(100, down_skewport.width()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 gfx::Size layer_bounds(1500, 1500); | 685 gfx::Size layer_bounds(1500, 1500); |
665 | 686 |
666 client.SetTileSize(gfx::Size(10, 10)); | 687 client.SetTileSize(gfx::Size(10, 10)); |
667 client.set_tree(ACTIVE_TREE); | 688 client.set_tree(ACTIVE_TREE); |
668 | 689 |
669 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 690 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
670 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 691 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
671 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 692 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
672 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 693 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
673 // tiling. | 694 // tiling. |
674 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client); | 695 tiling = |
696 TestablePictureLayerTiling::CreateDefault(0.25f, layer_bounds, &client); | |
675 gfx::Rect viewport_in_content_space = | 697 gfx::Rect viewport_in_content_space = |
676 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 698 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
677 | 699 |
678 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 700 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
679 tiling->UpdateAllTilePrioritiesForTesting(); | 701 tiling->UpdateAllTilePrioritiesForTesting(); |
680 | 702 |
681 gfx::Rect soon_rect = viewport; | 703 gfx::Rect soon_rect = viewport; |
682 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 704 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
683 gfx::Rect soon_rect_in_content_space = | 705 gfx::Rect soon_rect_in_content_space = |
684 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 706 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 840 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
819 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 841 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
820 | 842 |
821 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 843 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
822 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 844 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
823 | 845 |
824 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 846 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
825 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 847 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
826 | 848 |
827 // Test additional scales. | 849 // Test additional scales. |
828 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client); | 850 tiling = |
851 TestablePictureLayerTiling::CreateDefault(0.2f, layer_bounds, &client); | |
829 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 852 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
830 tiling->UpdateAllTilePrioritiesForTesting(); | 853 tiling->UpdateAllTilePrioritiesForTesting(); |
831 | 854 |
832 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 855 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
833 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 856 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
834 | 857 |
835 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 858 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
836 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 859 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
837 | 860 |
838 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 861 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1079 | 1102 |
1080 gfx::Rect viewport(50, 50, 100, 100); | 1103 gfx::Rect viewport(50, 50, 100, 100); |
1081 gfx::Size layer_bounds(800, 800); | 1104 gfx::Size layer_bounds(800, 800); |
1082 | 1105 |
1083 gfx::Rect soon_rect = viewport; | 1106 gfx::Rect soon_rect = viewport; |
1084 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1107 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
1085 | 1108 |
1086 client.SetTileSize(gfx::Size(30, 30)); | 1109 client.SetTileSize(gfx::Size(30, 30)); |
1087 client.set_tree(ACTIVE_TREE); | 1110 client.set_tree(ACTIVE_TREE); |
1088 | 1111 |
1089 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1112 tiling = |
1113 TestablePictureLayerTiling::CreateDefault(1.0f, layer_bounds, &client); | |
1090 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1114 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
1091 tiling->UpdateAllTilePrioritiesForTesting(); | 1115 tiling->UpdateAllTilePrioritiesForTesting(); |
1092 | 1116 |
1093 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1117 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
1094 EXPECT_FALSE(empty_iterator); | 1118 EXPECT_FALSE(empty_iterator); |
1095 | 1119 |
1096 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1120 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
1097 | 1121 |
1098 // Sanity check. | 1122 // Sanity check. |
1099 EXPECT_EQ(841u, all_tiles.size()); | 1123 EXPECT_EQ(841u, all_tiles.size()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 FakePictureLayerTilingClient client; | 1208 FakePictureLayerTilingClient client; |
1185 scoped_ptr<TestablePictureLayerTiling> tiling; | 1209 scoped_ptr<TestablePictureLayerTiling> tiling; |
1186 | 1210 |
1187 gfx::Rect viewport(50, 0, 100, 100); | 1211 gfx::Rect viewport(50, 0, 100, 100); |
1188 gfx::Rect moved_viewport(50, 0, 100, 500); | 1212 gfx::Rect moved_viewport(50, 0, 100, 500); |
1189 gfx::Size layer_bounds(1000, 1000); | 1213 gfx::Size layer_bounds(1000, 1000); |
1190 | 1214 |
1191 client.SetTileSize(gfx::Size(30, 30)); | 1215 client.SetTileSize(gfx::Size(30, 30)); |
1192 client.set_tree(ACTIVE_TREE); | 1216 client.set_tree(ACTIVE_TREE); |
1193 | 1217 |
1194 tiling = TestablePictureLayerTiling::Create(1.f, layer_bounds, &client); | 1218 tiling = |
1219 TestablePictureLayerTiling::CreateDefault(1.f, layer_bounds, &client); | |
1195 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1220 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
1196 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); | 1221 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); |
1197 tiling->UpdateAllTilePrioritiesForTesting(); | 1222 tiling->UpdateAllTilePrioritiesForTesting(); |
1198 | 1223 |
1199 gfx::Rect soon_rect = moved_viewport; | 1224 gfx::Rect soon_rect = moved_viewport; |
1200 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1225 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
1201 | 1226 |
1202 // There are 3 bins in TilePriority. | 1227 // There are 3 bins in TilePriority. |
1203 bool have_tiles[3] = {}; | 1228 bool have_tiles[3] = {}; |
1204 Tile* last_tile = NULL; | 1229 Tile* last_tile = NULL; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1319 bool intersects = rect.Intersects(geometry_rect); | 1344 bool intersects = rect.Intersects(geometry_rect); |
1320 bool expected_exists = intersect_exists ? intersects : !intersects; | 1345 bool expected_exists = intersect_exists ? intersects : !intersects; |
1321 EXPECT_EQ(expected_exists, tile != NULL) | 1346 EXPECT_EQ(expected_exists, tile != NULL) |
1322 << "Rects intersecting " << rect.ToString() << " should exist. " | 1347 << "Rects intersecting " << rect.ToString() << " should exist. " |
1323 << "Current tile rect is " << geometry_rect.ToString(); | 1348 << "Current tile rect is " << geometry_rect.ToString(); |
1324 } | 1349 } |
1325 | 1350 |
1326 TEST_F(PictureLayerTilingIteratorTest, | 1351 TEST_F(PictureLayerTilingIteratorTest, |
1327 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1352 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
1328 gfx::Size layer_bounds(10000, 10000); | 1353 gfx::Size layer_bounds(10000, 10000); |
1329 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1354 client_.SetTileSize(gfx::Size(100, 100)); |
1355 client_.set_tree(PENDING_TREE); | |
1356 LayerTreeSettings defaults; | |
1357 tiling_ = TestablePictureLayerTiling::Create( | |
1358 1.f, layer_bounds, &client_, 1, defaults.skewport_target_time_in_seconds, | |
1359 defaults.skewport_extrapolation_limit_in_content_pixels); | |
1330 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1360 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
1331 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1361 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
1332 | 1362 |
1333 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1363 gfx::Rect visible_rect(8000, 8000, 50, 50); |
1334 | 1364 |
1335 client_.set_tree(ACTIVE_TREE); | 1365 client_.set_tree(ACTIVE_TREE); |
1336 set_max_tiles_for_interest_area(1); | |
1337 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1366 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
1338 1.f, // current contents scale | 1367 1.f, // current contents scale |
1339 1.0, // current frame time | 1368 1.0, // current frame time |
1340 Occlusion()); | 1369 Occlusion()); |
1341 VerifyTiles(1.f, | 1370 VerifyTiles(1.f, |
1342 gfx::Rect(layer_bounds), | 1371 gfx::Rect(layer_bounds), |
1343 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); | 1372 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); |
1344 } | 1373 } |
1345 | 1374 |
1346 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { | 1375 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { |
1347 gfx::Size layer_bounds(1099, 801); | 1376 gfx::Size layer_bounds(1099, 801); |
1348 gfx::Size tile_size(100, 100); | 1377 gfx::Size tile_size(100, 100); |
1378 LayerTreeSettings defaults; | |
1349 | 1379 |
1350 client_.SetTileSize(tile_size); | 1380 client_.SetTileSize(tile_size); |
1351 client_.set_tree(PENDING_TREE); | 1381 client_.set_tree(PENDING_TREE); |
1352 | 1382 |
1353 auto active_set = PictureLayerTilingSet::Create(&client_); | 1383 auto active_set = PictureLayerTilingSet::Create( |
1384 &client_, 10000, defaults.skewport_target_time_in_seconds, | |
1385 defaults.skewport_extrapolation_limit_in_content_pixels); | |
1354 | 1386 |
1355 active_set->AddTiling(1.f, layer_bounds); | 1387 active_set->AddTiling(1.f, layer_bounds); |
1356 | 1388 |
1357 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1389 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
1358 base::Bind(&TileExists, false)); | 1390 base::Bind(&TileExists, false)); |
1359 | 1391 |
1360 UpdateAllTilePriorities(active_set.get(), | 1392 UpdateAllTilePriorities(active_set.get(), |
1361 gfx::Rect(layer_bounds), // visible content rect | 1393 gfx::Rect(layer_bounds), // visible content rect |
1362 1.f, // current contents scale | 1394 1.f, // current contents scale |
1363 1.0); // current frame time | 1395 1.0); // current frame time |
1364 | 1396 |
1365 // The active tiling has tiles now. | 1397 // The active tiling has tiles now. |
1366 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1398 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
1367 base::Bind(&TileExists, true)); | 1399 base::Bind(&TileExists, true)); |
1368 | 1400 |
1369 // Add the same tilings to the pending set. | 1401 // Add the same tilings to the pending set. |
1370 auto pending_set = PictureLayerTilingSet::Create(&client_); | 1402 auto pending_set = PictureLayerTilingSet::Create( |
1403 &client_, 10000, defaults.skewport_target_time_in_seconds, | |
1404 defaults.skewport_extrapolation_limit_in_content_pixels); | |
1371 Region invalidation; | 1405 Region invalidation; |
1372 pending_set->SyncTilings(*active_set, layer_bounds, invalidation, 0.f, | 1406 pending_set->SyncTilings(*active_set, layer_bounds, invalidation, 0.f, |
1373 client_.raster_source()); | 1407 client_.raster_source()); |
1374 | 1408 |
1375 // The pending tiling starts with no tiles. | 1409 // The pending tiling starts with no tiles. |
1376 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1410 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
1377 base::Bind(&TileExists, false)); | 1411 base::Bind(&TileExists, false)); |
1378 | 1412 |
1379 // ComputeTilePriorityRects on the pending tiling at the same frame time. The | 1413 // ComputeTilePriorityRects on the pending tiling at the same frame time. The |
1380 // pending tiling should get tiles. | 1414 // pending tiling should get tiles. |
(...skipping 18 matching lines...) Expand all Loading... | |
1399 gfx::Size current_layer_bounds(200, 200); | 1433 gfx::Size current_layer_bounds(200, 200); |
1400 float current_layer_contents_scale = 1.f; | 1434 float current_layer_contents_scale = 1.f; |
1401 gfx::Transform current_screen_transform; | 1435 gfx::Transform current_screen_transform; |
1402 double current_frame_time_in_seconds = 1.0; | 1436 double current_frame_time_in_seconds = 1.0; |
1403 | 1437 |
1404 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1438 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1405 current_screen_transform, device_viewport); | 1439 current_screen_transform, device_viewport); |
1406 | 1440 |
1407 client.SetTileSize(gfx::Size(100, 100)); | 1441 client.SetTileSize(gfx::Size(100, 100)); |
1408 client.set_tree(ACTIVE_TREE); | 1442 client.set_tree(ACTIVE_TREE); |
1409 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1443 tiling = |
1410 current_layer_bounds, | 1444 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1411 &client); | 1445 current_layer_bounds, &client); |
1412 | 1446 |
1413 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1447 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1414 current_layer_contents_scale, | 1448 current_layer_contents_scale, |
1415 current_frame_time_in_seconds, Occlusion()); | 1449 current_frame_time_in_seconds, Occlusion()); |
1416 tiling->UpdateAllTilePrioritiesForTesting(); | 1450 tiling->UpdateAllTilePrioritiesForTesting(); |
1417 | 1451 |
1418 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1452 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1419 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1453 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1420 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1454 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1421 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1455 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1453 double current_frame_time_in_seconds = 1.0; | 1487 double current_frame_time_in_seconds = 1.0; |
1454 | 1488 |
1455 current_screen_transform.Translate(850, 0); | 1489 current_screen_transform.Translate(850, 0); |
1456 last_screen_transform = current_screen_transform; | 1490 last_screen_transform = current_screen_transform; |
1457 | 1491 |
1458 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1492 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1459 current_screen_transform, device_viewport); | 1493 current_screen_transform, device_viewport); |
1460 | 1494 |
1461 client.SetTileSize(gfx::Size(100, 100)); | 1495 client.SetTileSize(gfx::Size(100, 100)); |
1462 client.set_tree(ACTIVE_TREE); | 1496 client.set_tree(ACTIVE_TREE); |
1463 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1497 tiling = |
1464 current_layer_bounds, | 1498 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1465 &client); | 1499 current_layer_bounds, &client); |
1466 | 1500 |
1467 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1501 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1468 current_layer_contents_scale, | 1502 current_layer_contents_scale, |
1469 current_frame_time_in_seconds, Occlusion()); | 1503 current_frame_time_in_seconds, Occlusion()); |
1470 tiling->UpdateAllTilePrioritiesForTesting(); | 1504 tiling->UpdateAllTilePrioritiesForTesting(); |
1471 | 1505 |
1472 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1506 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1473 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1507 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1474 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1508 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1475 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1509 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1517 double current_frame_time_in_seconds = 1.0; | 1551 double current_frame_time_in_seconds = 1.0; |
1518 | 1552 |
1519 current_screen_transform.Translate(705, 505); | 1553 current_screen_transform.Translate(705, 505); |
1520 last_screen_transform = current_screen_transform; | 1554 last_screen_transform = current_screen_transform; |
1521 | 1555 |
1522 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1556 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1523 current_screen_transform, device_viewport); | 1557 current_screen_transform, device_viewport); |
1524 | 1558 |
1525 client.SetTileSize(gfx::Size(100, 100)); | 1559 client.SetTileSize(gfx::Size(100, 100)); |
1526 client.set_tree(ACTIVE_TREE); | 1560 client.set_tree(ACTIVE_TREE); |
1527 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1561 tiling = |
1528 current_layer_bounds, | 1562 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1529 &client); | 1563 current_layer_bounds, &client); |
1530 | 1564 |
1531 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1565 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1532 current_layer_contents_scale, | 1566 current_layer_contents_scale, |
1533 current_frame_time_in_seconds, Occlusion()); | 1567 current_frame_time_in_seconds, Occlusion()); |
1534 tiling->UpdateAllTilePrioritiesForTesting(); | 1568 tiling->UpdateAllTilePrioritiesForTesting(); |
1535 | 1569 |
1536 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1570 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1537 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1571 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1538 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1572 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1539 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1573 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1575 // In this configuration, only the top-left tile would be visible. | 1609 // In this configuration, only the top-left tile would be visible. |
1576 current_screen_transform.Translate(600, 750); | 1610 current_screen_transform.Translate(600, 750); |
1577 current_screen_transform.RotateAboutZAxis(45); | 1611 current_screen_transform.RotateAboutZAxis(45); |
1578 last_screen_transform = current_screen_transform; | 1612 last_screen_transform = current_screen_transform; |
1579 | 1613 |
1580 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1614 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1581 current_screen_transform, device_viewport); | 1615 current_screen_transform, device_viewport); |
1582 | 1616 |
1583 client.SetTileSize(gfx::Size(100, 100)); | 1617 client.SetTileSize(gfx::Size(100, 100)); |
1584 client.set_tree(ACTIVE_TREE); | 1618 client.set_tree(ACTIVE_TREE); |
1585 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1619 tiling = |
1586 current_layer_bounds, | 1620 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1587 &client); | 1621 current_layer_bounds, &client); |
1588 | 1622 |
1589 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1623 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1590 current_layer_contents_scale, | 1624 current_layer_contents_scale, |
1591 current_frame_time_in_seconds, Occlusion()); | 1625 current_frame_time_in_seconds, Occlusion()); |
1592 tiling->UpdateAllTilePrioritiesForTesting(); | 1626 tiling->UpdateAllTilePrioritiesForTesting(); |
1593 | 1627 |
1594 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1628 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1595 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1629 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1596 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1630 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1597 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1631 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 MathUtil::MapQuad(current_screen_transform, | 1691 MathUtil::MapQuad(current_screen_transform, |
1658 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1692 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
1659 &clipped); | 1693 &clipped); |
1660 ASSERT_FALSE(clipped); | 1694 ASSERT_FALSE(clipped); |
1661 | 1695 |
1662 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1696 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1663 current_screen_transform, device_viewport); | 1697 current_screen_transform, device_viewport); |
1664 | 1698 |
1665 client.SetTileSize(gfx::Size(100, 100)); | 1699 client.SetTileSize(gfx::Size(100, 100)); |
1666 client.set_tree(ACTIVE_TREE); | 1700 client.set_tree(ACTIVE_TREE); |
1667 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1701 tiling = |
1668 current_layer_bounds, | 1702 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1669 &client); | 1703 current_layer_bounds, &client); |
1670 | 1704 |
1671 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1705 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1672 current_layer_contents_scale, | 1706 current_layer_contents_scale, |
1673 current_frame_time_in_seconds, Occlusion()); | 1707 current_frame_time_in_seconds, Occlusion()); |
1674 tiling->UpdateAllTilePrioritiesForTesting(); | 1708 tiling->UpdateAllTilePrioritiesForTesting(); |
1675 | 1709 |
1676 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1710 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1677 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1711 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1678 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1712 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1679 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1713 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1749 MathUtil::MapQuad(current_screen_transform, | 1783 MathUtil::MapQuad(current_screen_transform, |
1750 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1784 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
1751 &clipped); | 1785 &clipped); |
1752 ASSERT_FALSE(clipped); | 1786 ASSERT_FALSE(clipped); |
1753 | 1787 |
1754 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1788 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1755 current_screen_transform, device_viewport); | 1789 current_screen_transform, device_viewport); |
1756 | 1790 |
1757 client.SetTileSize(gfx::Size(100, 100)); | 1791 client.SetTileSize(gfx::Size(100, 100)); |
1758 client.set_tree(ACTIVE_TREE); | 1792 client.set_tree(ACTIVE_TREE); |
1759 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1793 tiling = |
1760 current_layer_bounds, | 1794 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1761 &client); | 1795 current_layer_bounds, &client); |
1762 | 1796 |
1763 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1797 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1764 current_layer_contents_scale, | 1798 current_layer_contents_scale, |
1765 current_frame_time_in_seconds, Occlusion()); | 1799 current_frame_time_in_seconds, Occlusion()); |
1766 tiling->UpdateAllTilePrioritiesForTesting(); | 1800 tiling->UpdateAllTilePrioritiesForTesting(); |
1767 | 1801 |
1768 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1802 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1769 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1803 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1770 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1804 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1771 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1805 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1811 | 1845 |
1812 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1846 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
1813 current_screen_transform.Translate(1800, 0); | 1847 current_screen_transform.Translate(1800, 0); |
1814 last_screen_transform.Translate(2800, 0); | 1848 last_screen_transform.Translate(2800, 0); |
1815 | 1849 |
1816 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1850 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1817 current_screen_transform, device_viewport); | 1851 current_screen_transform, device_viewport); |
1818 | 1852 |
1819 client.SetTileSize(gfx::Size(100, 100)); | 1853 client.SetTileSize(gfx::Size(100, 100)); |
1820 client.set_tree(ACTIVE_TREE); | 1854 client.set_tree(ACTIVE_TREE); |
1821 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1855 tiling = |
1822 current_layer_bounds, | 1856 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1823 &client); | 1857 current_layer_bounds, &client); |
1824 | 1858 |
1825 // previous ("last") frame | 1859 // previous ("last") frame |
1826 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1860 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1827 last_layer_contents_scale, | 1861 last_layer_contents_scale, |
1828 last_frame_time_in_seconds, Occlusion()); | 1862 last_frame_time_in_seconds, Occlusion()); |
1829 | 1863 |
1830 // current frame | 1864 // current frame |
1831 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1865 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1832 current_layer_contents_scale, | 1866 current_layer_contents_scale, |
1833 current_frame_time_in_seconds, Occlusion()); | 1867 current_frame_time_in_seconds, Occlusion()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1886 current_screen_transform.Translate(400, 550); | 1920 current_screen_transform.Translate(400, 550); |
1887 current_screen_transform.RotateAboutZAxis(45); | 1921 current_screen_transform.RotateAboutZAxis(45); |
1888 | 1922 |
1889 last_screen_transform.Translate(400, 550); | 1923 last_screen_transform.Translate(400, 550); |
1890 | 1924 |
1891 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1925 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1892 current_screen_transform, device_viewport); | 1926 current_screen_transform, device_viewport); |
1893 | 1927 |
1894 client.SetTileSize(gfx::Size(100, 100)); | 1928 client.SetTileSize(gfx::Size(100, 100)); |
1895 client.set_tree(ACTIVE_TREE); | 1929 client.set_tree(ACTIVE_TREE); |
1896 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1930 tiling = |
1897 current_layer_bounds, | 1931 TestablePictureLayerTiling::CreateDefault(1.0f, // contents_scale |
1898 &client); | 1932 current_layer_bounds, &client); |
1899 | 1933 |
1900 // previous ("last") frame | 1934 // previous ("last") frame |
1901 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1935 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1902 last_layer_contents_scale, | 1936 last_layer_contents_scale, |
1903 last_frame_time_in_seconds, Occlusion()); | 1937 last_frame_time_in_seconds, Occlusion()); |
1904 | 1938 |
1905 // current frame | 1939 // current frame |
1906 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1940 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1907 current_layer_contents_scale, | 1941 current_layer_contents_scale, |
1908 current_frame_time_in_seconds, Occlusion()); | 1942 current_frame_time_in_seconds, Occlusion()); |
(...skipping 23 matching lines...) Expand all Loading... | |
1932 // - Two tilings, one active one recycled with all tiles shared. | 1966 // - Two tilings, one active one recycled with all tiles shared. |
1933 // Procedure: | 1967 // Procedure: |
1934 // - Viewport moves somewhere far away and active tiling clears tiles. | 1968 // - Viewport moves somewhere far away and active tiling clears tiles. |
1935 // - Viewport moves back and a new active tiling tile is created. | 1969 // - Viewport moves back and a new active tiling tile is created. |
1936 // Result: | 1970 // Result: |
1937 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1971 // - Recycle tiling does _not_ have the tile in the same location (thus it |
1938 // will be shared next time a pending tiling is created). | 1972 // will be shared next time a pending tiling is created). |
1939 | 1973 |
1940 FakePictureLayerTilingClient active_client; | 1974 FakePictureLayerTilingClient active_client; |
1941 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 1975 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
1976 LayerTreeSettings defaults; | |
1942 | 1977 |
1943 active_client.SetTileSize(gfx::Size(100, 100)); | 1978 active_client.SetTileSize(gfx::Size(100, 100)); |
1944 active_client.set_tree(ACTIVE_TREE); | 1979 active_client.set_tree(ACTIVE_TREE); |
1945 active_client.set_max_tiles_for_interest_area(10); | 1980 active_tiling = TestablePictureLayerTiling::Create( |
1946 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1981 1.0f, // contents_scale |
1947 gfx::Size(10000, 10000), | 1982 gfx::Size(10000, 10000), &active_client, 10, |
1948 &active_client); | 1983 defaults.skewport_target_time_in_seconds, |
1984 defaults.skewport_extrapolation_limit_in_content_pixels); | |
1949 // Create all tiles on this tiling. | 1985 // Create all tiles on this tiling. |
1950 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1986 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
1951 Occlusion()); | 1987 Occlusion()); |
1952 | 1988 |
1953 FakePictureLayerTilingClient recycle_client; | 1989 FakePictureLayerTilingClient recycle_client; |
1954 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1990 recycle_client.SetTileSize(gfx::Size(100, 100)); |
1955 recycle_client.set_tree(PENDING_TREE); | 1991 recycle_client.set_tree(PENDING_TREE); |
1956 recycle_client.set_twin_tiling(active_tiling.get()); | 1992 recycle_client.set_twin_tiling(active_tiling.get()); |
1957 recycle_client.set_max_tiles_for_interest_area(10); | |
1958 | 1993 |
1959 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 1994 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
1960 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1995 recycle_tiling = TestablePictureLayerTiling::Create( |
1961 gfx::Size(10000, 10000), | 1996 1.0f, // contents_scale |
1962 &recycle_client); | 1997 gfx::Size(10000, 10000), &recycle_client, 10, |
1998 defaults.skewport_target_time_in_seconds, | |
1999 defaults.skewport_extrapolation_limit_in_content_pixels); | |
1963 | 2000 |
1964 // Create all tiles on the second tiling. All tiles should be shared. | 2001 // Create all tiles on the second tiling. All tiles should be shared. |
1965 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 2002 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
1966 1.0f, Occlusion()); | 2003 1.0f, Occlusion()); |
1967 | 2004 |
1968 // Set the second tiling as recycled. | 2005 // Set the second tiling as recycled. |
1969 active_client.set_twin_tiling(NULL); | 2006 active_client.set_twin_tiling(NULL); |
1970 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2007 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
1971 recycle_client.set_twin_tiling(NULL); | 2008 recycle_client.set_twin_tiling(NULL); |
1972 | 2009 |
(...skipping 17 matching lines...) Expand all Loading... | |
1990 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2027 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1991 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2028 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
1992 } | 2029 } |
1993 | 2030 |
1994 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 2031 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
1995 FakePictureLayerTilingClient active_client; | 2032 FakePictureLayerTilingClient active_client; |
1996 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 2033 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
1997 | 2034 |
1998 active_client.SetTileSize(gfx::Size(100, 100)); | 2035 active_client.SetTileSize(gfx::Size(100, 100)); |
1999 active_client.set_tree(ACTIVE_TREE); | 2036 active_client.set_tree(ACTIVE_TREE); |
2000 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2037 active_tiling = TestablePictureLayerTiling::CreateDefault( |
2001 gfx::Size(100, 100), | 2038 1.0f, // contents_scale |
2002 &active_client); | 2039 gfx::Size(100, 100), &active_client); |
2003 // Create all tiles on this tiling. | 2040 // Create all tiles on this tiling. |
2004 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 2041 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
2005 Occlusion()); | 2042 Occlusion()); |
2006 | 2043 |
2007 FakePictureLayerTilingClient recycle_client; | 2044 FakePictureLayerTilingClient recycle_client; |
2008 recycle_client.SetTileSize(gfx::Size(100, 100)); | 2045 recycle_client.SetTileSize(gfx::Size(100, 100)); |
2009 recycle_client.set_tree(PENDING_TREE); | 2046 recycle_client.set_tree(PENDING_TREE); |
2010 recycle_client.set_twin_tiling(active_tiling.get()); | 2047 recycle_client.set_twin_tiling(active_tiling.get()); |
2011 recycle_client.set_max_tiles_for_interest_area(10); | |
2012 | 2048 |
2049 LayerTreeSettings defaults; | |
2013 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2050 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
2014 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2051 recycle_tiling = TestablePictureLayerTiling::Create( |
2015 gfx::Size(100, 100), | 2052 1.0f, // contents_scale |
2016 &recycle_client); | 2053 gfx::Size(100, 100), &recycle_client, 10, |
2054 defaults.skewport_target_time_in_seconds, | |
2055 defaults.skewport_extrapolation_limit_in_content_pixels); | |
2017 | 2056 |
2018 // Create all tiles on the recycle tiling. All tiles should be shared. | 2057 // Create all tiles on the recycle tiling. All tiles should be shared. |
2019 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 2058 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
2020 1.0f, Occlusion()); | 2059 1.0f, Occlusion()); |
2021 | 2060 |
2022 // Set the second tiling as recycled. | 2061 // Set the second tiling as recycled. |
2023 active_client.set_twin_tiling(NULL); | 2062 active_client.set_twin_tiling(NULL); |
2024 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2063 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
2025 recycle_client.set_twin_tiling(NULL); | 2064 recycle_client.set_twin_tiling(NULL); |
2026 | 2065 |
(...skipping 28 matching lines...) Expand all Loading... | |
2055 invalidation, gfx::Size(250, 150)); | 2094 invalidation, gfx::Size(250, 150)); |
2056 | 2095 |
2057 // Tile size in the tiling should be resized to 250x200. | 2096 // Tile size in the tiling should be resized to 250x200. |
2058 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2097 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
2059 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2098 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
2060 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2099 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
2061 } | 2100 } |
2062 | 2101 |
2063 } // namespace | 2102 } // namespace |
2064 } // namespace cc | 2103 } // namespace cc |
OLD | NEW |