Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 227413011: Remove old texture path in TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 virtual void BeginTest() OVERRIDE { 1809 virtual void BeginTest() OVERRIDE {
1871 layer_tree_host()->SetNeedsRedraw(); 1810 layer_tree_host()->SetNeedsRedraw();
1872 PostSetNeedsCommitToMainThread(); 1811 PostSetNeedsCommitToMainThread();
1873 } 1812 }
1874 1813
1875 virtual void DidCommitAndDrawFrame() OVERRIDE { 1814 virtual void DidCommitAndDrawFrame() OVERRIDE {
1876 if (once_) 1815 if (once_)
1877 return; 1816 return;
1878 once_ = true; 1817 once_ = true;
1879 layer_tree_host()->SetNeedsRedraw(); 1818 layer_tree_host()->SetNeedsRedraw();
1880 layer_tree_host()->AcquireLayerTextures();
1881 { 1819 {
1882 base::AutoLock lock(lock_); 1820 base::AutoLock lock(lock_);
1883 draw_count_ = 0; 1821 draw_count_ = 0;
1884 } 1822 }
1885 layer_tree_host()->FinishAllRendering(); 1823 layer_tree_host()->FinishAllRendering();
1886 { 1824 {
1887 base::AutoLock lock(lock_); 1825 base::AutoLock lock(lock_);
1888 EXPECT_EQ(0, draw_count_); 1826 EXPECT_EQ(0, draw_count_);
1889 } 1827 }
1890 EndTest(); 1828 EndTest();
(...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after
5282 const gfx::Size bounds_; 5220 const gfx::Size bounds_;
5283 FakeContentLayerClient client_; 5221 FakeContentLayerClient client_;
5284 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5222 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5285 scoped_refptr<FakePictureLayer> picture_layer_; 5223 scoped_refptr<FakePictureLayer> picture_layer_;
5286 Layer* child_layer_; 5224 Layer* child_layer_;
5287 }; 5225 };
5288 5226
5289 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5227 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5290 5228
5291 } // namespace cc 5229 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698