OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 scoped_refptr<FakePicturePileImpl> active_pile = | 629 scoped_refptr<FakePicturePileImpl> active_pile = |
630 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 630 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
631 scoped_refptr<FakePicturePileImpl> lost_pile = | 631 scoped_refptr<FakePicturePileImpl> lost_pile = |
632 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 632 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
633 | 633 |
634 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); | 634 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); |
635 ActivateTree(); | 635 ActivateTree(); |
636 // Add a non-shared tiling on the active tree. | 636 // Add a non-shared tiling on the active tree. |
637 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); | 637 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); |
638 tiling->CreateAllTilesForTesting(); | 638 tiling->CreateAllTilesForTesting(); |
| 639 |
| 640 // Ensure UpdateTiles won't remove any tilings. |
| 641 active_layer_->MarkAllTilingsUsed(); |
| 642 |
639 // Then setup a new pending tree and activate it. | 643 // Then setup a new pending tree and activate it. |
640 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), | 644 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), |
641 layer_invalidation); | 645 layer_invalidation); |
642 | 646 |
643 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 647 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
644 EXPECT_EQ(3u, active_layer_->num_tilings()); | 648 EXPECT_EQ(3u, active_layer_->num_tilings()); |
645 | 649 |
646 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 650 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
647 EXPECT_GT(tilings->num_tilings(), 0u); | 651 EXPECT_GT(tilings->num_tilings(), 0u); |
648 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 652 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 // Set up the high and low res tilings before pinch zoom. | 916 // Set up the high and low res tilings before pinch zoom. |
913 SetupTrees(pending_pile, active_pile); | 917 SetupTrees(pending_pile, active_pile); |
914 ResetTilingsAndRasterScales(); | 918 ResetTilingsAndRasterScales(); |
915 | 919 |
916 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, false); | 920 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, false); |
917 EXPECT_BOTH_EQ(num_tilings(), 2u); | 921 EXPECT_BOTH_EQ(num_tilings(), 2u); |
918 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), 2.f); | 922 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), 2.f); |
919 EXPECT_BOTH_EQ(tilings()->tiling_at(1)->contents_scale(), | 923 EXPECT_BOTH_EQ(tilings()->tiling_at(1)->contents_scale(), |
920 2.f * low_res_factor); | 924 2.f * low_res_factor); |
921 | 925 |
| 926 // Ensure UpdateTiles won't remove any tilings. |
| 927 active_layer_->MarkAllTilingsUsed(); |
| 928 |
922 // Start a pinch gesture. | 929 // Start a pinch gesture. |
923 host_impl_.PinchGestureBegin(); | 930 host_impl_.PinchGestureBegin(); |
924 | 931 |
925 // Zoom out by a small amount. We should create a tiling at half | 932 // Zoom out by a small amount. We should create a tiling at half |
926 // the scale (2/kMaxScaleRatioDuringPinch). | 933 // the scale (2/kMaxScaleRatioDuringPinch). |
927 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, false); | 934 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, false); |
928 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 935 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
929 EXPECT_FLOAT_EQ(2.0f, | 936 EXPECT_FLOAT_EQ(2.0f, |
930 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 937 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
931 EXPECT_FLOAT_EQ(1.0f, | 938 EXPECT_FLOAT_EQ(1.0f, |
932 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 939 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
933 EXPECT_FLOAT_EQ(2.0f * low_res_factor, | 940 EXPECT_FLOAT_EQ(2.0f * low_res_factor, |
934 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 941 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
935 | 942 |
| 943 // Ensure UpdateTiles won't remove any tilings. |
| 944 active_layer_->MarkAllTilingsUsed(); |
| 945 |
936 // Zoom out further, close to our low-res scale factor. We should | 946 // Zoom out further, close to our low-res scale factor. We should |
937 // use that tiling as high-res, and not create a new tiling. | 947 // use that tiling as high-res, and not create a new tiling. |
938 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, | 948 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, |
939 low_res_factor * 2.1f, 1.0f, false); | 949 low_res_factor * 2.1f, 1.0f, false); |
940 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 950 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
941 | 951 |
942 // Zoom in a lot now. Since we increase by increments of | 952 // Zoom in a lot now. Since we increase by increments of |
943 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. | 953 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. |
944 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, false); | 954 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, false); |
945 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 955 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
(...skipping 16 matching lines...) Expand all Loading... |
962 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 972 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
963 | 973 |
964 // Set up the high and low res tilings before pinch zoom. | 974 // Set up the high and low res tilings before pinch zoom. |
965 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, false); | 975 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, false); |
966 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 976 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
967 EXPECT_FLOAT_EQ(0.24f, | 977 EXPECT_FLOAT_EQ(0.24f, |
968 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 978 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
969 EXPECT_FLOAT_EQ(0.0625f, | 979 EXPECT_FLOAT_EQ(0.0625f, |
970 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 980 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
971 | 981 |
| 982 // Ensure UpdateTiles won't remove any tilings. |
| 983 active_layer_->MarkAllTilingsUsed(); |
| 984 |
972 // Start a pinch gesture. | 985 // Start a pinch gesture. |
973 host_impl_.PinchGestureBegin(); | 986 host_impl_.PinchGestureBegin(); |
974 | 987 |
975 // Zoom out by a small amount. We should create a tiling at half | 988 // Zoom out by a small amount. We should create a tiling at half |
976 // the scale (1/kMaxScaleRatioDuringPinch). | 989 // the scale (1/kMaxScaleRatioDuringPinch). |
977 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, false); | 990 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, false); |
978 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 991 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
979 EXPECT_FLOAT_EQ(0.24f, | 992 EXPECT_FLOAT_EQ(0.24f, |
980 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 993 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
981 EXPECT_FLOAT_EQ(0.12f, | 994 EXPECT_FLOAT_EQ(0.12f, |
982 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 995 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
983 EXPECT_FLOAT_EQ(0.0625, | 996 EXPECT_FLOAT_EQ(0.0625, |
984 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 997 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
985 | 998 |
| 999 // Ensure UpdateTiles won't remove any tilings. |
| 1000 active_layer_->MarkAllTilingsUsed(); |
| 1001 |
986 // Zoom out further, close to our low-res scale factor. We should | 1002 // Zoom out further, close to our low-res scale factor. We should |
987 // use that tiling as high-res, and not create a new tiling. | 1003 // use that tiling as high-res, and not create a new tiling. |
988 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); | 1004 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); |
989 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1005 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
990 | 1006 |
991 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in | 1007 // Zoom in. 0.25(desired_scale) should be snapped to 0.24 during zoom-in |
992 // because 0.25(desired_scale) is within the ratio(1.2). | 1008 // because 0.25(desired_scale) is within the ratio(1.2). |
993 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, false); | 1009 SetContentsScaleOnBothLayers(0.25f, 1.0f, 0.25f, 1.0f, false); |
994 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1010 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
995 | 1011 |
(...skipping 19 matching lines...) Expand all Loading... |
1015 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1031 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
1016 EXPECT_LT(low_res_factor, 1.f); | 1032 EXPECT_LT(low_res_factor, 1.f); |
1017 | 1033 |
1018 float scale = 1.f; | 1034 float scale = 1.f; |
1019 float page_scale = 1.f; | 1035 float page_scale = 1.f; |
1020 | 1036 |
1021 SetupTrees(pending_pile, active_pile); | 1037 SetupTrees(pending_pile, active_pile); |
1022 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1038 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1023 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); | 1039 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); |
1024 | 1040 |
| 1041 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
| 1042 // |used_tilings| variable, and it's here only to ensure that active_layer_ |
| 1043 // won't remove tilings before the test has a chance to verify behavior. |
| 1044 active_layer_->MarkAllTilingsUsed(); |
| 1045 |
1025 // We only have ideal tilings, so they aren't removed. | 1046 // We only have ideal tilings, so they aren't removed. |
1026 used_tilings.clear(); | 1047 used_tilings.clear(); |
1027 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1048 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1028 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1049 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1029 | 1050 |
1030 host_impl_.PinchGestureBegin(); | 1051 host_impl_.PinchGestureBegin(); |
1031 | 1052 |
1032 // Changing the ideal but not creating new tilings. | 1053 // Changing the ideal but not creating new tilings. |
1033 scale = 1.5f; | 1054 scale = 1.5f; |
1034 page_scale = 1.5f; | 1055 page_scale = 1.5f; |
(...skipping 12 matching lines...) Expand all Loading... |
1047 page_scale = 1.2f; | 1068 page_scale = 1.2f; |
1048 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, false); | 1069 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, false); |
1049 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1070 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1050 EXPECT_FLOAT_EQ( | 1071 EXPECT_FLOAT_EQ( |
1051 1.f, | 1072 1.f, |
1052 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 1073 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
1053 EXPECT_FLOAT_EQ( | 1074 EXPECT_FLOAT_EQ( |
1054 1.f * low_res_factor, | 1075 1.f * low_res_factor, |
1055 active_layer_->tilings()->tiling_at(3)->contents_scale()); | 1076 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
1056 | 1077 |
| 1078 // Ensure UpdateTiles won't remove any tilings. |
| 1079 active_layer_->MarkAllTilingsUsed(); |
| 1080 |
1057 // Mark the non-ideal tilings as used. They won't be removed. | 1081 // Mark the non-ideal tilings as used. They won't be removed. |
1058 used_tilings.clear(); | 1082 used_tilings.clear(); |
1059 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 1083 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
1060 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); | 1084 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); |
1061 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1085 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1062 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1086 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1063 | 1087 |
1064 // Now move the ideal scale to 0.5. Our target stays 1.2. | 1088 // Now move the ideal scale to 0.5. Our target stays 1.2. |
1065 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, false); | 1089 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, false); |
1066 | 1090 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 animating_transform = false; | 1163 animating_transform = false; |
1140 SetContentsScaleOnBothLayers(contents_scale, | 1164 SetContentsScaleOnBothLayers(contents_scale, |
1141 device_scale, | 1165 device_scale, |
1142 page_scale, | 1166 page_scale, |
1143 maximum_animation_scale, | 1167 maximum_animation_scale, |
1144 animating_transform); | 1168 animating_transform); |
1145 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1169 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1146 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1170 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
1147 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1171 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1148 | 1172 |
| 1173 // Ensure UpdateTiles won't remove any tilings. |
| 1174 active_layer_->MarkAllTilingsUsed(); |
| 1175 |
1149 // Page scale animation, new high res, but no low res. We still have | 1176 // Page scale animation, new high res, but no low res. We still have |
1150 // a tiling at the previous scale, it's just not marked as low res on the | 1177 // a tiling at the previous scale, it's just not marked as low res on the |
1151 // active layer. The pending layer drops non-ideal tilings. | 1178 // active layer. The pending layer drops non-ideal tilings. |
1152 contents_scale = 2.f; | 1179 contents_scale = 2.f; |
1153 page_scale = 2.f; | 1180 page_scale = 2.f; |
1154 maximum_animation_scale = 2.f; | 1181 maximum_animation_scale = 2.f; |
1155 animating_transform = true; | 1182 animating_transform = true; |
1156 SetContentsScaleOnBothLayers(contents_scale, | 1183 SetContentsScaleOnBothLayers(contents_scale, |
1157 device_scale, | 1184 device_scale, |
1158 page_scale, | 1185 page_scale, |
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3248 | 3275 |
3249 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3276 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
3250 gfx::Size tile_size(100, 100); | 3277 gfx::Size tile_size(100, 100); |
3251 gfx::Size layer_bounds(1000, 1000); | 3278 gfx::Size layer_bounds(1000, 1000); |
3252 | 3279 |
3253 // Make sure some tiles are not shared. | 3280 // Make sure some tiles are not shared. |
3254 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3281 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3255 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3282 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3256 | 3283 |
3257 // All pending layer tiles required are not ready. | 3284 // All pending layer tiles required are not ready. |
3258 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3285 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
3259 | 3286 |
3260 // Initialize all low-res tiles. | 3287 // Initialize all low-res tiles. |
3261 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3288 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
3262 | 3289 |
3263 // Low-res tiles should not be enough. | 3290 // Low-res tiles should not be enough. |
3264 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3291 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
3265 | 3292 |
3266 // Initialize remaining tiles. | 3293 // Initialize remaining tiles. |
3267 pending_layer_->SetAllTilesReady(); | 3294 pending_layer_->SetAllTilesReady(); |
3268 | 3295 |
3269 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3296 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
3270 } | 3297 } |
3271 | 3298 |
3272 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { | 3299 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
3273 gfx::Size tile_size(100, 100); | 3300 gfx::Size tile_size(100, 100); |
3274 gfx::Size layer_bounds(1000, 1000); | 3301 gfx::Size layer_bounds(1000, 1000); |
3275 | 3302 |
3276 // Make sure some tiles are not shared. | 3303 // Make sure some tiles are not shared. |
3277 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3304 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3278 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3305 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3279 | 3306 |
3280 // All pending layer tiles required are not ready. | 3307 // All pending layer tiles required are not ready. |
3281 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3308 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
3282 | 3309 |
3283 // Initialize all high-res tiles. | 3310 // Initialize all high-res tiles. |
3284 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3311 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
3285 | 3312 |
3286 // High-res tiles should be enough, since they cover everything visible. | 3313 // High-res tiles should be enough, since they cover everything visible. |
3287 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3314 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
3288 } | 3315 } |
3289 | 3316 |
3290 TEST_F(PictureLayerImplTest, | 3317 TEST_F(PictureLayerImplTest, |
3291 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { | 3318 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
3292 gfx::Size tile_size(100, 100); | 3319 gfx::Size tile_size(100, 100); |
3293 gfx::Size layer_bounds(1000, 1000); | 3320 gfx::Size layer_bounds(1000, 1000); |
3294 | 3321 |
3295 // Make sure some tiles are not shared. | 3322 // Make sure some tiles are not shared. |
3296 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3323 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3297 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3324 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3298 | 3325 |
3299 // Initialize all high-res tiles in the active layer. | 3326 // Initialize all high-res tiles in the active layer. |
3300 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3327 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
3301 // And all the low-res tiles in the pending layer. | 3328 // And all the low-res tiles in the pending layer. |
3302 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3329 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
3303 | 3330 |
3304 // The unshared high-res tiles are not ready, so we cannot activate. | 3331 // The unshared high-res tiles are not ready, so we cannot activate. |
3305 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3332 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
3306 | 3333 |
3307 // When the unshared pending high-res tiles are ready, we can activate. | 3334 // When the unshared pending high-res tiles are ready, we can activate. |
3308 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3335 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
3309 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3336 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
3310 } | 3337 } |
3311 | 3338 |
3312 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { | 3339 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { |
3313 gfx::Size tile_size(100, 100); | 3340 gfx::Size tile_size(100, 100); |
3314 gfx::Size layer_bounds(1000, 1000); | 3341 gfx::Size layer_bounds(1000, 1000); |
3315 | 3342 |
3316 // Make sure some tiles are not shared. | 3343 // Make sure some tiles are not shared. |
3317 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3344 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3318 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3345 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3319 | 3346 |
3320 // Initialize all high-res tiles in the active layer. | 3347 // Initialize all high-res tiles in the active layer. |
3321 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3348 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
3322 | 3349 |
3323 // The unshared high-res tiles are not ready, so we cannot activate. | 3350 // The unshared high-res tiles are not ready, so we cannot activate. |
3324 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3351 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
3325 | 3352 |
3326 // When the unshared pending high-res tiles are ready, we can activate. | 3353 // When the unshared pending high-res tiles are ready, we can activate. |
3327 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3354 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
3328 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3355 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
3329 } | 3356 } |
3330 | 3357 |
3331 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { | 3358 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
3332 gfx::Size tile_size(400, 400); | 3359 gfx::Size tile_size(400, 400); |
3333 gfx::Size layer_bounds(1300, 1900); | 3360 gfx::Size layer_bounds(1300, 1900); |
3334 | 3361 |
3335 scoped_refptr<FakePicturePileImpl> pending_pile = | 3362 scoped_refptr<FakePicturePileImpl> pending_pile = |
3336 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3363 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3337 scoped_refptr<FakePicturePileImpl> active_pile = | 3364 scoped_refptr<FakePicturePileImpl> active_pile = |
3338 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3365 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 | 3632 |
3606 float device_scale = 1.7f; | 3633 float device_scale = 1.7f; |
3607 float page_scale = 3.2f; | 3634 float page_scale = 3.2f; |
3608 float scale = 1.f; | 3635 float scale = 1.f; |
3609 | 3636 |
3610 ResetTilingsAndRasterScales(); | 3637 ResetTilingsAndRasterScales(); |
3611 | 3638 |
3612 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 3639 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); |
3613 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3640 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3614 | 3641 |
| 3642 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to |
| 3643 // |used_tilings| variable, and it's here only to ensure that active_layer_ |
| 3644 // won't remove tilings before the test has a chance to verify behavior. |
| 3645 active_layer_->MarkAllTilingsUsed(); |
| 3646 |
3615 // We only have ideal tilings, so they aren't removed. | 3647 // We only have ideal tilings, so they aren't removed. |
3616 used_tilings.clear(); | 3648 used_tilings.clear(); |
3617 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3649 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3618 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3650 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3619 | 3651 |
3620 host_impl_.PinchGestureBegin(); | 3652 host_impl_.PinchGestureBegin(); |
3621 | 3653 |
3622 // Changing the ideal but not creating new tilings. | 3654 // Changing the ideal but not creating new tilings. |
3623 scale *= 1.5f; | 3655 scale *= 1.5f; |
3624 page_scale *= 1.5f; | 3656 page_scale *= 1.5f; |
3625 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 3657 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); |
3626 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3658 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3627 | 3659 |
3628 // The tilings are still our target scale, so they aren't removed. | 3660 // The tilings are still our target scale, so they aren't removed. |
3629 used_tilings.clear(); | 3661 used_tilings.clear(); |
3630 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3662 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3631 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3663 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3632 | 3664 |
3633 host_impl_.PinchGestureEnd(); | 3665 host_impl_.PinchGestureEnd(); |
3634 | 3666 |
3635 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 3667 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
3636 scale /= 4.f; | 3668 scale /= 4.f; |
3637 page_scale /= 4.f; | 3669 page_scale /= 4.f; |
3638 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false); | 3670 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false); |
3639 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3671 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3640 EXPECT_FLOAT_EQ(1.f, | 3672 EXPECT_FLOAT_EQ(1.f, |
3641 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 3673 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
3642 | 3674 |
| 3675 // Ensure UpdateTiles won't remove any tilings. |
| 3676 active_layer_->MarkAllTilingsUsed(); |
| 3677 |
3643 // Mark the non-ideal tilings as used. They won't be removed. | 3678 // Mark the non-ideal tilings as used. They won't be removed. |
3644 used_tilings.clear(); | 3679 used_tilings.clear(); |
3645 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 3680 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
3646 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3681 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3647 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3682 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3648 | 3683 |
3649 // Now move the ideal scale to 0.5. Our target stays 1.2. | 3684 // Now move the ideal scale to 0.5. Our target stays 1.2. |
3650 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false); | 3685 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false); |
3651 | 3686 |
3652 // The high resolution tiling is between target and ideal, so is not | 3687 // The high resolution tiling is between target and ideal, so is not |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4725 | 4760 |
4726 host_impl_.SetRequiresHighResToDraw(); | 4761 host_impl_.SetRequiresHighResToDraw(); |
4727 | 4762 |
4728 // Update tiles. | 4763 // Update tiles. |
4729 pending_layer_->draw_properties().visible_content_rect = viewport; | 4764 pending_layer_->draw_properties().visible_content_rect = viewport; |
4730 pending_layer_->draw_properties().screen_space_transform = transform; | 4765 pending_layer_->draw_properties().screen_space_transform = transform; |
4731 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 4766 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
4732 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4767 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
4733 | 4768 |
4734 // Ensure we can't activate. | 4769 // Ensure we can't activate. |
4735 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 4770 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); |
4736 | 4771 |
4737 // Now in the same frame, move the viewport (this can happen during | 4772 // Now in the same frame, move the viewport (this can happen during |
4738 // animation). | 4773 // animation). |
4739 viewport = gfx::Rect(0, 2000, 100, 100); | 4774 viewport = gfx::Rect(0, 2000, 100, 100); |
4740 | 4775 |
4741 // Update tiles. | 4776 // Update tiles. |
4742 pending_layer_->draw_properties().visible_content_rect = viewport; | 4777 pending_layer_->draw_properties().visible_content_rect = viewport; |
4743 pending_layer_->draw_properties().screen_space_transform = transform; | 4778 pending_layer_->draw_properties().screen_space_transform = transform; |
4744 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 4779 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
4745 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 4780 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
4746 | 4781 |
4747 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. | 4782 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. |
4748 std::vector<Tile*> tiles; | 4783 std::vector<Tile*> tiles; |
4749 for (PictureLayerTiling::CoverageIterator iter( | 4784 for (PictureLayerTiling::CoverageIterator iter( |
4750 pending_layer_->HighResTiling(), | 4785 pending_layer_->HighResTiling(), |
4751 1.f, | 4786 1.f, |
4752 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); | 4787 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); |
4753 iter; | 4788 iter; |
4754 ++iter) { | 4789 ++iter) { |
4755 if (*iter) | 4790 if (*iter) |
4756 tiles.push_back(*iter); | 4791 tiles.push_back(*iter); |
4757 } | 4792 } |
4758 | 4793 |
4759 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4794 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
4760 | 4795 |
4761 // Ensure we can activate. | 4796 // Ensure we can activate. |
4762 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 4797 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
4763 } | 4798 } |
4764 | 4799 |
4765 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { | 4800 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { |
4766 gfx::Size tile_size(100, 100); | 4801 gfx::Size tile_size(100, 100); |
4767 gfx::Size layer_bounds(400, 400); | 4802 gfx::Size layer_bounds(400, 400); |
4768 | 4803 |
4769 scoped_refptr<FakePicturePileImpl> filled_pile = | 4804 scoped_refptr<FakePicturePileImpl> filled_pile = |
4770 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4805 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4771 scoped_refptr<FakePicturePileImpl> partial_pile = | 4806 scoped_refptr<FakePicturePileImpl> partial_pile = |
4772 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 4807 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4882 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4917 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4883 EXPECT_EQ(result.width(), 448); | 4918 EXPECT_EQ(result.width(), 448); |
4884 EXPECT_EQ(result.height(), 448); | 4919 EXPECT_EQ(result.height(), 448); |
4885 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4920 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4886 EXPECT_EQ(result.width(), 512); | 4921 EXPECT_EQ(result.width(), 512); |
4887 EXPECT_EQ(result.height(), 500 + 2); | 4922 EXPECT_EQ(result.height(), 500 + 2); |
4888 } | 4923 } |
4889 | 4924 |
4890 } // namespace | 4925 } // namespace |
4891 } // namespace cc | 4926 } // namespace cc |
OLD | NEW |