| 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/layer.h" | 5 #include "cc/layer.h" |
| 6 | 6 |
| 7 #include "cc/keyframed_animation_curve.h" | 7 #include "cc/keyframed_animation_curve.h" |
| 8 #include "cc/layer_impl.h" | 8 #include "cc/layer_impl.h" |
| 9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
| 10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 EXPECT_FALSE(testLayer->NeedsDisplayForTesting()); | 589 EXPECT_FALSE(testLayer->NeedsDisplayForTesting()); |
| 590 | 590 |
| 591 // Calling setBounds only invalidates on the first time. | 591 // Calling setBounds only invalidates on the first time. |
| 592 EXPECT_SET_NEEDS_COMMIT(1, testLayer->SetBounds(gfx::Size(7, 10))); | 592 EXPECT_SET_NEEDS_COMMIT(1, testLayer->SetBounds(gfx::Size(7, 10))); |
| 593 EXPECT_FALSE(testLayer->NeedsDisplayForTesting()); | 593 EXPECT_FALSE(testLayer->NeedsDisplayForTesting()); |
| 594 } | 594 } |
| 595 | 595 |
| 596 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) | 596 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) |
| 597 { | 597 { |
| 598 scoped_refptr<Layer> testLayer = Layer::Create(); | 598 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 599 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); | 599 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.active_tree()
, 1); |
| 600 | 600 |
| 601 testLayer->SetNeedsDisplayRect(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5))); | 601 testLayer->SetNeedsDisplayRect(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5))); |
| 602 testLayer->PushPropertiesTo(implLayer.get()); | 602 testLayer->PushPropertiesTo(implLayer.get()); |
| 603 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)), implLayer-
>update_rect()); | 603 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)), implLayer-
>update_rect()); |
| 604 | 604 |
| 605 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. | 605 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. |
| 606 testLayer->SetNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5,
5))); | 606 testLayer->SetNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5,
5))); |
| 607 testLayer->PushPropertiesTo(implLayer.get()); | 607 testLayer->PushPropertiesTo(implLayer.get()); |
| 608 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(15, 15)), implLaye
r->update_rect()); | 608 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(15, 15)), implLaye
r->update_rect()); |
| 609 | 609 |
| 610 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. | 610 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. |
| 611 implLayer->ResetAllChangeTrackingForSubtree(); | 611 implLayer->ResetAllChangeTrackingForSubtree(); |
| 612 testLayer->SetNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5,
5))); | 612 testLayer->SetNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5,
5))); |
| 613 testLayer->PushPropertiesTo(implLayer.get()); | 613 testLayer->PushPropertiesTo(implLayer.get()); |
| 614 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)), impl
Layer->update_rect()); | 614 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)), impl
Layer->update_rect()); |
| 615 } | 615 } |
| 616 | 616 |
| 617 TEST_F(LayerTest, verifyPushPropertiesCausesSurfacePropertyChangedForTransform) | 617 TEST_F(LayerTest, verifyPushPropertiesCausesSurfacePropertyChangedForTransform) |
| 618 { | 618 { |
| 619 scoped_refptr<Layer> testLayer = Layer::Create(); | 619 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 620 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); | 620 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.active_tree()
, 1); |
| 621 | 621 |
| 622 gfx::Transform transform; | 622 gfx::Transform transform; |
| 623 transform.Rotate(45.0); | 623 transform.Rotate(45.0); |
| 624 testLayer->SetTransform(transform); | 624 testLayer->SetTransform(transform); |
| 625 | 625 |
| 626 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 626 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 627 | 627 |
| 628 testLayer->PushPropertiesTo(implLayer.get()); | 628 testLayer->PushPropertiesTo(implLayer.get()); |
| 629 | 629 |
| 630 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); | 630 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); |
| 631 } | 631 } |
| 632 | 632 |
| 633 TEST_F(LayerTest, verifyPushPropertiesCausesSurfacePropertyChangedForOpacity) | 633 TEST_F(LayerTest, verifyPushPropertiesCausesSurfacePropertyChangedForOpacity) |
| 634 { | 634 { |
| 635 scoped_refptr<Layer> testLayer = Layer::Create(); | 635 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 636 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); | 636 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.active_tree()
, 1); |
| 637 | 637 |
| 638 testLayer->SetOpacity(0.5); | 638 testLayer->SetOpacity(0.5); |
| 639 | 639 |
| 640 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 640 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 641 | 641 |
| 642 testLayer->PushPropertiesTo(implLayer.get()); | 642 testLayer->PushPropertiesTo(implLayer.get()); |
| 643 | 643 |
| 644 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); | 644 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); |
| 645 } | 645 } |
| 646 | 646 |
| 647 TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringIm
plOnlyTransformAnimation) | 647 TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringIm
plOnlyTransformAnimation) |
| 648 { | 648 { |
| 649 scoped_refptr<Layer> testLayer = Layer::Create(); | 649 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 650 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); | 650 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.active_tree()
, 1); |
| 651 | 651 |
| 652 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); | 652 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); |
| 653 implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get
()); | 653 implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get
()); |
| 654 | 654 |
| 655 addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1
.0, 0, 100); | 655 addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1
.0, 0, 100); |
| 656 | 656 |
| 657 gfx::Transform transform; | 657 gfx::Transform transform; |
| 658 transform.Rotate(45.0); | 658 transform.Rotate(45.0); |
| 659 testLayer->SetTransform(transform); | 659 testLayer->SetTransform(transform); |
| 660 | 660 |
| 661 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 661 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 662 testLayer->PushPropertiesTo(implLayer.get()); | 662 testLayer->PushPropertiesTo(implLayer.get()); |
| 663 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); | 663 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); |
| 664 | 664 |
| 665 implLayer->ResetAllChangeTrackingForSubtree(); | 665 implLayer->ResetAllChangeTrackingForSubtree(); |
| 666 addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1
.0, 0, 100); | 666 addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1
.0, 0, 100); |
| 667 implLayer->layer_animation_controller()->GetAnimation(Animation::Transform)-
>set_is_impl_only(true); | 667 implLayer->layer_animation_controller()->GetAnimation(Animation::Transform)-
>set_is_impl_only(true); |
| 668 transform.Rotate(45.0); | 668 transform.Rotate(45.0); |
| 669 testLayer->SetTransform(transform); | 669 testLayer->SetTransform(transform); |
| 670 | 670 |
| 671 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 671 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 672 testLayer->PushPropertiesTo(implLayer.get()); | 672 testLayer->PushPropertiesTo(implLayer.get()); |
| 673 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 673 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 674 } | 674 } |
| 675 | 675 |
| 676 TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringIm
plOnlyOpacityAnimation) | 676 TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringIm
plOnlyOpacityAnimation) |
| 677 { | 677 { |
| 678 scoped_refptr<Layer> testLayer = Layer::Create(); | 678 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 679 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); | 679 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.active_tree()
, 1); |
| 680 | 680 |
| 681 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); | 681 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); |
| 682 implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get
()); | 682 implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get
()); |
| 683 | 683 |
| 684 addOpacityTransitionToController(*implLayer->layer_animation_controller(), 1
.0, 0.3f, 0.7f, false); | 684 addOpacityTransitionToController(*implLayer->layer_animation_controller(), 1
.0, 0.3f, 0.7f, false); |
| 685 | 685 |
| 686 testLayer->SetOpacity(0.5f); | 686 testLayer->SetOpacity(0.5f); |
| 687 | 687 |
| 688 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 688 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 689 testLayer->PushPropertiesTo(implLayer.get()); | 689 testLayer->PushPropertiesTo(implLayer.get()); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 layer->SetLayerTreeHost(layerTreeHost.get()); | 968 layer->SetLayerTreeHost(layerTreeHost.get()); |
| 969 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); | 969 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); |
| 970 | 970 |
| 971 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the | 971 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the |
| 972 // animation should be rejected. | 972 // animation should be rejected. |
| 973 EXPECT_FALSE(addTestAnimation(layer.get())); | 973 EXPECT_FALSE(addTestAnimation(layer.get())); |
| 974 } | 974 } |
| 975 | 975 |
| 976 } // namespace | 976 } // namespace |
| 977 } // namespace cc | 977 } // namespace cc |
| OLD | NEW |