| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/animation/animation_curve.h" | 7 #include "cc/animation/animation_curve.h" |
| 8 #include "cc/animation/layer_animation_controller.h" | 8 #include "cc/animation/layer_animation_controller.h" |
| 9 #include "cc/animation/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| 11 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
| 12 #include "cc/test/animation_test_common.h" | 12 #include "cc/test/animation_test_common.h" |
| 13 #include "cc/test/fake_content_layer.h" | 13 #include "cc/test/fake_content_layer.h" |
| 14 #include "cc/test/fake_content_layer_client.h" | 14 #include "cc/test/fake_content_layer_client.h" |
| 15 #include "cc/test/layer_tree_test.h" | 15 #include "cc/test/layer_tree_test.h" |
| 16 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class AlwaysUpdateLayer : public Layer { |
| 22 public: |
| 23 static scoped_refptr<AlwaysUpdateLayer> Create() { |
| 24 return new AlwaysUpdateLayer(); |
| 25 } |
| 26 |
| 27 virtual bool DrawsContent() const OVERRIDE { return true; } |
| 28 virtual bool Update(ResourceUpdateQueue* queue, |
| 29 const OcclusionTracker* occlusion) OVERRIDE { |
| 30 return true; |
| 31 } |
| 32 |
| 33 private: |
| 34 AlwaysUpdateLayer() {} |
| 35 virtual ~AlwaysUpdateLayer() {} |
| 36 }; |
| 37 |
| 21 class LayerTreeHostAnimationTest : public LayerTreeTest { | 38 class LayerTreeHostAnimationTest : public LayerTreeTest { |
| 22 public: | 39 public: |
| 23 virtual void SetupTree() OVERRIDE { | 40 virtual void SetupTree() OVERRIDE { |
| 41 scoped_refptr<AlwaysUpdateLayer> root_layer = AlwaysUpdateLayer::Create(); |
| 42 root_layer->SetBounds(gfx::Size(1, 1)); |
| 43 root_layer->SetIsDrawable(true); |
| 44 root_layer->SetScrollable(true); |
| 45 layer_tree_host()->SetRootLayer(root_layer); |
| 46 |
| 24 LayerTreeTest::SetupTree(); | 47 LayerTreeTest::SetupTree(); |
| 25 layer_tree_host()->root_layer()->set_layer_animation_delegate(this); | 48 layer_tree_host()->root_layer()->set_layer_animation_delegate(this); |
| 26 } | 49 } |
| 27 }; | 50 }; |
| 28 | 51 |
| 29 // Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to | 52 // Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to |
| 30 // be set. | 53 // be set. |
| 31 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested | 54 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested |
| 32 : public LayerTreeHostAnimationTest { | 55 : public LayerTreeHostAnimationTest { |
| 33 public: | 56 public: |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 // Ensures that when opacity is being animated, this value does not cause the | 461 // Ensures that when opacity is being animated, this value does not cause the |
| 439 // subtree to be skipped. | 462 // subtree to be skipped. |
| 440 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity | 463 class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity |
| 441 : public LayerTreeHostAnimationTest { | 464 : public LayerTreeHostAnimationTest { |
| 442 public: | 465 public: |
| 443 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() | 466 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity() |
| 444 : update_check_layer_(FakeContentLayer::Create(&client_)) { | 467 : update_check_layer_(FakeContentLayer::Create(&client_)) { |
| 445 } | 468 } |
| 446 | 469 |
| 447 virtual void SetupTree() OVERRIDE { | 470 virtual void SetupTree() OVERRIDE { |
| 471 LayerTreeHostAnimationTest::SetupTree(); |
| 448 update_check_layer_->SetOpacity(0.f); | 472 update_check_layer_->SetOpacity(0.f); |
| 449 layer_tree_host()->SetRootLayer(update_check_layer_); | 473 layer_tree_host()->root_layer()->AddChild(update_check_layer_); |
| 450 LayerTreeHostAnimationTest::SetupTree(); | |
| 451 } | 474 } |
| 452 | 475 |
| 453 virtual void BeginTest() OVERRIDE { | 476 virtual void BeginTest() OVERRIDE { |
| 454 PostAddAnimationToMainThread(update_check_layer_.get()); | 477 PostAddAnimationToMainThread(update_check_layer_.get()); |
| 455 } | 478 } |
| 456 | 479 |
| 457 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 480 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 481 LayerImpl* update_check_layer_impl = |
| 482 host_impl->active_tree()->LayerById(update_check_layer_->id()); |
| 458 LayerAnimationController* controller_impl = | 483 LayerAnimationController* controller_impl = |
| 459 host_impl->active_tree()->root_layer()->layer_animation_controller(); | 484 update_check_layer_impl->layer_animation_controller(); |
| 460 Animation* animation_impl = | 485 Animation* animation_impl = |
| 461 controller_impl->GetAnimation(Animation::Opacity); | 486 controller_impl->GetAnimation(Animation::Opacity); |
| 462 controller_impl->RemoveAnimation(animation_impl->id()); | 487 controller_impl->RemoveAnimation(animation_impl->id()); |
| 463 EndTest(); | 488 EndTest(); |
| 464 } | 489 } |
| 465 | 490 |
| 466 virtual void AfterTest() OVERRIDE { | 491 virtual void DidCommit() OVERRIDE { |
| 467 // Update() should have been called once, proving that the layer was not | 492 // Update() should have been called once, proving that the layer was not |
| 468 // skipped. | 493 // skipped. |
| 469 EXPECT_EQ(1u, update_check_layer_->update_count()); | 494 EXPECT_EQ(1u, update_check_layer_->update_count()); |
| 495 update_check_layer_->reset_update_count(); |
| 496 } |
| 470 | 497 |
| 471 // clear update_check_layer_ so LayerTreeHost dies. | 498 virtual void AfterTest() OVERRIDE {} |
| 472 update_check_layer_ = NULL; | |
| 473 } | |
| 474 | 499 |
| 475 private: | 500 private: |
| 476 FakeContentLayerClient client_; | 501 FakeContentLayerClient client_; |
| 477 scoped_refptr<FakeContentLayer> update_check_layer_; | 502 scoped_refptr<FakeContentLayer> update_check_layer_; |
| 478 }; | 503 }; |
| 479 | 504 |
| 480 SINGLE_AND_MULTI_THREAD_TEST_F( | 505 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 481 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity); | 506 LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity); |
| 482 | 507 |
| 483 // Layers added to tree with existing active animations should have the | 508 // Layers added to tree with existing active animations should have the |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 int finished_times_; | 820 int finished_times_; |
| 796 FakeContentLayerClient client_; | 821 FakeContentLayerClient client_; |
| 797 scoped_refptr<FakeContentLayer> content_; | 822 scoped_refptr<FakeContentLayer> content_; |
| 798 }; | 823 }; |
| 799 | 824 |
| 800 MULTI_THREAD_TEST_F( | 825 MULTI_THREAD_TEST_F( |
| 801 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 826 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
| 802 | 827 |
| 803 } // namespace | 828 } // namespace |
| 804 } // namespace cc | 829 } // namespace cc |
| OLD | NEW |