| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 2985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 class PushPropertiesCountingLayer : public Layer { | 2996 class PushPropertiesCountingLayer : public Layer { |
| 2997 public: | 2997 public: |
| 2998 static scoped_refptr<PushPropertiesCountingLayer> Create() { | 2998 static scoped_refptr<PushPropertiesCountingLayer> Create() { |
| 2999 return new PushPropertiesCountingLayer(); | 2999 return new PushPropertiesCountingLayer(); |
| 3000 } | 3000 } |
| 3001 | 3001 |
| 3002 void PushPropertiesTo(LayerImpl* layer) override { | 3002 void PushPropertiesTo(LayerImpl* layer) override { |
| 3003 Layer::PushPropertiesTo(layer); | 3003 Layer::PushPropertiesTo(layer); |
| 3004 push_properties_count_++; | 3004 push_properties_count_++; |
| 3005 if (persist_needs_push_properties_) { | 3005 if (persist_needs_push_properties_) { |
| 3006 layer_tree_host()->AddLayerShouldPushProperties(this); | 3006 layer_tree_host()->GetLayerTree()->AddLayerShouldPushProperties(this); |
| 3007 } | 3007 } |
| 3008 } | 3008 } |
| 3009 | 3009 |
| 3010 // Something to make this layer push properties, but no other layer. | 3010 // Something to make this layer push properties, but no other layer. |
| 3011 void MakePushProperties() { SetContentsOpaque(!contents_opaque()); } | 3011 void MakePushProperties() { SetContentsOpaque(!contents_opaque()); } |
| 3012 | 3012 |
| 3013 std::unique_ptr<LayerImpl> CreateLayerImpl( | 3013 std::unique_ptr<LayerImpl> CreateLayerImpl( |
| 3014 LayerTreeImpl* tree_impl) override { | 3014 LayerTreeImpl* tree_impl) override { |
| 3015 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); | 3015 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); |
| 3016 } | 3016 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 other_root_->push_properties_count()) | 3083 other_root_->push_properties_count()) |
| 3084 << "num_commits: " << num_commits_; | 3084 << "num_commits: " << num_commits_; |
| 3085 EXPECT_EQ(expected_push_properties_leaf_layer_, | 3085 EXPECT_EQ(expected_push_properties_leaf_layer_, |
| 3086 leaf_always_pushing_layer_->push_properties_count()) | 3086 leaf_always_pushing_layer_->push_properties_count()) |
| 3087 << "num_commits: " << num_commits_; | 3087 << "num_commits: " << num_commits_; |
| 3088 | 3088 |
| 3089 ++num_commits_; | 3089 ++num_commits_; |
| 3090 | 3090 |
| 3091 // The scrollbar layer always needs to be pushed. | 3091 // The scrollbar layer always needs to be pushed. |
| 3092 if (root_->layer_tree_host()) { | 3092 if (root_->layer_tree_host()) { |
| 3093 EXPECT_FALSE(root_->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3093 EXPECT_FALSE(root_->layer_tree_host() |
| 3094 root_.get())); | 3094 ->GetLayerTree() |
| 3095 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3095 } | 3096 } |
| 3096 if (child2_->layer_tree_host()) { | 3097 if (child2_->layer_tree_host()) { |
| 3097 EXPECT_FALSE( | 3098 EXPECT_FALSE(child2_->layer_tree_host() |
| 3098 child2_->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3099 ->GetLayerTree() |
| 3099 child2_.get())); | 3100 ->LayerNeedsPushPropertiesForTesting(child2_.get())); |
| 3100 } | 3101 } |
| 3101 if (leaf_always_pushing_layer_->layer_tree_host()) { | 3102 if (leaf_always_pushing_layer_->layer_tree_host()) { |
| 3102 EXPECT_TRUE(leaf_always_pushing_layer_->layer_tree_host() | 3103 EXPECT_TRUE(leaf_always_pushing_layer_->layer_tree_host() |
| 3104 ->GetLayerTree() |
| 3103 ->LayerNeedsPushPropertiesForTesting( | 3105 ->LayerNeedsPushPropertiesForTesting( |
| 3104 leaf_always_pushing_layer_.get())); | 3106 leaf_always_pushing_layer_.get())); |
| 3105 } | 3107 } |
| 3106 | 3108 |
| 3107 // child_ and grandchild_ don't persist their need to push properties. | 3109 // child_ and grandchild_ don't persist their need to push properties. |
| 3108 if (child_->layer_tree_host()) { | 3110 if (child_->layer_tree_host()) { |
| 3109 EXPECT_FALSE( | 3111 EXPECT_FALSE(child_->layer_tree_host() |
| 3110 child_->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3112 ->GetLayerTree() |
| 3111 child_.get())); | 3113 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3112 } | 3114 } |
| 3113 if (grandchild_->layer_tree_host()) { | 3115 if (grandchild_->layer_tree_host()) { |
| 3114 EXPECT_FALSE( | 3116 EXPECT_FALSE(grandchild_->layer_tree_host() |
| 3115 grandchild_->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3117 ->GetLayerTree() |
| 3116 grandchild_.get())); | 3118 ->LayerNeedsPushPropertiesForTesting(grandchild_.get())); |
| 3117 } | 3119 } |
| 3118 | 3120 |
| 3119 if (other_root_->layer_tree_host()) { | 3121 if (other_root_->layer_tree_host()) { |
| 3120 EXPECT_FALSE( | 3122 EXPECT_FALSE(other_root_->layer_tree_host() |
| 3121 other_root_->layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3123 ->GetLayerTree() |
| 3122 other_root_.get())); | 3124 ->LayerNeedsPushPropertiesForTesting(other_root_.get())); |
| 3123 } | 3125 } |
| 3124 | 3126 |
| 3125 switch (num_commits_) { | 3127 switch (num_commits_) { |
| 3126 case 1: | 3128 case 1: |
| 3127 layer_tree_host()->SetRootLayer(root_); | 3129 layer_tree_host()->SetRootLayer(root_); |
| 3128 // Layers added to the tree get committed. | 3130 // Layers added to the tree get committed. |
| 3129 ++expected_push_properties_root_; | 3131 ++expected_push_properties_root_; |
| 3130 ++expected_push_properties_child_; | 3132 ++expected_push_properties_child_; |
| 3131 ++expected_push_properties_grandchild_; | 3133 ++expected_push_properties_grandchild_; |
| 3132 ++expected_push_properties_child2_; | 3134 ++expected_push_properties_child2_; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3463 case 1: { | 3465 case 1: { |
| 3464 // During update, the ignore_set_needs_commit_ bit is set to true to | 3466 // During update, the ignore_set_needs_commit_ bit is set to true to |
| 3465 // avoid causing a second commit to be scheduled. If a property change | 3467 // avoid causing a second commit to be scheduled. If a property change |
| 3466 // is made during this, however, it needs to be pushed in the upcoming | 3468 // is made during this, however, it needs to be pushed in the upcoming |
| 3467 // commit. | 3469 // commit. |
| 3468 std::unique_ptr<base::AutoReset<bool>> ignore = | 3470 std::unique_ptr<base::AutoReset<bool>> ignore = |
| 3469 scrollbar_layer_->IgnoreSetNeedsCommit(); | 3471 scrollbar_layer_->IgnoreSetNeedsCommit(); |
| 3470 | 3472 |
| 3471 scrollbar_layer_->SetBounds(gfx::Size(30, 30)); | 3473 scrollbar_layer_->SetBounds(gfx::Size(30, 30)); |
| 3472 | 3474 |
| 3473 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3475 EXPECT_TRUE( |
| 3474 scrollbar_layer_.get())); | 3476 layer_tree_host() |
| 3477 ->GetLayerTree() |
| 3478 ->LayerNeedsPushPropertiesForTesting(scrollbar_layer_.get())); |
| 3475 layer_tree_host()->SetNeedsCommit(); | 3479 layer_tree_host()->SetNeedsCommit(); |
| 3476 | 3480 |
| 3477 scrollbar_layer_->reset_push_properties_count(); | 3481 scrollbar_layer_->reset_push_properties_count(); |
| 3478 EXPECT_EQ(0u, scrollbar_layer_->push_properties_count()); | 3482 EXPECT_EQ(0u, scrollbar_layer_->push_properties_count()); |
| 3479 break; | 3483 break; |
| 3480 } | 3484 } |
| 3481 case 2: | 3485 case 2: |
| 3482 EXPECT_EQ(1u, scrollbar_layer_->push_properties_count()); | 3486 EXPECT_EQ(1u, scrollbar_layer_->push_properties_count()); |
| 3483 EndTest(); | 3487 EndTest(); |
| 3484 break; | 3488 break; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3500 void SetupTree() override { | 3504 void SetupTree() override { |
| 3501 root_ = PushPropertiesCountingLayer::Create(); | 3505 root_ = PushPropertiesCountingLayer::Create(); |
| 3502 child_ = PushPropertiesCountingLayer::Create(); | 3506 child_ = PushPropertiesCountingLayer::Create(); |
| 3503 root_->AddChild(child_); | 3507 root_->AddChild(child_); |
| 3504 | 3508 |
| 3505 layer_tree_host()->SetRootLayer(root_); | 3509 layer_tree_host()->SetRootLayer(root_); |
| 3506 LayerTreeHostTest::SetupTree(); | 3510 LayerTreeHostTest::SetupTree(); |
| 3507 } | 3511 } |
| 3508 | 3512 |
| 3509 void DidCommitAndDrawFrame() override { | 3513 void DidCommitAndDrawFrame() override { |
| 3514 LayerTree* layer_tree = layer_tree_host()->GetLayerTree(); |
| 3510 switch (layer_tree_host()->source_frame_number()) { | 3515 switch (layer_tree_host()->source_frame_number()) { |
| 3511 case 0: | 3516 case 0: |
| 3512 break; | 3517 break; |
| 3513 case 1: { | 3518 case 1: { |
| 3514 // During update, the ignore_set_needs_commit_ bit is set to true to | 3519 // During update, the ignore_set_needs_commit_ bit is set to true to |
| 3515 // avoid causing a second commit to be scheduled. If a property change | 3520 // avoid causing a second commit to be scheduled. If a property change |
| 3516 // is made during this, however, it needs to be pushed in the upcoming | 3521 // is made during this, however, it needs to be pushed in the upcoming |
| 3517 // commit. | 3522 // commit. |
| 3518 EXPECT_FALSE( | 3523 EXPECT_FALSE( |
| 3519 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3524 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3520 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3525 EXPECT_FALSE( |
| 3521 child_.get())); | 3526 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3522 EXPECT_EQ(0, root_->NumDescendantsThatDrawContent()); | 3527 EXPECT_EQ(0, root_->NumDescendantsThatDrawContent()); |
| 3523 root_->reset_push_properties_count(); | 3528 root_->reset_push_properties_count(); |
| 3524 child_->reset_push_properties_count(); | 3529 child_->reset_push_properties_count(); |
| 3525 child_->SetDrawsContent(true); | 3530 child_->SetDrawsContent(true); |
| 3526 EXPECT_EQ(1, root_->NumDescendantsThatDrawContent()); | 3531 EXPECT_EQ(1, root_->NumDescendantsThatDrawContent()); |
| 3527 EXPECT_EQ(0u, root_->push_properties_count()); | 3532 EXPECT_EQ(0u, root_->push_properties_count()); |
| 3528 EXPECT_EQ(0u, child_->push_properties_count()); | 3533 EXPECT_EQ(0u, child_->push_properties_count()); |
| 3529 EXPECT_TRUE( | 3534 EXPECT_TRUE( |
| 3530 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3535 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3531 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3536 EXPECT_TRUE( |
| 3532 child_.get())); | 3537 |
| 3538 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3533 break; | 3539 break; |
| 3534 } | 3540 } |
| 3535 case 2: | 3541 case 2: |
| 3536 EXPECT_EQ(1u, root_->push_properties_count()); | 3542 EXPECT_EQ(1u, root_->push_properties_count()); |
| 3537 EXPECT_EQ(1u, child_->push_properties_count()); | 3543 EXPECT_EQ(1u, child_->push_properties_count()); |
| 3538 EXPECT_FALSE( | 3544 EXPECT_FALSE( |
| 3539 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3545 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3540 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3546 EXPECT_FALSE( |
| 3541 child_.get())); | 3547 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3542 EndTest(); | 3548 EndTest(); |
| 3543 break; | 3549 break; |
| 3544 } | 3550 } |
| 3545 } | 3551 } |
| 3546 | 3552 |
| 3547 void AfterTest() override {} | 3553 void AfterTest() override {} |
| 3548 | 3554 |
| 3549 scoped_refptr<PushPropertiesCountingLayer> root_; | 3555 scoped_refptr<PushPropertiesCountingLayer> root_; |
| 3550 scoped_refptr<PushPropertiesCountingLayer> child_; | 3556 scoped_refptr<PushPropertiesCountingLayer> child_; |
| 3551 }; | 3557 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3598 | 3604 |
| 3599 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush | 3605 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush |
| 3600 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { | 3606 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { |
| 3601 protected: | 3607 protected: |
| 3602 void DidCommitAndDrawFrame() override { | 3608 void DidCommitAndDrawFrame() override { |
| 3603 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; | 3609 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; |
| 3604 switch (last_source_frame_number) { | 3610 switch (last_source_frame_number) { |
| 3605 case 0: | 3611 case 0: |
| 3606 // All layers will need push properties as we set their layer tree host | 3612 // All layers will need push properties as we set their layer tree host |
| 3607 layer_tree_host()->SetRootLayer(root_); | 3613 layer_tree_host()->SetRootLayer(root_); |
| 3614 EXPECT_TRUE(layer_tree_host() |
| 3615 ->GetLayerTree() |
| 3616 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3617 EXPECT_TRUE(layer_tree_host() |
| 3618 ->GetLayerTree() |
| 3619 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3608 EXPECT_TRUE( | 3620 EXPECT_TRUE( |
| 3609 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3621 layer_tree_host() |
| 3610 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3622 ->GetLayerTree() |
| 3611 child_.get())); | 3623 ->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3612 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3624 EXPECT_TRUE( |
| 3613 grandchild1_.get())); | 3625 layer_tree_host() |
| 3614 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3626 ->GetLayerTree() |
| 3615 grandchild2_.get())); | 3627 ->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3616 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3628 EXPECT_TRUE( |
| 3617 grandchild3_.get())); | 3629 layer_tree_host() |
| 3630 ->GetLayerTree() |
| 3631 ->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3618 break; | 3632 break; |
| 3619 case 1: | 3633 case 1: |
| 3620 EndTest(); | 3634 EndTest(); |
| 3621 break; | 3635 break; |
| 3622 } | 3636 } |
| 3623 } | 3637 } |
| 3624 }; | 3638 }; |
| 3625 | 3639 |
| 3626 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush); | 3640 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush); |
| 3627 | 3641 |
| 3628 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion | 3642 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion |
| 3629 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { | 3643 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { |
| 3630 protected: | 3644 protected: |
| 3631 void DidCommitAndDrawFrame() override { | 3645 void DidCommitAndDrawFrame() override { |
| 3632 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; | 3646 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; |
| 3633 switch (last_source_frame_number) { | 3647 switch (last_source_frame_number) { |
| 3634 case 0: | 3648 case 0: |
| 3635 layer_tree_host()->SetRootLayer(root_); | 3649 layer_tree_host()->SetRootLayer(root_); |
| 3636 break; | 3650 break; |
| 3637 case 1: | 3651 case 1: |
| 3652 EXPECT_FALSE(layer_tree_host() |
| 3653 ->GetLayerTree() |
| 3654 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3655 EXPECT_FALSE(layer_tree_host() |
| 3656 ->GetLayerTree() |
| 3657 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3638 EXPECT_FALSE( | 3658 EXPECT_FALSE( |
| 3639 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3659 layer_tree_host() |
| 3640 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3660 ->GetLayerTree() |
| 3641 child_.get())); | 3661 ->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3642 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3662 EXPECT_FALSE( |
| 3643 grandchild1_.get())); | 3663 layer_tree_host() |
| 3644 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3664 ->GetLayerTree() |
| 3645 grandchild2_.get())); | 3665 ->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3646 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3666 EXPECT_FALSE( |
| 3647 grandchild3_.get())); | 3667 layer_tree_host() |
| 3668 ->GetLayerTree() |
| 3669 ->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3648 | 3670 |
| 3649 grandchild1_->RemoveFromParent(); | 3671 grandchild1_->RemoveFromParent(); |
| 3650 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); | 3672 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3651 | 3673 |
| 3674 EXPECT_FALSE(layer_tree_host() |
| 3675 ->GetLayerTree() |
| 3676 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3677 EXPECT_FALSE(layer_tree_host() |
| 3678 ->GetLayerTree() |
| 3679 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3652 EXPECT_FALSE( | 3680 EXPECT_FALSE( |
| 3653 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3681 layer_tree_host() |
| 3654 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3682 ->GetLayerTree() |
| 3655 child_.get())); | 3683 ->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3656 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3684 EXPECT_FALSE( |
| 3657 grandchild2_.get())); | 3685 layer_tree_host() |
| 3658 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3686 ->GetLayerTree() |
| 3659 grandchild3_.get())); | 3687 ->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3660 | 3688 |
| 3661 child_->AddChild(grandchild1_); | 3689 child_->AddChild(grandchild1_); |
| 3662 | 3690 |
| 3691 EXPECT_FALSE(layer_tree_host() |
| 3692 ->GetLayerTree() |
| 3693 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3694 EXPECT_FALSE(layer_tree_host() |
| 3695 ->GetLayerTree() |
| 3696 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3697 EXPECT_TRUE( |
| 3698 layer_tree_host() |
| 3699 ->GetLayerTree() |
| 3700 ->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3663 EXPECT_FALSE( | 3701 EXPECT_FALSE( |
| 3664 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3702 layer_tree_host() |
| 3665 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3703 ->GetLayerTree() |
| 3666 child_.get())); | 3704 ->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3667 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3705 EXPECT_FALSE( |
| 3668 grandchild1_.get())); | 3706 layer_tree_host() |
| 3669 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3707 ->GetLayerTree() |
| 3670 grandchild2_.get())); | 3708 ->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3671 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
| 3672 grandchild3_.get())); | |
| 3673 | 3709 |
| 3674 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); | 3710 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3675 | 3711 |
| 3712 EXPECT_FALSE(layer_tree_host() |
| 3713 ->GetLayerTree() |
| 3714 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3715 EXPECT_FALSE(layer_tree_host() |
| 3716 ->GetLayerTree() |
| 3717 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3718 EXPECT_TRUE( |
| 3719 layer_tree_host() |
| 3720 ->GetLayerTree() |
| 3721 ->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3722 EXPECT_TRUE( |
| 3723 layer_tree_host() |
| 3724 ->GetLayerTree() |
| 3725 ->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3676 EXPECT_FALSE( | 3726 EXPECT_FALSE( |
| 3677 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3727 layer_tree_host() |
| 3678 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3728 ->GetLayerTree() |
| 3679 child_.get())); | 3729 ->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3680 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
| 3681 grandchild1_.get())); | |
| 3682 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
| 3683 grandchild2_.get())); | |
| 3684 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | |
| 3685 grandchild3_.get())); | |
| 3686 | 3730 |
| 3687 // grandchild2_ will still need a push properties. | 3731 // grandchild2_ will still need a push properties. |
| 3688 grandchild1_->RemoveFromParent(); | 3732 grandchild1_->RemoveFromParent(); |
| 3689 | 3733 |
| 3690 EXPECT_FALSE( | 3734 EXPECT_FALSE(layer_tree_host() |
| 3691 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3735 ->GetLayerTree() |
| 3692 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3736 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3693 child_.get())); | 3737 EXPECT_FALSE(layer_tree_host() |
| 3738 ->GetLayerTree() |
| 3739 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3694 | 3740 |
| 3695 // grandchild3_ does not need a push properties, so recursing should | 3741 // grandchild3_ does not need a push properties, so recursing should |
| 3696 // no longer be needed. | 3742 // no longer be needed. |
| 3697 grandchild2_->RemoveFromParent(); | 3743 grandchild2_->RemoveFromParent(); |
| 3698 | 3744 |
| 3699 EXPECT_FALSE( | 3745 EXPECT_FALSE(layer_tree_host() |
| 3700 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3746 ->GetLayerTree() |
| 3701 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3747 ->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3702 child_.get())); | 3748 EXPECT_FALSE(layer_tree_host() |
| 3749 ->GetLayerTree() |
| 3750 ->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3703 EndTest(); | 3751 EndTest(); |
| 3704 break; | 3752 break; |
| 3705 } | 3753 } |
| 3706 } | 3754 } |
| 3707 }; | 3755 }; |
| 3708 | 3756 |
| 3709 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion); | 3757 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion); |
| 3710 | 3758 |
| 3711 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence | 3759 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence |
| 3712 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { | 3760 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { |
| 3713 protected: | 3761 protected: |
| 3714 void DidCommitAndDrawFrame() override { | 3762 void DidCommitAndDrawFrame() override { |
| 3763 LayerTree* layer_tree = layer_tree_host()->GetLayerTree(); |
| 3715 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; | 3764 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; |
| 3716 switch (last_source_frame_number) { | 3765 switch (last_source_frame_number) { |
| 3717 case 0: | 3766 case 0: |
| 3718 layer_tree_host()->SetRootLayer(root_); | 3767 layer_tree_host()->SetRootLayer(root_); |
| 3719 grandchild1_->set_persist_needs_push_properties(true); | 3768 grandchild1_->set_persist_needs_push_properties(true); |
| 3720 grandchild2_->set_persist_needs_push_properties(true); | 3769 grandchild2_->set_persist_needs_push_properties(true); |
| 3721 break; | 3770 break; |
| 3722 case 1: | 3771 case 1: |
| 3723 EXPECT_FALSE( | 3772 EXPECT_FALSE( |
| 3724 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3773 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3725 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3774 EXPECT_FALSE( |
| 3726 child_.get())); | 3775 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3727 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3776 EXPECT_TRUE( |
| 3728 grandchild1_.get())); | 3777 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3729 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3778 EXPECT_TRUE( |
| 3730 grandchild2_.get())); | 3779 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3731 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3780 EXPECT_FALSE( |
| 3732 grandchild3_.get())); | 3781 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3733 | 3782 |
| 3734 // grandchild2_ will still need a push properties. | 3783 // grandchild2_ will still need a push properties. |
| 3735 grandchild1_->RemoveFromParent(); | 3784 grandchild1_->RemoveFromParent(); |
| 3736 | 3785 |
| 3737 EXPECT_FALSE( | 3786 EXPECT_FALSE( |
| 3738 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3787 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3739 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3788 EXPECT_FALSE( |
| 3740 child_.get())); | 3789 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3741 | 3790 |
| 3742 // grandchild3_ does not need a push properties, so recursing should | 3791 // grandchild3_ does not need a push properties, so recursing should |
| 3743 // no longer be needed. | 3792 // no longer be needed. |
| 3744 grandchild2_->RemoveFromParent(); | 3793 grandchild2_->RemoveFromParent(); |
| 3745 | 3794 |
| 3746 EXPECT_FALSE( | 3795 EXPECT_FALSE( |
| 3747 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3796 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3748 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3797 EXPECT_FALSE( |
| 3749 child_.get())); | 3798 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3750 EndTest(); | 3799 EndTest(); |
| 3751 break; | 3800 break; |
| 3752 } | 3801 } |
| 3753 } | 3802 } |
| 3754 }; | 3803 }; |
| 3755 | 3804 |
| 3756 MULTI_THREAD_TEST_F( | 3805 MULTI_THREAD_TEST_F( |
| 3757 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence); | 3806 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence); |
| 3758 | 3807 |
| 3759 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree | 3808 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree |
| 3760 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { | 3809 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { |
| 3761 protected: | 3810 protected: |
| 3762 void DidCommitAndDrawFrame() override { | 3811 void DidCommitAndDrawFrame() override { |
| 3812 LayerTree* layer_tree = layer_tree_host()->GetLayerTree(); |
| 3763 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; | 3813 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; |
| 3764 switch (last_source_frame_number) { | 3814 switch (last_source_frame_number) { |
| 3765 case 0: | 3815 case 0: |
| 3766 layer_tree_host()->SetRootLayer(root_); | 3816 layer_tree_host()->SetRootLayer(root_); |
| 3767 break; | 3817 break; |
| 3768 case 1: | 3818 case 1: |
| 3769 EXPECT_FALSE( | 3819 EXPECT_FALSE( |
| 3770 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3820 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3771 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3821 EXPECT_FALSE( |
| 3772 child_.get())); | 3822 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3773 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3823 EXPECT_FALSE( |
| 3774 grandchild1_.get())); | 3824 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3775 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3825 EXPECT_FALSE( |
| 3776 grandchild2_.get())); | 3826 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3777 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3827 EXPECT_FALSE( |
| 3778 grandchild3_.get())); | 3828 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3779 | 3829 |
| 3780 // Change grandchildren while their parent is not in the tree. | 3830 // Change grandchildren while their parent is not in the tree. |
| 3781 child_->RemoveFromParent(); | 3831 child_->RemoveFromParent(); |
| 3782 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); | 3832 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3783 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); | 3833 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3784 root_->AddChild(child_); | 3834 root_->AddChild(child_); |
| 3785 | 3835 |
| 3786 EXPECT_FALSE( | 3836 EXPECT_FALSE( |
| 3787 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3837 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3788 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3838 EXPECT_TRUE( |
| 3789 child_.get())); | 3839 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3790 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3840 EXPECT_TRUE( |
| 3791 grandchild1_.get())); | 3841 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3792 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3842 EXPECT_TRUE( |
| 3793 grandchild2_.get())); | 3843 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3794 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3844 EXPECT_TRUE( |
| 3795 grandchild3_.get())); | 3845 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3796 | 3846 |
| 3797 grandchild1_->RemoveFromParent(); | 3847 grandchild1_->RemoveFromParent(); |
| 3798 | 3848 |
| 3799 EXPECT_FALSE( | 3849 EXPECT_FALSE( |
| 3800 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3850 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3801 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3851 EXPECT_TRUE( |
| 3802 child_.get())); | 3852 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3803 | 3853 |
| 3804 grandchild2_->RemoveFromParent(); | 3854 grandchild2_->RemoveFromParent(); |
| 3805 | 3855 |
| 3806 EXPECT_FALSE( | 3856 EXPECT_FALSE( |
| 3807 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3857 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3808 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3858 EXPECT_TRUE( |
| 3809 child_.get())); | 3859 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3810 | 3860 |
| 3811 grandchild3_->RemoveFromParent(); | 3861 grandchild3_->RemoveFromParent(); |
| 3812 | 3862 |
| 3813 EXPECT_FALSE( | 3863 EXPECT_FALSE( |
| 3814 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3864 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3815 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3865 EXPECT_TRUE( |
| 3816 child_.get())); | 3866 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3817 | 3867 |
| 3818 EndTest(); | 3868 EndTest(); |
| 3819 break; | 3869 break; |
| 3820 } | 3870 } |
| 3821 } | 3871 } |
| 3822 }; | 3872 }; |
| 3823 | 3873 |
| 3824 MULTI_THREAD_TEST_F( | 3874 MULTI_THREAD_TEST_F( |
| 3825 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree); | 3875 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree); |
| 3826 | 3876 |
| 3827 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild | 3877 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild |
| 3828 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { | 3878 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { |
| 3829 protected: | 3879 protected: |
| 3830 void DidCommitAndDrawFrame() override { | 3880 void DidCommitAndDrawFrame() override { |
| 3881 LayerTree* layer_tree = layer_tree_host()->GetLayerTree(); |
| 3831 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; | 3882 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; |
| 3832 switch (last_source_frame_number) { | 3883 switch (last_source_frame_number) { |
| 3833 case 0: | 3884 case 0: |
| 3834 layer_tree_host()->SetRootLayer(root_); | 3885 layer_tree_host()->SetRootLayer(root_); |
| 3835 break; | 3886 break; |
| 3836 case 1: | 3887 case 1: |
| 3837 EXPECT_FALSE( | 3888 EXPECT_FALSE( |
| 3838 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3889 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3839 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3890 EXPECT_FALSE( |
| 3840 child_.get())); | 3891 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3841 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3892 EXPECT_FALSE( |
| 3842 grandchild1_.get())); | 3893 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3843 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3894 EXPECT_FALSE( |
| 3844 grandchild2_.get())); | 3895 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3845 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3896 EXPECT_FALSE( |
| 3846 grandchild3_.get())); | 3897 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3847 | 3898 |
| 3848 child_->SetPosition(gfx::PointF(1.f, 1.f)); | 3899 child_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3849 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); | 3900 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3850 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); | 3901 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3851 | 3902 |
| 3852 EXPECT_FALSE( | 3903 EXPECT_FALSE( |
| 3853 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3904 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3854 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3905 EXPECT_TRUE( |
| 3855 child_.get())); | 3906 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3856 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3907 EXPECT_TRUE( |
| 3857 grandchild1_.get())); | 3908 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3858 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3909 EXPECT_TRUE( |
| 3859 grandchild2_.get())); | 3910 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3860 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3911 EXPECT_FALSE( |
| 3861 grandchild3_.get())); | 3912 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3862 | 3913 |
| 3863 grandchild1_->RemoveFromParent(); | 3914 grandchild1_->RemoveFromParent(); |
| 3864 | 3915 |
| 3865 EXPECT_FALSE( | 3916 EXPECT_FALSE( |
| 3866 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3917 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3867 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3918 EXPECT_TRUE( |
| 3868 child_.get())); | 3919 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3869 | 3920 |
| 3870 grandchild2_->RemoveFromParent(); | 3921 grandchild2_->RemoveFromParent(); |
| 3871 | 3922 |
| 3872 EXPECT_FALSE( | 3923 EXPECT_FALSE( |
| 3873 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3924 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3874 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3925 EXPECT_TRUE( |
| 3875 child_.get())); | 3926 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3876 | 3927 |
| 3877 child_->RemoveFromParent(); | 3928 child_->RemoveFromParent(); |
| 3878 | 3929 |
| 3879 EXPECT_FALSE( | 3930 EXPECT_FALSE( |
| 3880 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3931 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3881 | 3932 |
| 3882 EndTest(); | 3933 EndTest(); |
| 3883 break; | 3934 break; |
| 3884 } | 3935 } |
| 3885 } | 3936 } |
| 3886 }; | 3937 }; |
| 3887 | 3938 |
| 3888 MULTI_THREAD_TEST_F( | 3939 MULTI_THREAD_TEST_F( |
| 3889 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild); | 3940 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild); |
| 3890 | 3941 |
| 3891 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent | 3942 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent |
| 3892 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { | 3943 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { |
| 3893 protected: | 3944 protected: |
| 3894 void DidCommitAndDrawFrame() override { | 3945 void DidCommitAndDrawFrame() override { |
| 3946 LayerTree* layer_tree = layer_tree_host()->GetLayerTree(); |
| 3895 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; | 3947 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; |
| 3896 switch (last_source_frame_number) { | 3948 switch (last_source_frame_number) { |
| 3897 case 0: | 3949 case 0: |
| 3898 layer_tree_host()->SetRootLayer(root_); | 3950 layer_tree_host()->SetRootLayer(root_); |
| 3899 break; | 3951 break; |
| 3900 case 1: | 3952 case 1: |
| 3901 EXPECT_FALSE( | 3953 EXPECT_FALSE( |
| 3902 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3954 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3903 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3955 EXPECT_FALSE( |
| 3904 child_.get())); | 3956 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3905 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3957 EXPECT_FALSE( |
| 3906 grandchild1_.get())); | 3958 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3907 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3959 EXPECT_FALSE( |
| 3908 grandchild2_.get())); | 3960 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3909 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3961 EXPECT_FALSE( |
| 3910 grandchild3_.get())); | 3962 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3911 | 3963 |
| 3912 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); | 3964 grandchild1_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3913 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); | 3965 grandchild2_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3914 child_->SetPosition(gfx::PointF(1.f, 1.f)); | 3966 child_->SetPosition(gfx::PointF(1.f, 1.f)); |
| 3915 | 3967 |
| 3916 EXPECT_FALSE( | 3968 EXPECT_FALSE( |
| 3917 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3969 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3918 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3970 EXPECT_TRUE( |
| 3919 child_.get())); | 3971 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3920 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3972 EXPECT_TRUE( |
| 3921 grandchild1_.get())); | 3973 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild1_.get())); |
| 3922 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3974 EXPECT_TRUE( |
| 3923 grandchild2_.get())); | 3975 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild2_.get())); |
| 3924 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3976 EXPECT_FALSE( |
| 3925 grandchild3_.get())); | 3977 layer_tree->LayerNeedsPushPropertiesForTesting(grandchild3_.get())); |
| 3926 | 3978 |
| 3927 grandchild1_->RemoveFromParent(); | 3979 grandchild1_->RemoveFromParent(); |
| 3928 | 3980 |
| 3929 EXPECT_FALSE( | 3981 EXPECT_FALSE( |
| 3930 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3982 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3931 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3983 EXPECT_TRUE( |
| 3932 child_.get())); | 3984 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3933 | 3985 |
| 3934 grandchild2_->RemoveFromParent(); | 3986 grandchild2_->RemoveFromParent(); |
| 3935 | 3987 |
| 3936 EXPECT_FALSE( | 3988 EXPECT_FALSE( |
| 3937 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3989 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3938 EXPECT_TRUE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 3990 EXPECT_TRUE( |
| 3939 child_.get())); | 3991 layer_tree->LayerNeedsPushPropertiesForTesting(child_.get())); |
| 3940 | 3992 |
| 3941 child_->RemoveFromParent(); | 3993 child_->RemoveFromParent(); |
| 3942 | 3994 |
| 3943 EXPECT_FALSE( | 3995 EXPECT_FALSE( |
| 3944 layer_tree_host()->LayerNeedsPushPropertiesForTesting(root_.get())); | 3996 layer_tree->LayerNeedsPushPropertiesForTesting(root_.get())); |
| 3945 | 3997 |
| 3946 EndTest(); | 3998 EndTest(); |
| 3947 break; | 3999 break; |
| 3948 } | 4000 } |
| 3949 } | 4001 } |
| 3950 }; | 4002 }; |
| 3951 | 4003 |
| 3952 MULTI_THREAD_TEST_F( | 4004 MULTI_THREAD_TEST_F( |
| 3953 LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent); | 4005 LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent); |
| 3954 | 4006 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4094 child_layer_->SetIsDrawable(true); | 4146 child_layer_->SetIsDrawable(true); |
| 4095 parent_layer_->AddChild(child_layer_); | 4147 parent_layer_->AddChild(child_layer_); |
| 4096 | 4148 |
| 4097 layer_tree_host()->SetRootLayer(root_layer_); | 4149 layer_tree_host()->SetRootLayer(root_layer_); |
| 4098 LayerTreeHostTest::SetupTree(); | 4150 LayerTreeHostTest::SetupTree(); |
| 4099 } | 4151 } |
| 4100 | 4152 |
| 4101 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4153 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 4102 | 4154 |
| 4103 void DidCommitAndDrawFrame() override { | 4155 void DidCommitAndDrawFrame() override { |
| 4156 LayerTree* layer_tree = layer_tree_host()->GetLayerTree(); |
| 4104 switch (layer_tree_host()->source_frame_number()) { | 4157 switch (layer_tree_host()->source_frame_number()) { |
| 4105 case 1: | 4158 case 1: |
| 4106 // The layer type used does not need to push properties every frame. | 4159 // The layer type used does not need to push properties every frame. |
| 4107 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 4160 EXPECT_FALSE( |
| 4108 child_layer_.get())); | 4161 layer_tree->LayerNeedsPushPropertiesForTesting(child_layer_.get())); |
| 4109 | 4162 |
| 4110 // Change the bounds of the child layer, but make it skipped | 4163 // Change the bounds of the child layer, but make it skipped |
| 4111 // by CalculateDrawProperties. | 4164 // by CalculateDrawProperties. |
| 4112 parent_layer_->SetOpacity(0.f); | 4165 parent_layer_->SetOpacity(0.f); |
| 4113 child_layer_->SetBounds(gfx::Size(5, 5)); | 4166 child_layer_->SetBounds(gfx::Size(5, 5)); |
| 4114 break; | 4167 break; |
| 4115 case 2: | 4168 case 2: |
| 4116 // The bounds of the child layer were pushed to the impl side. | 4169 // The bounds of the child layer were pushed to the impl side. |
| 4117 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( | 4170 EXPECT_FALSE( |
| 4118 child_layer_.get())); | 4171 layer_tree->LayerNeedsPushPropertiesForTesting(child_layer_.get())); |
| 4119 | 4172 |
| 4120 EndTest(); | 4173 EndTest(); |
| 4121 break; | 4174 break; |
| 4122 } | 4175 } |
| 4123 } | 4176 } |
| 4124 | 4177 |
| 4125 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 4178 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 4126 LayerImpl* child = impl->active_tree()->LayerById(child_layer_->id()); | 4179 LayerImpl* child = impl->active_tree()->LayerById(child_layer_->id()); |
| 4127 | 4180 |
| 4128 switch (impl->active_tree()->source_frame_number()) { | 4181 switch (impl->active_tree()->source_frame_number()) { |
| (...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6893 private: | 6946 private: |
| 6894 FakeContentLayerClient client_; | 6947 FakeContentLayerClient client_; |
| 6895 const gfx::Size viewport_size_; | 6948 const gfx::Size viewport_size_; |
| 6896 const gfx::Size large_image_size_; | 6949 const gfx::Size large_image_size_; |
| 6897 }; | 6950 }; |
| 6898 | 6951 |
| 6899 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); | 6952 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 6900 | 6953 |
| 6901 } // namespace | 6954 } // namespace |
| 6902 } // namespace cc | 6955 } // namespace cc |
| OLD | NEW |