| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 impl->BlockNotifyReadyToActivateForTesting(true); | 740 impl->BlockNotifyReadyToActivateForTesting(true); |
| 741 } | 741 } |
| 742 | 742 |
| 743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | 743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
| 744 const BeginFrameArgs& args) OVERRIDE { | 744 const BeginFrameArgs& args) OVERRIDE { |
| 745 if (impl->pending_tree()) | 745 if (impl->pending_tree()) |
| 746 frame_count_with_pending_tree_++; | 746 frame_count_with_pending_tree_++; |
| 747 | 747 |
| 748 if (frame_count_with_pending_tree_ == 1) { | 748 if (frame_count_with_pending_tree_ == 1) { |
| 749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); | 749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); |
| 750 first_frame_time_ = impl->CurrentFrameTimeTicks(); | 750 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; |
| 751 } else if (frame_count_with_pending_tree_ == 2) { | 751 } else if (frame_count_with_pending_tree_ == 2) { |
| 752 impl->BlockNotifyReadyToActivateForTesting(false); | 752 impl->BlockNotifyReadyToActivateForTesting(false); |
| 753 } | 753 } |
| 754 } | 754 } |
| 755 | 755 |
| 756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 757 if (frame_count_with_pending_tree_ > 1) { | 757 if (frame_count_with_pending_tree_ > 1) { |
| 758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); | 758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); |
| 759 EXPECT_NE(first_frame_time_.ToInternalValue(), | 759 EXPECT_NE(first_frame_time_.ToInternalValue(), |
| 760 impl->CurrentFrameTimeTicks().ToInternalValue()); | 760 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); |
| 761 EndTest(); | 761 EndTest(); |
| 762 return; | 762 return; |
| 763 } | 763 } |
| 764 | 764 |
| 765 EXPECT_FALSE(impl->settings().impl_side_painting); | 765 EXPECT_FALSE(impl->settings().impl_side_painting); |
| 766 EndTest(); | 766 EndTest(); |
| 767 } | 767 } |
| 768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 769 if (impl->settings().impl_side_painting) | 769 if (impl->settings().impl_side_painting) |
| 770 EXPECT_NE(frame_count_with_pending_tree_, 1); | 770 EXPECT_NE(frame_count_with_pending_tree_, 1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 789 virtual void BeginTest() OVERRIDE { | 789 virtual void BeginTest() OVERRIDE { |
| 790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
| 791 layer_tree_host()->set_background_color(SK_ColorGRAY); | 791 layer_tree_host()->set_background_color(SK_ColorGRAY); |
| 792 | 792 |
| 793 PostSetNeedsCommitToMainThread(); | 793 PostSetNeedsCommitToMainThread(); |
| 794 } | 794 } |
| 795 | 795 |
| 796 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 796 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 797 frame_++; | 797 frame_++; |
| 798 if (frame_ == 1) { | 798 if (frame_ == 1) { |
| 799 first_frame_time_ = impl->CurrentFrameTimeTicks(); | 799 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; |
| 800 impl->SetNeedsRedraw(); | 800 impl->SetNeedsRedraw(); |
| 801 | 801 |
| 802 // Since we might use a low-resolution clock on Windows, we need to | 802 // Since we might use a low-resolution clock on Windows, we need to |
| 803 // make sure that the clock has incremented past first_frame_time_. | 803 // make sure that the clock has incremented past first_frame_time_. |
| 804 while (first_frame_time_ == gfx::FrameTime::Now()) { | 804 while (first_frame_time_ == gfx::FrameTime::Now()) { |
| 805 } | 805 } |
| 806 | 806 |
| 807 return; | 807 return; |
| 808 } | 808 } |
| 809 | 809 |
| 810 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); | 810 EXPECT_NE(first_frame_time_, impl->CurrentBeginFrameArgs().frame_time); |
| 811 EndTest(); | 811 EndTest(); |
| 812 } | 812 } |
| 813 | 813 |
| 814 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 814 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 815 // Ensure there isn't a commit between the two draws, to ensure that a | 815 // Ensure there isn't a commit between the two draws, to ensure that a |
| 816 // commit isn't required for updating the current frame time. We can | 816 // commit isn't required for updating the current frame time. We can |
| 817 // only check for this in the multi-threaded case, since in the single- | 817 // only check for this in the multi-threaded case, since in the single- |
| 818 // threaded case there will always be a commit between consecutive draws. | 818 // threaded case there will always be a commit between consecutive draws. |
| 819 if (HasImplThread()) | 819 if (HasImplThread()) |
| 820 EXPECT_EQ(0, frame_); | 820 EXPECT_EQ(0, frame_); |
| (...skipping 4146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4967 1000.0 / layer_tree_host()->settings().refresh_rate; | 4967 1000.0 / layer_tree_host()->settings().refresh_rate; |
| 4968 MainThreadTaskRunner()->PostDelayedTask( | 4968 MainThreadTaskRunner()->PostDelayedTask( |
| 4969 FROM_HERE, | 4969 FROM_HERE, |
| 4970 base::Bind( | 4970 base::Bind( |
| 4971 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, | 4971 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, |
| 4972 base::Unretained(this)), | 4972 base::Unretained(this)), |
| 4973 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * | 4973 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * |
| 4974 milliseconds_per_frame)); | 4974 milliseconds_per_frame)); |
| 4975 } | 4975 } |
| 4976 | 4976 |
| 4977 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { | 4977 virtual void BeginMainFrame(const BeginFrameArgs& args) OVERRIDE { |
| 4978 child_layer_->SetNeedsDisplay(); | 4978 child_layer_->SetNeedsDisplay(); |
| 4979 } | 4979 } |
| 4980 | 4980 |
| 4981 virtual void AfterTest() OVERRIDE { | 4981 virtual void AfterTest() OVERRIDE { |
| 4982 EXPECT_LE(kExpectedNumCommits, num_commits_); | 4982 EXPECT_LE(kExpectedNumCommits, num_commits_); |
| 4983 EXPECT_LE(kExpectedNumCommits, num_draws_); | 4983 EXPECT_LE(kExpectedNumCommits, num_draws_); |
| 4984 int update_count = content_layer_ ? content_layer_->PaintContentsCount() | 4984 int update_count = content_layer_ ? content_layer_->PaintContentsCount() |
| 4985 : picture_layer_->update_count(); | 4985 : picture_layer_->update_count(); |
| 4986 EXPECT_LE(kExpectedNumCommits, update_count); | 4986 EXPECT_LE(kExpectedNumCommits, update_count); |
| 4987 } | 4987 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5014 const gfx::Size bounds_; | 5014 const gfx::Size bounds_; |
| 5015 FakeContentLayerClient client_; | 5015 FakeContentLayerClient client_; |
| 5016 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5016 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5017 scoped_refptr<FakePictureLayer> picture_layer_; | 5017 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5018 Layer* child_layer_; | 5018 Layer* child_layer_; |
| 5019 }; | 5019 }; |
| 5020 | 5020 |
| 5021 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5021 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5022 | 5022 |
| 5023 } // namespace cc | 5023 } // namespace cc |
| OLD | NEW |