| 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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 } | 933 } |
| 934 | 934 |
| 935 virtual void AfterTest() OVERRIDE {} | 935 virtual void AfterTest() OVERRIDE {} |
| 936 | 936 |
| 937 private: | 937 private: |
| 938 bool done_; | 938 bool done_; |
| 939 }; | 939 }; |
| 940 | 940 |
| 941 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCanDrawBlocksDrawing); | 941 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCanDrawBlocksDrawing); |
| 942 | 942 |
| 943 // beginLayerWrite should prevent draws from executing until a commit occurs | |
| 944 class LayerTreeHostTestWriteLayersRedraw : public LayerTreeHostTest { | |
| 945 public: | |
| 946 LayerTreeHostTestWriteLayersRedraw() : num_commits_(0), num_draws_(0) {} | |
| 947 | |
| 948 virtual void BeginTest() OVERRIDE { | |
| 949 PostAcquireLayerTextures(); | |
| 950 PostSetNeedsRedrawToMainThread(); // should be inhibited without blocking | |
| 951 PostSetNeedsCommitToMainThread(); | |
| 952 } | |
| 953 | |
| 954 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 955 num_draws_++; | |
| 956 EXPECT_EQ(num_draws_, num_commits_); | |
| 957 } | |
| 958 | |
| 959 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 960 num_commits_++; | |
| 961 EndTest(); | |
| 962 } | |
| 963 | |
| 964 virtual void AfterTest() OVERRIDE { EXPECT_EQ(1, num_commits_); } | |
| 965 | |
| 966 private: | |
| 967 int num_commits_; | |
| 968 int num_draws_; | |
| 969 }; | |
| 970 | |
| 971 MULTI_THREAD_TEST_F(LayerTreeHostTestWriteLayersRedraw); | |
| 972 | |
| 973 // Verify that when resuming visibility, Requesting layer write permission | |
| 974 // will not deadlock the main thread even though there are not yet any | |
| 975 // scheduled redraws. This behavior is critical for reliably surviving tab | |
| 976 // switching. There are no failure conditions to this test, it just passes | |
| 977 // by not timing out. | |
| 978 class LayerTreeHostTestWriteLayersAfterVisible : public LayerTreeHostTest { | |
| 979 public: | |
| 980 LayerTreeHostTestWriteLayersAfterVisible() : num_commits_(0) {} | |
| 981 | |
| 982 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 983 | |
| 984 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 985 num_commits_++; | |
| 986 if (num_commits_ == 2) | |
| 987 EndTest(); | |
| 988 else if (num_commits_ < 2) { | |
| 989 PostSetVisibleToMainThread(false); | |
| 990 PostSetVisibleToMainThread(true); | |
| 991 PostAcquireLayerTextures(); | |
| 992 PostSetNeedsCommitToMainThread(); | |
| 993 } | |
| 994 } | |
| 995 | |
| 996 virtual void AfterTest() OVERRIDE {} | |
| 997 | |
| 998 private: | |
| 999 int num_commits_; | |
| 1000 }; | |
| 1001 | |
| 1002 MULTI_THREAD_TEST_F(LayerTreeHostTestWriteLayersAfterVisible); | |
| 1003 | |
| 1004 // A compositeAndReadback while invisible should force a normal commit without | 943 // A compositeAndReadback while invisible should force a normal commit without |
| 1005 // assertion. | 944 // assertion. |
| 1006 class LayerTreeHostTestCompositeAndReadbackWhileInvisible | 945 class LayerTreeHostTestCompositeAndReadbackWhileInvisible |
| 1007 : public LayerTreeHostTest { | 946 : public LayerTreeHostTest { |
| 1008 public: | 947 public: |
| 1009 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {} | 948 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {} |
| 1010 | 949 |
| 1011 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 950 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 1012 | 951 |
| 1013 virtual void DidCommitAndDrawFrame() OVERRIDE { | 952 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 virtual void BeginTest() OVERRIDE { | 1811 virtual void BeginTest() OVERRIDE { |
| 1873 layer_tree_host()->SetNeedsRedraw(); | 1812 layer_tree_host()->SetNeedsRedraw(); |
| 1874 PostSetNeedsCommitToMainThread(); | 1813 PostSetNeedsCommitToMainThread(); |
| 1875 } | 1814 } |
| 1876 | 1815 |
| 1877 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1816 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 1878 if (once_) | 1817 if (once_) |
| 1879 return; | 1818 return; |
| 1880 once_ = true; | 1819 once_ = true; |
| 1881 layer_tree_host()->SetNeedsRedraw(); | 1820 layer_tree_host()->SetNeedsRedraw(); |
| 1882 layer_tree_host()->AcquireLayerTextures(); | |
| 1883 { | 1821 { |
| 1884 base::AutoLock lock(lock_); | 1822 base::AutoLock lock(lock_); |
| 1885 draw_count_ = 0; | 1823 draw_count_ = 0; |
| 1886 } | 1824 } |
| 1887 layer_tree_host()->FinishAllRendering(); | 1825 layer_tree_host()->FinishAllRendering(); |
| 1888 { | 1826 { |
| 1889 base::AutoLock lock(lock_); | 1827 base::AutoLock lock(lock_); |
| 1890 EXPECT_EQ(0, draw_count_); | 1828 EXPECT_EQ(0, draw_count_); |
| 1891 } | 1829 } |
| 1892 EndTest(); | 1830 EndTest(); |
| (...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5284 const gfx::Size bounds_; | 5222 const gfx::Size bounds_; |
| 5285 FakeContentLayerClient client_; | 5223 FakeContentLayerClient client_; |
| 5286 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5224 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5287 scoped_refptr<FakePictureLayer> picture_layer_; | 5225 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5288 Layer* child_layer_; | 5226 Layer* child_layer_; |
| 5289 }; | 5227 }; |
| 5290 | 5228 |
| 5291 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5229 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5292 | 5230 |
| 5293 } // namespace cc | 5231 } // namespace cc |
| OLD | NEW |