| 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) { | 57 PictureLayerTilingClient* client, |
| 58 const LayerTreeSettings& settings) { |
| 58 return make_scoped_ptr(new TestablePictureLayerTiling( | 59 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 59 contents_scale, | 60 contents_scale, layer_bounds, client, |
| 60 layer_bounds, | 61 settings.max_tiles_for_interest_area, |
| 61 client)); | 62 settings.skewport_target_time_in_seconds, |
| 63 settings.skewport_extrapolation_limit_in_content_pixels)); |
| 62 } | 64 } |
| 63 | 65 |
| 64 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 66 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 65 bool eviction_tiles_cache_valid() const { | 67 bool eviction_tiles_cache_valid() const { |
| 66 return eviction_tiles_cache_valid_; | 68 return eviction_tiles_cache_valid_; |
| 67 } | 69 } |
| 68 | 70 |
| 69 using PictureLayerTiling::ComputeSkewport; | 71 using PictureLayerTiling::ComputeSkewport; |
| 70 using PictureLayerTiling::RemoveTileAt; | 72 using PictureLayerTiling::RemoveTileAt; |
| 71 | 73 |
| 72 protected: | 74 protected: |
| 73 TestablePictureLayerTiling(float contents_scale, | 75 TestablePictureLayerTiling(float contents_scale, |
| 74 const gfx::Size& layer_bounds, | 76 const gfx::Size& layer_bounds, |
| 75 PictureLayerTilingClient* client) | 77 PictureLayerTilingClient* client, |
| 76 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 78 size_t max_tiles_for_interest_area, |
| 79 float skewport_target_time, |
| 80 int skewport_extrapolation_limit) |
| 81 : PictureLayerTiling(contents_scale, |
| 82 layer_bounds, |
| 83 client, |
| 84 max_tiles_for_interest_area, |
| 85 skewport_target_time, |
| 86 skewport_extrapolation_limit) {} |
| 77 }; | 87 }; |
| 78 | 88 |
| 79 class PictureLayerTilingIteratorTest : public testing::Test { | 89 class PictureLayerTilingIteratorTest : public testing::Test { |
| 80 public: | 90 public: |
| 81 PictureLayerTilingIteratorTest() {} | 91 PictureLayerTilingIteratorTest() {} |
| 82 virtual ~PictureLayerTilingIteratorTest() {} | 92 virtual ~PictureLayerTilingIteratorTest() {} |
| 83 | 93 |
| 84 void Initialize(const gfx::Size& tile_size, | 94 void Initialize(const gfx::Size& tile_size, |
| 85 float contents_scale, | 95 float contents_scale, |
| 86 const gfx::Size& layer_bounds) { | 96 const gfx::Size& layer_bounds) { |
| 87 client_.SetTileSize(tile_size); | 97 client_.SetTileSize(tile_size); |
| 88 client_.set_tree(PENDING_TREE); | 98 client_.set_tree(PENDING_TREE); |
| 89 tiling_ = TestablePictureLayerTiling::Create(contents_scale, | 99 tiling_ = TestablePictureLayerTiling::Create(contents_scale, layer_bounds, |
| 90 layer_bounds, | 100 &client_, LayerTreeSettings()); |
| 91 &client_); | |
| 92 } | 101 } |
| 93 | 102 |
| 94 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 103 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
| 95 tiling_->SetLiveTilesRect(live_tiles_rect); | 104 tiling_->SetLiveTilesRect(live_tiles_rect); |
| 96 | 105 |
| 97 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 106 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
| 98 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 107 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
| 99 iter != tiles.end(); | 108 iter != tiles.end(); |
| 100 ++iter) { | 109 ++iter) { |
| 101 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); | 110 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 182 |
| 174 void VerifyTilesCoverNonContainedRect(float rect_scale, | 183 void VerifyTilesCoverNonContainedRect(float rect_scale, |
| 175 const gfx::Rect& dest_rect) { | 184 const gfx::Rect& dest_rect) { |
| 176 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; | 185 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; |
| 177 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( | 186 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( |
| 178 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); | 187 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); |
| 179 clamped_rect.Intersect(dest_rect); | 188 clamped_rect.Intersect(dest_rect); |
| 180 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); | 189 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); |
| 181 } | 190 } |
| 182 | 191 |
| 183 void set_max_tiles_for_interest_area(size_t area) { | |
| 184 client_.set_max_tiles_for_interest_area(area); | |
| 185 } | |
| 186 | |
| 187 protected: | 192 protected: |
| 188 FakePictureLayerTilingClient client_; | 193 FakePictureLayerTilingClient client_; |
| 189 scoped_ptr<TestablePictureLayerTiling> tiling_; | 194 scoped_ptr<TestablePictureLayerTiling> tiling_; |
| 190 | 195 |
| 191 private: | 196 private: |
| 192 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); | 197 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
| 193 }; | 198 }; |
| 194 | 199 |
| 195 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { | 200 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
| 196 // Verifies that a resize with invalidation for newly exposed pixels will | 201 // Verifies that a resize with invalidation for newly exposed pixels will |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | 529 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); |
| 525 | 530 |
| 526 // Partially covering content, but too large | 531 // Partially covering content, but too large |
| 527 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 532 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
| 528 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 533 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 529 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | 534 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 530 } | 535 } |
| 531 | 536 |
| 532 TEST(PictureLayerTilingTest, SkewportLimits) { | 537 TEST(PictureLayerTilingTest, SkewportLimits) { |
| 533 FakePictureLayerTilingClient client; | 538 FakePictureLayerTilingClient client; |
| 534 client.set_skewport_extrapolation_limit_in_content_pixels(75); | |
| 535 client.set_tree(ACTIVE_TREE); | 539 client.set_tree(ACTIVE_TREE); |
| 536 scoped_ptr<TestablePictureLayerTiling> tiling; | 540 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 537 | 541 |
| 538 gfx::Rect viewport(0, 0, 100, 100); | 542 gfx::Rect viewport(0, 0, 100, 100); |
| 539 gfx::Size layer_bounds(200, 200); | 543 gfx::Size layer_bounds(200, 200); |
| 540 | 544 |
| 541 client.SetTileSize(gfx::Size(100, 100)); | 545 client.SetTileSize(gfx::Size(100, 100)); |
| 542 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 546 LayerTreeSettings settings; |
| 547 settings.max_tiles_for_interest_area = 10000; |
| 548 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
| 549 tiling = |
| 550 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); |
| 543 | 551 |
| 544 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 552 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 545 | 553 |
| 546 // Move viewport down 50 pixels in 0.5 seconds. | 554 // Move viewport down 50 pixels in 0.5 seconds. |
| 547 gfx::Rect down_skewport = | 555 gfx::Rect down_skewport = |
| 548 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 556 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 549 | 557 |
| 550 EXPECT_EQ(0, down_skewport.x()); | 558 EXPECT_EQ(0, down_skewport.x()); |
| 551 EXPECT_EQ(50, down_skewport.y()); | 559 EXPECT_EQ(50, down_skewport.y()); |
| 552 EXPECT_EQ(100, down_skewport.width()); | 560 EXPECT_EQ(100, down_skewport.width()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 606 |
| 599 TEST(PictureLayerTilingTest, ComputeSkewport) { | 607 TEST(PictureLayerTilingTest, ComputeSkewport) { |
| 600 FakePictureLayerTilingClient client; | 608 FakePictureLayerTilingClient client; |
| 601 scoped_ptr<TestablePictureLayerTiling> tiling; | 609 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 602 | 610 |
| 603 gfx::Rect viewport(0, 0, 100, 100); | 611 gfx::Rect viewport(0, 0, 100, 100); |
| 604 gfx::Size layer_bounds(200, 200); | 612 gfx::Size layer_bounds(200, 200); |
| 605 | 613 |
| 606 client.SetTileSize(gfx::Size(100, 100)); | 614 client.SetTileSize(gfx::Size(100, 100)); |
| 607 client.set_tree(ACTIVE_TREE); | 615 client.set_tree(ACTIVE_TREE); |
| 608 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 616 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, |
| 617 LayerTreeSettings()); |
| 609 | 618 |
| 610 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 619 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 611 | 620 |
| 612 // Move viewport down 50 pixels in 0.5 seconds. | 621 // Move viewport down 50 pixels in 0.5 seconds. |
| 613 gfx::Rect down_skewport = | 622 gfx::Rect down_skewport = |
| 614 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 623 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
| 615 | 624 |
| 616 EXPECT_EQ(0, down_skewport.x()); | 625 EXPECT_EQ(0, down_skewport.x()); |
| 617 EXPECT_EQ(50, down_skewport.y()); | 626 EXPECT_EQ(50, down_skewport.y()); |
| 618 EXPECT_EQ(100, down_skewport.width()); | 627 EXPECT_EQ(100, down_skewport.width()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 666 |
| 658 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { | 667 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
| 659 FakePictureLayerTilingClient client; | 668 FakePictureLayerTilingClient client; |
| 660 scoped_ptr<TestablePictureLayerTiling> tiling; | 669 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 661 | 670 |
| 662 gfx::Rect viewport(0, 0, 100, 100); | 671 gfx::Rect viewport(0, 0, 100, 100); |
| 663 gfx::Size layer_bounds(1500, 1500); | 672 gfx::Size layer_bounds(1500, 1500); |
| 664 | 673 |
| 665 client.SetTileSize(gfx::Size(10, 10)); | 674 client.SetTileSize(gfx::Size(10, 10)); |
| 666 client.set_tree(ACTIVE_TREE); | 675 client.set_tree(ACTIVE_TREE); |
| 676 LayerTreeSettings settings; |
| 677 settings.max_tiles_for_interest_area = 10000; |
| 667 | 678 |
| 668 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 679 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
| 669 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 680 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
| 670 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 681 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
| 671 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 682 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
| 672 // tiling. | 683 // tiling. |
| 673 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client); | 684 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client, |
| 685 settings); |
| 674 gfx::Rect viewport_in_content_space = | 686 gfx::Rect viewport_in_content_space = |
| 675 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 687 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
| 676 | 688 |
| 677 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 689 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
| 678 tiling->UpdateAllTilePrioritiesForTesting(); | 690 tiling->UpdateAllTilePrioritiesForTesting(); |
| 679 | 691 |
| 680 gfx::Rect soon_rect = viewport; | 692 gfx::Rect soon_rect = viewport; |
| 681 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 693 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 682 gfx::Rect soon_rect_in_content_space = | 694 gfx::Rect soon_rect_in_content_space = |
| 683 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 695 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 829 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 818 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 830 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
| 819 | 831 |
| 820 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 832 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 821 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 833 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
| 822 | 834 |
| 823 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 835 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| 824 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 836 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
| 825 | 837 |
| 826 // Test additional scales. | 838 // Test additional scales. |
| 827 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client); | 839 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client, |
| 840 LayerTreeSettings()); |
| 828 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 841 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
| 829 tiling->UpdateAllTilePrioritiesForTesting(); | 842 tiling->UpdateAllTilePrioritiesForTesting(); |
| 830 | 843 |
| 831 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 844 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
| 832 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 845 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
| 833 | 846 |
| 834 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 847 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
| 835 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 848 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
| 836 | 849 |
| 837 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 850 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 scoped_ptr<TestablePictureLayerTiling> tiling; | 1090 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 1078 | 1091 |
| 1079 gfx::Rect viewport(50, 50, 100, 100); | 1092 gfx::Rect viewport(50, 50, 100, 100); |
| 1080 gfx::Size layer_bounds(800, 800); | 1093 gfx::Size layer_bounds(800, 800); |
| 1081 | 1094 |
| 1082 gfx::Rect soon_rect = viewport; | 1095 gfx::Rect soon_rect = viewport; |
| 1083 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1096 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1084 | 1097 |
| 1085 client.SetTileSize(gfx::Size(30, 30)); | 1098 client.SetTileSize(gfx::Size(30, 30)); |
| 1086 client.set_tree(ACTIVE_TREE); | 1099 client.set_tree(ACTIVE_TREE); |
| 1100 LayerTreeSettings settings; |
| 1101 settings.max_tiles_for_interest_area = 10000; |
| 1087 | 1102 |
| 1088 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1103 tiling = |
| 1104 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); |
| 1089 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1105 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1090 tiling->UpdateAllTilePrioritiesForTesting(); | 1106 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1091 | 1107 |
| 1092 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1108 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
| 1093 EXPECT_FALSE(empty_iterator); | 1109 EXPECT_FALSE(empty_iterator); |
| 1094 | 1110 |
| 1095 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1111 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1096 | 1112 |
| 1097 // Sanity check. | 1113 // Sanity check. |
| 1098 EXPECT_EQ(841u, all_tiles.size()); | 1114 EXPECT_EQ(841u, all_tiles.size()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { | 1198 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { |
| 1183 FakePictureLayerTilingClient client; | 1199 FakePictureLayerTilingClient client; |
| 1184 scoped_ptr<TestablePictureLayerTiling> tiling; | 1200 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 1185 | 1201 |
| 1186 gfx::Rect viewport(50, 0, 100, 100); | 1202 gfx::Rect viewport(50, 0, 100, 100); |
| 1187 gfx::Rect moved_viewport(50, 0, 100, 500); | 1203 gfx::Rect moved_viewport(50, 0, 100, 500); |
| 1188 gfx::Size layer_bounds(1000, 1000); | 1204 gfx::Size layer_bounds(1000, 1000); |
| 1189 | 1205 |
| 1190 client.SetTileSize(gfx::Size(30, 30)); | 1206 client.SetTileSize(gfx::Size(30, 30)); |
| 1191 client.set_tree(ACTIVE_TREE); | 1207 client.set_tree(ACTIVE_TREE); |
| 1208 LayerTreeSettings settings; |
| 1209 settings.max_tiles_for_interest_area = 10000; |
| 1192 | 1210 |
| 1193 tiling = TestablePictureLayerTiling::Create(1.f, layer_bounds, &client); | 1211 tiling = |
| 1212 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client, settings); |
| 1194 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1213 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
| 1195 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); | 1214 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); |
| 1196 tiling->UpdateAllTilePrioritiesForTesting(); | 1215 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1197 | 1216 |
| 1198 gfx::Rect soon_rect = moved_viewport; | 1217 gfx::Rect soon_rect = moved_viewport; |
| 1199 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1218 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
| 1200 | 1219 |
| 1201 // There are 3 bins in TilePriority. | 1220 // There are 3 bins in TilePriority. |
| 1202 bool have_tiles[3] = {}; | 1221 bool have_tiles[3] = {}; |
| 1203 Tile* last_tile = NULL; | 1222 Tile* last_tile = NULL; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 bool intersects = rect.Intersects(geometry_rect); | 1337 bool intersects = rect.Intersects(geometry_rect); |
| 1319 bool expected_exists = intersect_exists ? intersects : !intersects; | 1338 bool expected_exists = intersect_exists ? intersects : !intersects; |
| 1320 EXPECT_EQ(expected_exists, tile != NULL) | 1339 EXPECT_EQ(expected_exists, tile != NULL) |
| 1321 << "Rects intersecting " << rect.ToString() << " should exist. " | 1340 << "Rects intersecting " << rect.ToString() << " should exist. " |
| 1322 << "Current tile rect is " << geometry_rect.ToString(); | 1341 << "Current tile rect is " << geometry_rect.ToString(); |
| 1323 } | 1342 } |
| 1324 | 1343 |
| 1325 TEST_F(PictureLayerTilingIteratorTest, | 1344 TEST_F(PictureLayerTilingIteratorTest, |
| 1326 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1345 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
| 1327 gfx::Size layer_bounds(10000, 10000); | 1346 gfx::Size layer_bounds(10000, 10000); |
| 1328 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1347 client_.SetTileSize(gfx::Size(100, 100)); |
| 1348 client_.set_tree(PENDING_TREE); |
| 1349 LayerTreeSettings settings; |
| 1350 settings.max_tiles_for_interest_area = 1; |
| 1351 |
| 1352 tiling_ = |
| 1353 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client_, settings); |
| 1329 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1354 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
| 1330 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1355 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| 1331 | 1356 |
| 1332 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1357 gfx::Rect visible_rect(8000, 8000, 50, 50); |
| 1333 | 1358 |
| 1334 client_.set_tree(ACTIVE_TREE); | 1359 client_.set_tree(ACTIVE_TREE); |
| 1335 set_max_tiles_for_interest_area(1); | |
| 1336 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1360 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
| 1337 1.f, // current contents scale | 1361 1.f, // current contents scale |
| 1338 1.0, // current frame time | 1362 1.0, // current frame time |
| 1339 Occlusion()); | 1363 Occlusion()); |
| 1340 VerifyTiles(1.f, | 1364 VerifyTiles(1.f, |
| 1341 gfx::Rect(layer_bounds), | 1365 gfx::Rect(layer_bounds), |
| 1342 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); | 1366 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); |
| 1343 } | 1367 } |
| 1344 | 1368 |
| 1345 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { | 1369 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { |
| 1346 gfx::Size layer_bounds(1099, 801); | 1370 gfx::Size layer_bounds(1099, 801); |
| 1347 gfx::Size tile_size(100, 100); | 1371 gfx::Size tile_size(100, 100); |
| 1348 | 1372 |
| 1349 client_.SetTileSize(tile_size); | 1373 client_.SetTileSize(tile_size); |
| 1350 client_.set_tree(PENDING_TREE); | 1374 client_.set_tree(PENDING_TREE); |
| 1351 | 1375 |
| 1352 auto active_set = PictureLayerTilingSet::Create(&client_); | 1376 LayerTreeSettings defaults; |
| 1377 auto active_set = PictureLayerTilingSet::Create( |
| 1378 &client_, 10000, defaults.skewport_target_time_in_seconds, |
| 1379 defaults.skewport_extrapolation_limit_in_content_pixels); |
| 1353 | 1380 |
| 1354 active_set->AddTiling(1.f, layer_bounds); | 1381 active_set->AddTiling(1.f, layer_bounds); |
| 1355 | 1382 |
| 1356 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1383 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
| 1357 base::Bind(&TileExists, false)); | 1384 base::Bind(&TileExists, false)); |
| 1358 | 1385 |
| 1359 UpdateAllTilePriorities(active_set.get(), | 1386 UpdateAllTilePriorities(active_set.get(), |
| 1360 gfx::Rect(layer_bounds), // visible content rect | 1387 gfx::Rect(layer_bounds), // visible content rect |
| 1361 1.f, // current contents scale | 1388 1.f, // current contents scale |
| 1362 1.0); // current frame time | 1389 1.0); // current frame time |
| 1363 | 1390 |
| 1364 // The active tiling has tiles now. | 1391 // The active tiling has tiles now. |
| 1365 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1392 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
| 1366 base::Bind(&TileExists, true)); | 1393 base::Bind(&TileExists, true)); |
| 1367 | 1394 |
| 1368 // Add the same tilings to the pending set. | 1395 // Add the same tilings to the pending set. |
| 1369 auto pending_set = PictureLayerTilingSet::Create(&client_); | 1396 auto pending_set = PictureLayerTilingSet::Create( |
| 1397 &client_, 10000, defaults.skewport_target_time_in_seconds, |
| 1398 defaults.skewport_extrapolation_limit_in_content_pixels); |
| 1370 Region invalidation; | 1399 Region invalidation; |
| 1371 pending_set->SyncTilingsForTesting(*active_set, layer_bounds, invalidation, | 1400 pending_set->SyncTilingsForTesting(*active_set, layer_bounds, invalidation, |
| 1372 0.f, client_.raster_source()); | 1401 0.f, client_.raster_source()); |
| 1373 | 1402 |
| 1374 // The pending tiling starts with no tiles. | 1403 // The pending tiling starts with no tiles. |
| 1375 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1404 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
| 1376 base::Bind(&TileExists, false)); | 1405 base::Bind(&TileExists, false)); |
| 1377 | 1406 |
| 1378 // ComputeTilePriorityRects on the pending tiling at the same frame time. The | 1407 // ComputeTilePriorityRects on the pending tiling at the same frame time. The |
| 1379 // pending tiling should get tiles. | 1408 // pending tiling should get tiles. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1399 float current_layer_contents_scale = 1.f; | 1428 float current_layer_contents_scale = 1.f; |
| 1400 gfx::Transform current_screen_transform; | 1429 gfx::Transform current_screen_transform; |
| 1401 double current_frame_time_in_seconds = 1.0; | 1430 double current_frame_time_in_seconds = 1.0; |
| 1402 | 1431 |
| 1403 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1432 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1404 current_screen_transform, device_viewport); | 1433 current_screen_transform, device_viewport); |
| 1405 | 1434 |
| 1406 client.SetTileSize(gfx::Size(100, 100)); | 1435 client.SetTileSize(gfx::Size(100, 100)); |
| 1407 client.set_tree(ACTIVE_TREE); | 1436 client.set_tree(ACTIVE_TREE); |
| 1408 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1437 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1409 current_layer_bounds, | 1438 current_layer_bounds, &client, |
| 1410 &client); | 1439 LayerTreeSettings()); |
| 1411 | 1440 |
| 1412 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1441 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1413 current_layer_contents_scale, | 1442 current_layer_contents_scale, |
| 1414 current_frame_time_in_seconds, Occlusion()); | 1443 current_frame_time_in_seconds, Occlusion()); |
| 1415 tiling->UpdateAllTilePrioritiesForTesting(); | 1444 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1416 | 1445 |
| 1417 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1446 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1418 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1447 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1419 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1448 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1420 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1449 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 | 1482 |
| 1454 current_screen_transform.Translate(850, 0); | 1483 current_screen_transform.Translate(850, 0); |
| 1455 last_screen_transform = current_screen_transform; | 1484 last_screen_transform = current_screen_transform; |
| 1456 | 1485 |
| 1457 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1486 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1458 current_screen_transform, device_viewport); | 1487 current_screen_transform, device_viewport); |
| 1459 | 1488 |
| 1460 client.SetTileSize(gfx::Size(100, 100)); | 1489 client.SetTileSize(gfx::Size(100, 100)); |
| 1461 client.set_tree(ACTIVE_TREE); | 1490 client.set_tree(ACTIVE_TREE); |
| 1462 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1491 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1463 current_layer_bounds, | 1492 current_layer_bounds, &client, |
| 1464 &client); | 1493 LayerTreeSettings()); |
| 1465 | 1494 |
| 1466 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1495 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1467 current_layer_contents_scale, | 1496 current_layer_contents_scale, |
| 1468 current_frame_time_in_seconds, Occlusion()); | 1497 current_frame_time_in_seconds, Occlusion()); |
| 1469 tiling->UpdateAllTilePrioritiesForTesting(); | 1498 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1470 | 1499 |
| 1471 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1500 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1472 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1501 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1473 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1502 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1474 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1503 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 | 1546 |
| 1518 current_screen_transform.Translate(705, 505); | 1547 current_screen_transform.Translate(705, 505); |
| 1519 last_screen_transform = current_screen_transform; | 1548 last_screen_transform = current_screen_transform; |
| 1520 | 1549 |
| 1521 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1550 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1522 current_screen_transform, device_viewport); | 1551 current_screen_transform, device_viewport); |
| 1523 | 1552 |
| 1524 client.SetTileSize(gfx::Size(100, 100)); | 1553 client.SetTileSize(gfx::Size(100, 100)); |
| 1525 client.set_tree(ACTIVE_TREE); | 1554 client.set_tree(ACTIVE_TREE); |
| 1526 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1555 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1527 current_layer_bounds, | 1556 current_layer_bounds, &client, |
| 1528 &client); | 1557 LayerTreeSettings()); |
| 1529 | 1558 |
| 1530 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1559 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1531 current_layer_contents_scale, | 1560 current_layer_contents_scale, |
| 1532 current_frame_time_in_seconds, Occlusion()); | 1561 current_frame_time_in_seconds, Occlusion()); |
| 1533 tiling->UpdateAllTilePrioritiesForTesting(); | 1562 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1534 | 1563 |
| 1535 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1564 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1536 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1565 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1537 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1566 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1538 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1567 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 current_screen_transform.Translate(600, 750); | 1604 current_screen_transform.Translate(600, 750); |
| 1576 current_screen_transform.RotateAboutZAxis(45); | 1605 current_screen_transform.RotateAboutZAxis(45); |
| 1577 last_screen_transform = current_screen_transform; | 1606 last_screen_transform = current_screen_transform; |
| 1578 | 1607 |
| 1579 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1608 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1580 current_screen_transform, device_viewport); | 1609 current_screen_transform, device_viewport); |
| 1581 | 1610 |
| 1582 client.SetTileSize(gfx::Size(100, 100)); | 1611 client.SetTileSize(gfx::Size(100, 100)); |
| 1583 client.set_tree(ACTIVE_TREE); | 1612 client.set_tree(ACTIVE_TREE); |
| 1584 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1613 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1585 current_layer_bounds, | 1614 current_layer_bounds, &client, |
| 1586 &client); | 1615 LayerTreeSettings()); |
| 1587 | 1616 |
| 1588 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1617 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1589 current_layer_contents_scale, | 1618 current_layer_contents_scale, |
| 1590 current_frame_time_in_seconds, Occlusion()); | 1619 current_frame_time_in_seconds, Occlusion()); |
| 1591 tiling->UpdateAllTilePrioritiesForTesting(); | 1620 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1592 | 1621 |
| 1593 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1622 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1594 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1623 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1595 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1624 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1596 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1625 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1686 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
| 1658 &clipped); | 1687 &clipped); |
| 1659 ASSERT_FALSE(clipped); | 1688 ASSERT_FALSE(clipped); |
| 1660 | 1689 |
| 1661 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1690 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1662 current_screen_transform, device_viewport); | 1691 current_screen_transform, device_viewport); |
| 1663 | 1692 |
| 1664 client.SetTileSize(gfx::Size(100, 100)); | 1693 client.SetTileSize(gfx::Size(100, 100)); |
| 1665 client.set_tree(ACTIVE_TREE); | 1694 client.set_tree(ACTIVE_TREE); |
| 1666 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1695 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1667 current_layer_bounds, | 1696 current_layer_bounds, &client, |
| 1668 &client); | 1697 LayerTreeSettings()); |
| 1669 | 1698 |
| 1670 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1699 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1671 current_layer_contents_scale, | 1700 current_layer_contents_scale, |
| 1672 current_frame_time_in_seconds, Occlusion()); | 1701 current_frame_time_in_seconds, Occlusion()); |
| 1673 tiling->UpdateAllTilePrioritiesForTesting(); | 1702 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1674 | 1703 |
| 1675 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1704 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1676 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1705 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1677 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1706 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1678 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1707 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1778 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
| 1750 &clipped); | 1779 &clipped); |
| 1751 ASSERT_FALSE(clipped); | 1780 ASSERT_FALSE(clipped); |
| 1752 | 1781 |
| 1753 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1782 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1754 current_screen_transform, device_viewport); | 1783 current_screen_transform, device_viewport); |
| 1755 | 1784 |
| 1756 client.SetTileSize(gfx::Size(100, 100)); | 1785 client.SetTileSize(gfx::Size(100, 100)); |
| 1757 client.set_tree(ACTIVE_TREE); | 1786 client.set_tree(ACTIVE_TREE); |
| 1758 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1787 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1759 current_layer_bounds, | 1788 current_layer_bounds, &client, |
| 1760 &client); | 1789 LayerTreeSettings()); |
| 1761 | 1790 |
| 1762 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1791 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1763 current_layer_contents_scale, | 1792 current_layer_contents_scale, |
| 1764 current_frame_time_in_seconds, Occlusion()); | 1793 current_frame_time_in_seconds, Occlusion()); |
| 1765 tiling->UpdateAllTilePrioritiesForTesting(); | 1794 tiling->UpdateAllTilePrioritiesForTesting(); |
| 1766 | 1795 |
| 1767 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1796 ASSERT_TRUE(tiling->TileAt(0, 0)); |
| 1768 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1797 ASSERT_TRUE(tiling->TileAt(0, 1)); |
| 1769 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1798 ASSERT_TRUE(tiling->TileAt(1, 0)); |
| 1770 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1799 ASSERT_TRUE(tiling->TileAt(1, 1)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 | 1839 |
| 1811 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1840 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
| 1812 current_screen_transform.Translate(1800, 0); | 1841 current_screen_transform.Translate(1800, 0); |
| 1813 last_screen_transform.Translate(2800, 0); | 1842 last_screen_transform.Translate(2800, 0); |
| 1814 | 1843 |
| 1815 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1844 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1816 current_screen_transform, device_viewport); | 1845 current_screen_transform, device_viewport); |
| 1817 | 1846 |
| 1818 client.SetTileSize(gfx::Size(100, 100)); | 1847 client.SetTileSize(gfx::Size(100, 100)); |
| 1819 client.set_tree(ACTIVE_TREE); | 1848 client.set_tree(ACTIVE_TREE); |
| 1849 LayerTreeSettings settings; |
| 1850 settings.max_tiles_for_interest_area = 10000; |
| 1820 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1851 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1821 current_layer_bounds, | 1852 current_layer_bounds, &client, |
| 1822 &client); | 1853 settings); |
| 1823 | 1854 |
| 1824 // previous ("last") frame | 1855 // previous ("last") frame |
| 1825 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1856 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1826 last_layer_contents_scale, | 1857 last_layer_contents_scale, |
| 1827 last_frame_time_in_seconds, Occlusion()); | 1858 last_frame_time_in_seconds, Occlusion()); |
| 1828 | 1859 |
| 1829 // current frame | 1860 // current frame |
| 1830 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1861 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1831 current_layer_contents_scale, | 1862 current_layer_contents_scale, |
| 1832 current_frame_time_in_seconds, Occlusion()); | 1863 current_frame_time_in_seconds, Occlusion()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 current_screen_transform.RotateAboutZAxis(45); | 1917 current_screen_transform.RotateAboutZAxis(45); |
| 1887 | 1918 |
| 1888 last_screen_transform.Translate(400, 550); | 1919 last_screen_transform.Translate(400, 550); |
| 1889 | 1920 |
| 1890 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1921 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1891 current_screen_transform, device_viewport); | 1922 current_screen_transform, device_viewport); |
| 1892 | 1923 |
| 1893 client.SetTileSize(gfx::Size(100, 100)); | 1924 client.SetTileSize(gfx::Size(100, 100)); |
| 1894 client.set_tree(ACTIVE_TREE); | 1925 client.set_tree(ACTIVE_TREE); |
| 1895 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1926 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1896 current_layer_bounds, | 1927 current_layer_bounds, &client, |
| 1897 &client); | 1928 LayerTreeSettings()); |
| 1898 | 1929 |
| 1899 // previous ("last") frame | 1930 // previous ("last") frame |
| 1900 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1931 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1901 last_layer_contents_scale, | 1932 last_layer_contents_scale, |
| 1902 last_frame_time_in_seconds, Occlusion()); | 1933 last_frame_time_in_seconds, Occlusion()); |
| 1903 | 1934 |
| 1904 // current frame | 1935 // current frame |
| 1905 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1936 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
| 1906 current_layer_contents_scale, | 1937 current_layer_contents_scale, |
| 1907 current_frame_time_in_seconds, Occlusion()); | 1938 current_frame_time_in_seconds, Occlusion()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1934 // - Viewport moves back and a new active tiling tile is created. | 1965 // - Viewport moves back and a new active tiling tile is created. |
| 1935 // Result: | 1966 // Result: |
| 1936 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1967 // - Recycle tiling does _not_ have the tile in the same location (thus it |
| 1937 // will be shared next time a pending tiling is created). | 1968 // will be shared next time a pending tiling is created). |
| 1938 | 1969 |
| 1939 FakePictureLayerTilingClient active_client; | 1970 FakePictureLayerTilingClient active_client; |
| 1940 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 1971 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
| 1941 | 1972 |
| 1942 active_client.SetTileSize(gfx::Size(100, 100)); | 1973 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1943 active_client.set_tree(ACTIVE_TREE); | 1974 active_client.set_tree(ACTIVE_TREE); |
| 1944 active_client.set_max_tiles_for_interest_area(10); | 1975 LayerTreeSettings settings; |
| 1976 settings.max_tiles_for_interest_area = 10; |
| 1945 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1977 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1946 gfx::Size(10000, 10000), | 1978 gfx::Size(10000, 10000), |
| 1947 &active_client); | 1979 &active_client, settings); |
| 1948 // Create all tiles on this tiling. | 1980 // Create all tiles on this tiling. |
| 1949 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1981 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 1950 Occlusion()); | 1982 Occlusion()); |
| 1951 | 1983 |
| 1952 FakePictureLayerTilingClient recycle_client; | 1984 FakePictureLayerTilingClient recycle_client; |
| 1953 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1985 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 1954 recycle_client.set_tree(PENDING_TREE); | 1986 recycle_client.set_tree(PENDING_TREE); |
| 1955 recycle_client.set_twin_tiling(active_tiling.get()); | 1987 recycle_client.set_twin_tiling(active_tiling.get()); |
| 1956 recycle_client.set_max_tiles_for_interest_area(10); | |
| 1957 | 1988 |
| 1958 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 1989 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
| 1959 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1990 recycle_tiling = TestablePictureLayerTiling::Create( |
| 1960 gfx::Size(10000, 10000), | 1991 1.0f, // contents_scale |
| 1961 &recycle_client); | 1992 gfx::Size(10000, 10000), &recycle_client, settings); |
| 1962 | 1993 |
| 1963 // Create all tiles on the second tiling. All tiles should be shared. | 1994 // Create all tiles on the second tiling. All tiles should be shared. |
| 1964 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1995 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 1965 1.0f, Occlusion()); | 1996 1.0f, Occlusion()); |
| 1966 | 1997 |
| 1967 // Set the second tiling as recycled. | 1998 // Set the second tiling as recycled. |
| 1968 active_client.set_twin_tiling(NULL); | 1999 active_client.set_twin_tiling(NULL); |
| 1969 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2000 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 1970 recycle_client.set_twin_tiling(NULL); | 2001 recycle_client.set_twin_tiling(NULL); |
| 1971 | 2002 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1989 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2020 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 1990 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2021 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 1991 } | 2022 } |
| 1992 | 2023 |
| 1993 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 2024 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
| 1994 FakePictureLayerTilingClient active_client; | 2025 FakePictureLayerTilingClient active_client; |
| 1995 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 2026 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
| 1996 | 2027 |
| 1997 active_client.SetTileSize(gfx::Size(100, 100)); | 2028 active_client.SetTileSize(gfx::Size(100, 100)); |
| 1998 active_client.set_tree(ACTIVE_TREE); | 2029 active_client.set_tree(ACTIVE_TREE); |
| 1999 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2030 active_tiling = TestablePictureLayerTiling::Create( |
| 2000 gfx::Size(100, 100), | 2031 1.0f, // contents_scale |
| 2001 &active_client); | 2032 gfx::Size(100, 100), &active_client, LayerTreeSettings()); |
| 2002 // Create all tiles on this tiling. | 2033 // Create all tiles on this tiling. |
| 2003 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 2034 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
| 2004 Occlusion()); | 2035 Occlusion()); |
| 2005 | 2036 |
| 2006 FakePictureLayerTilingClient recycle_client; | 2037 FakePictureLayerTilingClient recycle_client; |
| 2007 recycle_client.SetTileSize(gfx::Size(100, 100)); | 2038 recycle_client.SetTileSize(gfx::Size(100, 100)); |
| 2008 recycle_client.set_tree(PENDING_TREE); | 2039 recycle_client.set_tree(PENDING_TREE); |
| 2009 recycle_client.set_twin_tiling(active_tiling.get()); | 2040 recycle_client.set_twin_tiling(active_tiling.get()); |
| 2010 recycle_client.set_max_tiles_for_interest_area(10); | |
| 2011 | 2041 |
| 2042 LayerTreeSettings settings; |
| 2043 settings.max_tiles_for_interest_area = 10; |
| 2012 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2044 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
| 2013 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2045 recycle_tiling = TestablePictureLayerTiling::Create( |
| 2014 gfx::Size(100, 100), | 2046 1.0f, // contents_scale |
| 2015 &recycle_client); | 2047 gfx::Size(100, 100), &recycle_client, settings); |
| 2016 | 2048 |
| 2017 // Create all tiles on the recycle tiling. All tiles should be shared. | 2049 // Create all tiles on the recycle tiling. All tiles should be shared. |
| 2018 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 2050 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
| 2019 1.0f, Occlusion()); | 2051 1.0f, Occlusion()); |
| 2020 | 2052 |
| 2021 // Set the second tiling as recycled. | 2053 // Set the second tiling as recycled. |
| 2022 active_client.set_twin_tiling(NULL); | 2054 active_client.set_twin_tiling(NULL); |
| 2023 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2055 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
| 2024 recycle_client.set_twin_tiling(NULL); | 2056 recycle_client.set_twin_tiling(NULL); |
| 2025 | 2057 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2052 tiling_->Resize(gfx::Size(250, 150)); | 2084 tiling_->Resize(gfx::Size(250, 150)); |
| 2053 | 2085 |
| 2054 // Tile size in the tiling should be resized to 250x200. | 2086 // Tile size in the tiling should be resized to 250x200. |
| 2055 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2087 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 2056 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2088 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 2057 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2089 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 2058 } | 2090 } |
| 2059 | 2091 |
| 2060 } // namespace | 2092 } // namespace |
| 2061 } // namespace cc | 2093 } // namespace cc |
| OLD | NEW |