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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 }; | 694 }; |
695 | 695 |
696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); | 696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); |
697 | 697 |
698 // This test verifies that LayerTreeHostImpl's current frame time gets | 698 // This test verifies that LayerTreeHostImpl's current frame time gets |
699 // updated in consecutive frames when it doesn't draw due to tree | 699 // updated in consecutive frames when it doesn't draw due to tree |
700 // activation failure. | 700 // activation failure. |
701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails | 701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails |
702 : public LayerTreeHostTest { | 702 : public LayerTreeHostTest { |
703 public: | 703 public: |
704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {} | 704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() |
| 705 : frame_count_with_pending_tree_(0) {} |
705 | 706 |
706 virtual void BeginTest() OVERRIDE { | 707 virtual void BeginTest() OVERRIDE { |
707 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 708 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
708 layer_tree_host()->set_background_color(SK_ColorGRAY); | 709 layer_tree_host()->set_background_color(SK_ColorGRAY); |
709 | 710 |
710 PostSetNeedsCommitToMainThread(); | 711 PostSetNeedsCommitToMainThread(); |
711 } | 712 } |
712 | 713 |
| 714 virtual void WillBeginFrameOnThread(LayerTreeHostImpl* host_impl, |
| 715 const BeginFrameArgs& args) OVERRIDE { |
| 716 if (host_impl->pending_tree()) |
| 717 frame_count_with_pending_tree_++; |
| 718 BlockNotifyReadyToActivate(frame_count_with_pending_tree_ <= 1); |
| 719 } |
| 720 |
713 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 721 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
714 if (frame_ >= 1) { | 722 if (frame_count_with_pending_tree_ > 1) { |
715 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); | 723 EXPECT_NE(first_frame_time_.ToInternalValue(), |
| 724 impl->CurrentFrameTimeTicks().ToInternalValue()); |
716 EndTest(); | 725 EndTest(); |
717 return; | 726 return; |
718 } | 727 } |
719 | 728 |
720 EXPECT_FALSE(impl->settings().impl_side_painting); | 729 EXPECT_FALSE(impl->settings().impl_side_painting); |
721 EndTest(); | 730 EndTest(); |
722 } | 731 } |
723 | 732 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
724 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { | 733 if (impl->settings().impl_side_painting) |
725 if (frame_ >= 1) | 734 EXPECT_NE(frame_count_with_pending_tree_, 1); |
726 return true; | |
727 | |
728 return false; | |
729 } | |
730 | |
731 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl) | |
732 OVERRIDE { | |
733 frame_++; | |
734 if (frame_ == 1) { | |
735 first_frame_time_ = impl->CurrentFrameTimeTicks(); | |
736 | |
737 // Since base::TimeTicks::Now() uses a low-resolution clock on | |
738 // Windows, we need to make sure that the clock has incremented past | |
739 // first_frame_time_. | |
740 while (first_frame_time_ == base::TimeTicks::Now()) {} | |
741 | |
742 return false; | |
743 } | |
744 | |
745 return true; | |
746 } | 735 } |
747 | 736 |
748 virtual void AfterTest() OVERRIDE {} | 737 virtual void AfterTest() OVERRIDE {} |
749 | 738 |
750 private: | 739 private: |
751 int frame_; | 740 int frame_count_with_pending_tree_; |
752 base::TimeTicks first_frame_time_; | 741 base::TimeTicks first_frame_time_; |
753 }; | 742 }; |
754 | 743 |
755 SINGLE_AND_MULTI_THREAD_TEST_F( | 744 SINGLE_AND_MULTI_THREAD_TEST_F( |
756 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); | 745 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); |
757 | 746 |
758 // This test verifies that LayerTreeHostImpl's current frame time gets | 747 // This test verifies that LayerTreeHostImpl's current frame time gets |
759 // updated in consecutive frames when it draws in each frame. | 748 // updated in consecutive frames when it draws in each frame. |
760 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { | 749 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { |
761 public: | 750 public: |
(...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4465 int num_will_begin_frames_; | 4454 int num_will_begin_frames_; |
4466 int num_impl_commits_; | 4455 int num_impl_commits_; |
4467 }; | 4456 }; |
4468 | 4457 |
4469 // Commits can only be aborted when using the thread proxy. | 4458 // Commits can only be aborted when using the thread proxy. |
4470 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); | 4459 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); |
4471 | 4460 |
4472 } // namespace | 4461 } // namespace |
4473 | 4462 |
4474 } // namespace cc | 4463 } // namespace cc |
OLD | NEW |