| 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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 impl->BlockNotifyReadyToActivateForTesting(true); | 765 impl->BlockNotifyReadyToActivateForTesting(true); |
| 766 } | 766 } |
| 767 | 767 |
| 768 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | 768 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
| 769 const BeginFrameArgs& args) OVERRIDE { | 769 const BeginFrameArgs& args) OVERRIDE { |
| 770 if (impl->pending_tree()) | 770 if (impl->pending_tree()) |
| 771 frame_count_with_pending_tree_++; | 771 frame_count_with_pending_tree_++; |
| 772 | 772 |
| 773 if (frame_count_with_pending_tree_ == 1) { | 773 if (frame_count_with_pending_tree_ == 1) { |
| 774 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); | 774 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); |
| 775 first_frame_time_ = impl->CurrentFrameTimeTicks(); | 775 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; |
| 776 } else if (frame_count_with_pending_tree_ == 2) { | 776 } else if (frame_count_with_pending_tree_ == 2) { |
| 777 impl->BlockNotifyReadyToActivateForTesting(false); | 777 impl->BlockNotifyReadyToActivateForTesting(false); |
| 778 } | 778 } |
| 779 } | 779 } |
| 780 | 780 |
| 781 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 781 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 782 if (frame_count_with_pending_tree_ > 1) { | 782 if (frame_count_with_pending_tree_ > 1) { |
| 783 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); | 783 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); |
| 784 EXPECT_NE(first_frame_time_.ToInternalValue(), | 784 EXPECT_NE(first_frame_time_.ToInternalValue(), |
| 785 impl->CurrentFrameTimeTicks().ToInternalValue()); | 785 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); |
| 786 EndTest(); | 786 EndTest(); |
| 787 return; | 787 return; |
| 788 } | 788 } |
| 789 | 789 |
| 790 EXPECT_FALSE(impl->settings().impl_side_painting); | 790 EXPECT_FALSE(impl->settings().impl_side_painting); |
| 791 EndTest(); | 791 EndTest(); |
| 792 } | 792 } |
| 793 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 793 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 794 if (impl->settings().impl_side_painting) | 794 if (impl->settings().impl_side_painting) |
| 795 EXPECT_NE(frame_count_with_pending_tree_, 1); | 795 EXPECT_NE(frame_count_with_pending_tree_, 1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 814 virtual void BeginTest() OVERRIDE { | 814 virtual void BeginTest() OVERRIDE { |
| 815 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 815 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
| 816 layer_tree_host()->set_background_color(SK_ColorGRAY); | 816 layer_tree_host()->set_background_color(SK_ColorGRAY); |
| 817 | 817 |
| 818 PostSetNeedsCommitToMainThread(); | 818 PostSetNeedsCommitToMainThread(); |
| 819 } | 819 } |
| 820 | 820 |
| 821 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 821 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 822 frame_++; | 822 frame_++; |
| 823 if (frame_ == 1) { | 823 if (frame_ == 1) { |
| 824 first_frame_time_ = impl->CurrentFrameTimeTicks(); | 824 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; |
| 825 impl->SetNeedsRedraw(); | 825 impl->SetNeedsRedraw(); |
| 826 | 826 |
| 827 // Since we might use a low-resolution clock on Windows, we need to | 827 // Since we might use a low-resolution clock on Windows, we need to |
| 828 // make sure that the clock has incremented past first_frame_time_. | 828 // make sure that the clock has incremented past first_frame_time_. |
| 829 while (first_frame_time_ == gfx::FrameTime::Now()) { | 829 while (first_frame_time_ == gfx::FrameTime::Now()) { |
| 830 } | 830 } |
| 831 | 831 |
| 832 return; | 832 return; |
| 833 } | 833 } |
| 834 | 834 |
| 835 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); | 835 EXPECT_NE(first_frame_time_, impl->CurrentBeginFrameArgs().frame_time); |
| 836 EndTest(); | 836 EndTest(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 839 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 840 // Ensure there isn't a commit between the two draws, to ensure that a | 840 // Ensure there isn't a commit between the two draws, to ensure that a |
| 841 // commit isn't required for updating the current frame time. We can | 841 // commit isn't required for updating the current frame time. We can |
| 842 // only check for this in the multi-threaded case, since in the single- | 842 // only check for this in the multi-threaded case, since in the single- |
| 843 // threaded case there will always be a commit between consecutive draws. | 843 // threaded case there will always be a commit between consecutive draws. |
| 844 if (HasImplThread()) | 844 if (HasImplThread()) |
| 845 EXPECT_EQ(0, frame_); | 845 EXPECT_EQ(0, frame_); |
| (...skipping 4081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4927 double milliseconds_per_frame = | 4927 double milliseconds_per_frame = |
| 4928 1000 / layer_tree_host()->settings().refresh_rate; | 4928 1000 / layer_tree_host()->settings().refresh_rate; |
| 4929 EndTestAfterDelay(50 * kExpectedNumCommits * milliseconds_per_frame); | 4929 EndTestAfterDelay(50 * kExpectedNumCommits * milliseconds_per_frame); |
| 4930 MainThreadTaskRunner()->PostTask( | 4930 MainThreadTaskRunner()->PostTask( |
| 4931 FROM_HERE, | 4931 FROM_HERE, |
| 4932 base::Bind( | 4932 base::Bind( |
| 4933 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, | 4933 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, |
| 4934 base::Unretained(this))); | 4934 base::Unretained(this))); |
| 4935 } | 4935 } |
| 4936 | 4936 |
| 4937 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { | 4937 virtual void BeginMainFrame(const BeginFrameArgs& args) OVERRIDE { |
| 4938 child_layer_->SetNeedsDisplay(); | 4938 child_layer_->SetNeedsDisplay(); |
| 4939 } | 4939 } |
| 4940 | 4940 |
| 4941 virtual void AfterTest() OVERRIDE { | 4941 virtual void AfterTest() OVERRIDE { |
| 4942 EXPECT_LE(kExpectedNumCommits, num_commits_); | 4942 EXPECT_LE(kExpectedNumCommits, num_commits_); |
| 4943 EXPECT_LE(kExpectedNumCommits, num_draws_); | 4943 EXPECT_LE(kExpectedNumCommits, num_draws_); |
| 4944 int update_count = content_layer_ ? content_layer_->PaintContentsCount() | 4944 int update_count = content_layer_ ? content_layer_->PaintContentsCount() |
| 4945 : picture_layer_->update_count(); | 4945 : picture_layer_->update_count(); |
| 4946 EXPECT_LE(kExpectedNumCommits, update_count); | 4946 EXPECT_LE(kExpectedNumCommits, update_count); |
| 4947 } | 4947 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4967 const gfx::Size bounds_; | 4967 const gfx::Size bounds_; |
| 4968 FakeContentLayerClient client_; | 4968 FakeContentLayerClient client_; |
| 4969 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4969 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 4970 scoped_refptr<FakePictureLayer> picture_layer_; | 4970 scoped_refptr<FakePictureLayer> picture_layer_; |
| 4971 Layer* child_layer_; | 4971 Layer* child_layer_; |
| 4972 }; | 4972 }; |
| 4973 | 4973 |
| 4974 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4974 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 4975 | 4975 |
| 4976 } // namespace cc | 4976 } // namespace cc |
| OLD | NEW |