| 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 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2373 animating_transform = false; | 2374 animating_transform = false; |
| 2374 | 2375 |
| 2375 SetContentsScaleOnBothLayers(contents_scale, | 2376 SetContentsScaleOnBothLayers(contents_scale, |
| 2376 device_scale, | 2377 device_scale, |
| 2377 page_scale, | 2378 page_scale, |
| 2378 maximum_animation_scale, | 2379 maximum_animation_scale, |
| 2379 animating_transform); | 2380 animating_transform); |
| 2380 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2381 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
| 2381 | 2382 |
| 2382 // When animating with an unknown maximum animation scale factor, a new | 2383 // When animating with an unknown maximum animation scale factor, a new |
| 2383 // high-res tiling should be created at the animation's initial scale. | 2384 // high-res tiling should be created at a source scale of 1. |
| 2384 animating_transform = true; | 2385 animating_transform = true; |
| 2385 contents_scale = 2.f; | 2386 contents_scale = 2.f; |
| 2386 maximum_animation_scale = 0.f; | 2387 maximum_animation_scale = 0.f; |
| 2387 | 2388 |
| 2388 SetContentsScaleOnBothLayers(contents_scale, | 2389 SetContentsScaleOnBothLayers(contents_scale, |
| 2389 device_scale, | 2390 device_scale, |
| 2390 page_scale, | 2391 page_scale, |
| 2391 maximum_animation_scale, | 2392 maximum_animation_scale, |
| 2392 animating_transform); | 2393 animating_transform); |
| 2393 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2394 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
| 2394 | 2395 |
| 2395 // Further changes to scale during the animation should not cause a new | 2396 // Further changes to scale during the animation should not cause a new |
| 2396 // high-res tiling to get created. | 2397 // high-res tiling to get created. |
| 2397 contents_scale = 3.f; | 2398 contents_scale = 3.f; |
| 2398 | 2399 |
| 2399 SetContentsScaleOnBothLayers(contents_scale, | 2400 SetContentsScaleOnBothLayers(contents_scale, |
| 2400 device_scale, | 2401 device_scale, |
| 2401 page_scale, | 2402 page_scale, |
| 2402 maximum_animation_scale, | 2403 maximum_animation_scale, |
| 2403 animating_transform); | 2404 animating_transform); |
| 2404 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2405 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
| 2405 | 2406 |
| 2406 // Once we stop animating, a new high-res tiling should be created. | 2407 // Once we stop animating, a new high-res tiling should be created. |
| 2407 animating_transform = false; | 2408 animating_transform = false; |
| 2408 contents_scale = 4.f; | 2409 contents_scale = 4.f; |
| 2409 | 2410 |
| 2410 SetContentsScaleOnBothLayers(contents_scale, | 2411 SetContentsScaleOnBothLayers(contents_scale, |
| 2411 device_scale, | 2412 device_scale, |
| 2412 page_scale, | 2413 page_scale, |
| 2413 maximum_animation_scale, | 2414 maximum_animation_scale, |
| 2414 animating_transform); | 2415 animating_transform); |
| 2415 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2416 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
| 2416 | 2417 |
| 2417 // When animating with a maxmium animation scale factor that is so large | 2418 // When animating with a maxmium animation scale factor that is so large |
| 2418 // that the layer grows larger than the viewport at this scale, a new | 2419 // that the layer grows larger than the viewport at this scale, a new |
| 2419 // high-res tiling should get created at the animation's initial scale, not | 2420 // high-res tiling should get created at a source scale of 1, not at its |
| 2420 // at its maximum scale. | 2421 // maximum scale. |
| 2421 animating_transform = true; | 2422 animating_transform = true; |
| 2422 contents_scale = 2.f; | 2423 contents_scale = 2.f; |
| 2423 maximum_animation_scale = 11.f; | 2424 maximum_animation_scale = 11.f; |
| 2424 | 2425 |
| 2425 SetContentsScaleOnBothLayers(contents_scale, | 2426 SetContentsScaleOnBothLayers(contents_scale, |
| 2426 device_scale, | 2427 device_scale, |
| 2427 page_scale, | 2428 page_scale, |
| 2428 maximum_animation_scale, | 2429 maximum_animation_scale, |
| 2429 animating_transform); | 2430 animating_transform); |
| 2430 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 2431 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), page_scale * device_scale); |
| 2431 | 2432 |
| 2432 // Once we stop animating, a new high-res tiling should be created. | 2433 // Once we stop animating, a new high-res tiling should be created. |
| 2433 animating_transform = false; | 2434 animating_transform = false; |
| 2434 contents_scale = 11.f; | 2435 contents_scale = 11.f; |
| 2435 | 2436 |
| 2436 SetContentsScaleOnBothLayers(contents_scale, | 2437 SetContentsScaleOnBothLayers(contents_scale, |
| 2437 device_scale, | 2438 device_scale, |
| 2438 page_scale, | 2439 page_scale, |
| 2439 maximum_animation_scale, | 2440 maximum_animation_scale, |
| 2440 animating_transform); | 2441 animating_transform); |
| 2441 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2442 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
| 2442 | 2443 |
| 2443 // When animating with a maxmium animation scale factor that is so large | 2444 // When animating with a maxmium animation scale factor that is so large |
| 2444 // that the layer grows larger than the viewport at this scale, and where | 2445 // that the layer grows larger than the viewport at this scale, and where |
| 2445 // the intial source scale is < 1, a new high-res tiling should get created | 2446 // the intial source scale is < 1, a new high-res tiling should get created |
| 2446 // at source scale 1. | 2447 // at source scale 1. |
| 2447 animating_transform = true; | 2448 animating_transform = true; |
| 2448 contents_scale = 0.1f; | 2449 contents_scale = 0.1f; |
| 2449 maximum_animation_scale = 11.f; | 2450 maximum_animation_scale = 11.f; |
| 2450 | 2451 |
| 2451 SetContentsScaleOnBothLayers(contents_scale, | 2452 SetContentsScaleOnBothLayers(contents_scale, |
| 2452 device_scale, | 2453 device_scale, |
| 2453 page_scale, | 2454 page_scale, |
| 2454 maximum_animation_scale, | 2455 maximum_animation_scale, |
| 2455 animating_transform); | 2456 animating_transform); |
| 2456 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); | 2457 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
| 2457 | 2458 |
| 2458 // Once we stop animating, a new high-res tiling should be created. | 2459 // Once we stop animating, a new high-res tiling should be created. |
| 2459 animating_transform = false; | 2460 animating_transform = false; |
| 2461 contents_scale = 12.f; |
| 2462 |
| 2463 SetContentsScaleOnBothLayers(contents_scale, |
| 2464 device_scale, |
| 2465 page_scale, |
| 2466 maximum_animation_scale, |
| 2467 animating_transform); |
| 2468 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 12.f); |
| 2469 |
| 2470 // When animating toward a smaller scale, but that is still so large that the |
| 2471 // layer grows larger than the viewport at this scale, a new high-res tiling |
| 2472 // should get created at source scale 1. |
| 2473 animating_transform = true; |
| 2474 contents_scale = 11.f; |
| 2475 maximum_animation_scale = 11.f; |
| 2476 |
| 2477 SetContentsScaleOnBothLayers(contents_scale, |
| 2478 device_scale, |
| 2479 page_scale, |
| 2480 maximum_animation_scale, |
| 2481 animating_transform); |
| 2482 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), device_scale * page_scale); |
| 2483 |
| 2484 // Once we stop animating, a new high-res tiling should be created. |
| 2485 animating_transform = false; |
| 2460 contents_scale = 11.f; | 2486 contents_scale = 11.f; |
| 2461 | 2487 |
| 2462 SetContentsScaleOnBothLayers(contents_scale, | 2488 SetContentsScaleOnBothLayers(contents_scale, |
| 2463 device_scale, | 2489 device_scale, |
| 2464 page_scale, | 2490 page_scale, |
| 2465 maximum_animation_scale, | 2491 maximum_animation_scale, |
| 2466 animating_transform); | 2492 animating_transform); |
| 2467 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); | 2493 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 11.f); |
| 2468 } | 2494 } |
| 2469 | 2495 |
| (...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4487 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4513 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4488 EXPECT_EQ(result.width(), 448); | 4514 EXPECT_EQ(result.width(), 448); |
| 4489 EXPECT_EQ(result.height(), 448); | 4515 EXPECT_EQ(result.height(), 448); |
| 4490 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4516 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4491 EXPECT_EQ(result.width(), 512); | 4517 EXPECT_EQ(result.width(), 512); |
| 4492 EXPECT_EQ(result.height(), 500); | 4518 EXPECT_EQ(result.height(), 500); |
| 4493 } | 4519 } |
| 4494 | 4520 |
| 4495 } // namespace | 4521 } // namespace |
| 4496 } // namespace cc | 4522 } // namespace cc |
| OLD | NEW |