| 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 } |
| 719 |
| 713 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 720 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 714 if (frame_ >= 1) { | 721 if (frame_count_with_pending_tree_ > 1) { |
| 715 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); | 722 EXPECT_NE(first_frame_time_.ToInternalValue(), |
| 723 impl->CurrentFrameTimeTicks().ToInternalValue()); |
| 716 EndTest(); | 724 EndTest(); |
| 717 return; | 725 return; |
| 718 } | 726 } |
| 719 | 727 |
| 720 EXPECT_FALSE(impl->settings().impl_side_painting); | 728 EXPECT_FALSE(impl->settings().impl_side_painting); |
| 721 EndTest(); | 729 EndTest(); |
| 722 } | 730 } |
| 723 | 731 |
| 724 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { | 732 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { |
| 725 if (frame_ >= 1) | 733 return frame_count_with_pending_tree_ > 1; |
| 726 return true; | |
| 727 | |
| 728 return false; | |
| 729 } | 734 } |
| 730 | 735 |
| 731 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl) | 736 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 732 OVERRIDE { | 737 if (impl->settings().impl_side_painting) |
| 733 frame_++; | 738 EXPECT_NE(frame_count_with_pending_tree_, 1); |
| 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 } | 739 } |
| 747 | 740 |
| 748 virtual void AfterTest() OVERRIDE {} | 741 virtual void AfterTest() OVERRIDE {} |
| 749 | 742 |
| 750 private: | 743 private: |
| 751 int frame_; | 744 int frame_count_with_pending_tree_; |
| 752 base::TimeTicks first_frame_time_; | 745 base::TimeTicks first_frame_time_; |
| 753 }; | 746 }; |
| 754 | 747 |
| 755 SINGLE_AND_MULTI_THREAD_TEST_F( | 748 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 756 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); | 749 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); |
| 757 | 750 |
| 758 // This test verifies that LayerTreeHostImpl's current frame time gets | 751 // This test verifies that LayerTreeHostImpl's current frame time gets |
| 759 // updated in consecutive frames when it draws in each frame. | 752 // updated in consecutive frames when it draws in each frame. |
| 760 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { | 753 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { |
| 761 public: | 754 public: |
| (...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4465 int num_will_begin_frames_; | 4458 int num_will_begin_frames_; |
| 4466 int num_impl_commits_; | 4459 int num_impl_commits_; |
| 4467 }; | 4460 }; |
| 4468 | 4461 |
| 4469 // Commits can only be aborted when using the thread proxy. | 4462 // Commits can only be aborted when using the thread proxy. |
| 4470 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); | 4463 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); |
| 4471 | 4464 |
| 4472 } // namespace | 4465 } // namespace |
| 4473 | 4466 |
| 4474 } // namespace cc | 4467 } // namespace cc |
| OLD | NEW |