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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 TestHooks* test_hooks_; | 325 TestHooks* test_hooks_; |
326 bool test_started_; | 326 bool test_started_; |
327 }; | 327 }; |
328 | 328 |
329 LayerTreeTest::LayerTreeTest() | 329 LayerTreeTest::LayerTreeTest() |
330 : beginning_(false), | 330 : beginning_(false), |
331 end_when_begin_returns_(false), | 331 end_when_begin_returns_(false), |
332 timed_out_(false), | 332 timed_out_(false), |
333 scheduled_(false), | 333 scheduled_(false), |
334 schedule_when_set_visible_true_(false), | |
335 started_(false), | 334 started_(false), |
336 ended_(false), | 335 ended_(false), |
337 delegating_renderer_(false), | 336 delegating_renderer_(false), |
338 timeout_seconds_(0), | 337 timeout_seconds_(0), |
339 weak_factory_(this) { | 338 weak_factory_(this) { |
340 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); | 339 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); |
341 | 340 |
342 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was | 341 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was |
343 // specified (for running in a debugger). | 342 // specified (for running in a debugger). |
344 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 343 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 layer_tree_host_->SetNeedsRedrawRect(damage_rect); | 579 layer_tree_host_->SetNeedsRedrawRect(damage_rect); |
581 } | 580 } |
582 | 581 |
583 void LayerTreeTest::DispatchSetVisible(bool visible) { | 582 void LayerTreeTest::DispatchSetVisible(bool visible) { |
584 DCHECK(!proxy() || proxy()->IsMainThread()); | 583 DCHECK(!proxy() || proxy()->IsMainThread()); |
585 | 584 |
586 if (!layer_tree_host_) | 585 if (!layer_tree_host_) |
587 return; | 586 return; |
588 | 587 |
589 layer_tree_host_->SetVisible(visible); | 588 layer_tree_host_->SetVisible(visible); |
590 | |
591 // If the LTH is being made visible and a previous ScheduleComposite() was | |
592 // deferred because the LTH was not visible, re-schedule the composite now. | |
593 if (layer_tree_host_->visible() && schedule_when_set_visible_true_) | |
594 ScheduleComposite(); | |
595 } | 589 } |
596 | 590 |
597 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { | 591 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { |
598 DCHECK(!proxy() || proxy()->IsMainThread()); | 592 DCHECK(!proxy() || proxy()->IsMainThread()); |
599 | 593 |
600 if (layer_tree_host_) | 594 if (layer_tree_host_) |
601 layer_tree_host_->SetNextCommitForcesRedraw(); | 595 layer_tree_host_->SetNextCommitForcesRedraw(); |
602 } | 596 } |
603 | 597 |
604 void LayerTreeTest::DispatchComposite() { | 598 void LayerTreeTest::DispatchComposite() { |
605 scheduled_ = false; | 599 scheduled_ = false; |
606 | 600 |
607 if (!layer_tree_host_) | 601 if (!layer_tree_host_) |
608 return; | 602 return; |
609 | 603 |
610 // If the LTH is not visible, defer the composite until the LTH is made | 604 layer_tree_host_->SetNeedsCommit(); |
611 // visible. | |
612 if (!layer_tree_host_->visible()) { | |
613 schedule_when_set_visible_true_ = true; | |
614 return; | |
615 } | |
616 | |
617 schedule_when_set_visible_true_ = false; | |
618 base::TimeTicks now = gfx::FrameTime::Now(); | |
619 layer_tree_host_->Composite(now); | |
620 } | 605 } |
621 | 606 |
622 void LayerTreeTest::RunTest(bool threaded, | 607 void LayerTreeTest::RunTest(bool threaded, |
623 bool delegating_renderer, | 608 bool delegating_renderer, |
624 bool impl_side_painting) { | 609 bool impl_side_painting) { |
625 if (threaded) { | 610 if (threaded) { |
626 impl_thread_.reset(new base::Thread("Compositor")); | 611 impl_thread_.reset(new base::Thread("Compositor")); |
627 ASSERT_TRUE(impl_thread_->Start()); | 612 ASSERT_TRUE(impl_thread_->Start()); |
628 } | 613 } |
629 | 614 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 return -1; | 693 return -1; |
709 } | 694 } |
710 | 695 |
711 void LayerTreeTest::DestroyLayerTreeHost() { | 696 void LayerTreeTest::DestroyLayerTreeHost() { |
712 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 697 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
713 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 698 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
714 layer_tree_host_.reset(); | 699 layer_tree_host_.reset(); |
715 } | 700 } |
716 | 701 |
717 } // namespace cc | 702 } // namespace cc |
OLD | NEW |