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

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

Issue 676953003: cc: Always keep the PictureLayerImpl::twin_layer_ pointer valid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twins: anothercheck Created 6 years, 1 month 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
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/test/fake_content_layer_client.h" 7 #include "cc/test/fake_content_layer_client.h"
8 #include "cc/test/fake_picture_layer.h" 8 #include "cc/test/fake_picture_layer.h"
9 #include "cc/test/fake_picture_layer_impl.h" 9 #include "cc/test/fake_picture_layer_impl.h"
10 #include "cc/test/layer_tree_test.h" 10 #include "cc/test/layer_tree_test.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (pending_root_impl->children().empty()) { 59 if (pending_root_impl->children().empty()) {
60 EXPECT_EQ(2, activates_); 60 EXPECT_EQ(2, activates_);
61 return; 61 return;
62 } 62 }
63 63
64 FakePictureLayerImpl* pending_picture_impl = 64 FakePictureLayerImpl* pending_picture_impl =
65 static_cast<FakePictureLayerImpl*>(pending_root_impl->children()[0]); 65 static_cast<FakePictureLayerImpl*>(pending_root_impl->children()[0]);
66 66
67 if (!active_root_impl) { 67 if (!active_root_impl) {
68 EXPECT_EQ(0, activates_); 68 EXPECT_EQ(0, activates_);
69 EXPECT_EQ(NULL, pending_picture_impl->twin_layer()); 69 EXPECT_EQ(nullptr, pending_picture_impl->GetPendingOrActiveTwinLayer());
70 return; 70 return;
71 } 71 }
72 72
73 if (active_root_impl->children().empty()) { 73 if (active_root_impl->children().empty()) {
74 EXPECT_EQ(3, activates_); 74 EXPECT_EQ(3, activates_);
75 EXPECT_EQ(NULL, pending_picture_impl->twin_layer()); 75 EXPECT_EQ(nullptr, pending_picture_impl->GetPendingOrActiveTwinLayer());
76 return; 76 return;
77 } 77 }
78 78
79 FakePictureLayerImpl* active_picture_impl = 79 FakePictureLayerImpl* active_picture_impl =
80 static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]); 80 static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]);
81 81
82 // After the first activation, when we commit again, we'll have a pending 82 // After the first activation, when we commit again, we'll have a pending
83 // and active layer. Then we recreate a picture layer in the 4th activate 83 // and active layer. Then we recreate a picture layer in the 4th activate
84 // and the next commit will have a pending and active twin again. 84 // and the next commit will have a pending and active twin again.
85 EXPECT_TRUE(activates_ == 1 || activates_ == 4); 85 EXPECT_TRUE(activates_ == 1 || activates_ == 4);
86 86
87 EXPECT_EQ(pending_picture_impl, active_picture_impl->twin_layer()); 87 EXPECT_EQ(pending_picture_impl,
88 EXPECT_EQ(active_picture_impl, pending_picture_impl->twin_layer()); 88 active_picture_impl->GetPendingOrActiveTwinLayer());
89 EXPECT_EQ(active_picture_impl,
90 pending_picture_impl->GetPendingOrActiveTwinLayer());
91 EXPECT_EQ(nullptr, active_picture_impl->GetRecycledTwinLayer());
89 } 92 }
90 93
91 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { 94 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
92 LayerImpl* active_root_impl = impl->active_tree()->root_layer(); 95 LayerImpl* active_root_impl = impl->active_tree()->root_layer();
96 LayerImpl* recycle_root_impl = impl->recycle_tree()->root_layer();
93 97
94 if (active_root_impl->children().empty()) { 98 if (active_root_impl->children().empty()) {
95 EXPECT_EQ(2, activates_); 99 EXPECT_EQ(2, activates_);
96 } else { 100 } else {
97 FakePictureLayerImpl* active_picture_impl = 101 FakePictureLayerImpl* active_picture_impl =
98 static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]); 102 static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]);
103 FakePictureLayerImpl* recycle_picture_impl =
104 static_cast<FakePictureLayerImpl*>(recycle_root_impl->children()[0]);
99 105
100 EXPECT_EQ(NULL, active_picture_impl->twin_layer()); 106 EXPECT_EQ(nullptr, active_picture_impl->GetPendingOrActiveTwinLayer());
107 EXPECT_EQ(recycle_picture_impl,
108 active_picture_impl->GetRecycledTwinLayer());
101 } 109 }
102 110
103 ++activates_; 111 ++activates_;
104 if (activates_ <= 4) 112 if (activates_ <= 4)
105 PostSetNeedsCommitToMainThread(); 113 PostSetNeedsCommitToMainThread();
106 else 114 else
107 EndTest(); 115 EndTest();
108 } 116 }
109 117
110 void AfterTest() override {} 118 void AfterTest() override {}
111 119
112 FakeContentLayerClient client_; 120 FakeContentLayerClient client_;
113 int activates_; 121 int activates_;
114 }; 122 };
115 123
116 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer); 124 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer);
117 125
118 } // namespace 126 } // namespace
119 } // namespace cc 127 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698