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" |
| 6 |
5 #include <limits> | 7 #include <limits> |
6 #include <set> | 8 #include <set> |
7 | 9 |
8 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
9 #include "cc/resources/picture_layer_tiling.h" | |
10 #include "cc/resources/picture_layer_tiling_set.h" | 11 #include "cc/resources/picture_layer_tiling_set.h" |
11 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
13 #include "cc/test/fake_picture_layer_tiling_client.h" | 14 #include "cc/test/fake_picture_layer_tiling_client.h" |
14 #include "cc/test/fake_picture_pile_impl.h" | 15 #include "cc/test/fake_picture_pile_impl.h" |
15 #include "cc/test/test_context_provider.h" | 16 #include "cc/test/test_context_provider.h" |
16 #include "cc/test/test_shared_bitmap_manager.h" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "ui/gfx/geometry/quad_f.h" | 19 #include "ui/gfx/geometry/quad_f.h" |
19 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ~PictureLayerTilingIteratorTest() override {} | 79 ~PictureLayerTilingIteratorTest() override {} |
79 | 80 |
80 void Initialize(const gfx::Size& tile_size, | 81 void Initialize(const gfx::Size& tile_size, |
81 float contents_scale, | 82 float contents_scale, |
82 const gfx::Size& layer_bounds) { | 83 const gfx::Size& layer_bounds) { |
83 client_.SetTileSize(tile_size); | 84 client_.SetTileSize(tile_size); |
84 client_.set_tree(PENDING_TREE); | 85 client_.set_tree(PENDING_TREE); |
85 scoped_refptr<FakePicturePileImpl> pile = | 86 scoped_refptr<FakePicturePileImpl> pile = |
86 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 87 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
87 tiling_ = TestablePictureLayerTiling::Create(contents_scale, pile, &client_, | 88 tiling_ = TestablePictureLayerTiling::Create(contents_scale, pile, &client_, |
88 LayerTreeSettings()); | |
89 } | |
90 | |
91 void InitializeActive(const gfx::Size& tile_size, | |
92 float contents_scale, | |
93 const gfx::Size& layer_bounds) { | |
94 client_.SetTileSize(tile_size); | |
95 client_.set_tree(ACTIVE_TREE); | |
96 scoped_refptr<FakePicturePileImpl> pile = | |
97 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | |
98 tiling_ = TestablePictureLayerTiling::Create(contents_scale, pile, &client_, | |
99 LayerTreeSettings()); | 89 LayerTreeSettings()); |
100 } | 90 } |
101 | 91 |
102 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 92 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
103 tiling_->SetLiveTilesRect(live_tiles_rect); | 93 tiling_->SetLiveTilesRect(live_tiles_rect); |
104 | 94 |
105 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 95 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
106 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 96 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
107 iter != tiles.end(); | 97 iter != tiles.end(); |
108 ++iter) { | 98 ++iter) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 182 |
193 private: | 183 private: |
194 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); | 184 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
195 }; | 185 }; |
196 | 186 |
197 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { | 187 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
198 // Verifies that a resize with invalidation for newly exposed pixels will | 188 // Verifies that a resize with invalidation for newly exposed pixels will |
199 // deletes tiles that intersect that invalidation. | 189 // deletes tiles that intersect that invalidation. |
200 gfx::Size tile_size(100, 100); | 190 gfx::Size tile_size(100, 100); |
201 gfx::Size original_layer_size(10, 10); | 191 gfx::Size original_layer_size(10, 10); |
202 InitializeActive(tile_size, 1.f, original_layer_size); | 192 Initialize(tile_size, 1.f, original_layer_size); |
203 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 193 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
204 | 194 |
205 // Tiling only has one tile, since its total size is less than one. | 195 // Tiling only has one tile, since its total size is less than one. |
206 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 196 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
207 | 197 |
208 // Stop creating tiles so that any invalidations are left as holes. | 198 // Stop creating tiles so that any invalidations are left as holes. |
209 gfx::Size new_layer_size(200, 200); | 199 gfx::Size new_layer_size(200, 200); |
210 scoped_refptr<FakePicturePileImpl> pile = | 200 scoped_refptr<FakePicturePileImpl> pile = |
211 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(new_layer_size); | 201 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize(new_layer_size); |
212 | 202 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 for (int j = 0; j < 4; ++j) | 398 for (int j = 0; j < 4; ++j) |
409 EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; | 399 EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
410 } | 400 } |
411 } | 401 } |
412 | 402 |
413 TEST_F(PictureLayerTilingIteratorTest, ResizeOverBorderPixelsDeletesTiles) { | 403 TEST_F(PictureLayerTilingIteratorTest, ResizeOverBorderPixelsDeletesTiles) { |
414 // Verifies that a resize with invalidation for newly exposed pixels will | 404 // Verifies that a resize with invalidation for newly exposed pixels will |
415 // deletes tiles that intersect that invalidation. | 405 // deletes tiles that intersect that invalidation. |
416 gfx::Size tile_size(100, 100); | 406 gfx::Size tile_size(100, 100); |
417 gfx::Size original_layer_size(99, 99); | 407 gfx::Size original_layer_size(99, 99); |
418 InitializeActive(tile_size, 1.f, original_layer_size); | 408 Initialize(tile_size, 1.f, original_layer_size); |
419 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 409 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
420 | 410 |
421 // Tiling only has one tile, since its total size is less than one. | 411 // Tiling only has one tile, since its total size is less than one. |
422 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 412 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
423 | 413 |
424 // Stop creating tiles so that any invalidations are left as holes. | 414 // Stop creating tiles so that any invalidations are left as holes. |
425 scoped_refptr<FakePicturePileImpl> pile = | 415 scoped_refptr<FakePicturePileImpl> pile = |
426 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize( | 416 FakePicturePileImpl::CreateEmptyPileWithDefaultTileSize( |
427 gfx::Size(200, 200)); | 417 gfx::Size(200, 200)); |
428 tiling_->SetRasterSourceAndResize(pile); | 418 tiling_->SetRasterSourceAndResize(pile); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 796 |
807 // No movement in the viewport implies that tiles will either be NOW | 797 // No movement in the viewport implies that tiles will either be NOW |
808 // or EVENTUALLY, with the exception of tiles that are between 0 and 312 | 798 // or EVENTUALLY, with the exception of tiles that are between 0 and 312 |
809 // pixels away from the viewport, which will be in the SOON bin. | 799 // pixels away from the viewport, which will be in the SOON bin. |
810 bool have_now = false; | 800 bool have_now = false; |
811 bool have_eventually = false; | 801 bool have_eventually = false; |
812 bool have_soon = false; | 802 bool have_soon = false; |
813 for (int i = 0; i < 47; ++i) { | 803 for (int i = 0; i < 47; ++i) { |
814 for (int j = 0; j < 47; ++j) { | 804 for (int j = 0; j < 47; ++j) { |
815 Tile* tile = tiling->TileAt(i, j); | 805 Tile* tile = tiling->TileAt(i, j); |
816 TilePriority priority = tile->priority(); | 806 TilePriority priority = tile->priority(ACTIVE_TREE); |
817 | 807 |
818 gfx::Rect tile_rect = tiling->TilingDataForTesting().TileBounds(i, j); | 808 gfx::Rect tile_rect = tiling->TilingDataForTesting().TileBounds(i, j); |
819 if (viewport_in_content_space.Intersects(tile_rect)) { | 809 if (viewport_in_content_space.Intersects(tile_rect)) { |
820 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 810 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
821 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 811 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
822 have_now = true; | 812 have_now = true; |
823 } else if (soon_rect_in_content_space.Intersects(tile_rect)) { | 813 } else if (soon_rect_in_content_space.Intersects(tile_rect)) { |
824 EXPECT_EQ(TilePriority::SOON, priority.priority_bin); | 814 EXPECT_EQ(TilePriority::SOON, priority.priority_bin); |
825 have_soon = true; | 815 have_soon = true; |
826 } else { | 816 } else { |
(...skipping 11 matching lines...) Expand all Loading... |
838 // Spot check some distances. | 828 // Spot check some distances. |
839 // Tile at 5, 1 should begin at 41x9 in content space (without borders), | 829 // Tile at 5, 1 should begin at 41x9 in content space (without borders), |
840 // so the distance to a viewport that ends at 25x25 in content space | 830 // so the distance to a viewport that ends at 25x25 in content space |
841 // should be 17 (41 - 25 + 1). In layer space, then that should be | 831 // should be 17 (41 - 25 + 1). In layer space, then that should be |
842 // 17 / 0.25 = 68 pixels. | 832 // 17 / 0.25 = 68 pixels. |
843 | 833 |
844 // We can verify that the content rect (with borders) is one pixel off | 834 // We can verify that the content rect (with borders) is one pixel off |
845 // 41,9 8x8 on all sides. | 835 // 41,9 8x8 on all sides. |
846 EXPECT_EQ(tiling->TileAt(5, 1)->content_rect().ToString(), "40,8 10x10"); | 836 EXPECT_EQ(tiling->TileAt(5, 1)->content_rect().ToString(), "40,8 10x10"); |
847 | 837 |
848 TilePriority priority = tiling->TileAt(5, 1)->priority(); | 838 TilePriority priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
849 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); | 839 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); |
850 | 840 |
851 priority = tiling->TileAt(2, 5)->priority(); | 841 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
852 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); | 842 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); |
853 | 843 |
854 priority = tiling->TileAt(3, 4)->priority(); | 844 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
855 EXPECT_FLOAT_EQ(40.f, priority.distance_to_visible); | 845 EXPECT_FLOAT_EQ(40.f, priority.distance_to_visible); |
856 | 846 |
857 // Move the viewport down 40 pixels. | 847 // Move the viewport down 40 pixels. |
858 viewport = gfx::Rect(0, 40, 100, 100); | 848 viewport = gfx::Rect(0, 40, 100, 100); |
859 viewport_in_content_space = | 849 viewport_in_content_space = |
860 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 850 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
861 gfx::Rect skewport = tiling->ComputeSkewport(2.0, viewport_in_content_space); | 851 gfx::Rect skewport = tiling->ComputeSkewport(2.0, viewport_in_content_space); |
862 | 852 |
863 // Compute the soon border. | 853 // Compute the soon border. |
864 inset = PictureLayerTiling::CalculateSoonBorderDistance( | 854 inset = PictureLayerTiling::CalculateSoonBorderDistance( |
(...skipping 11 matching lines...) Expand all Loading... |
876 | 866 |
877 have_now = false; | 867 have_now = false; |
878 have_eventually = false; | 868 have_eventually = false; |
879 have_soon = false; | 869 have_soon = false; |
880 | 870 |
881 // Viewport moved, so we expect to find some NOW tiles, some SOON tiles and | 871 // Viewport moved, so we expect to find some NOW tiles, some SOON tiles and |
882 // some EVENTUALLY tiles. | 872 // some EVENTUALLY tiles. |
883 for (int i = 0; i < 47; ++i) { | 873 for (int i = 0; i < 47; ++i) { |
884 for (int j = 0; j < 47; ++j) { | 874 for (int j = 0; j < 47; ++j) { |
885 Tile* tile = tiling->TileAt(i, j); | 875 Tile* tile = tiling->TileAt(i, j); |
886 TilePriority priority = tile->priority(); | 876 TilePriority priority = tile->priority(ACTIVE_TREE); |
887 | 877 |
888 gfx::Rect tile_rect = tiling->TilingDataForTesting().TileBounds(i, j); | 878 gfx::Rect tile_rect = tiling->TilingDataForTesting().TileBounds(i, j); |
889 if (viewport_in_content_space.Intersects(tile_rect)) { | 879 if (viewport_in_content_space.Intersects(tile_rect)) { |
890 EXPECT_EQ(TilePriority::NOW, priority.priority_bin) << "i: " << i | 880 EXPECT_EQ(TilePriority::NOW, priority.priority_bin) << "i: " << i |
891 << " j: " << j; | 881 << " j: " << j; |
892 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible) << "i: " << i | 882 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible) << "i: " << i |
893 << " j: " << j; | 883 << " j: " << j; |
894 have_now = true; | 884 have_now = true; |
895 } else if (skewport.Intersects(tile_rect) || | 885 } else if (skewport.Intersects(tile_rect) || |
896 soon_rect_in_content_space.Intersects(tile_rect)) { | 886 soon_rect_in_content_space.Intersects(tile_rect)) { |
897 EXPECT_EQ(TilePriority::SOON, priority.priority_bin) << "i: " << i | 887 EXPECT_EQ(TilePriority::SOON, priority.priority_bin) << "i: " << i |
898 << " j: " << j; | 888 << " j: " << j; |
899 EXPECT_GT(priority.distance_to_visible, 0.f) << "i: " << i | 889 EXPECT_GT(priority.distance_to_visible, 0.f) << "i: " << i |
900 << " j: " << j; | 890 << " j: " << j; |
901 have_soon = true; | 891 have_soon = true; |
902 } else { | 892 } else { |
903 EXPECT_EQ(TilePriority::EVENTUALLY, priority.priority_bin) | 893 EXPECT_EQ(TilePriority::EVENTUALLY, priority.priority_bin) |
904 << "i: " << i << " j: " << j; | 894 << "i: " << i << " j: " << j; |
905 EXPECT_GT(priority.distance_to_visible, 0.f) << "i: " << i | 895 EXPECT_GT(priority.distance_to_visible, 0.f) << "i: " << i |
906 << " j: " << j; | 896 << " j: " << j; |
907 have_eventually = true; | 897 have_eventually = true; |
908 } | 898 } |
909 } | 899 } |
910 } | 900 } |
911 | 901 |
912 EXPECT_TRUE(have_now); | 902 EXPECT_TRUE(have_now); |
913 EXPECT_TRUE(have_soon); | 903 EXPECT_TRUE(have_soon); |
914 EXPECT_TRUE(have_eventually); | 904 EXPECT_TRUE(have_eventually); |
915 | 905 |
916 priority = tiling->TileAt(5, 1)->priority(); | 906 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
917 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); | 907 EXPECT_FLOAT_EQ(68.f, priority.distance_to_visible); |
918 | 908 |
919 priority = tiling->TileAt(2, 5)->priority(); | 909 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
920 EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible); | 910 EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible); |
921 | 911 |
922 priority = tiling->TileAt(3, 4)->priority(); | 912 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
923 EXPECT_FLOAT_EQ(4.f, priority.distance_to_visible); | 913 EXPECT_FLOAT_EQ(4.f, priority.distance_to_visible); |
924 | 914 |
925 // Change the underlying layer scale. | 915 // Change the underlying layer scale. |
926 tiling->ComputeTilePriorityRects(viewport, 2.0f, 3.0, Occlusion()); | 916 tiling->ComputeTilePriorityRects(viewport, 2.0f, 3.0, Occlusion()); |
927 tiling->UpdateAllTilePrioritiesForTesting(); | 917 tiling->UpdateAllTilePrioritiesForTesting(); |
928 | 918 |
929 priority = tiling->TileAt(5, 1)->priority(); | 919 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
930 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 920 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
931 | 921 |
932 priority = tiling->TileAt(2, 5)->priority(); | 922 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
933 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 923 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
934 | 924 |
935 priority = tiling->TileAt(3, 4)->priority(); | 925 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
936 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 926 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
937 | 927 |
938 // Test additional scales. | 928 // Test additional scales. |
939 tiling = TestablePictureLayerTiling::Create(0.2f, pile, &client, | 929 tiling = TestablePictureLayerTiling::Create(0.2f, pile, &client, |
940 LayerTreeSettings()); | 930 LayerTreeSettings()); |
941 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 931 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
942 tiling->UpdateAllTilePrioritiesForTesting(); | 932 tiling->UpdateAllTilePrioritiesForTesting(); |
943 | 933 |
944 priority = tiling->TileAt(5, 1)->priority(); | 934 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
945 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 935 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
946 | 936 |
947 priority = tiling->TileAt(2, 5)->priority(); | 937 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
948 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 938 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
949 | 939 |
950 priority = tiling->TileAt(3, 4)->priority(); | 940 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
951 EXPECT_FLOAT_EQ(60.f, priority.distance_to_visible); | 941 EXPECT_FLOAT_EQ(60.f, priority.distance_to_visible); |
952 | 942 |
953 tiling->ComputeTilePriorityRects(viewport, 0.5f, 5.0, Occlusion()); | 943 tiling->ComputeTilePriorityRects(viewport, 0.5f, 5.0, Occlusion()); |
954 tiling->UpdateAllTilePrioritiesForTesting(); | 944 tiling->UpdateAllTilePrioritiesForTesting(); |
955 | 945 |
956 priority = tiling->TileAt(5, 1)->priority(); | 946 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
957 EXPECT_FLOAT_EQ(55.f, priority.distance_to_visible); | 947 EXPECT_FLOAT_EQ(55.f, priority.distance_to_visible); |
958 | 948 |
959 priority = tiling->TileAt(2, 5)->priority(); | 949 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
960 EXPECT_FLOAT_EQ(35.f, priority.distance_to_visible); | 950 EXPECT_FLOAT_EQ(35.f, priority.distance_to_visible); |
961 | 951 |
962 priority = tiling->TileAt(3, 4)->priority(); | 952 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
963 EXPECT_FLOAT_EQ(30.f, priority.distance_to_visible); | 953 EXPECT_FLOAT_EQ(30.f, priority.distance_to_visible); |
964 } | 954 } |
965 | 955 |
966 TEST(PictureLayerTilingTest, ExpandRectEqual) { | 956 TEST(PictureLayerTilingTest, ExpandRectEqual) { |
967 gfx::Rect in(40, 50, 100, 200); | 957 gfx::Rect in(40, 50, 100, 200); |
968 gfx::Rect bounds(-1000, -1000, 10000, 10000); | 958 gfx::Rect bounds(-1000, -1000, 10000, 10000); |
969 int64 target_area = 100 * 200; | 959 int64 target_area = 100 * 200; |
970 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 960 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
971 in, target_area, bounds, NULL); | 961 in, target_area, bounds, NULL); |
972 EXPECT_EQ(in.ToString(), out.ToString()); | 962 EXPECT_EQ(in.ToString(), out.ToString()); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1310 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1321 current_layer_contents_scale, | 1311 current_layer_contents_scale, |
1322 current_frame_time_in_seconds, Occlusion()); | 1312 current_frame_time_in_seconds, Occlusion()); |
1323 tiling->UpdateAllTilePrioritiesForTesting(); | 1313 tiling->UpdateAllTilePrioritiesForTesting(); |
1324 | 1314 |
1325 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1315 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1326 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1316 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1327 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1317 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1328 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1318 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1329 | 1319 |
1330 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1320 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1331 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1321 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1332 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1322 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
1333 | 1323 |
1334 priority = tiling->TileAt(0, 1)->priority(); | 1324 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1335 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1325 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1336 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1326 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
1337 | 1327 |
1338 priority = tiling->TileAt(1, 0)->priority(); | 1328 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1339 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1329 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1340 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1330 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
1341 | 1331 |
1342 priority = tiling->TileAt(1, 1)->priority(); | 1332 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1343 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1333 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1344 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1334 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
1345 } | 1335 } |
1346 | 1336 |
1347 TEST(ComputeTilePriorityRectsTest, OffscreenTiles) { | 1337 TEST(ComputeTilePriorityRectsTest, OffscreenTiles) { |
1348 // The TilePriority of offscreen tiles (without movement) should have nonzero | 1338 // The TilePriority of offscreen tiles (without movement) should have nonzero |
1349 // distance_to_visible and infinite time_to_visible. | 1339 // distance_to_visible and infinite time_to_visible. |
1350 FakePictureLayerTilingClient client; | 1340 FakePictureLayerTilingClient client; |
1351 | 1341 |
1352 gfx::Size device_viewport(800, 600); | 1342 gfx::Size device_viewport(800, 600); |
(...skipping 23 matching lines...) Expand all Loading... |
1376 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1366 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1377 current_layer_contents_scale, | 1367 current_layer_contents_scale, |
1378 current_frame_time_in_seconds, Occlusion()); | 1368 current_frame_time_in_seconds, Occlusion()); |
1379 tiling->UpdateAllTilePrioritiesForTesting(); | 1369 tiling->UpdateAllTilePrioritiesForTesting(); |
1380 | 1370 |
1381 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1371 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1382 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1372 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1383 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1373 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1384 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1374 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1385 | 1375 |
1386 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1376 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1387 EXPECT_GT(priority.distance_to_visible, 0.f); | 1377 EXPECT_GT(priority.distance_to_visible, 0.f); |
1388 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1378 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1389 | 1379 |
1390 priority = tiling->TileAt(0, 1)->priority(); | 1380 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1391 EXPECT_GT(priority.distance_to_visible, 0.f); | 1381 EXPECT_GT(priority.distance_to_visible, 0.f); |
1392 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1382 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1393 | 1383 |
1394 priority = tiling->TileAt(1, 0)->priority(); | 1384 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1395 EXPECT_GT(priority.distance_to_visible, 0.f); | 1385 EXPECT_GT(priority.distance_to_visible, 0.f); |
1396 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1386 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1397 | 1387 |
1398 priority = tiling->TileAt(1, 1)->priority(); | 1388 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1399 EXPECT_GT(priority.distance_to_visible, 0.f); | 1389 EXPECT_GT(priority.distance_to_visible, 0.f); |
1400 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1390 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1401 | 1391 |
1402 // Furthermore, in this scenario tiles on the right hand side should have a | 1392 // Furthermore, in this scenario tiles on the right hand side should have a |
1403 // larger distance to visible. | 1393 // larger distance to visible. |
1404 TilePriority left = tiling->TileAt(0, 0)->priority(); | 1394 TilePriority left = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1405 TilePriority right = tiling->TileAt(1, 0)->priority(); | 1395 TilePriority right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1406 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); | 1396 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); |
1407 | 1397 |
1408 left = tiling->TileAt(0, 1)->priority(); | 1398 left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1409 right = tiling->TileAt(1, 1)->priority(); | 1399 right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1410 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); | 1400 EXPECT_GT(right.distance_to_visible, left.distance_to_visible); |
1411 } | 1401 } |
1412 | 1402 |
1413 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenLayer) { | 1403 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenLayer) { |
1414 // Sanity check that a layer with some tiles visible and others offscreen has | 1404 // Sanity check that a layer with some tiles visible and others offscreen has |
1415 // correct TilePriorities for each tile. | 1405 // correct TilePriorities for each tile. |
1416 FakePictureLayerTilingClient client; | 1406 FakePictureLayerTilingClient client; |
1417 | 1407 |
1418 gfx::Size device_viewport(800, 600); | 1408 gfx::Size device_viewport(800, 600); |
1419 gfx::Size last_layer_bounds(200, 200); | 1409 gfx::Size last_layer_bounds(200, 200); |
(...skipping 22 matching lines...) Expand all Loading... |
1442 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1432 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1443 current_layer_contents_scale, | 1433 current_layer_contents_scale, |
1444 current_frame_time_in_seconds, Occlusion()); | 1434 current_frame_time_in_seconds, Occlusion()); |
1445 tiling->UpdateAllTilePrioritiesForTesting(); | 1435 tiling->UpdateAllTilePrioritiesForTesting(); |
1446 | 1436 |
1447 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1437 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1448 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1438 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1449 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1439 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1450 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1440 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1451 | 1441 |
1452 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1442 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1453 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1443 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1454 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1444 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
1455 | 1445 |
1456 priority = tiling->TileAt(0, 1)->priority(); | 1446 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1457 EXPECT_GT(priority.distance_to_visible, 0.f); | 1447 EXPECT_GT(priority.distance_to_visible, 0.f); |
1458 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1448 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1459 | 1449 |
1460 priority = tiling->TileAt(1, 0)->priority(); | 1450 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1461 EXPECT_GT(priority.distance_to_visible, 0.f); | 1451 EXPECT_GT(priority.distance_to_visible, 0.f); |
1462 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1452 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1463 | 1453 |
1464 priority = tiling->TileAt(1, 1)->priority(); | 1454 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1465 EXPECT_GT(priority.distance_to_visible, 0.f); | 1455 EXPECT_GT(priority.distance_to_visible, 0.f); |
1466 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1456 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1467 } | 1457 } |
1468 | 1458 |
1469 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenRotatedLayer) { | 1459 TEST(ComputeTilePriorityRectsTest, PartiallyOffscreenRotatedLayer) { |
1470 // Each tile of a layer may be affected differently by a transform; Check | 1460 // Each tile of a layer may be affected differently by a transform; Check |
1471 // that ComputeTilePriorityRects correctly accounts for the transform between | 1461 // that ComputeTilePriorityRects correctly accounts for the transform between |
1472 // layer space and screen space. | 1462 // layer space and screen space. |
1473 FakePictureLayerTilingClient client; | 1463 FakePictureLayerTilingClient client; |
1474 | 1464 |
(...skipping 27 matching lines...) Expand all Loading... |
1502 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1492 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1503 current_layer_contents_scale, | 1493 current_layer_contents_scale, |
1504 current_frame_time_in_seconds, Occlusion()); | 1494 current_frame_time_in_seconds, Occlusion()); |
1505 tiling->UpdateAllTilePrioritiesForTesting(); | 1495 tiling->UpdateAllTilePrioritiesForTesting(); |
1506 | 1496 |
1507 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1497 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1508 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1498 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1509 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1499 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1510 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1500 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1511 | 1501 |
1512 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1502 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1513 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1503 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1514 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1504 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1515 | 1505 |
1516 priority = tiling->TileAt(0, 1)->priority(); | 1506 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1517 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1507 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1518 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1508 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1519 | 1509 |
1520 priority = tiling->TileAt(1, 0)->priority(); | 1510 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1521 EXPECT_GT(priority.distance_to_visible, 0.f); | 1511 EXPECT_GT(priority.distance_to_visible, 0.f); |
1522 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1512 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1523 | 1513 |
1524 priority = tiling->TileAt(1, 1)->priority(); | 1514 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1525 EXPECT_GT(priority.distance_to_visible, 0.f); | 1515 EXPECT_GT(priority.distance_to_visible, 0.f); |
1526 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1516 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1527 | 1517 |
1528 // Furthermore, in this scenario the bottom-right tile should have the larger | 1518 // Furthermore, in this scenario the bottom-right tile should have the larger |
1529 // distance to visible. | 1519 // distance to visible. |
1530 TilePriority top_left = tiling->TileAt(0, 0)->priority(); | 1520 TilePriority top_left = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1531 TilePriority top_right = tiling->TileAt(1, 0)->priority(); | 1521 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1532 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(); | 1522 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1533 EXPECT_GT(top_right.distance_to_visible, top_left.distance_to_visible); | 1523 EXPECT_GT(top_right.distance_to_visible, top_left.distance_to_visible); |
1534 | 1524 |
1535 EXPECT_EQ(bottom_right.distance_to_visible, top_right.distance_to_visible); | 1525 EXPECT_EQ(bottom_right.distance_to_visible, top_right.distance_to_visible); |
1536 } | 1526 } |
1537 | 1527 |
1538 TEST(ComputeTilePriorityRectsTest, PerspectiveLayer) { | 1528 TEST(ComputeTilePriorityRectsTest, PerspectiveLayer) { |
1539 // Perspective transforms need to take a different code path. | 1529 // Perspective transforms need to take a different code path. |
1540 // This test checks tile priorities of a perspective layer. | 1530 // This test checks tile priorities of a perspective layer. |
1541 FakePictureLayerTilingClient client; | 1531 FakePictureLayerTilingClient client; |
1542 | 1532 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 current_frame_time_in_seconds, Occlusion()); | 1578 current_frame_time_in_seconds, Occlusion()); |
1589 tiling->UpdateAllTilePrioritiesForTesting(); | 1579 tiling->UpdateAllTilePrioritiesForTesting(); |
1590 | 1580 |
1591 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1581 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1592 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1582 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1593 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1583 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1594 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1584 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1595 | 1585 |
1596 // All tiles will have a positive distance_to_visible | 1586 // All tiles will have a positive distance_to_visible |
1597 // and an infinite time_to_visible. | 1587 // and an infinite time_to_visible. |
1598 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1588 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1599 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); | 1589 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); |
1600 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1590 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1601 | 1591 |
1602 priority = tiling->TileAt(0, 1)->priority(); | 1592 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1603 EXPECT_GT(priority.distance_to_visible, 0.f); | 1593 EXPECT_GT(priority.distance_to_visible, 0.f); |
1604 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1594 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1605 | 1595 |
1606 priority = tiling->TileAt(1, 0)->priority(); | 1596 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1607 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); | 1597 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); |
1608 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1598 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1609 | 1599 |
1610 priority = tiling->TileAt(1, 1)->priority(); | 1600 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1611 EXPECT_GT(priority.distance_to_visible, 0.f); | 1601 EXPECT_GT(priority.distance_to_visible, 0.f); |
1612 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1602 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1613 | 1603 |
1614 // Furthermore, in this scenario the top-left distance_to_visible | 1604 // Furthermore, in this scenario the top-left distance_to_visible |
1615 // will be smallest, followed by top-right. The bottom layers | 1605 // will be smallest, followed by top-right. The bottom layers |
1616 // will of course be further than the top layers. | 1606 // will of course be further than the top layers. |
1617 TilePriority top_left = tiling->TileAt(0, 0)->priority(); | 1607 TilePriority top_left = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1618 TilePriority top_right = tiling->TileAt(1, 0)->priority(); | 1608 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1619 TilePriority bottom_left = tiling->TileAt(0, 1)->priority(); | 1609 TilePriority bottom_left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1620 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(); | 1610 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1621 | 1611 |
1622 EXPECT_GT(bottom_right.distance_to_visible, top_right.distance_to_visible); | 1612 EXPECT_GT(bottom_right.distance_to_visible, top_right.distance_to_visible); |
1623 | 1613 |
1624 EXPECT_GT(bottom_left.distance_to_visible, top_left.distance_to_visible); | 1614 EXPECT_GT(bottom_left.distance_to_visible, top_left.distance_to_visible); |
1625 } | 1615 } |
1626 | 1616 |
1627 TEST(ComputeTilePriorityRectsTest, PerspectiveLayerClippedByW) { | 1617 TEST(ComputeTilePriorityRectsTest, PerspectiveLayerClippedByW) { |
1628 // Perspective transforms need to take a different code path. | 1618 // Perspective transforms need to take a different code path. |
1629 // This test checks tile priorities of a perspective layer. | 1619 // This test checks tile priorities of a perspective layer. |
1630 FakePictureLayerTilingClient client; | 1620 FakePictureLayerTilingClient client; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 current_frame_time_in_seconds, Occlusion()); | 1672 current_frame_time_in_seconds, Occlusion()); |
1683 tiling->UpdateAllTilePrioritiesForTesting(); | 1673 tiling->UpdateAllTilePrioritiesForTesting(); |
1684 | 1674 |
1685 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1675 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1686 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1676 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1687 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1677 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1688 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1678 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1689 | 1679 |
1690 // Left-side tiles will be clipped by the transform, so we have to assume | 1680 // Left-side tiles will be clipped by the transform, so we have to assume |
1691 // they are visible just in case. | 1681 // they are visible just in case. |
1692 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1682 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1693 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1683 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1694 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); | 1684 EXPECT_FLOAT_EQ(TilePriority::NOW, priority.priority_bin); |
1695 | 1685 |
1696 priority = tiling->TileAt(0, 1)->priority(); | 1686 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1697 EXPECT_GT(priority.distance_to_visible, 0.f); | 1687 EXPECT_GT(priority.distance_to_visible, 0.f); |
1698 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1688 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1699 | 1689 |
1700 // Right-side tiles will have a positive distance_to_visible | 1690 // Right-side tiles will have a positive distance_to_visible |
1701 // and an infinite time_to_visible. | 1691 // and an infinite time_to_visible. |
1702 priority = tiling->TileAt(1, 0)->priority(); | 1692 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1703 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); | 1693 EXPECT_FLOAT_EQ(priority.distance_to_visible, 0.f); |
1704 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1694 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1705 | 1695 |
1706 priority = tiling->TileAt(1, 1)->priority(); | 1696 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1707 EXPECT_GT(priority.distance_to_visible, 0.f); | 1697 EXPECT_GT(priority.distance_to_visible, 0.f); |
1708 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1698 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1709 } | 1699 } |
1710 | 1700 |
1711 TEST(ComputeTilePriorityRectsTest, BasicMotion) { | 1701 TEST(ComputeTilePriorityRectsTest, BasicMotion) { |
1712 // Test that time_to_visible is computed correctly when | 1702 // Test that time_to_visible is computed correctly when |
1713 // there is some motion. | 1703 // there is some motion. |
1714 FakePictureLayerTilingClient client; | 1704 FakePictureLayerTilingClient client; |
1715 | 1705 |
1716 gfx::Size device_viewport(800, 600); | 1706 gfx::Size device_viewport(800, 600); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1741 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1752 current_layer_contents_scale, | 1742 current_layer_contents_scale, |
1753 current_frame_time_in_seconds, Occlusion()); | 1743 current_frame_time_in_seconds, Occlusion()); |
1754 tiling->UpdateAllTilePrioritiesForTesting(); | 1744 tiling->UpdateAllTilePrioritiesForTesting(); |
1755 | 1745 |
1756 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1746 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1757 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1747 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1758 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1748 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1759 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1749 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1760 | 1750 |
1761 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1751 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1762 EXPECT_GT(priority.distance_to_visible, 0.f); | 1752 EXPECT_GT(priority.distance_to_visible, 0.f); |
1763 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1753 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1764 | 1754 |
1765 priority = tiling->TileAt(0, 1)->priority(); | 1755 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1766 EXPECT_GT(priority.distance_to_visible, 0.f); | 1756 EXPECT_GT(priority.distance_to_visible, 0.f); |
1767 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1757 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1768 | 1758 |
1769 // time_to_visible for the right hand side layers needs an extra 0.099 | 1759 // time_to_visible for the right hand side layers needs an extra 0.099 |
1770 // seconds because this tile is 99 pixels further away. | 1760 // seconds because this tile is 99 pixels further away. |
1771 priority = tiling->TileAt(1, 0)->priority(); | 1761 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1772 EXPECT_GT(priority.distance_to_visible, 0.f); | 1762 EXPECT_GT(priority.distance_to_visible, 0.f); |
1773 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1763 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1774 | 1764 |
1775 priority = tiling->TileAt(1, 1)->priority(); | 1765 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); |
1776 EXPECT_GT(priority.distance_to_visible, 0.f); | 1766 EXPECT_GT(priority.distance_to_visible, 0.f); |
1777 EXPECT_NE(TilePriority::NOW, priority.priority_bin); | 1767 EXPECT_NE(TilePriority::NOW, priority.priority_bin); |
1778 } | 1768 } |
1779 | 1769 |
1780 TEST(ComputeTilePriorityRectsTest, RotationMotion) { | 1770 TEST(ComputeTilePriorityRectsTest, RotationMotion) { |
1781 // Each tile of a layer may be affected differently by a transform; Check | 1771 // Each tile of a layer may be affected differently by a transform; Check |
1782 // that ComputeTilePriorityRects correctly accounts for the transform between | 1772 // that ComputeTilePriorityRects correctly accounts for the transform between |
1783 // layer space and screen space. | 1773 // layer space and screen space. |
1784 | 1774 |
1785 FakePictureLayerTilingClient client; | 1775 FakePictureLayerTilingClient client; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1819 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1830 current_layer_contents_scale, | 1820 current_layer_contents_scale, |
1831 current_frame_time_in_seconds, Occlusion()); | 1821 current_frame_time_in_seconds, Occlusion()); |
1832 tiling->UpdateAllTilePrioritiesForTesting(); | 1822 tiling->UpdateAllTilePrioritiesForTesting(); |
1833 | 1823 |
1834 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1824 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1835 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1825 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1836 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1826 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1837 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1827 ASSERT_TRUE(tiling->TileAt(1, 1)); |
1838 | 1828 |
1839 TilePriority priority = tiling->TileAt(0, 0)->priority(); | 1829 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); |
1840 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1830 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1841 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1831 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1842 | 1832 |
1843 priority = tiling->TileAt(0, 1)->priority(); | 1833 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); |
1844 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1834 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1845 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1835 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1846 | 1836 |
1847 priority = tiling->TileAt(1, 0)->priority(); | 1837 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1848 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1838 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1849 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1839 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1850 } | 1840 } |
1851 | 1841 |
1852 TEST(PictureLayerTilingTest, RecycledTilesCleared) { | 1842 TEST(PictureLayerTilingTest, RecycledTilesCleared) { |
1853 // This test performs the following: | 1843 // This test performs the following: |
1854 // Setup: | 1844 // Setup: |
1855 // - Two tilings, one active one recycled with all tiles shared. | 1845 // - Two tilings, one active one recycled with all tiles shared. |
1856 // Procedure: | 1846 // Procedure: |
1857 // - Viewport moves somewhere far away and active tiling clears tiles. | 1847 // - Viewport moves somewhere far away and active tiling clears tiles. |
(...skipping 30 matching lines...) Expand all Loading... |
1888 | 1878 |
1889 // Create all tiles on the second tiling. All tiles should be shared. | 1879 // Create all tiles on the second tiling. All tiles should be shared. |
1890 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1880 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
1891 1.0f, Occlusion()); | 1881 1.0f, Occlusion()); |
1892 | 1882 |
1893 // Set the second tiling as recycled. | 1883 // Set the second tiling as recycled. |
1894 active_client.set_twin_tiling(NULL); | 1884 active_client.set_twin_tiling(NULL); |
1895 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 1885 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
1896 recycle_client.set_twin_tiling(NULL); | 1886 recycle_client.set_twin_tiling(NULL); |
1897 | 1887 |
| 1888 // Verify that tiles exist and are shared. |
1898 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1889 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1899 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1890 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
| 1891 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
1900 | 1892 |
1901 // Move the viewport far away from the (0, 0) tile. | 1893 // Move the viewport far away from the (0, 0) tile. |
1902 active_tiling->ComputeTilePriorityRects(gfx::Rect(9000, 9000, 100, 100), 1.0f, | 1894 active_tiling->ComputeTilePriorityRects(gfx::Rect(9000, 9000, 100, 100), 1.0f, |
1903 2.0, Occlusion()); | 1895 2.0, Occlusion()); |
1904 // Ensure the tile was deleted. | 1896 // Ensure the tile was deleted on both tilings. |
1905 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 1897 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
1906 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1898 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
1907 | 1899 |
1908 // Move the viewport back to (0, 0) tile. | 1900 // Move the viewport back to (0, 0) tile. |
1909 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, | 1901 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, |
1910 Occlusion()); | 1902 Occlusion()); |
1911 | 1903 |
1912 // Ensure that we now have a tile here on both active. | 1904 // Ensure that we now have a tile here on both tilings again. |
1913 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1905 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1914 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1906 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
1915 } | 1907 } |
1916 | 1908 |
1917 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 1909 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
1918 FakePictureLayerTilingClient active_client; | 1910 FakePictureLayerTilingClient active_client; |
1919 active_client.SetTileSize(gfx::Size(100, 100)); | 1911 active_client.SetTileSize(gfx::Size(100, 100)); |
1920 active_client.set_tree(ACTIVE_TREE); | 1912 active_client.set_tree(ACTIVE_TREE); |
1921 | 1913 |
1922 scoped_refptr<FakePicturePileImpl> pile = | 1914 scoped_refptr<FakePicturePileImpl> pile = |
1923 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 1915 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
1924 gfx::Size(100, 100)); | 1916 gfx::Size(100, 100)); |
(...skipping 19 matching lines...) Expand all Loading... |
1944 | 1936 |
1945 // Create all tiles on the recycle tiling. All tiles should be shared. | 1937 // Create all tiles on the recycle tiling. All tiles should be shared. |
1946 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1938 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
1947 1.0f, Occlusion()); | 1939 1.0f, Occlusion()); |
1948 | 1940 |
1949 // Set the second tiling as recycled. | 1941 // Set the second tiling as recycled. |
1950 active_client.set_twin_tiling(NULL); | 1942 active_client.set_twin_tiling(NULL); |
1951 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 1943 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
1952 recycle_client.set_twin_tiling(NULL); | 1944 recycle_client.set_twin_tiling(NULL); |
1953 | 1945 |
| 1946 // Verify that tiles exist and are shared. |
1954 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 1947 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1955 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1948 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
| 1949 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
1956 | 1950 |
1957 // Reset the active tiling. The recycle tiles should be released too. | 1951 // Reset the active tiling. The recycle tiles should be released too. |
1958 active_tiling->Reset(); | 1952 active_tiling->Reset(); |
1959 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 1953 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
1960 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 1954 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
1961 } | 1955 } |
1962 | 1956 |
1963 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { | 1957 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { |
1964 // The tiling has four rows and three columns. | 1958 // The tiling has four rows and three columns. |
1965 Initialize(gfx::Size(150, 100), 1.f, gfx::Size(250, 150)); | 1959 Initialize(gfx::Size(150, 100), 1.f, gfx::Size(250, 150)); |
(...skipping 16 matching lines...) Expand all Loading... |
1982 tiling_->SetRasterSourceAndResize(pile); | 1976 tiling_->SetRasterSourceAndResize(pile); |
1983 | 1977 |
1984 // Tile size in the tiling should be resized to 250x200. | 1978 // Tile size in the tiling should be resized to 250x200. |
1985 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 1979 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
1986 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 1980 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
1987 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 1981 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
1988 } | 1982 } |
1989 | 1983 |
1990 } // namespace | 1984 } // namespace |
1991 } // namespace cc | 1985 } // namespace cc |
OLD | NEW |