| 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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 384 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 385 TestHooks* test_hooks_; | 385 TestHooks* test_hooks_; |
| 386 bool test_started_; | 386 bool test_started_; |
| 387 }; | 387 }; |
| 388 | 388 |
| 389 LayerTreeTest::LayerTreeTest() | 389 LayerTreeTest::LayerTreeTest() |
| 390 : beginning_(false), | 390 : beginning_(false), |
| 391 end_when_begin_returns_(false), | 391 end_when_begin_returns_(false), |
| 392 timed_out_(false), | 392 timed_out_(false), |
| 393 scheduled_(false), | 393 scheduled_(false), |
| 394 schedule_when_set_visible_true_(false), | |
| 395 started_(false), | 394 started_(false), |
| 396 ended_(false), | 395 ended_(false), |
| 397 delegating_renderer_(false), | 396 delegating_renderer_(false), |
| 398 timeout_seconds_(0), | 397 timeout_seconds_(0), |
| 399 weak_factory_(this) { | 398 weak_factory_(this) { |
| 400 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); | 399 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 401 | 400 |
| 402 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was | 401 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was |
| 403 // specified (for running in a debugger). | 402 // specified (for running in a debugger). |
| 404 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 403 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 layer_tree_host_->SetNeedsRedrawRect(damage_rect); | 611 layer_tree_host_->SetNeedsRedrawRect(damage_rect); |
| 613 } | 612 } |
| 614 | 613 |
| 615 void LayerTreeTest::DispatchSetVisible(bool visible) { | 614 void LayerTreeTest::DispatchSetVisible(bool visible) { |
| 616 DCHECK(!proxy() || proxy()->IsMainThread()); | 615 DCHECK(!proxy() || proxy()->IsMainThread()); |
| 617 | 616 |
| 618 if (!layer_tree_host_) | 617 if (!layer_tree_host_) |
| 619 return; | 618 return; |
| 620 | 619 |
| 621 layer_tree_host_->SetVisible(visible); | 620 layer_tree_host_->SetVisible(visible); |
| 622 | |
| 623 // If the LTH is being made visible and a previous ScheduleComposite() was | |
| 624 // deferred because the LTH was not visible, re-schedule the composite now. | |
| 625 if (layer_tree_host_->visible() && schedule_when_set_visible_true_) | |
| 626 ScheduleComposite(); | |
| 627 } | 621 } |
| 628 | 622 |
| 629 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { | 623 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { |
| 630 DCHECK(!proxy() || proxy()->IsMainThread()); | 624 DCHECK(!proxy() || proxy()->IsMainThread()); |
| 631 | 625 |
| 632 if (layer_tree_host_) | 626 if (layer_tree_host_) |
| 633 layer_tree_host_->SetNextCommitForcesRedraw(); | 627 layer_tree_host_->SetNextCommitForcesRedraw(); |
| 634 } | 628 } |
| 635 | 629 |
| 636 void LayerTreeTest::DispatchComposite() { | 630 void LayerTreeTest::DispatchComposite() { |
| 637 scheduled_ = false; | 631 scheduled_ = false; |
| 638 | 632 |
| 639 if (!layer_tree_host_) | 633 if (!layer_tree_host_) |
| 640 return; | 634 return; |
| 641 | 635 |
| 642 // If the LTH is not visible, defer the composite until the LTH is made | 636 layer_tree_host_->SetNeedsCommit(); |
| 643 // visible. | |
| 644 if (!layer_tree_host_->visible()) { | |
| 645 schedule_when_set_visible_true_ = true; | |
| 646 return; | |
| 647 } | |
| 648 | |
| 649 schedule_when_set_visible_true_ = false; | |
| 650 base::TimeTicks now = gfx::FrameTime::Now(); | |
| 651 layer_tree_host_->Composite(now); | |
| 652 } | 637 } |
| 653 | 638 |
| 654 void LayerTreeTest::RunTest(bool threaded, | 639 void LayerTreeTest::RunTest(bool threaded, |
| 655 bool delegating_renderer, | 640 bool delegating_renderer, |
| 656 bool impl_side_painting) { | 641 bool impl_side_painting) { |
| 657 if (threaded) { | 642 if (threaded) { |
| 658 impl_thread_.reset(new base::Thread("Compositor")); | 643 impl_thread_.reset(new base::Thread("Compositor")); |
| 659 ASSERT_TRUE(impl_thread_->Start()); | 644 ASSERT_TRUE(impl_thread_->Start()); |
| 660 } | 645 } |
| 661 | 646 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 return -1; | 722 return -1; |
| 738 } | 723 } |
| 739 | 724 |
| 740 void LayerTreeTest::DestroyLayerTreeHost() { | 725 void LayerTreeTest::DestroyLayerTreeHost() { |
| 741 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 726 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 742 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 727 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 743 layer_tree_host_.reset(); | 728 layer_tree_host_.reset(); |
| 744 } | 729 } |
| 745 | 730 |
| 746 } // namespace cc | 731 } // namespace cc |
| OLD | NEW |