| 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 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 page_scale, | 1088 page_scale, |
| 1089 maximum_animation_scale, | 1089 maximum_animation_scale, |
| 1090 animating_transform); | 1090 animating_transform); |
| 1091 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1091 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 1092 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1092 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
| 1093 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1093 EXPECT_BOTH_EQ(num_tilings(), 2u); |
| 1094 | 1094 |
| 1095 // Page scale animation, new high res, but not new low res because animating. | 1095 // Page scale animation, new high res, but not new low res because animating. |
| 1096 contents_scale = 2.f; | 1096 contents_scale = 2.f; |
| 1097 page_scale = 2.f; | 1097 page_scale = 2.f; |
| 1098 maximum_animation_scale = 2.f; |
| 1098 animating_transform = true; | 1099 animating_transform = true; |
| 1099 SetContentsScaleOnBothLayers(contents_scale, | 1100 SetContentsScaleOnBothLayers(contents_scale, |
| 1100 device_scale, | 1101 device_scale, |
| 1101 page_scale, | 1102 page_scale, |
| 1102 maximum_animation_scale, | 1103 maximum_animation_scale, |
| 1103 animating_transform); | 1104 animating_transform); |
| 1104 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1105 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
| 1105 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1106 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
| 1106 EXPECT_BOTH_EQ(num_tilings(), 3u); | 1107 EXPECT_BOTH_EQ(num_tilings(), 3u); |
| 1107 | 1108 |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 animating_transform = false; | 2309 animating_transform = false; |
| 2309 | 2310 |
| 2310 SetContentsScaleOnBothLayers(contents_scale, | 2311 SetContentsScaleOnBothLayers(contents_scale, |
| 2311 device_scale, | 2312 device_scale, |
| 2312 page_scale, | 2313 page_scale, |
| 2313 maximum_animation_scale, | 2314 maximum_animation_scale, |
| 2314 animating_transform); | 2315 animating_transform); |
| 2315 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2316 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
| 2316 | 2317 |
| 2317 // When animating with an unknown maximum animation scale factor, a new | 2318 // When animating with an unknown maximum animation scale factor, a new |
| 2318 // high-res tiling should be created at the animation's initial scale. | 2319 // high-res tiling should be created at a source scale of 1. |
| 2319 animating_transform = true; | 2320 animating_transform = true; |
| 2320 contents_scale = 2.f; | 2321 contents_scale = 2.f; |
| 2321 maximum_animation_scale = 0.f; | 2322 maximum_animation_scale = 0.f; |
| 2322 | 2323 |
| 2323 SetContentsScaleOnBothLayers(contents_scale, | 2324 SetContentsScaleOnBothLayers(contents_scale, |
| 2324 device_scale, | 2325 device_scale, |
| 2325 page_scale, | 2326 page_scale, |
| 2326 maximum_animation_scale, | 2327 maximum_animation_scale, |
| 2327 animating_transform); | 2328 animating_transform); |
| 2328 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2329 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
| 2329 | 2330 |
| 2330 // Further changes to scale during the animation should not cause a new | 2331 // Further changes to scale during the animation should not cause a new |
| 2331 // high-res tiling to get created. | 2332 // high-res tiling to get created. |
| 2332 contents_scale = 3.f; | 2333 contents_scale = 3.f; |
| 2333 | 2334 |
| 2334 SetContentsScaleOnBothLayers(contents_scale, | 2335 SetContentsScaleOnBothLayers(contents_scale, |
| 2335 device_scale, | 2336 device_scale, |
| 2336 page_scale, | 2337 page_scale, |
| 2337 maximum_animation_scale, | 2338 maximum_animation_scale, |
| 2338 animating_transform); | 2339 animating_transform); |
| 2339 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2340 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
| 2340 | 2341 |
| 2341 // Once we stop animating, a new high-res tiling should be created. | 2342 // Once we stop animating, a new high-res tiling should be created. |
| 2342 animating_transform = false; | 2343 animating_transform = false; |
| 2343 contents_scale = 4.f; | 2344 contents_scale = 4.f; |
| 2344 | 2345 |
| 2345 SetContentsScaleOnBothLayers(contents_scale, | 2346 SetContentsScaleOnBothLayers(contents_scale, |
| 2346 device_scale, | 2347 device_scale, |
| 2347 page_scale, | 2348 page_scale, |
| 2348 maximum_animation_scale, | 2349 maximum_animation_scale, |
| 2349 animating_transform); | 2350 animating_transform); |
| 2350 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2351 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
| 2351 | 2352 |
| 2352 // When animating with a maxmium animation scale factor that is so large | 2353 // When animating with a maxmium animation scale factor that is so large |
| 2353 // that the layer grows larger than the viewport at this scale, a new | 2354 // that the layer grows larger than the viewport at this scale, a new |
| 2354 // high-res tiling should get created at the animation's initial scale, not | 2355 // high-res tiling should get created at a source scale of 1, not at its |
| 2355 // at its maximum scale. | 2356 // maximum scale. |
| 2356 animating_transform = true; | 2357 animating_transform = true; |
| 2357 contents_scale = 2.f; | 2358 contents_scale = 2.f; |
| 2358 maximum_animation_scale = 11.f; | 2359 maximum_animation_scale = 11.f; |
| 2359 | 2360 |
| 2360 SetContentsScaleOnBothLayers(contents_scale, | 2361 SetContentsScaleOnBothLayers(contents_scale, |
| 2361 device_scale, | 2362 device_scale, |
| 2362 page_scale, | 2363 page_scale, |
| 2363 maximum_animation_scale, | 2364 maximum_animation_scale, |
| 2364 animating_transform); | 2365 animating_transform); |
| 2365 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2366 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
| 2366 | 2367 |
| 2367 // Once we stop animating, a new high-res tiling should be created. | 2368 // Once we stop animating, a new high-res tiling should be created. |
| 2368 animating_transform = false; | 2369 animating_transform = false; |
| 2369 contents_scale = 11.f; | 2370 contents_scale = 11.f; |
| 2370 | 2371 |
| 2371 SetContentsScaleOnBothLayers(contents_scale, | 2372 SetContentsScaleOnBothLayers(contents_scale, |
| 2372 device_scale, | 2373 device_scale, |
| 2373 page_scale, | 2374 page_scale, |
| 2374 maximum_animation_scale, | 2375 maximum_animation_scale, |
| 2375 animating_transform); | 2376 animating_transform); |
| 2376 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2377 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
| 2377 | 2378 |
| 2378 // When animating with a maxmium animation scale factor that is so large | 2379 // When animating with a maxmium animation scale factor that is so large |
| 2379 // that the layer grows larger than the viewport at this scale, and where | 2380 // that the layer grows larger than the viewport at this scale, and where |
| 2380 // the intial source scale is < 1, a new high-res tiling should get created | 2381 // the intial source scale is < 1, a new high-res tiling should get created |
| 2381 // at source scale 1. | 2382 // at source scale 1. |
| 2382 animating_transform = true; | 2383 animating_transform = true; |
| 2383 contents_scale = 0.1f; | 2384 contents_scale = 0.1f; |
| 2384 maximum_animation_scale = 11.f; | 2385 maximum_animation_scale = 11.f; |
| 2385 | 2386 |
| 2386 SetContentsScaleOnBothLayers(contents_scale, | 2387 SetContentsScaleOnBothLayers(contents_scale, |
| 2387 device_scale, | 2388 device_scale, |
| 2388 page_scale, | 2389 page_scale, |
| 2389 maximum_animation_scale, | 2390 maximum_animation_scale, |
| 2390 animating_transform); | 2391 animating_transform); |
| 2391 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); | 2392 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
| 2392 | 2393 |
| 2393 // Once we stop animating, a new high-res tiling should be created. | 2394 // Once we stop animating, a new high-res tiling should be created. |
| 2394 animating_transform = false; | 2395 animating_transform = false; |
| 2396 contents_scale = 12.f; |
| 2397 |
| 2398 SetContentsScaleOnBothLayers(contents_scale, |
| 2399 device_scale, |
| 2400 page_scale, |
| 2401 maximum_animation_scale, |
| 2402 animating_transform); |
| 2403 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 12.f); |
| 2404 |
| 2405 // When animating toward a smaller scale, but that is still so large that the |
| 2406 // layer grows larger than the viewport at this scale, a new high-res tiling |
| 2407 // should get created at source scale 1. |
| 2408 animating_transform = true; |
| 2409 contents_scale = 11.f; |
| 2410 maximum_animation_scale = 11.f; |
| 2411 |
| 2412 SetContentsScaleOnBothLayers(contents_scale, |
| 2413 device_scale, |
| 2414 page_scale, |
| 2415 maximum_animation_scale, |
| 2416 animating_transform); |
| 2417 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
| 2418 |
| 2419 // Once we stop animating, a new high-res tiling should be created. |
| 2420 animating_transform = false; |
| 2395 contents_scale = 11.f; | 2421 contents_scale = 11.f; |
| 2396 | 2422 |
| 2397 SetContentsScaleOnBothLayers(contents_scale, | 2423 SetContentsScaleOnBothLayers(contents_scale, |
| 2398 device_scale, | 2424 device_scale, |
| 2399 page_scale, | 2425 page_scale, |
| 2400 maximum_animation_scale, | 2426 maximum_animation_scale, |
| 2401 animating_transform); | 2427 animating_transform); |
| 2402 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2428 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
| 2403 } | 2429 } |
| 2404 | 2430 |
| (...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4370 SetupPendingTree(pending_pile2); | 4396 SetupPendingTree(pending_pile2); |
| 4371 ActivateTree(); | 4397 ActivateTree(); |
| 4372 | 4398 |
| 4373 // We've switched to a solid color, so we should end up with no tilings. | 4399 // We've switched to a solid color, so we should end up with no tilings. |
| 4374 ASSERT_TRUE(active_layer_->tilings()); | 4400 ASSERT_TRUE(active_layer_->tilings()); |
| 4375 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4401 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4376 } | 4402 } |
| 4377 | 4403 |
| 4378 } // namespace | 4404 } // namespace |
| 4379 } // namespace cc | 4405 } // namespace cc |
| OLD | NEW |