| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 // Ensure UpdateTiles won't remove any tilings. | 1094 // Ensure UpdateTiles won't remove any tilings. |
| 1095 active_layer_->MarkAllTilingsUsed(); | 1095 active_layer_->MarkAllTilingsUsed(); |
| 1096 | 1096 |
| 1097 // Mark the non-ideal tilings as used. They won't be removed. | 1097 // Mark the non-ideal tilings as used. They won't be removed. |
| 1098 used_tilings.clear(); | 1098 used_tilings.clear(); |
| 1099 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 1099 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 1100 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); | 1100 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); |
| 1101 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1101 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1102 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 1102 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
| 1103 | 1103 |
| 1104 // Now move the ideal scale to 0.5. | 1104 // Now move the ideal scale to 0.5. Our target stays 1.2. |
| 1105 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); | 1105 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, 0.f, false); |
| 1106 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); | |
| 1107 | 1106 |
| 1108 // And begin an animation to 1.2. There are now 3 tilings, 0.5, 1.0 and 1.2. | 1107 // The high resolution tiling is between target and ideal, so is not |
| 1109 // The the 0.5 is ideal, but the 1.2 is high res. 1.0 sits between them. | 1108 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
| 1110 // high-res tiling is in the middle. There are also ex-low-res tilings paired | |
| 1111 // with each of the 3 tilings mentioned here, but since we're animating none | |
| 1112 // are marked as LOW_RESOLUTION. | |
| 1113 SetContentsScaleOnBothLayers(0.5, 1.f, page_scale, 1.2f, 0.f, true); | |
| 1114 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); | |
| 1115 EXPECT_EQ(HIGH_RESOLUTION, | |
| 1116 active_layer_->tilings()->tiling_at(0)->resolution()); | |
| 1117 EXPECT_EQ(1.2f, // High-res, though not the ideal scale. | |
| 1118 active_layer_->tilings()->tiling_at(0)->contents_scale()); | |
| 1119 EXPECT_EQ(1.f, // Tiling in the middle attack. | |
| 1120 active_layer_->tilings()->tiling_at(1)->contents_scale()); | |
| 1121 EXPECT_EQ(0.5f, // Ideal scale, but not considered high-res. | |
| 1122 active_layer_->tilings()->tiling_at(2)->contents_scale()); | |
| 1123 | |
| 1124 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
| 1125 active_layer_->tilings()->tiling_at(1)->resolution()); | |
| 1126 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
| 1127 active_layer_->tilings()->tiling_at(2)->resolution()); | |
| 1128 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
| 1129 active_layer_->tilings()->tiling_at(3)->resolution()); | |
| 1130 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
| 1131 active_layer_->tilings()->tiling_at(4)->resolution()); | |
| 1132 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
| 1133 active_layer_->tilings()->tiling_at(5)->resolution()); | |
| 1134 | |
| 1135 EXPECT_EQ(1.2f * low_res_factor, // Low-res, paired with current high-res. | |
| 1136 active_layer_->tilings()->tiling_at(3)->contents_scale()); | |
| 1137 EXPECT_EQ(1.f * low_res_factor, // Ex-low-res, paired with the middle one. | |
| 1138 active_layer_->tilings()->tiling_at(4)->contents_scale()); | |
| 1139 EXPECT_EQ(0.5f * low_res_factor, // Ex-low-res, paired with current ideal. | |
| 1140 active_layer_->tilings()->tiling_at(5)->contents_scale()); | |
| 1141 | |
| 1142 // The high resolution tiling is between target and ideal, so is not removed. | |
| 1143 // The ex-low-res tilings are all smaller scale, so they are removed. | |
| 1144 used_tilings.clear(); | 1109 used_tilings.clear(); |
| 1145 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1110 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1146 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1111 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1147 | 1112 |
| 1148 // Now move the ideal scale to 1.0 on the active layer. The high-res tiling | 1113 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 1149 // stays 1.2. | 1114 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, 0.f, false); |
| 1150 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, page_scale, 1.2f, | |
| 1151 0.f, true); | |
| 1152 | 1115 |
| 1153 // All the tilings are between are target and the ideal, so they are not | 1116 // All the tilings are between are target and the ideal, so they are not |
| 1154 // Because the pending layer's ideal scale is still 0.5, all tilings fall | 1117 // removed. |
| 1155 // in the range [0.5,1.2] and are kept. | |
| 1156 used_tilings.clear(); | 1118 used_tilings.clear(); |
| 1157 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1119 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1158 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1120 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1159 | 1121 |
| 1160 // Move the ideal scale on the pending layer to 1.0 as well. Our high-res | 1122 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 1161 // stays 1.2 still. | 1123 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, 1.f, page_scale, 1.f, |
| 1162 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, page_scale, 1.f, | |
| 1163 0.f, false); | 1124 0.f, false); |
| 1164 | 1125 |
| 1165 // Our 0.5 tiling now falls outside the range between our ideal scale and our | 1126 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 1166 // high-res raster scale. But it is in our used tilings set, so nothing is | 1127 // in the range [1.0,1.2] and are kept. |
| 1167 // deleted. | |
| 1168 used_tilings.clear(); | 1128 used_tilings.clear(); |
| 1169 used_tilings.push_back(active_layer_->tilings()->tiling_at(2)); | |
| 1170 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1129 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1171 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1130 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1172 | 1131 |
| 1132 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 1133 // 1.2 still. |
| 1134 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, 1.f, page_scale, 1.f, |
| 1135 0.f, false); |
| 1136 |
| 1137 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 1138 // target raster scale. But it is in our used tilings set, so nothing is |
| 1139 // deleted. |
| 1140 used_tilings.clear(); |
| 1141 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 1142 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1143 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1144 |
| 1173 // If we remove it from our used tilings set, it is outside the range to keep | 1145 // If we remove it from our used tilings set, it is outside the range to keep |
| 1174 // so it is deleted. | 1146 // so it is deleted. |
| 1175 used_tilings.clear(); | 1147 used_tilings.clear(); |
| 1176 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1148 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1177 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1149 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 1178 } | 1150 } |
| 1179 | 1151 |
| 1180 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { | 1152 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
| 1181 // Make sure this layer covers multiple tiles, since otherwise low | 1153 // Make sure this layer covers multiple tiles, since otherwise low |
| 1182 // res won't get created because it is too small. | 1154 // res won't get created because it is too small. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 ResetTilingsAndRasterScales(); | 1243 ResetTilingsAndRasterScales(); |
| 1272 | 1244 |
| 1273 // Contents that are smaller than one tile, no low res. | 1245 // Contents that are smaller than one tile, no low res. |
| 1274 contents_scale = 0.123f; | 1246 contents_scale = 0.123f; |
| 1275 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1247 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1276 maximum_animation_scale, | 1248 maximum_animation_scale, |
| 1277 starting_animation_scale, animating_transform); | 1249 starting_animation_scale, animating_transform); |
| 1278 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1250 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1279 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1251 EXPECT_BOTH_EQ(num_tilings(), 1u); |
| 1280 | 1252 |
| 1253 // TODO(danakj): Remove these when raster scale doesn't get fixed? |
| 1281 ResetTilingsAndRasterScales(); | 1254 ResetTilingsAndRasterScales(); |
| 1282 | 1255 |
| 1283 // Any content bounds that would create more than one tile will | 1256 // Any content bounds that would create more than one tile will |
| 1284 // generate a low res tiling. | 1257 // generate a low res tiling. |
| 1285 contents_scale = 2.5f; | 1258 contents_scale = 2.5f; |
| 1286 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 1259 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 1287 maximum_animation_scale, | 1260 maximum_animation_scale, |
| 1288 starting_animation_scale, animating_transform); | 1261 starting_animation_scale, animating_transform); |
| 1289 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1262 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
| 1290 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), | 1263 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), |
| 1291 contents_scale * low_res_factor); | 1264 contents_scale * low_res_factor); |
| 1292 EXPECT_FALSE(pending_layer_->LowResTiling()); | 1265 EXPECT_FALSE(pending_layer_->LowResTiling()); |
| 1293 EXPECT_EQ(active_layer_->num_tilings(), 2u); | 1266 EXPECT_EQ(active_layer_->num_tilings(), 2u); |
| 1294 EXPECT_EQ(pending_layer_->num_tilings(), 1u); | 1267 EXPECT_EQ(pending_layer_->num_tilings(), 1u); |
| 1295 | 1268 |
| 1296 // Mask layers dont create low res since they always fit on one tile. | 1269 // Mask layers dont create low res since they always fit on one tile. |
| 1297 std::unique_ptr<FakePictureLayerImpl> mask = | 1270 std::unique_ptr<FakePictureLayerImpl> mask = |
| 1298 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1271 FakePictureLayerImpl::CreateMaskWithRasterSource( |
| 1299 host_impl_.pending_tree(), 3, pending_raster_source); | 1272 host_impl_.pending_tree(), 3, pending_raster_source); |
| 1300 mask->SetBounds(layer_bounds); | 1273 mask->SetBounds(layer_bounds); |
| 1301 mask->SetDrawsContent(true); | 1274 mask->SetDrawsContent(true); |
| 1302 pending_layer_->SetMaskLayer(std::move(mask)); | 1275 pending_layer_->SetMaskLayer(std::move(mask)); |
| 1303 pending_layer_->SetHasRenderSurface(true); | 1276 pending_layer_->SetHasRenderSurface(true); |
| 1304 RebuildPropertyTreesOnPendingTree(); | 1277 RebuildPropertyTreesOnPendingTree(); |
| 1305 host_impl_.pending_tree()->UpdateDrawProperties(false); | 1278 host_impl_.pending_tree()->UpdateDrawProperties(false); |
| 1306 | 1279 |
| 1307 FakePictureLayerImpl* mask_raw = | 1280 FakePictureLayerImpl* mask_raw = |
| 1308 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); | 1281 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
| 1282 // We did an UpdateDrawProperties above, which will set a contents scale on |
| 1283 // the mask layer, so allow us to reset the contents scale. |
| 1284 mask_raw->ReleaseResources(); |
| 1285 mask_raw->RecreateResources(); |
| 1286 |
| 1309 SetupDrawPropertiesAndUpdateTiles( | 1287 SetupDrawPropertiesAndUpdateTiles( |
| 1310 mask_raw, contents_scale, device_scale, page_scale, | 1288 mask_raw, contents_scale, device_scale, page_scale, |
| 1311 maximum_animation_scale, starting_animation_scale, animating_transform); | 1289 maximum_animation_scale, starting_animation_scale, animating_transform); |
| 1312 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); | 1290 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); |
| 1313 EXPECT_EQ(mask_raw->num_tilings(), 1u); | 1291 EXPECT_EQ(mask_raw->num_tilings(), 1u); |
| 1314 } | 1292 } |
| 1315 | 1293 |
| 1316 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1294 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
| 1317 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1295 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1318 | 1296 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 | 1950 |
| 1973 TEST_F(PictureLayerImplTest, | 1951 TEST_F(PictureLayerImplTest, |
| 1974 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { | 1952 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { |
| 1975 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1953 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 1976 | 1954 |
| 1977 gfx::Size tile_size(100, 100); | 1955 gfx::Size tile_size(100, 100); |
| 1978 gfx::Size layer_bounds(200, 200); | 1956 gfx::Size layer_bounds(200, 200); |
| 1979 gfx::Size viewport_size(400, 400); | 1957 gfx::Size viewport_size(400, 400); |
| 1980 | 1958 |
| 1981 host_impl_.SetViewportSize(viewport_size); | 1959 host_impl_.SetViewportSize(viewport_size); |
| 1960 SetInitialDeviceScaleFactor(2.f); |
| 1982 | 1961 |
| 1983 // Start with an ideal and raster contents scale of 2. | |
| 1984 SetInitialDeviceScaleFactor(2.f); | |
| 1985 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | 1962 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| 1986 | 1963 |
| 1987 // One ideal tile exists, this will get used when drawing. | 1964 // One ideal tile exists, this will get used when drawing. |
| 1988 std::vector<Tile*> ideal_tiles; | 1965 std::vector<Tile*> ideal_tiles; |
| 1989 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); | 1966 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); |
| 1990 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); | 1967 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); |
| 1991 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1968 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
| 1992 ideal_tiles); | 1969 ideal_tiles); |
| 1993 | 1970 |
| 1994 // Due to the animation, the raster contents scale moves to 1, while the | 1971 // Due to layer scale throttling, the raster contents scale is changed to 1, |
| 1995 // ideal will still be 2. | 1972 // while the ideal is still 2. |
| 1973 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1974 false); |
| 1996 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.f, 1.f, 1.f, 1.f, 0.f, | 1975 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.f, 1.f, 1.f, 1.f, 0.f, |
| 1997 true); | 1976 false); |
| 1998 | 1977 |
| 1999 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); | 1978 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); |
| 2000 EXPECT_EQ(1.f, active_layer_->raster_contents_scale()); | 1979 EXPECT_EQ(1.f, active_layer_->raster_contents_scale()); |
| 2001 EXPECT_EQ(2.f, active_layer_->ideal_contents_scale()); | 1980 EXPECT_EQ(2.f, active_layer_->ideal_contents_scale()); |
| 2002 | 1981 |
| 2003 // Both tilings still exist. | 1982 // Both tilings still exist. |
| 2004 ASSERT_GE(active_layer_->tilings()->num_tilings(), 2u); | |
| 2005 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); | 1983 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 2006 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); | 1984 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 2007 | 1985 |
| 2008 // All high res tiles have resources. | 1986 // All high res tiles have resources. |
| 2009 std::vector<Tile*> high_tiles = | 1987 std::vector<Tile*> high_tiles = |
| 2010 active_layer_->HighResTiling()->AllTilesForTesting(); | 1988 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 2011 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); | 1989 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); |
| 2012 | 1990 |
| 2013 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 1991 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 2014 AppendQuadsData data; | 1992 AppendQuadsData data; |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3260 float page_scale = 1.f; | 3238 float page_scale = 1.f; |
| 3261 float maximum_animation_scale = 1.f; | 3239 float maximum_animation_scale = 1.f; |
| 3262 float starting_animation_scale = 0.f; | 3240 float starting_animation_scale = 0.f; |
| 3263 bool animating_transform = false; | 3241 bool animating_transform = false; |
| 3264 | 3242 |
| 3265 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3243 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3266 maximum_animation_scale, | 3244 maximum_animation_scale, |
| 3267 starting_animation_scale, animating_transform); | 3245 starting_animation_scale, animating_transform); |
| 3268 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 3246 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 3269 | 3247 |
| 3270 // Changing the source scale without being in an animation should be | 3248 // Changing the source scale without being in an animation will cause |
| 3271 // immediately honored. | 3249 // the layer to reset its source scale to 1.f. |
| 3272 contents_scale = 3.f; | 3250 contents_scale = 3.f; |
| 3273 | 3251 |
| 3274 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3252 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3275 maximum_animation_scale, | 3253 maximum_animation_scale, |
| 3276 starting_animation_scale, animating_transform); | 3254 starting_animation_scale, animating_transform); |
| 3277 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); | 3255 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 3278 | 3256 |
| 3279 // Further changes to the source scale will continue to be honored. | 3257 // Further changes to the source scale will no longer be reflected in the |
| 3258 // contents scale. |
| 3280 contents_scale = 0.5f; | 3259 contents_scale = 0.5f; |
| 3281 | 3260 |
| 3282 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, | 3261 SetContentsScaleOnBothLayers(contents_scale, device_scale, page_scale, |
| 3283 maximum_animation_scale, | 3262 maximum_animation_scale, |
| 3284 starting_animation_scale, animating_transform); | 3263 starting_animation_scale, animating_transform); |
| 3285 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); | 3264 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 3286 } | 3265 } |
| 3287 | 3266 |
| 3288 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3267 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
| 3289 gfx::Size tile_size(100, 100); | 3268 gfx::Size tile_size(100, 100); |
| 3290 gfx::Size layer_bounds(1000, 1000); | 3269 gfx::Size layer_bounds(1000, 1000); |
| 3291 | 3270 |
| 3292 // Make sure pending tree has tiles. | 3271 // Make sure pending tree has tiles. |
| 3293 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); | 3272 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
| 3294 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); | 3273 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
| 3295 | 3274 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3575 | 3554 |
| 3576 // Ensure UpdateTiles won't remove any tilings. | 3555 // Ensure UpdateTiles won't remove any tilings. |
| 3577 active_layer_->MarkAllTilingsUsed(); | 3556 active_layer_->MarkAllTilingsUsed(); |
| 3578 | 3557 |
| 3579 // Mark the non-ideal tilings as used. They won't be removed. | 3558 // Mark the non-ideal tilings as used. They won't be removed. |
| 3580 used_tilings.clear(); | 3559 used_tilings.clear(); |
| 3581 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 3560 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 3582 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3561 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3583 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3562 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 3584 | 3563 |
| 3585 // Now move the ideal scale to 0.5. | 3564 // Now move the ideal scale to 0.5. Our target stays 1.2. |
| 3586 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, 0.f, false); | 3565 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, 0.f, false); |
| 3587 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | |
| 3588 | |
| 3589 // And begin an animation to 1.2. There are now 3 tilings, 0.5, 1.0 and 1.2. | |
| 3590 // The the 0.5 is ideal, but the 1.2 is high res. 1.0 sits between them. | |
| 3591 // high-res tiling is in the middle. | |
| 3592 SetContentsScaleOnBothLayers(0.5, device_scale, page_scale, 1.2f, 0.f, true); | |
| 3593 EXPECT_EQ(HIGH_RESOLUTION, | |
| 3594 active_layer_->tilings()->tiling_at(0)->resolution()); | |
| 3595 EXPECT_EQ(1.2f, // High-res, though not the ideal scale. | |
| 3596 active_layer_->tilings()->tiling_at(0)->contents_scale()); | |
| 3597 EXPECT_EQ(1.f, // Tiling in the middle attack. | |
| 3598 active_layer_->tilings()->tiling_at(1)->contents_scale()); | |
| 3599 EXPECT_EQ(0.5f, // Ideal scale, but not considered high-res. | |
| 3600 active_layer_->tilings()->tiling_at(2)->contents_scale()); | |
| 3601 | 3566 |
| 3602 // The high resolution tiling is between target and ideal, so is not | 3567 // The high resolution tiling is between target and ideal, so is not |
| 3568 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
| 3569 used_tilings.clear(); |
| 3570 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3571 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 3572 |
| 3573 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 3574 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, 0.f, false); |
| 3575 |
| 3576 // All the tilings are between are target and the ideal, so they are not |
| 3603 // removed. | 3577 // removed. |
| 3604 used_tilings.clear(); | 3578 used_tilings.clear(); |
| 3605 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3579 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3606 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 3580 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 3607 | 3581 |
| 3608 // Now move the ideal scale to 1.0 on the active layer. The high-res tiling | 3582 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 3609 // stays 1.2. | 3583 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, device_scale, |
| 3610 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, device_scale, | 3584 page_scale, 1.f, 0.f, false); |
| 3611 page_scale, 1.2f, 0.f, true); | |
| 3612 | 3585 |
| 3613 // Because the pending layer's ideal scale is still 0.5, all tilings fall | 3586 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 3614 // in the range [0.5,1.2] and are kept. | 3587 // in the range [1.0,1.2] and are kept. |
| 3615 used_tilings.clear(); | 3588 used_tilings.clear(); |
| 3616 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3589 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3617 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 3590 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 3618 | 3591 |
| 3619 // Move the ideal scale on the pending layer to 1.0 as well. Our high-res | 3592 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 3620 // stays 1.2 still. | 3593 // 1.2 still. |
| 3621 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, device_scale, | 3594 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, device_scale, |
| 3622 page_scale, 1.f, 0.f, false); | 3595 page_scale, 1.f, 0.f, false); |
| 3623 | 3596 |
| 3624 // Our 0.5 tiling now falls outside the range between our ideal scale and our | 3597 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 3625 // high-res raster scale. But it is in our used tilings set, so nothing is | 3598 // target raster scale. But it is in our used tilings set, so nothing is |
| 3626 // deleted. | 3599 // deleted. |
| 3627 used_tilings.clear(); | 3600 used_tilings.clear(); |
| 3628 used_tilings.push_back(active_layer_->tilings()->tiling_at(2)); | 3601 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 3629 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3602 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3630 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 3603 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 3631 | 3604 |
| 3632 // If we remove it from our used tilings set, it is outside the range to keep | 3605 // If we remove it from our used tilings set, it is outside the range to keep |
| 3633 // so it is deleted. | 3606 // so it is deleted. |
| 3634 used_tilings.clear(); | 3607 used_tilings.clear(); |
| 3635 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3608 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 3636 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3609 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
| 3637 } | 3610 } |
| 3638 | 3611 |
| 3639 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { | 3612 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { |
| 3640 gfx::Size layer_bounds(1300, 1900); | 3613 gfx::Size layer_bounds(1300, 1900); |
| 3641 SetupDefaultTrees(layer_bounds); | 3614 SetupDefaultTrees(layer_bounds); |
| 3642 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3615 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3643 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3616 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); |
| 3644 | 3617 |
| 3645 // All tilings should be removed when losing output surface. | 3618 // All tilings should be removed when losing output surface. |
| 3646 active_layer_->ReleaseResources(); | 3619 active_layer_->ReleaseResources(); |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4916 // New low res tiling. | 4889 // New low res tiling. |
| 4917 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 4890 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
| 4918 | 4891 |
| 4919 // This tiling will be high res now, it won't contain low res content since it | 4892 // This tiling will be high res now, it won't contain low res content since it |
| 4920 // was all destroyed. | 4893 // was all destroyed. |
| 4921 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 4894 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
| 4922 } | 4895 } |
| 4923 | 4896 |
| 4924 } // namespace | 4897 } // namespace |
| 4925 } // namespace cc | 4898 } // namespace cc |
| OLD | NEW |