| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 7318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7329 | 7329 |
| 7330 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), | 7330 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), |
| 7331 gfx::PointF(), gfx::Size(1, 2), true, false, | 7331 gfx::PointF(), gfx::Size(1, 2), true, false, |
| 7332 false); | 7332 false); |
| 7333 | 7333 |
| 7334 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); | 7334 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); |
| 7335 | 7335 |
| 7336 ExecuteCalculateDrawProperties(grand_parent_raw); | 7336 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7337 | 7337 |
| 7338 // No layers have animations. | 7338 // No layers have animations. |
| 7339 EXPECT_EQ( | 7339 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7340 0.f, | 7340 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7341 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7341 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7342 EXPECT_EQ(0.f, | 7342 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7343 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7344 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7345 EXPECT_EQ( | |
| 7346 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7347 | 7343 |
| 7348 EXPECT_EQ( | 7344 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7349 0.f, | 7345 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7350 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7346 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7351 EXPECT_EQ(0.f, | 7347 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7352 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7353 EXPECT_EQ(0.f, | |
| 7354 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7355 EXPECT_EQ( | |
| 7356 0.f, | |
| 7357 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7358 | 7348 |
| 7359 TransformOperations translation; | 7349 TransformOperations translation; |
| 7360 translation.AppendTranslate(1.f, 2.f, 3.f); | 7350 translation.AppendTranslate(1.f, 2.f, 3.f); |
| 7361 | 7351 |
| 7362 scoped_refptr<AnimationTimeline> timeline; | 7352 scoped_refptr<AnimationTimeline> timeline; |
| 7363 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7353 timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7364 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7354 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7365 | 7355 |
| 7366 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7356 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
| 7367 TransformOperations(), translation); | 7357 TransformOperations(), translation); |
| 7368 | 7358 |
| 7369 // No layers have scale-affecting animations. | 7359 // No layers have scale-affecting animations. |
| 7370 EXPECT_EQ( | 7360 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7371 0.f, | 7361 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7372 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7362 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7373 EXPECT_EQ(0.f, | 7363 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7374 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7375 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7376 EXPECT_EQ( | |
| 7377 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7378 | 7364 |
| 7379 EXPECT_EQ( | 7365 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7380 0.f, | 7366 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7381 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7367 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7382 EXPECT_EQ(0.f, | 7368 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7383 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7384 EXPECT_EQ(0.f, | |
| 7385 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7386 EXPECT_EQ( | |
| 7387 0.f, | |
| 7388 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7389 | 7369 |
| 7390 TransformOperations scale; | 7370 TransformOperations scale; |
| 7391 scale.AppendScale(5.f, 4.f, 3.f); | 7371 scale.AppendScale(5.f, 4.f, 3.f); |
| 7392 | 7372 |
| 7393 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7373 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, |
| 7394 TransformOperations(), scale); | 7374 TransformOperations(), scale); |
| 7395 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7375 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7396 ExecuteCalculateDrawProperties(grand_parent_raw); | 7376 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7397 | 7377 |
| 7398 // Only |child| has a scale-affecting animation. | 7378 // Only |child| has a scale-affecting animation. |
| 7399 EXPECT_EQ( | 7379 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7400 0.f, | 7380 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7401 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7381 EXPECT_EQ(5.f, GetMaximumAnimationScale(child_raw)); |
| 7402 EXPECT_EQ(0.f, | 7382 EXPECT_EQ(5.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7403 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7404 EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7405 EXPECT_EQ( | |
| 7406 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7407 | 7383 |
| 7408 EXPECT_EQ( | 7384 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7409 0.f, | 7385 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7410 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7386 EXPECT_EQ(1.f, GetStartingAnimationScale(child_raw)); |
| 7411 EXPECT_EQ(0.f, | 7387 EXPECT_EQ(1.f, GetStartingAnimationScale(grand_child_raw)); |
| 7412 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7413 EXPECT_EQ(1.f, | |
| 7414 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7415 EXPECT_EQ( | |
| 7416 1.f, | |
| 7417 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7418 | 7388 |
| 7419 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, | 7389 AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0, |
| 7420 TransformOperations(), scale); | 7390 TransformOperations(), scale); |
| 7421 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7391 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7422 ExecuteCalculateDrawProperties(grand_parent_raw); | 7392 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7423 | 7393 |
| 7424 // |grand_parent| and |child| have scale-affecting animations. | 7394 // |grand_parent| and |child| have scale-affecting animations. |
| 7425 EXPECT_EQ( | 7395 EXPECT_EQ(5.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7426 5.f, | 7396 EXPECT_EQ(5.f, GetMaximumAnimationScale(parent_raw)); |
| 7427 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7428 EXPECT_EQ(5.f, | |
| 7429 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7430 // We don't support combining animated scales from two nodes; 0.f means | 7397 // We don't support combining animated scales from two nodes; 0.f means |
| 7431 // that the maximum scale could not be computed. | 7398 // that the maximum scale could not be computed. |
| 7432 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | 7399 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7433 EXPECT_EQ( | 7400 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7434 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7435 | 7401 |
| 7436 EXPECT_EQ( | 7402 EXPECT_EQ(1.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7437 1.f, | 7403 EXPECT_EQ(1.f, GetStartingAnimationScale(parent_raw)); |
| 7438 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7404 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7439 EXPECT_EQ(1.f, | 7405 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7440 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7441 EXPECT_EQ(0.f, | |
| 7442 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7443 EXPECT_EQ( | |
| 7444 0.f, | |
| 7445 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7446 | 7406 |
| 7447 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7407 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
| 7448 TransformOperations(), scale); | 7408 TransformOperations(), scale); |
| 7449 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7409 parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7450 ExecuteCalculateDrawProperties(grand_parent_raw); | 7410 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7451 | 7411 |
| 7452 // |grand_parent|, |parent|, and |child| have scale-affecting animations. | 7412 // |grand_parent|, |parent|, and |child| have scale-affecting animations. |
| 7453 EXPECT_EQ( | 7413 EXPECT_EQ(5.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7454 5.f, | 7414 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7455 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7415 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7456 EXPECT_EQ(0.f, | 7416 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7457 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7458 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7459 EXPECT_EQ( | |
| 7460 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7461 | 7417 |
| 7462 EXPECT_EQ( | 7418 EXPECT_EQ(1.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7463 1.f, | 7419 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7464 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7420 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7465 EXPECT_EQ(0.f, | 7421 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7466 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7467 EXPECT_EQ(0.f, | |
| 7468 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7469 EXPECT_EQ( | |
| 7470 0.f, | |
| 7471 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7472 | 7422 |
| 7473 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, | 7423 AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline, |
| 7474 TargetProperty::TRANSFORM); | 7424 TargetProperty::TRANSFORM); |
| 7475 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, | 7425 AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, |
| 7476 TargetProperty::TRANSFORM); | 7426 TargetProperty::TRANSFORM); |
| 7477 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7427 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, |
| 7478 TargetProperty::TRANSFORM); | 7428 TargetProperty::TRANSFORM); |
| 7479 | 7429 |
| 7480 TransformOperations perspective; | 7430 TransformOperations perspective; |
| 7481 perspective.AppendPerspective(10.f); | 7431 perspective.AppendPerspective(10.f); |
| 7482 | 7432 |
| 7483 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, | 7433 AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, |
| 7484 TransformOperations(), perspective); | 7434 TransformOperations(), perspective); |
| 7485 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7435 child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7486 ExecuteCalculateDrawProperties(grand_parent_raw); | 7436 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7487 | 7437 |
| 7488 // |child| has a scale-affecting animation but computing the maximum of this | 7438 // |child| has a scale-affecting animation but computing the maximum of this |
| 7489 // animation is not supported. | 7439 // animation is not supported. |
| 7490 EXPECT_EQ( | 7440 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7491 0.f, | 7441 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7492 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7442 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7493 EXPECT_EQ(0.f, | 7443 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7494 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7495 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7496 EXPECT_EQ( | |
| 7497 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7498 | 7444 |
| 7499 EXPECT_EQ( | 7445 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7500 0.f, | 7446 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7501 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7447 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7502 EXPECT_EQ(0.f, | 7448 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7503 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7504 EXPECT_EQ(0.f, | |
| 7505 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7506 EXPECT_EQ( | |
| 7507 0.f, | |
| 7508 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7509 | 7449 |
| 7510 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, | 7450 AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, |
| 7511 TargetProperty::TRANSFORM); | 7451 TargetProperty::TRANSFORM); |
| 7512 gfx::Transform scale_matrix; | 7452 gfx::Transform scale_matrix; |
| 7513 scale_matrix.Scale(1.f, 2.f); | 7453 scale_matrix.Scale(1.f, 2.f); |
| 7514 grand_parent_raw->SetTransform(scale_matrix); | 7454 grand_parent_raw->SetTransform(scale_matrix); |
| 7515 parent_raw->SetTransform(scale_matrix); | 7455 parent_raw->SetTransform(scale_matrix); |
| 7516 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7456 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7517 | 7457 |
| 7518 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, | 7458 AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, |
| 7519 TransformOperations(), scale); | 7459 TransformOperations(), scale); |
| 7520 ExecuteCalculateDrawProperties(grand_parent_raw); | 7460 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7521 | 7461 |
| 7522 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7462 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
| 7523 // animation with maximum scale 5.f. | 7463 // animation with maximum scale 5.f. |
| 7524 EXPECT_EQ( | 7464 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7525 0.f, | 7465 EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw)); |
| 7526 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7466 EXPECT_EQ(10.f, GetMaximumAnimationScale(child_raw)); |
| 7527 EXPECT_EQ(10.f, | 7467 EXPECT_EQ(10.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7528 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7529 EXPECT_EQ(10.f, | |
| 7530 child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7531 EXPECT_EQ( | |
| 7532 10.f, | |
| 7533 grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7534 | 7468 |
| 7535 EXPECT_EQ( | 7469 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7536 0.f, | 7470 EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw)); |
| 7537 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7471 EXPECT_EQ(2.f, GetStartingAnimationScale(child_raw)); |
| 7538 EXPECT_EQ(2.f, | 7472 EXPECT_EQ(2.f, GetStartingAnimationScale(grand_child_raw)); |
| 7539 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7540 EXPECT_EQ(2.f, | |
| 7541 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7542 EXPECT_EQ( | |
| 7543 2.f, | |
| 7544 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7545 | 7473 |
| 7546 gfx::Transform perspective_matrix; | 7474 gfx::Transform perspective_matrix; |
| 7547 perspective_matrix.ApplyPerspectiveDepth(2.f); | 7475 perspective_matrix.ApplyPerspectiveDepth(2.f); |
| 7548 child_raw->SetTransform(perspective_matrix); | 7476 child_raw->SetTransform(perspective_matrix); |
| 7549 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7477 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7550 ExecuteCalculateDrawProperties(grand_parent_raw); | 7478 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7551 | 7479 |
| 7552 // |child| has a transform that's neither a translation nor a scale. | 7480 // |child| has a transform that's neither a translation nor a scale. |
| 7553 EXPECT_EQ( | 7481 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7554 0.f, | 7482 EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw)); |
| 7555 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7483 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7556 EXPECT_EQ(10.f, | 7484 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7557 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7558 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7559 EXPECT_EQ( | |
| 7560 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7561 | 7485 |
| 7562 EXPECT_EQ( | 7486 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7563 0.f, | 7487 EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw)); |
| 7564 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7488 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7565 EXPECT_EQ(2.f, | 7489 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7566 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7567 EXPECT_EQ(0.f, | |
| 7568 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7569 EXPECT_EQ( | |
| 7570 0.f, | |
| 7571 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7572 | 7490 |
| 7573 parent_raw->SetTransform(perspective_matrix); | 7491 parent_raw->SetTransform(perspective_matrix); |
| 7574 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7492 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7575 ExecuteCalculateDrawProperties(grand_parent_raw); | 7493 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7576 | 7494 |
| 7577 // |parent| and |child| have transforms that are neither translations nor | 7495 // |parent| and |child| have transforms that are neither translations nor |
| 7578 // scales. | 7496 // scales. |
| 7579 EXPECT_EQ( | 7497 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7580 0.f, | 7498 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7581 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7499 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7582 EXPECT_EQ(0.f, | 7500 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7583 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7584 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7585 EXPECT_EQ( | |
| 7586 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7587 | 7501 |
| 7588 EXPECT_EQ( | 7502 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7589 0.f, | 7503 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7590 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7504 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7591 EXPECT_EQ(0.f, | 7505 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7592 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7593 EXPECT_EQ(0.f, | |
| 7594 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7595 EXPECT_EQ( | |
| 7596 0.f, | |
| 7597 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7598 | 7506 |
| 7599 parent_raw->SetTransform(identity_matrix); | 7507 parent_raw->SetTransform(identity_matrix); |
| 7600 child_raw->SetTransform(identity_matrix); | 7508 child_raw->SetTransform(identity_matrix); |
| 7601 grand_parent_raw->SetTransform(perspective_matrix); | 7509 grand_parent_raw->SetTransform(perspective_matrix); |
| 7602 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7510 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7603 | 7511 |
| 7604 ExecuteCalculateDrawProperties(grand_parent_raw); | 7512 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7605 | 7513 |
| 7606 // |grand_parent| has a transform that's neither a translation nor a scale. | 7514 // |grand_parent| has a transform that's neither a translation nor a scale. |
| 7607 EXPECT_EQ( | 7515 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7608 0.f, | 7516 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7609 grand_parent_raw->draw_properties().maximum_animation_contents_scale); | 7517 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7610 EXPECT_EQ(0.f, | 7518 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7611 parent_raw->draw_properties().maximum_animation_contents_scale); | |
| 7612 EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7613 EXPECT_EQ( | |
| 7614 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale); | |
| 7615 | 7519 |
| 7616 EXPECT_EQ( | 7520 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7617 0.f, | 7521 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7618 grand_parent_raw->draw_properties().starting_animation_contents_scale); | 7522 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7619 EXPECT_EQ(0.f, | 7523 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7620 parent_raw->draw_properties().starting_animation_contents_scale); | |
| 7621 EXPECT_EQ(0.f, | |
| 7622 child_raw->draw_properties().starting_animation_contents_scale); | |
| 7623 EXPECT_EQ( | |
| 7624 0.f, | |
| 7625 grand_child_raw->draw_properties().starting_animation_contents_scale); | |
| 7626 } | 7524 } |
| 7627 | 7525 |
| 7628 static void GatherDrawnLayers(LayerImplList* rsll, | 7526 static void GatherDrawnLayers(LayerImplList* rsll, |
| 7629 std::set<LayerImpl*>* drawn_layers) { | 7527 std::set<LayerImpl*>* drawn_layers) { |
| 7630 for (LayerIterator it = LayerIterator::Begin(rsll), | 7528 for (LayerIterator it = LayerIterator::Begin(rsll), |
| 7631 end = LayerIterator::End(rsll); | 7529 end = LayerIterator::End(rsll); |
| 7632 it != end; ++it) { | 7530 it != end; ++it) { |
| 7633 LayerImpl* layer = *it; | 7531 LayerImpl* layer = *it; |
| 7634 if (it.represents_itself()) | 7532 if (it.represents_itself()) |
| 7635 drawn_layers->insert(layer); | 7533 drawn_layers->insert(layer); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7967 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7865 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7968 ExecuteCalculateDrawProperties(root_layer); | 7866 ExecuteCalculateDrawProperties(root_layer); |
| 7969 | 7867 |
| 7970 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7868 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
| 7971 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 7869 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
| 7972 EXPECT_FLOAT_EQ( | 7870 EXPECT_FLOAT_EQ( |
| 7973 3.f, | 7871 3.f, |
| 7974 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); | 7872 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); |
| 7975 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); | 7873 EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale()); |
| 7976 | 7874 |
| 7977 EXPECT_FLOAT_EQ( | 7875 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
| 7978 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | 7876 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
| 7979 EXPECT_FLOAT_EQ( | 7877 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); |
| 7980 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
| 7981 EXPECT_FLOAT_EQ( | |
| 7982 8.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
| 7983 | 7878 |
| 7984 // Changing page-scale would affect ideal_contents_scale and | 7879 // Changing page-scale would affect ideal_contents_scale and |
| 7985 // maximum_animation_contents_scale. | 7880 // maximum_animation_contents_scale. |
| 7986 | 7881 |
| 7987 float page_scale_factor = 3.f; | 7882 float page_scale_factor = 3.f; |
| 7988 float device_scale_factor = 1.0f; | 7883 float device_scale_factor = 1.0f; |
| 7989 std::vector<LayerImpl*> render_surface_layer_list; | 7884 std::vector<LayerImpl*> render_surface_layer_list; |
| 7990 gfx::Size device_viewport_size = | 7885 gfx::Size device_viewport_size = |
| 7991 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 7886 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 7992 root_layer->bounds().height() * device_scale_factor); | 7887 root_layer->bounds().height() * device_scale_factor); |
| 7993 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7888 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7994 root_layer, device_viewport_size, &render_surface_layer_list); | 7889 root_layer, device_viewport_size, &render_surface_layer_list); |
| 7995 | 7890 |
| 7996 inputs.page_scale_factor = page_scale_factor; | 7891 inputs.page_scale_factor = page_scale_factor; |
| 7997 inputs.can_adjust_raster_scales = true; | 7892 inputs.can_adjust_raster_scales = true; |
| 7998 inputs.page_scale_layer = root_layer; | 7893 inputs.page_scale_layer = root_layer; |
| 7999 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7894 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 8000 | 7895 |
| 8001 EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale()); | 7896 EXPECT_FLOAT_EQ(3.f, root_layer->GetIdealContentsScale()); |
| 8002 EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale()); | 7897 EXPECT_FLOAT_EQ(9.f, child1_layer->GetIdealContentsScale()); |
| 8003 EXPECT_FLOAT_EQ( | 7898 EXPECT_FLOAT_EQ( |
| 8004 9.f, | 7899 9.f, |
| 8005 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); | 7900 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); |
| 8006 EXPECT_FLOAT_EQ(9.f, child1_layer->test_properties() | 7901 EXPECT_FLOAT_EQ(9.f, child1_layer->test_properties() |
| 8007 ->replica_layer->test_properties() | 7902 ->replica_layer->test_properties() |
| 8008 ->mask_layer->GetIdealContentsScale()); | 7903 ->mask_layer->GetIdealContentsScale()); |
| 8009 EXPECT_FLOAT_EQ(15.f, child2_layer->GetIdealContentsScale()); | 7904 EXPECT_FLOAT_EQ(15.f, child2_layer->GetIdealContentsScale()); |
| 8010 | 7905 |
| 8011 EXPECT_FLOAT_EQ( | 7906 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
| 8012 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | 7907 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
| 8013 EXPECT_FLOAT_EQ( | 7908 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); |
| 8014 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
| 8015 EXPECT_FLOAT_EQ( | |
| 8016 24.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
| 8017 | 7909 |
| 8018 // Changing device-scale would affect ideal_contents_scale and | 7910 // Changing device-scale would affect ideal_contents_scale and |
| 8019 // maximum_animation_contents_scale. | 7911 // maximum_animation_contents_scale. |
| 8020 | 7912 |
| 8021 device_scale_factor = 4.0f; | 7913 device_scale_factor = 4.0f; |
| 8022 inputs.device_scale_factor = device_scale_factor; | 7914 inputs.device_scale_factor = device_scale_factor; |
| 8023 inputs.can_adjust_raster_scales = true; | 7915 inputs.can_adjust_raster_scales = true; |
| 8024 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7916 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8025 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7917 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 8026 | 7918 |
| 8027 EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale()); | 7919 EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale()); |
| 8028 EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale()); | 7920 EXPECT_FLOAT_EQ(36.f, child1_layer->GetIdealContentsScale()); |
| 8029 EXPECT_FLOAT_EQ( | 7921 EXPECT_FLOAT_EQ( |
| 8030 36.f, | 7922 36.f, |
| 8031 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); | 7923 child1_layer->test_properties()->mask_layer->GetIdealContentsScale()); |
| 8032 EXPECT_FLOAT_EQ(36.f, child1_layer->test_properties() | 7924 EXPECT_FLOAT_EQ(36.f, child1_layer->test_properties() |
| 8033 ->replica_layer->test_properties() | 7925 ->replica_layer->test_properties() |
| 8034 ->mask_layer->GetIdealContentsScale()); | 7926 ->mask_layer->GetIdealContentsScale()); |
| 8035 EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale()); | 7927 EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale()); |
| 8036 | 7928 |
| 8037 EXPECT_FLOAT_EQ( | 7929 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
| 8038 0.f, root_layer->draw_properties().maximum_animation_contents_scale); | 7930 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
| 8039 EXPECT_FLOAT_EQ( | 7931 EXPECT_FLOAT_EQ(96.f, GetMaximumAnimationScale(child2_layer)); |
| 8040 0.f, child1_layer->draw_properties().maximum_animation_contents_scale); | |
| 8041 EXPECT_FLOAT_EQ( | |
| 8042 96.f, child2_layer->draw_properties().maximum_animation_contents_scale); | |
| 8043 } | 7932 } |
| 8044 | 7933 |
| 8045 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { | 7934 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { |
| 8046 LayerImpl* root = root_layer_for_testing(); | 7935 LayerImpl* root = root_layer_for_testing(); |
| 8047 LayerImpl* clip = AddChild<LayerImpl>(root); | 7936 LayerImpl* clip = AddChild<LayerImpl>(root); |
| 8048 LayerImpl* content = AddChild<LayerImpl>(clip); | 7937 LayerImpl* content = AddChild<LayerImpl>(clip); |
| 8049 | 7938 |
| 8050 const gfx::Transform identity_matrix; | 7939 const gfx::Transform identity_matrix; |
| 8051 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 7940 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 8052 gfx::PointF(), gfx::Size(768 / 2, 3000), true, | 7941 gfx::PointF(), gfx::Size(768 / 2, 3000), true, |
| (...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10327 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10216 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10328 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10217 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10329 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10218 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10330 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10219 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10331 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10220 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10332 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10221 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10333 } | 10222 } |
| 10334 | 10223 |
| 10335 } // namespace | 10224 } // namespace |
| 10336 } // namespace cc | 10225 } // namespace cc |
| OLD | NEW |