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