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 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1823 | 1823 |
1824 private: | 1824 private: |
1825 FakeContentLayerClient client_; | 1825 FakeContentLayerClient client_; |
1826 scoped_refptr<EvictionTestLayer> layer_; | 1826 scoped_refptr<EvictionTestLayer> layer_; |
1827 LayerTreeHostImpl* impl_for_evict_textures_; | 1827 LayerTreeHostImpl* impl_for_evict_textures_; |
1828 int num_commits_; | 1828 int num_commits_; |
1829 }; | 1829 }; |
1830 | 1830 |
1831 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestEvictTextures); | 1831 MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestEvictTextures); |
1832 | 1832 |
1833 class LayerTreeHostTestContinuousCommit : public LayerTreeHostTest { | |
1834 public: | |
1835 LayerTreeHostTestContinuousCommit() | |
1836 : num_commit_complete_(0), num_draw_layers_(0) {} | |
1837 | |
1838 virtual void BeginTest() OVERRIDE { | |
1839 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | |
1840 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); | |
1841 | |
1842 PostSetNeedsCommitToMainThread(); | |
1843 } | |
1844 | |
1845 virtual void DidCommit() OVERRIDE { | |
1846 if (num_draw_layers_ == 2) | |
1847 return; | |
1848 layer_tree_host()->SetNeedsCommit(); | |
1849 } | |
1850 | |
1851 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
1852 if (num_draw_layers_ == 1) | |
1853 num_commit_complete_++; | |
1854 } | |
1855 | |
1856 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
1857 num_draw_layers_++; | |
1858 if (num_draw_layers_ == 2) | |
1859 EndTest(); | |
1860 } | |
1861 | |
1862 virtual void AfterTest() OVERRIDE { | |
1863 // Check that we didn't commit twice between first and second draw. | |
1864 EXPECT_EQ(1, num_commit_complete_); | |
1865 } | |
1866 | |
1867 private: | |
1868 int num_commit_complete_; | |
1869 int num_draw_layers_; | |
1870 }; | |
1871 | |
1872 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousCommit); | |
1873 | |
1874 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { | 1833 class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
1875 public: | 1834 public: |
1876 LayerTreeHostTestContinuousInvalidate() | 1835 LayerTreeHostTestContinuousInvalidate() |
1877 : num_commit_complete_(0), num_draw_layers_(0) {} | 1836 : num_commit_complete_(0), num_draw_layers_(0) {} |
1878 | 1837 |
1879 virtual void BeginTest() OVERRIDE { | 1838 virtual void BeginTest() OVERRIDE { |
1880 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); | 1839 layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
1881 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); | 1840 layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); |
1882 | 1841 |
1883 content_layer_ = ContentLayer::Create(&client_); | 1842 content_layer_ = ContentLayer::Create(&client_); |
(...skipping 2715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4599 private: | 4558 private: |
4600 int* set_needs_commit_count_; | 4559 int* set_needs_commit_count_; |
4601 int* set_needs_redraw_count_; | 4560 int* set_needs_redraw_count_; |
4602 }; | 4561 }; |
4603 | 4562 |
4604 class LayerTreeHostTestSimpleSwapPromiseMonitor : public LayerTreeHostTest { | 4563 class LayerTreeHostTestSimpleSwapPromiseMonitor : public LayerTreeHostTest { |
4605 public: | 4564 public: |
4606 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 4565 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
4607 | 4566 |
4608 virtual void WillBeginMainFrame() OVERRIDE { | 4567 virtual void WillBeginMainFrame() OVERRIDE { |
4568 if (TestEnded()) | |
4569 return; | |
4570 | |
4609 int set_needs_commit_count = 0; | 4571 int set_needs_commit_count = 0; |
4610 int set_needs_redraw_count = 0; | 4572 int set_needs_redraw_count = 0; |
4611 | 4573 |
4612 { | 4574 { |
4613 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 4575 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
4614 new SimpleSwapPromiseMonitor(layer_tree_host(), | 4576 new SimpleSwapPromiseMonitor(layer_tree_host(), |
4615 NULL, | 4577 NULL, |
4616 &set_needs_commit_count, | 4578 &set_needs_commit_count, |
4617 &set_needs_redraw_count)); | 4579 &set_needs_redraw_count)); |
4618 layer_tree_host()->SetNeedsCommit(); | 4580 layer_tree_host()->SetNeedsCommit(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4909 child_layer_->SetBounds(bounds_); | 4871 child_layer_->SetBounds(bounds_); |
4910 child_layer_->SetIsDrawable(true); | 4872 child_layer_->SetIsDrawable(true); |
4911 root_layer->AddChild(child_layer_); | 4873 root_layer->AddChild(child_layer_); |
4912 | 4874 |
4913 layer_tree_host()->SetRootLayer(root_layer); | 4875 layer_tree_host()->SetRootLayer(root_layer); |
4914 layer_tree_host()->SetViewportSize(bounds_); | 4876 layer_tree_host()->SetViewportSize(bounds_); |
4915 LayerTreeHostTest::SetupTree(); | 4877 LayerTreeHostTest::SetupTree(); |
4916 } | 4878 } |
4917 | 4879 |
4918 virtual void BeginTest() OVERRIDE { | 4880 virtual void BeginTest() OVERRIDE { |
4919 // Wait 50x longer than expected. | |
4920 double milliseconds_per_frame = | |
4921 1000 / layer_tree_host()->settings().refresh_rate; | |
4922 EndTestAfterDelay(50 * kExpectedNumCommits * milliseconds_per_frame); | |
4923 MainThreadTaskRunner()->PostTask( | 4881 MainThreadTaskRunner()->PostTask( |
4924 FROM_HERE, | 4882 FROM_HERE, |
4925 base::Bind( | 4883 base::Bind( |
4926 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, | 4884 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, |
4927 base::Unretained(this))); | 4885 base::Unretained(this))); |
4886 // Wait 50x longer than expected. | |
4887 double milliseconds_per_frame = | |
4888 1000 / layer_tree_host()->settings().refresh_rate; | |
enne (OOO)
2014/08/11 19:50:12
1000.0
danakj
2014/08/11 20:03:02
Thanks, done.
| |
4889 MainThreadTaskRunner()->PostDelayedTask( | |
4890 FROM_HERE, | |
4891 base::Bind( | |
4892 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, | |
4893 base::Unretained(this)), | |
4894 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * | |
4895 milliseconds_per_frame)); | |
4928 } | 4896 } |
4929 | 4897 |
4930 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { | 4898 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { |
4931 child_layer_->SetNeedsDisplay(); | 4899 child_layer_->SetNeedsDisplay(); |
4932 } | 4900 } |
4933 | 4901 |
4934 virtual void AfterTest() OVERRIDE { | 4902 virtual void AfterTest() OVERRIDE { |
4935 EXPECT_LE(kExpectedNumCommits, num_commits_); | 4903 EXPECT_LE(kExpectedNumCommits, num_commits_); |
4936 EXPECT_LE(kExpectedNumCommits, num_draws_); | 4904 EXPECT_LE(kExpectedNumCommits, num_draws_); |
4937 int update_count = content_layer_ ? content_layer_->PaintContentsCount() | 4905 int update_count = content_layer_ ? content_layer_->PaintContentsCount() |
(...skipping 10 matching lines...) Expand all Loading... | |
4948 ++num_commits_; | 4916 ++num_commits_; |
4949 } | 4917 } |
4950 | 4918 |
4951 private: | 4919 private: |
4952 void EnableContinuousPainting() { | 4920 void EnableContinuousPainting() { |
4953 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | 4921 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); |
4954 debug_state.continuous_painting = true; | 4922 debug_state.continuous_painting = true; |
4955 layer_tree_host()->SetDebugState(debug_state); | 4923 layer_tree_host()->SetDebugState(debug_state); |
4956 } | 4924 } |
4957 | 4925 |
4926 void DisableContinuousPainting() { | |
4927 LayerTreeDebugState debug_state = layer_tree_host()->debug_state(); | |
4928 debug_state.continuous_painting = false; | |
4929 layer_tree_host()->SetDebugState(debug_state); | |
4930 EndTest(); | |
4931 } | |
4932 | |
4958 int num_commits_; | 4933 int num_commits_; |
4959 int num_draws_; | 4934 int num_draws_; |
4960 const gfx::Size bounds_; | 4935 const gfx::Size bounds_; |
4961 FakeContentLayerClient client_; | 4936 FakeContentLayerClient client_; |
4962 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4937 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
4963 scoped_refptr<FakePictureLayer> picture_layer_; | 4938 scoped_refptr<FakePictureLayer> picture_layer_; |
4964 Layer* child_layer_; | 4939 Layer* child_layer_; |
4965 }; | 4940 }; |
4966 | 4941 |
4967 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4942 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
4968 | 4943 |
4969 } // namespace cc | 4944 } // namespace cc |
OLD | NEW |