| 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 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/resources/picture_layer_tiling_set.h" | 10 #include "cc/resources/picture_layer_tiling_set.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( | 27 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( |
| 28 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); | 28 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); |
| 29 | 29 |
| 30 return ToEnclosingRect(viewport_in_layer_space); | 30 return ToEnclosingRect(viewport_in_layer_space); |
| 31 } | 31 } |
| 32 | 32 |
| 33 class TestablePictureLayerTiling : public PictureLayerTiling { | 33 class TestablePictureLayerTiling : public PictureLayerTiling { |
| 34 public: | 34 public: |
| 35 using PictureLayerTiling::SetLiveTilesRect; | 35 using PictureLayerTiling::SetLiveTilesRect; |
| 36 using PictureLayerTiling::TileAt; | 36 using PictureLayerTiling::TileAt; |
| 37 using PictureLayerTiling::TileBundleAt; |
| 37 | 38 |
| 38 static scoped_ptr<TestablePictureLayerTiling> Create( | 39 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 39 float contents_scale, | 40 float contents_scale, |
| 40 gfx::Size layer_bounds, | 41 gfx::Size layer_bounds, |
| 41 PictureLayerTilingClient* client) { | 42 PictureLayerTilingClient* client) { |
| 42 return make_scoped_ptr(new TestablePictureLayerTiling( | 43 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 43 contents_scale, | 44 contents_scale, |
| 44 layer_bounds, | 45 layer_bounds, |
| 45 client)); | 46 client)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 protected: | 49 protected: |
| 49 TestablePictureLayerTiling(float contents_scale, | 50 TestablePictureLayerTiling(float contents_scale, |
| 50 gfx::Size layer_bounds, | 51 gfx::Size layer_bounds, |
| 51 PictureLayerTilingClient* client) | 52 PictureLayerTilingClient* client) |
| 52 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 53 : PictureLayerTiling(contents_scale, layer_bounds, client) { } |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 class PictureLayerTilingIteratorTest : public testing::Test { | 56 class PictureLayerTilingIteratorTest : public testing::Test { |
| 56 public: | 57 public: |
| 57 PictureLayerTilingIteratorTest() {} | 58 PictureLayerTilingIteratorTest() {} |
| 58 virtual ~PictureLayerTilingIteratorTest() {} | 59 virtual ~PictureLayerTilingIteratorTest() {} |
| 59 | 60 |
| 60 void Initialize(gfx::Size tile_size, | 61 void Initialize(gfx::Size tile_size, |
| 61 float contents_scale, | 62 float contents_scale, |
| 62 gfx::Size layer_bounds) { | 63 gfx::Size layer_bounds) { |
| 63 client_.SetTileSize(tile_size); | 64 client_.SetTileSize(tile_size); |
| 65 client_.MarkActive(); |
| 64 tiling_ = TestablePictureLayerTiling::Create(contents_scale, | 66 tiling_ = TestablePictureLayerTiling::Create(contents_scale, |
| 65 layer_bounds, | 67 layer_bounds, |
| 66 &client_); | 68 &client_); |
| 67 } | 69 } |
| 68 | 70 |
| 69 void SetLiveRectAndVerifyTiles(gfx::Rect live_tiles_rect) { | 71 void SetLiveRectAndVerifyTiles(gfx::Rect live_tiles_rect) { |
| 70 tiling_->SetLiveTilesRect(live_tiles_rect); | 72 tiling_->SetLiveTilesRect(ACTIVE_TREE, live_tiles_rect); |
| 71 | 73 |
| 72 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 74 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
| 73 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 75 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
| 74 iter != tiles.end(); | 76 iter != tiles.end(); |
| 75 ++iter) { | 77 ++iter) { |
| 76 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); | 78 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 void VerifyTilesExactlyCoverRect( | 82 void VerifyTilesExactlyCoverRect( |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 visible_layer_rect, | 767 visible_layer_rect, |
| 766 last_layer_bounds, | 768 last_layer_bounds, |
| 767 current_layer_bounds, | 769 current_layer_bounds, |
| 768 last_layer_contents_scale, | 770 last_layer_contents_scale, |
| 769 current_layer_contents_scale, | 771 current_layer_contents_scale, |
| 770 last_screen_transform, | 772 last_screen_transform, |
| 771 current_screen_transform, | 773 current_screen_transform, |
| 772 current_frame_time_in_seconds, | 774 current_frame_time_in_seconds, |
| 773 max_tiles_for_interest_area); | 775 max_tiles_for_interest_area); |
| 774 | 776 |
| 775 ASSERT_TRUE(tiling->TileAt(0, 0)); | 777 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 0, 0)); |
| 776 ASSERT_TRUE(tiling->TileAt(0, 1)); | 778 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 0, 1)); |
| 777 ASSERT_TRUE(tiling->TileAt(1, 0)); | 779 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 1, 0)); |
| 778 ASSERT_TRUE(tiling->TileAt(1, 1)); | 780 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 1, 1)); |
| 781 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 779 | 782 |
| 780 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 783 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 781 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | |
| 782 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | |
| 783 | |
| 784 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | |
| 785 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | |
| 786 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | |
| 787 | |
| 788 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | |
| 789 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | |
| 790 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | |
| 791 | |
| 792 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | |
| 793 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | 784 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); |
| 794 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | 785 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); |
| 795 } | 786 } |
| 796 | 787 |
| 797 TEST(UpdateTilePrioritiesTest, OffscreenTiles) { | 788 TEST(UpdateTilePrioritiesTest, OffscreenTiles) { |
| 798 // The TilePriority of offscreen tiles (without movement) should have nonzero | 789 // The TilePriority of offscreen tiles (without movement) should have nonzero |
| 799 // distance_to_visible and infinite time_to_visible. | 790 // distance_to_visible and infinite time_to_visible. |
| 800 | 791 |
| 801 FakePictureLayerTilingClient client; | 792 FakePictureLayerTilingClient client; |
| 802 scoped_ptr<TestablePictureLayerTiling> tiling; | 793 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 803 | 794 |
| 804 gfx::Size device_viewport(800, 600); | 795 gfx::Size device_viewport(800, 600); |
| 805 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen; nothing is visible. | 796 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen; nothing is visible. |
| 806 gfx::Size last_layer_bounds(200, 200); | 797 gfx::Size last_layer_bounds(400, 400); |
| 807 gfx::Size current_layer_bounds(200, 200); | 798 gfx::Size current_layer_bounds(400, 400); |
| 808 float last_layer_contents_scale = 1.f; | 799 float last_layer_contents_scale = 1.f; |
| 809 float current_layer_contents_scale = 1.f; | 800 float current_layer_contents_scale = 1.f; |
| 810 gfx::Transform last_screen_transform; | 801 gfx::Transform last_screen_transform; |
| 811 gfx::Transform current_screen_transform; | 802 gfx::Transform current_screen_transform; |
| 812 double current_frame_time_in_seconds = 1.0; | 803 double current_frame_time_in_seconds = 1.0; |
| 813 size_t max_tiles_for_interest_area = 10000; | 804 size_t max_tiles_for_interest_area = 10000; |
| 814 | 805 |
| 815 current_screen_transform.Translate(850, 0); | 806 current_screen_transform.Translate(850, 0); |
| 816 last_screen_transform = current_screen_transform; | 807 last_screen_transform = current_screen_transform; |
| 817 | 808 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 830 visible_layer_rect, | 821 visible_layer_rect, |
| 831 last_layer_bounds, | 822 last_layer_bounds, |
| 832 current_layer_bounds, | 823 current_layer_bounds, |
| 833 last_layer_contents_scale, | 824 last_layer_contents_scale, |
| 834 current_layer_contents_scale, | 825 current_layer_contents_scale, |
| 835 last_screen_transform, | 826 last_screen_transform, |
| 836 current_screen_transform, | 827 current_screen_transform, |
| 837 current_frame_time_in_seconds, | 828 current_frame_time_in_seconds, |
| 838 max_tiles_for_interest_area); | 829 max_tiles_for_interest_area); |
| 839 | 830 |
| 840 ASSERT_TRUE(tiling->TileAt(0, 0)); | 831 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 0, 0)); |
| 841 ASSERT_TRUE(tiling->TileAt(0, 1)); | 832 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 0, 1)); |
| 842 ASSERT_TRUE(tiling->TileAt(1, 0)); | 833 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 1, 0)); |
| 843 ASSERT_TRUE(tiling->TileAt(1, 1)); | 834 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 1, 1)); |
| 835 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 844 | 836 |
| 845 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 837 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 846 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 838 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 847 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 839 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 848 priority.time_to_visible_in_seconds); | 840 priority.time_to_visible_in_seconds); |
| 849 | 841 |
| 850 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 842 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 2, 2)); |
| 851 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 843 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 2, 3)); |
| 852 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 844 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 3, 2)); |
| 853 priority.time_to_visible_in_seconds); | 845 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 3, 3)); |
| 846 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 847 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 848 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 854 | 849 |
| 855 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 850 // Furthermore, in this scenario bundles on the right hand side should have a |
| 856 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | |
| 857 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | |
| 858 priority.time_to_visible_in_seconds); | |
| 859 | |
| 860 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | |
| 861 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | |
| 862 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | |
| 863 priority.time_to_visible_in_seconds); | |
| 864 | |
| 865 // Furthermore, in this scenario tiles on the right hand side should have a | |
| 866 // larger distance to visible. | 851 // larger distance to visible. |
| 867 TilePriority left = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 852 TilePriority left = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 868 TilePriority right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 853 TilePriority right = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 869 EXPECT_GT(right.distance_to_visible_in_pixels, | 854 EXPECT_GT(right.distance_to_visible_in_pixels, |
| 870 left.distance_to_visible_in_pixels); | 855 left.distance_to_visible_in_pixels); |
| 871 | 856 |
| 872 left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 857 left = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 873 right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 858 right = tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 874 EXPECT_GT(right.distance_to_visible_in_pixels, | 859 EXPECT_GT(right.distance_to_visible_in_pixels, |
| 875 left.distance_to_visible_in_pixels); | 860 left.distance_to_visible_in_pixels); |
| 876 } | 861 } |
| 877 | 862 |
| 878 TEST(UpdateTilePrioritiesTest, PartiallyOffscreenLayer) { | 863 TEST(UpdateTilePrioritiesTest, PartiallyOffscreenLayer) { |
| 879 // Sanity check that a layer with some tiles visible and others offscreen has | 864 // Sanity check that a layer with some tiles visible and others offscreen has |
| 880 // correct TilePriorities for each tile. | 865 // correct TilePriorities for each tile. |
| 881 | 866 |
| 882 FakePictureLayerTilingClient client; | 867 FakePictureLayerTilingClient client; |
| 883 scoped_ptr<TestablePictureLayerTiling> tiling; | 868 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 884 | 869 |
| 885 gfx::Size device_viewport(800, 600); | 870 gfx::Size device_viewport(800, 600); |
| 886 gfx::Rect visible_layer_rect(0, 0, 100, 100); // only top quarter. | 871 gfx::Rect visible_layer_rect(0, 0, 100, 100); // only top quarter. |
| 887 gfx::Size last_layer_bounds(200, 200); | 872 gfx::Size last_layer_bounds(400, 400); |
| 888 gfx::Size current_layer_bounds(200, 200); | 873 gfx::Size current_layer_bounds(400, 400); |
| 889 float last_layer_contents_scale = 1.f; | 874 float last_layer_contents_scale = 1.f; |
| 890 float current_layer_contents_scale = 1.f; | 875 float current_layer_contents_scale = 1.f; |
| 891 gfx::Transform last_screen_transform; | 876 gfx::Transform last_screen_transform; |
| 892 gfx::Transform current_screen_transform; | 877 gfx::Transform current_screen_transform; |
| 893 double current_frame_time_in_seconds = 1.0; | 878 double current_frame_time_in_seconds = 1.0; |
| 894 size_t max_tiles_for_interest_area = 10000; | 879 size_t max_tiles_for_interest_area = 10000; |
| 895 | 880 |
| 896 current_screen_transform.Translate(705, 505); | 881 current_screen_transform.Translate(705, 505); |
| 897 last_screen_transform = current_screen_transform; | 882 last_screen_transform = current_screen_transform; |
| 898 | 883 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 911 visible_layer_rect, | 896 visible_layer_rect, |
| 912 last_layer_bounds, | 897 last_layer_bounds, |
| 913 current_layer_bounds, | 898 current_layer_bounds, |
| 914 last_layer_contents_scale, | 899 last_layer_contents_scale, |
| 915 current_layer_contents_scale, | 900 current_layer_contents_scale, |
| 916 last_screen_transform, | 901 last_screen_transform, |
| 917 current_screen_transform, | 902 current_screen_transform, |
| 918 current_frame_time_in_seconds, | 903 current_frame_time_in_seconds, |
| 919 max_tiles_for_interest_area); | 904 max_tiles_for_interest_area); |
| 920 | 905 |
| 921 ASSERT_TRUE(tiling->TileAt(0, 0)); | 906 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 0, 0)); |
| 922 ASSERT_TRUE(tiling->TileAt(0, 1)); | 907 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 0, 1)); |
| 923 ASSERT_TRUE(tiling->TileAt(1, 0)); | 908 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 1, 0)); |
| 924 ASSERT_TRUE(tiling->TileAt(1, 1)); | 909 ASSERT_TRUE(tiling->TileAt(ACTIVE_TREE, 1, 1)); |
| 910 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 911 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 912 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 913 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 925 | 914 |
| 926 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 915 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 927 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | 916 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); |
| 928 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | 917 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); |
| 929 | 918 |
| 930 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 919 priority = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 931 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 920 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 932 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 921 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 933 priority.time_to_visible_in_seconds); | 922 priority.time_to_visible_in_seconds); |
| 934 | 923 |
| 935 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 924 priority = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 936 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 925 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 937 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 926 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 938 priority.time_to_visible_in_seconds); | 927 priority.time_to_visible_in_seconds); |
| 939 | 928 |
| 940 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 929 priority = tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 941 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 930 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 942 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 931 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 943 priority.time_to_visible_in_seconds); | 932 priority.time_to_visible_in_seconds); |
| 944 } | 933 } |
| 945 | 934 |
| 946 TEST(UpdateTilePrioritiesTest, PartiallyOffscreenRotatedLayer) { | 935 TEST(UpdateTilePrioritiesTest, PartiallyOffscreenRotatedLayer) { |
| 947 // Each tile of a layer may be affected differently by a transform; Check | 936 // Each tile of a layer may be affected differently by a transform; Check |
| 948 // that UpdateTilePriorities correctly accounts for the transform between | 937 // that UpdateTilePriorities correctly accounts for the transform between |
| 949 // layer space and screen space. | 938 // layer space and screen space. |
| 950 | 939 |
| 951 FakePictureLayerTilingClient client; | 940 FakePictureLayerTilingClient client; |
| 952 scoped_ptr<TestablePictureLayerTiling> tiling; | 941 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 953 | 942 |
| 954 gfx::Size device_viewport(800, 600); | 943 gfx::Size device_viewport(800, 600); |
| 955 gfx::Rect visible_layer_rect(0, 0, 100, 100); // only top-left quarter. | 944 gfx::Rect visible_layer_rect(0, 0, 100, 100); // only top-left quarter. |
| 956 gfx::Size last_layer_bounds(200, 200); | 945 gfx::Size last_layer_bounds(400, 400); |
| 957 gfx::Size current_layer_bounds(200, 200); | 946 gfx::Size current_layer_bounds(400, 400); |
| 958 float last_layer_contents_scale = 1.f; | 947 float last_layer_contents_scale = 1.f; |
| 959 float current_layer_contents_scale = 1.f; | 948 float current_layer_contents_scale = 1.f; |
| 960 gfx::Transform last_screen_transform; | 949 gfx::Transform last_screen_transform; |
| 961 gfx::Transform current_screen_transform; | 950 gfx::Transform current_screen_transform; |
| 962 double current_frame_time_in_seconds = 1.0; | 951 double current_frame_time_in_seconds = 1.0; |
| 963 size_t max_tiles_for_interest_area = 10000; | 952 size_t max_tiles_for_interest_area = 10000; |
| 964 | 953 |
| 965 // A diagonally rotated layer that is partially off the bottom of the screen. | 954 // A diagonally rotated layer that is partially off the bottom of the screen. |
| 966 // In this configuration, only the top-left tile would be visible. | 955 // In this configuration, only the top-left tile would be visible. |
| 967 current_screen_transform.Translate(400, 550); | 956 current_screen_transform.Translate(400, 550); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 983 visible_layer_rect, | 972 visible_layer_rect, |
| 984 last_layer_bounds, | 973 last_layer_bounds, |
| 985 current_layer_bounds, | 974 current_layer_bounds, |
| 986 last_layer_contents_scale, | 975 last_layer_contents_scale, |
| 987 current_layer_contents_scale, | 976 current_layer_contents_scale, |
| 988 last_screen_transform, | 977 last_screen_transform, |
| 989 current_screen_transform, | 978 current_screen_transform, |
| 990 current_frame_time_in_seconds, | 979 current_frame_time_in_seconds, |
| 991 max_tiles_for_interest_area); | 980 max_tiles_for_interest_area); |
| 992 | 981 |
| 993 ASSERT_TRUE(tiling->TileAt(0, 0)); | 982 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 994 ASSERT_TRUE(tiling->TileAt(0, 1)); | 983 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 995 ASSERT_TRUE(tiling->TileAt(1, 0)); | 984 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 996 ASSERT_TRUE(tiling->TileAt(1, 1)); | 985 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 997 | 986 |
| 998 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 987 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 999 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | 988 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); |
| 1000 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | 989 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); |
| 1001 | 990 |
| 1002 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 991 priority = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1003 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 992 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1004 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 993 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1005 priority.time_to_visible_in_seconds); | 994 priority.time_to_visible_in_seconds); |
| 1006 | 995 |
| 1007 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 996 priority = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1008 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 997 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1009 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 998 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1010 priority.time_to_visible_in_seconds); | 999 priority.time_to_visible_in_seconds); |
| 1011 | 1000 |
| 1012 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1001 priority = tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 1013 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1002 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1014 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1003 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1015 priority.time_to_visible_in_seconds); | 1004 priority.time_to_visible_in_seconds); |
| 1016 | 1005 |
| 1017 // Furthermore, in this scenario the bottom-right tile should have the larger | 1006 // Furthermore, in this scenario the bottom-right tile should have the larger |
| 1018 // distance to visible. | 1007 // distance to visible. |
| 1019 TilePriority top_left = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1008 TilePriority top_left = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 1020 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1009 TilePriority top_right = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1021 TilePriority bottom_left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1010 TilePriority bottom_left = |
| 1022 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1011 tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1012 TilePriority bottom_right = |
| 1013 tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 1023 EXPECT_GT(top_right.distance_to_visible_in_pixels, | 1014 EXPECT_GT(top_right.distance_to_visible_in_pixels, |
| 1024 top_left.distance_to_visible_in_pixels); | 1015 top_left.distance_to_visible_in_pixels); |
| 1025 EXPECT_GT(bottom_left.distance_to_visible_in_pixels, | 1016 EXPECT_GT(bottom_left.distance_to_visible_in_pixels, |
| 1026 top_left.distance_to_visible_in_pixels); | 1017 top_left.distance_to_visible_in_pixels); |
| 1027 | 1018 |
| 1028 EXPECT_GT(bottom_right.distance_to_visible_in_pixels, | 1019 EXPECT_GT(bottom_right.distance_to_visible_in_pixels, |
| 1029 bottom_left.distance_to_visible_in_pixels); | 1020 bottom_left.distance_to_visible_in_pixels); |
| 1030 EXPECT_GT(bottom_right.distance_to_visible_in_pixels, | 1021 EXPECT_GT(bottom_right.distance_to_visible_in_pixels, |
| 1031 top_right.distance_to_visible_in_pixels); | 1022 top_right.distance_to_visible_in_pixels); |
| 1032 } | 1023 } |
| 1033 | 1024 |
| 1034 TEST(UpdateTilePrioritiesTest, PerspectiveLayer) { | 1025 TEST(UpdateTilePrioritiesTest, PerspectiveLayer) { |
| 1035 // Perspective transforms need to take a different code path. | 1026 // Perspective transforms need to take a different code path. |
| 1036 // This test checks tile priorities of a perspective layer. | 1027 // This test checks tile priorities of a perspective layer. |
| 1037 | 1028 |
| 1038 FakePictureLayerTilingClient client; | 1029 FakePictureLayerTilingClient client; |
| 1039 scoped_ptr<TestablePictureLayerTiling> tiling; | 1030 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 1040 | 1031 |
| 1041 gfx::Size device_viewport(800, 600); | 1032 gfx::Size device_viewport(800, 600); |
| 1042 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. | 1033 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. |
| 1043 gfx::Size last_layer_bounds(200, 200); | 1034 gfx::Size last_layer_bounds(400, 400); |
| 1044 gfx::Size current_layer_bounds(200, 200); | 1035 gfx::Size current_layer_bounds(400, 400); |
| 1045 float last_layer_contents_scale = 1.f; | 1036 float last_layer_contents_scale = 1.f; |
| 1046 float current_layer_contents_scale = 1.f; | 1037 float current_layer_contents_scale = 1.f; |
| 1047 gfx::Transform last_screen_transform; | 1038 gfx::Transform last_screen_transform; |
| 1048 gfx::Transform current_screen_transform; | 1039 gfx::Transform current_screen_transform; |
| 1049 double current_frame_time_in_seconds = 1.0; | 1040 double current_frame_time_in_seconds = 1.0; |
| 1050 size_t max_tiles_for_interest_area = 10000; | 1041 size_t max_tiles_for_interest_area = 10000; |
| 1051 | 1042 |
| 1052 // A 3d perspective layer rotated about its Y axis, translated to almost | 1043 // A 3d perspective layer rotated about its Y axis, translated to almost |
| 1053 // fully offscreen. The left side will appear closer (i.e. larger in 2d) than | 1044 // fully offscreen. The left side will appear closer (i.e. larger in 2d) than |
| 1054 // the right side, so the top-left tile will technically be closer than the | 1045 // the right side, so the top-left tile will technically be closer than the |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1085 visible_layer_rect, | 1076 visible_layer_rect, |
| 1086 last_layer_bounds, | 1077 last_layer_bounds, |
| 1087 current_layer_bounds, | 1078 current_layer_bounds, |
| 1088 last_layer_contents_scale, | 1079 last_layer_contents_scale, |
| 1089 current_layer_contents_scale, | 1080 current_layer_contents_scale, |
| 1090 last_screen_transform, | 1081 last_screen_transform, |
| 1091 current_screen_transform, | 1082 current_screen_transform, |
| 1092 current_frame_time_in_seconds, | 1083 current_frame_time_in_seconds, |
| 1093 max_tiles_for_interest_area); | 1084 max_tiles_for_interest_area); |
| 1094 | 1085 |
| 1095 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1086 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 1096 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1087 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 1097 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1088 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 1098 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1089 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 1099 | 1090 |
| 1100 // All tiles will have a positive distance_to_visible | 1091 // All tiles will have a positive distance_to_visible |
| 1101 // and an infinite time_to_visible. | 1092 // and an infinite time_to_visible. |
| 1102 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1093 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 1103 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1094 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1104 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1095 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1105 priority.time_to_visible_in_seconds); | 1096 priority.time_to_visible_in_seconds); |
| 1106 | 1097 |
| 1107 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1098 priority = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1108 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1099 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1109 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1100 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1110 priority.time_to_visible_in_seconds); | 1101 priority.time_to_visible_in_seconds); |
| 1111 | 1102 |
| 1112 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1103 priority = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1113 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1104 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1114 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1105 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1115 priority.time_to_visible_in_seconds); | 1106 priority.time_to_visible_in_seconds); |
| 1116 | 1107 |
| 1117 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1108 priority = tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 1118 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1109 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1119 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1110 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1120 priority.time_to_visible_in_seconds); | 1111 priority.time_to_visible_in_seconds); |
| 1121 | 1112 |
| 1122 // Furthermore, in this scenario the top-left distance_to_visible | 1113 // Furthermore, in this scenario the top-left distance_to_visible |
| 1123 // will be smallest, followed by top-right. The bottom layers | 1114 // will be smallest, followed by top-right. The bottom layers |
| 1124 // will of course be further than the top layers. | 1115 // will of course be further than the top layers. |
| 1125 TilePriority top_left = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1116 TilePriority top_left = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 1126 TilePriority top_right = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1117 TilePriority top_right = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1127 TilePriority bottom_left = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1118 TilePriority bottom_left = |
| 1128 TilePriority bottom_right = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1119 tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1120 TilePriority bottom_right = |
| 1121 tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 1129 EXPECT_GT(top_right.distance_to_visible_in_pixels, | 1122 EXPECT_GT(top_right.distance_to_visible_in_pixels, |
| 1130 top_left.distance_to_visible_in_pixels); | 1123 top_left.distance_to_visible_in_pixels); |
| 1131 | 1124 |
| 1132 EXPECT_GT(bottom_right.distance_to_visible_in_pixels, | 1125 EXPECT_GT(bottom_right.distance_to_visible_in_pixels, |
| 1133 top_right.distance_to_visible_in_pixels); | 1126 top_right.distance_to_visible_in_pixels); |
| 1134 | 1127 |
| 1135 EXPECT_GT(bottom_left.distance_to_visible_in_pixels, | 1128 EXPECT_GT(bottom_left.distance_to_visible_in_pixels, |
| 1136 top_left.distance_to_visible_in_pixels); | 1129 top_left.distance_to_visible_in_pixels); |
| 1137 } | 1130 } |
| 1138 | 1131 |
| 1139 TEST(UpdateTilePrioritiesTest, PerspectiveLayerClippedByW) { | 1132 TEST(UpdateTilePrioritiesTest, PerspectiveLayerClippedByW) { |
| 1140 // Perspective transforms need to take a different code path. | 1133 // Perspective transforms need to take a different code path. |
| 1141 // This test checks tile priorities of a perspective layer. | 1134 // This test checks tile priorities of a perspective layer. |
| 1142 | 1135 |
| 1143 FakePictureLayerTilingClient client; | 1136 FakePictureLayerTilingClient client; |
| 1144 scoped_ptr<TestablePictureLayerTiling> tiling; | 1137 scoped_ptr<TestablePictureLayerTiling> tiling; |
| 1145 | 1138 |
| 1146 gfx::Size device_viewport(800, 600); | 1139 gfx::Size device_viewport(800, 600); |
| 1147 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. | 1140 gfx::Rect visible_layer_rect(0, 0, 0, 0); // offscreen. |
| 1148 gfx::Size last_layer_bounds(200, 200); | 1141 gfx::Size last_layer_bounds(400, 400); |
| 1149 gfx::Size current_layer_bounds(200, 200); | 1142 gfx::Size current_layer_bounds(400, 400); |
| 1150 float last_layer_contents_scale = 1.f; | 1143 float last_layer_contents_scale = 1.f; |
| 1151 float current_layer_contents_scale = 1.f; | 1144 float current_layer_contents_scale = 1.f; |
| 1152 gfx::Transform last_screen_transform; | 1145 gfx::Transform last_screen_transform; |
| 1153 gfx::Transform current_screen_transform; | 1146 gfx::Transform current_screen_transform; |
| 1154 double current_frame_time_in_seconds = 1.0; | 1147 double current_frame_time_in_seconds = 1.0; |
| 1155 size_t max_tiles_for_interest_area = 10000; | 1148 size_t max_tiles_for_interest_area = 10000; |
| 1156 | 1149 |
| 1157 // A 3d perspective layer rotated about its Y axis, translated to almost | 1150 // A 3d perspective layer rotated about its Y axis, translated to almost |
| 1158 // fully offscreen. The left side will appear closer (i.e. larger in 2d) than | 1151 // fully offscreen. The left side will appear closer (i.e. larger in 2d) than |
| 1159 // the right side, so the top-left tile will technically be closer than the | 1152 // the right side, so the top-left tile will technically be closer than the |
| 1160 // top-right. | 1153 // top-right. |
| 1161 | 1154 |
| 1162 // Translate layer to offscreen | 1155 // Translate layer to offscreen |
| 1163 current_screen_transform.Translate(400.0, 970.0); | 1156 current_screen_transform.Translate(400.0, 970.0); |
| 1164 // Apply perspective and rotation about the center of the layer | 1157 // Apply perspective and rotation about the center of the layer |
| 1165 current_screen_transform.Translate(100.0, 100.0); | 1158 current_screen_transform.Translate(200.0, 200.0); |
| 1166 current_screen_transform.ApplyPerspectiveDepth(10.0); | 1159 current_screen_transform.ApplyPerspectiveDepth(10.0); |
| 1167 current_screen_transform.RotateAboutYAxis(10.0); | 1160 current_screen_transform.RotateAboutYAxis(10.0); |
| 1168 current_screen_transform.Translate(-100.0, -100.0); | 1161 current_screen_transform.Translate(-200.0, -200.0); |
| 1169 last_screen_transform = current_screen_transform; | 1162 last_screen_transform = current_screen_transform; |
| 1170 | 1163 |
| 1171 // Sanity check that this transform does cause w<0 clipping for the left side | 1164 // Sanity check that this transform does cause w<0 clipping for the left side |
| 1172 // of the layer, but not the right side. | 1165 // of the layer, but not the right side. |
| 1173 bool clipped; | 1166 bool clipped; |
| 1174 MathUtil::MapQuad(current_screen_transform, | 1167 MathUtil::MapQuad(current_screen_transform, |
| 1175 gfx::QuadF(gfx::RectF(0, 0, 100, 200)), | 1168 gfx::QuadF(gfx::RectF(0, 0, 200, 400)), |
| 1176 &clipped); | 1169 &clipped); |
| 1177 ASSERT_TRUE(clipped); | 1170 ASSERT_TRUE(clipped); |
| 1178 | 1171 |
| 1179 MathUtil::MapQuad(current_screen_transform, | 1172 MathUtil::MapQuad(current_screen_transform, |
| 1180 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1173 gfx::QuadF(gfx::RectF(200, 0, 200, 400)), |
| 1181 &clipped); | 1174 &clipped); |
| 1182 ASSERT_FALSE(clipped); | 1175 ASSERT_FALSE(clipped); |
| 1183 | 1176 |
| 1184 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1177 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1185 current_screen_transform, device_viewport); | 1178 current_screen_transform, device_viewport); |
| 1186 | 1179 |
| 1187 client.SetTileSize(gfx::Size(100, 100)); | 1180 client.SetTileSize(gfx::Size(100, 100)); |
| 1188 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1181 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1189 current_layer_bounds, | 1182 current_layer_bounds, |
| 1190 &client); | 1183 &client); |
| 1191 | 1184 |
| 1192 tiling->UpdateTilePriorities( | 1185 tiling->UpdateTilePriorities( |
| 1193 ACTIVE_TREE, | 1186 ACTIVE_TREE, |
| 1194 device_viewport, | 1187 device_viewport, |
| 1195 viewport_in_layer_space, | 1188 viewport_in_layer_space, |
| 1196 visible_layer_rect, | 1189 visible_layer_rect, |
| 1197 last_layer_bounds, | 1190 last_layer_bounds, |
| 1198 current_layer_bounds, | 1191 current_layer_bounds, |
| 1199 last_layer_contents_scale, | 1192 last_layer_contents_scale, |
| 1200 current_layer_contents_scale, | 1193 current_layer_contents_scale, |
| 1201 last_screen_transform, | 1194 last_screen_transform, |
| 1202 current_screen_transform, | 1195 current_screen_transform, |
| 1203 current_frame_time_in_seconds, | 1196 current_frame_time_in_seconds, |
| 1204 max_tiles_for_interest_area); | 1197 max_tiles_for_interest_area); |
| 1205 | 1198 |
| 1206 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1199 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 1207 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1200 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 1208 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1201 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 1209 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1202 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 1210 | 1203 |
| 1211 // Left-side tiles will be clipped by the transform, so we have to assume | 1204 // Left-side tiles will be clipped by the transform, so we have to assume |
| 1212 // they are visible just in case. | 1205 // they are visible just in case. |
| 1213 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1206 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 1214 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | 1207 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); |
| 1215 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | 1208 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); |
| 1216 | 1209 |
| 1217 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1210 priority = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1218 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | 1211 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); |
| 1219 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | 1212 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); |
| 1220 | 1213 |
| 1221 // Right-side tiles will have a positive distance_to_visible | 1214 // Right-side tiles will have a positive distance_to_visible |
| 1222 // and an infinite time_to_visible. | 1215 // and an infinite time_to_visible. |
| 1223 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1216 priority = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1224 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1217 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1225 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1218 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1226 priority.time_to_visible_in_seconds); | 1219 priority.time_to_visible_in_seconds); |
| 1227 | 1220 |
| 1228 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1221 priority = tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 1229 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1222 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1230 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1223 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1231 priority.time_to_visible_in_seconds); | 1224 priority.time_to_visible_in_seconds); |
| 1232 } | 1225 } |
| 1233 | 1226 |
| 1234 TEST(UpdateTilePrioritiesTest, BasicMotion) { | 1227 TEST(UpdateTilePrioritiesTest, BasicMotion) { |
| 1235 // Test that time_to_visible is computed correctly when | 1228 // Test that time_to_visible is computed correctly when |
| 1236 // there is some motion. | 1229 // there is some motion. |
| 1237 | 1230 |
| 1238 FakePictureLayerTilingClient client; | 1231 FakePictureLayerTilingClient client; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1250 double current_frame_time_in_seconds = 2.0; | 1243 double current_frame_time_in_seconds = 2.0; |
| 1251 size_t max_tiles_for_interest_area = 10000; | 1244 size_t max_tiles_for_interest_area = 10000; |
| 1252 | 1245 |
| 1253 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1246 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
| 1254 current_screen_transform.Translate(1800, 0); | 1247 current_screen_transform.Translate(1800, 0); |
| 1255 last_screen_transform.Translate(2800, 0); | 1248 last_screen_transform.Translate(2800, 0); |
| 1256 | 1249 |
| 1257 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1250 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1258 current_screen_transform, device_viewport); | 1251 current_screen_transform, device_viewport); |
| 1259 | 1252 |
| 1260 client.SetTileSize(gfx::Size(100, 100)); | 1253 client.SetTileSize(gfx::Size(50, 50)); |
| 1261 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1254 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1262 current_layer_bounds, | 1255 current_layer_bounds, |
| 1263 &client); | 1256 &client); |
| 1264 | 1257 |
| 1265 // previous ("last") frame | 1258 // previous ("last") frame |
| 1266 tiling->UpdateTilePriorities( | 1259 tiling->UpdateTilePriorities( |
| 1267 ACTIVE_TREE, | 1260 ACTIVE_TREE, |
| 1268 device_viewport, | 1261 device_viewport, |
| 1269 viewport_in_layer_space, | 1262 viewport_in_layer_space, |
| 1270 visible_layer_rect, | 1263 visible_layer_rect, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1285 visible_layer_rect, | 1278 visible_layer_rect, |
| 1286 last_layer_bounds, | 1279 last_layer_bounds, |
| 1287 current_layer_bounds, | 1280 current_layer_bounds, |
| 1288 last_layer_contents_scale, | 1281 last_layer_contents_scale, |
| 1289 current_layer_contents_scale, | 1282 current_layer_contents_scale, |
| 1290 last_screen_transform, | 1283 last_screen_transform, |
| 1291 current_screen_transform, | 1284 current_screen_transform, |
| 1292 current_frame_time_in_seconds, | 1285 current_frame_time_in_seconds, |
| 1293 max_tiles_for_interest_area); | 1286 max_tiles_for_interest_area); |
| 1294 | 1287 |
| 1295 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1288 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 1296 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1289 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 1297 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1290 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 1298 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1291 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 1299 | 1292 |
| 1300 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1293 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 1301 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1294 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1302 EXPECT_FLOAT_EQ(1.f, | 1295 EXPECT_FLOAT_EQ(1.f, |
| 1303 priority.time_to_visible_in_seconds); | 1296 priority.time_to_visible_in_seconds); |
| 1304 | 1297 |
| 1305 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1298 priority = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1306 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1299 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1307 EXPECT_FLOAT_EQ(1.f, | 1300 EXPECT_FLOAT_EQ(1.f, |
| 1308 priority.time_to_visible_in_seconds); | 1301 priority.time_to_visible_in_seconds); |
| 1309 | 1302 |
| 1310 // time_to_visible for the right hand side layers needs an extra 0.099 | 1303 // time_to_visible for the right hand side layers needs an extra 0.099 |
| 1311 // seconds because this tile is 99 pixels further away. | 1304 // seconds because this tile is 99 pixels further away. |
| 1312 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1305 priority = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1313 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1306 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1314 EXPECT_FLOAT_EQ(1.099f, | 1307 EXPECT_FLOAT_EQ(1.099f, |
| 1315 priority.time_to_visible_in_seconds); | 1308 priority.time_to_visible_in_seconds); |
| 1316 | 1309 |
| 1317 priority = tiling->TileAt(1, 1)->priority(ACTIVE_TREE); | 1310 priority = tiling->TileBundleAt(1, 1)->GetPriority(ACTIVE_TREE); |
| 1318 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1311 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1319 EXPECT_FLOAT_EQ(1.099f, | 1312 EXPECT_FLOAT_EQ(1.099f, |
| 1320 priority.time_to_visible_in_seconds); | 1313 priority.time_to_visible_in_seconds); |
| 1321 } | 1314 } |
| 1322 | 1315 |
| 1323 TEST(UpdateTilePrioritiesTest, RotationMotion) { | 1316 TEST(UpdateTilePrioritiesTest, RotationMotion) { |
| 1324 // Each tile of a layer may be affected differently by a transform; Check | 1317 // Each tile of a layer may be affected differently by a transform; Check |
| 1325 // that UpdateTilePriorities correctly accounts for the transform between | 1318 // that UpdateTilePriorities correctly accounts for the transform between |
| 1326 // layer space and screen space. | 1319 // layer space and screen space. |
| 1327 | 1320 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1348 // - bottom-left layer will have a positive non-zero time_to_visible | 1341 // - bottom-left layer will have a positive non-zero time_to_visible |
| 1349 // because it is rotating toward the viewport. | 1342 // because it is rotating toward the viewport. |
| 1350 current_screen_transform.Translate(400, 550); | 1343 current_screen_transform.Translate(400, 550); |
| 1351 current_screen_transform.RotateAboutZAxis(45); | 1344 current_screen_transform.RotateAboutZAxis(45); |
| 1352 | 1345 |
| 1353 last_screen_transform.Translate(400, 550); | 1346 last_screen_transform.Translate(400, 550); |
| 1354 | 1347 |
| 1355 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1348 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
| 1356 current_screen_transform, device_viewport); | 1349 current_screen_transform, device_viewport); |
| 1357 | 1350 |
| 1358 client.SetTileSize(gfx::Size(100, 100)); | 1351 client.SetTileSize(gfx::Size(50, 50)); |
| 1359 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1352 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
| 1360 current_layer_bounds, | 1353 current_layer_bounds, |
| 1361 &client); | 1354 &client); |
| 1362 | 1355 |
| 1363 // previous ("last") frame | 1356 // previous ("last") frame |
| 1364 tiling->UpdateTilePriorities( | 1357 tiling->UpdateTilePriorities( |
| 1365 ACTIVE_TREE, | 1358 ACTIVE_TREE, |
| 1366 device_viewport, | 1359 device_viewport, |
| 1367 viewport_in_layer_space, | 1360 viewport_in_layer_space, |
| 1368 visible_layer_rect, | 1361 visible_layer_rect, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1383 visible_layer_rect, | 1376 visible_layer_rect, |
| 1384 last_layer_bounds, | 1377 last_layer_bounds, |
| 1385 current_layer_bounds, | 1378 current_layer_bounds, |
| 1386 last_layer_contents_scale, | 1379 last_layer_contents_scale, |
| 1387 current_layer_contents_scale, | 1380 current_layer_contents_scale, |
| 1388 last_screen_transform, | 1381 last_screen_transform, |
| 1389 current_screen_transform, | 1382 current_screen_transform, |
| 1390 current_frame_time_in_seconds, | 1383 current_frame_time_in_seconds, |
| 1391 max_tiles_for_interest_area); | 1384 max_tiles_for_interest_area); |
| 1392 | 1385 |
| 1393 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1386 ASSERT_TRUE(tiling->TileBundleAt(0, 0)); |
| 1394 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1387 ASSERT_TRUE(tiling->TileBundleAt(0, 1)); |
| 1395 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1388 ASSERT_TRUE(tiling->TileBundleAt(1, 0)); |
| 1396 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1389 ASSERT_TRUE(tiling->TileBundleAt(1, 1)); |
| 1397 | 1390 |
| 1398 TilePriority priority = tiling->TileAt(0, 0)->priority(ACTIVE_TREE); | 1391 TilePriority priority = tiling->TileBundleAt(0, 0)->GetPriority(ACTIVE_TREE); |
| 1399 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); | 1392 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible_in_pixels); |
| 1400 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); | 1393 EXPECT_FLOAT_EQ(0.f, priority.time_to_visible_in_seconds); |
| 1401 | 1394 |
| 1402 priority = tiling->TileAt(0, 1)->priority(ACTIVE_TREE); | 1395 priority = tiling->TileBundleAt(0, 1)->GetPriority(ACTIVE_TREE); |
| 1403 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1396 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1404 EXPECT_GT(priority.time_to_visible_in_seconds, 0.f); | 1397 EXPECT_GT(priority.time_to_visible_in_seconds, 0.f); |
| 1405 | 1398 |
| 1406 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1399 priority = tiling->TileBundleAt(1, 0)->GetPriority(ACTIVE_TREE); |
| 1407 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); | 1400 EXPECT_GT(priority.distance_to_visible_in_pixels, 0.f); |
| 1408 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), | 1401 EXPECT_FLOAT_EQ(std::numeric_limits<float>::infinity(), |
| 1409 priority.time_to_visible_in_seconds); | 1402 priority.time_to_visible_in_seconds); |
| 1410 } | 1403 } |
| 1411 | 1404 |
| 1412 } // namespace | 1405 } // namespace |
| 1413 } // namespace cc | 1406 } // namespace cc |
| OLD | NEW |