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/scroll_offset_animation_curve.h" | 9 #include "cc/animation/scroll_offset_animation_curve.h" |
10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // impl thread animations. | 275 // impl thread animations. |
276 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes | 276 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes |
277 : public LayerTreeHostAnimationTest { | 277 : public LayerTreeHostAnimationTest { |
278 public: | 278 public: |
279 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes() {} | 279 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes() {} |
280 | 280 |
281 void SetupTree() override { | 281 void SetupTree() override { |
282 LayerTreeHostAnimationTest::SetupTree(); | 282 LayerTreeHostAnimationTest::SetupTree(); |
283 content_ = FakeContentLayer::Create(&client_); | 283 content_ = FakeContentLayer::Create(&client_); |
284 content_->SetBounds(gfx::Size(4, 4)); | 284 content_->SetBounds(gfx::Size(4, 4)); |
| 285 layer_tree_host()->root_layer()->AddChild(content_); |
285 content_->set_layer_animation_delegate(this); | 286 content_->set_layer_animation_delegate(this); |
286 layer_tree_host()->root_layer()->AddChild(content_); | |
287 } | 287 } |
288 | 288 |
289 void BeginTest() override { PostAddAnimationToMainThread(content_.get()); } | 289 void BeginTest() override { PostAddAnimationToMainThread(content_.get()); } |
290 | 290 |
291 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 291 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
292 Animation::TargetProperty target_property, | 292 Animation::TargetProperty target_property, |
293 int group) override { | 293 int group) override { |
294 LayerAnimationController* controller = | 294 LayerAnimationController* controller = |
295 layer_tree_host()->root_layer()->children()[0]-> | 295 layer_tree_host()->root_layer()->children()[0]-> |
296 layer_animation_controller(); | 296 layer_animation_controller(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 class LayerTreeHostAnimationTestLayerAddedWithAnimation | 404 class LayerTreeHostAnimationTestLayerAddedWithAnimation |
405 : public LayerTreeHostAnimationTest { | 405 : public LayerTreeHostAnimationTest { |
406 public: | 406 public: |
407 LayerTreeHostAnimationTestLayerAddedWithAnimation() {} | 407 LayerTreeHostAnimationTestLayerAddedWithAnimation() {} |
408 | 408 |
409 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 409 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
410 | 410 |
411 void DidCommit() override { | 411 void DidCommit() override { |
412 if (layer_tree_host()->source_frame_number() == 1) { | 412 if (layer_tree_host()->source_frame_number() == 1) { |
413 scoped_refptr<Layer> layer = Layer::Create(); | 413 scoped_refptr<Layer> layer = Layer::Create(); |
| 414 layer->RegisterForAnimations(layer_tree_host()->animation_registrar(), |
| 415 layer_tree_host()->settings()); |
414 layer->set_layer_animation_delegate(this); | 416 layer->set_layer_animation_delegate(this); |
415 | 417 |
416 // Any valid AnimationCurve will do here. | 418 // Any valid AnimationCurve will do here. |
417 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); | 419 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); |
418 scoped_ptr<Animation> animation( | 420 scoped_ptr<Animation> animation( |
419 Animation::Create(curve.Pass(), 1, 1, Animation::OPACITY)); | 421 Animation::Create(curve.Pass(), 1, 1, Animation::OPACITY)); |
420 layer->layer_animation_controller()->AddAnimation(animation.Pass()); | 422 layer->layer_animation_controller()->AddAnimation(animation.Pass()); |
421 | 423 |
422 // We add the animation *before* attaching the layer to the tree. | 424 // We add the animation *before* attaching the layer to the tree. |
423 layer_tree_host()->root_layer()->AddChild(layer); | 425 layer_tree_host()->root_layer()->AddChild(layer); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 // true. | 555 // true. |
554 class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw | 556 class LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw |
555 : public LayerTreeHostAnimationTest { | 557 : public LayerTreeHostAnimationTest { |
556 public: | 558 public: |
557 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw() : started_times_(0) {} | 559 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw() : started_times_(0) {} |
558 | 560 |
559 void SetupTree() override { | 561 void SetupTree() override { |
560 LayerTreeHostAnimationTest::SetupTree(); | 562 LayerTreeHostAnimationTest::SetupTree(); |
561 content_ = FakeContentLayer::Create(&client_); | 563 content_ = FakeContentLayer::Create(&client_); |
562 content_->SetBounds(gfx::Size(4, 4)); | 564 content_->SetBounds(gfx::Size(4, 4)); |
| 565 layer_tree_host()->root_layer()->AddChild(content_); |
563 content_->set_layer_animation_delegate(this); | 566 content_->set_layer_animation_delegate(this); |
564 layer_tree_host()->root_layer()->AddChild(content_); | |
565 } | 567 } |
566 | 568 |
567 void BeginTest() override { | 569 void BeginTest() override { |
568 layer_tree_host()->SetViewportSize(gfx::Size()); | 570 layer_tree_host()->SetViewportSize(gfx::Size()); |
569 PostAddAnimationToMainThread(content_.get()); | 571 PostAddAnimationToMainThread(content_.get()); |
570 } | 572 } |
571 | 573 |
572 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 574 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
573 Animation::TargetProperty target_property, | 575 Animation::TargetProperty target_property, |
574 int group) override { | 576 int group) override { |
(...skipping 18 matching lines...) Expand all Loading... |
593 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw); | 595 LayerTreeHostAnimationTestRunAnimationWhenNotCanDraw); |
594 | 596 |
595 // Animations should not be started when frames are being skipped due to | 597 // Animations should not be started when frames are being skipped due to |
596 // checkerboard. | 598 // checkerboard. |
597 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations | 599 class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations |
598 : public LayerTreeHostAnimationTest { | 600 : public LayerTreeHostAnimationTest { |
599 void SetupTree() override { | 601 void SetupTree() override { |
600 LayerTreeHostAnimationTest::SetupTree(); | 602 LayerTreeHostAnimationTest::SetupTree(); |
601 content_ = FakeContentLayer::Create(&client_); | 603 content_ = FakeContentLayer::Create(&client_); |
602 content_->SetBounds(gfx::Size(4, 4)); | 604 content_->SetBounds(gfx::Size(4, 4)); |
| 605 layer_tree_host()->root_layer()->AddChild(content_); |
603 content_->set_layer_animation_delegate(this); | 606 content_->set_layer_animation_delegate(this); |
604 layer_tree_host()->root_layer()->AddChild(content_); | |
605 } | 607 } |
606 | 608 |
607 void InitializeSettings(LayerTreeSettings* settings) override { | 609 void InitializeSettings(LayerTreeSettings* settings) override { |
608 // Make sure that drawing many times doesn't cause a checkerboarded | 610 // Make sure that drawing many times doesn't cause a checkerboarded |
609 // animation to start so we avoid flake in this test. | 611 // animation to start so we avoid flake in this test. |
610 settings->timeout_and_draw_when_animation_checkerboards = false; | 612 settings->timeout_and_draw_when_animation_checkerboards = false; |
611 } | 613 } |
612 | 614 |
613 void BeginTest() override { | 615 void BeginTest() override { |
614 prevented_draw_ = 0; | 616 prevented_draw_ = 0; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 private: | 987 private: |
986 scoped_refptr<Layer> content_; | 988 scoped_refptr<Layer> content_; |
987 int num_swap_buffers_; | 989 int num_swap_buffers_; |
988 }; | 990 }; |
989 | 991 |
990 SINGLE_AND_MULTI_THREAD_TEST_F( | 992 SINGLE_AND_MULTI_THREAD_TEST_F( |
991 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 993 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
992 | 994 |
993 } // namespace | 995 } // namespace |
994 } // namespace cc | 996 } // namespace cc |
OLD | NEW |