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

Side by Side Diff: cc/tree_synchronizer_unittest.cc

Issue 12648005: cc: Chromify the LayerTreeHostImpl class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compl Created 7 years, 9 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
« no previous file with comments | « cc/tiled_layer_unittest.cc ('k') | webkit/compositor_bindings/web_to_ccinput_handler_adapter.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 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/tree_synchronizer.h" 5 #include "cc/tree_synchronizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/layer.h" 9 #include "cc/layer.h"
10 #include "cc/layer_animation_controller.h" 10 #include "cc/layer_animation_controller.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 protected: 137 protected:
138 FakeImplProxy m_proxy; 138 FakeImplProxy m_proxy;
139 FakeLayerTreeHostImpl m_hostImpl; 139 FakeLayerTreeHostImpl m_hostImpl;
140 }; 140 };
141 141
142 // Attempts to synchronizes a null tree. This should not crash, and should 142 // Attempts to synchronizes a null tree. This should not crash, and should
143 // return a null tree. 143 // return a null tree.
144 TEST_F(TreeSynchronizerTest, syncNullTree) 144 TEST_F(TreeSynchronizerTest, syncNullTree)
145 { 145 {
146 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (static_cast<Layer*>(NULL), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 146 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (static_cast<Layer*>(NULL), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
147 147
148 EXPECT_TRUE(!layerImplTreeRoot.get()); 148 EXPECT_TRUE(!layerImplTreeRoot.get());
149 } 149 }
150 150
151 // Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers. 151 // Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers.
152 TEST_F(TreeSynchronizerTest, syncSimpleTreeFromEmpty) 152 TEST_F(TreeSynchronizerTest, syncSimpleTreeFromEmpty)
153 { 153 {
154 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 154 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
155 layerTreeRoot->AddChild(Layer::Create()); 155 layerTreeRoot->AddChild(Layer::Create());
156 layerTreeRoot->AddChild(Layer::Create()); 156 layerTreeRoot->AddChild(Layer::Create());
157 157
158 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 158 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
159 159
160 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 160 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
161 } 161 }
162 162
163 // Constructs a very simple tree and synchronizes it attempting to reuse some la yers 163 // Constructs a very simple tree and synchronizes it attempting to reuse some la yers
164 TEST_F(TreeSynchronizerTest, syncSimpleTreeReusingLayers) 164 TEST_F(TreeSynchronizerTest, syncSimpleTreeReusingLayers)
165 { 165 {
166 std::vector<int> layerImplDestructionList; 166 std::vector<int> layerImplDestructionList;
167 167
168 scoped_refptr<Layer> layerTreeRoot = MockLayer::Create(&layerImplDestruction List); 168 scoped_refptr<Layer> layerTreeRoot = MockLayer::Create(&layerImplDestruction List);
169 layerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList)); 169 layerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList));
170 layerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList)); 170 layerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList));
171 171
172 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 172 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
173 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 173 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
174 174
175 // We have to push properties to pick up the destruction list pointer. 175 // We have to push properties to pick up the destruction list pointer.
176 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 176 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
177 177
178 // Add a new layer to the Layer side 178 // Add a new layer to the Layer side
179 layerTreeRoot->children()[0]->AddChild(MockLayer::Create(&layerImplDestructi onList)); 179 layerTreeRoot->children()[0]->AddChild(MockLayer::Create(&layerImplDestructi onList));
180 // Remove one. 180 // Remove one.
181 layerTreeRoot->children()[1]->RemoveFromParent(); 181 layerTreeRoot->children()[1]->RemoveFromParent();
182 int secondLayerImplId = layerImplTreeRoot->children()[1]->id(); 182 int secondLayerImplId = layerImplTreeRoot->children()[1]->id();
183 183
184 // Synchronize again. After the sync the trees should be equivalent and we s hould have created and destroyed one LayerImpl. 184 // Synchronize again. After the sync the trees should be equivalent and we s hould have created and destroyed one LayerImpl.
185 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 185 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
186 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 186 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
187 187
188 ASSERT_EQ(1u, layerImplDestructionList.size()); 188 ASSERT_EQ(1u, layerImplDestructionList.size());
189 EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]); 189 EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]);
190 } 190 }
191 191
192 // Constructs a very simple tree and checks that a stacking-order change is trac ked properly. 192 // Constructs a very simple tree and checks that a stacking-order change is trac ked properly.
193 TEST_F(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) 193 TEST_F(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange)
194 { 194 {
195 std::vector<int> layerImplDestructionList; 195 std::vector<int> layerImplDestructionList;
196 196
197 // Set up the tree and sync once. child2 needs to be synced here, too, even though we 197 // Set up the tree and sync once. child2 needs to be synced here, too, even though we
198 // remove it to set up the intended scenario. 198 // remove it to set up the intended scenario.
199 scoped_refptr<Layer> layerTreeRoot = MockLayer::Create(&layerImplDestruction List); 199 scoped_refptr<Layer> layerTreeRoot = MockLayer::Create(&layerImplDestruction List);
200 scoped_refptr<Layer> child2 = MockLayer::Create(&layerImplDestructionList); 200 scoped_refptr<Layer> child2 = MockLayer::Create(&layerImplDestructionList);
201 layerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList)); 201 layerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList));
202 layerTreeRoot->AddChild(child2); 202 layerTreeRoot->AddChild(child2);
203 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 203 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
204 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 204 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
205 205
206 // We have to push properties to pick up the destruction list pointer. 206 // We have to push properties to pick up the destruction list pointer.
207 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 207 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
208 208
209 layerImplTreeRoot->ResetAllChangeTrackingForSubtree(); 209 layerImplTreeRoot->ResetAllChangeTrackingForSubtree();
210 210
211 // re-insert the layer and sync again. 211 // re-insert the layer and sync again.
212 child2->RemoveFromParent(); 212 child2->RemoveFromParent();
213 layerTreeRoot->AddChild(child2); 213 layerTreeRoot->AddChild(child2);
214 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 214 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
215 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 215 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
216 216
217 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 217 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
218 218
219 // Check that the impl thread properly tracked the change. 219 // Check that the impl thread properly tracked the change.
220 EXPECT_FALSE(layerImplTreeRoot->LayerPropertyChanged()); 220 EXPECT_FALSE(layerImplTreeRoot->LayerPropertyChanged());
221 EXPECT_FALSE(layerImplTreeRoot->children()[0]->LayerPropertyChanged()); 221 EXPECT_FALSE(layerImplTreeRoot->children()[0]->LayerPropertyChanged());
222 EXPECT_TRUE(layerImplTreeRoot->children()[1]->LayerPropertyChanged()); 222 EXPECT_TRUE(layerImplTreeRoot->children()[1]->LayerPropertyChanged());
223 } 223 }
224 224
225 TEST_F(TreeSynchronizerTest, syncSimpleTreeAndProperties) 225 TEST_F(TreeSynchronizerTest, syncSimpleTreeAndProperties)
226 { 226 {
227 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 227 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
228 layerTreeRoot->AddChild(Layer::Create()); 228 layerTreeRoot->AddChild(Layer::Create());
229 layerTreeRoot->AddChild(Layer::Create()); 229 layerTreeRoot->AddChild(Layer::Create());
230 230
231 // Pick some random properties to set. The values are not important, we're j ust testing that at least some properties are making it through. 231 // Pick some random properties to set. The values are not important, we're j ust testing that at least some properties are making it through.
232 gfx::PointF rootPosition = gfx::PointF(2.3f, 7.4f); 232 gfx::PointF rootPosition = gfx::PointF(2.3f, 7.4f);
233 layerTreeRoot->SetPosition(rootPosition); 233 layerTreeRoot->SetPosition(rootPosition);
234 234
235 float firstChildOpacity = 0.25f; 235 float firstChildOpacity = 0.25f;
236 layerTreeRoot->children()[0]->SetOpacity(firstChildOpacity); 236 layerTreeRoot->children()[0]->SetOpacity(firstChildOpacity);
237 237
238 gfx::Size secondChildBounds = gfx::Size(25, 53); 238 gfx::Size secondChildBounds = gfx::Size(25, 53);
239 layerTreeRoot->children()[1]->SetBounds(secondChildBounds); 239 layerTreeRoot->children()[1]->SetBounds(secondChildBounds);
240 240
241 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 241 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
242 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 242 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
243 243
244 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 244 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
245 245
246 // Check that the property values we set on the Layer tree are reflected in the LayerImpl tree. 246 // Check that the property values we set on the Layer tree are reflected in the LayerImpl tree.
247 gfx::PointF rootLayerImplPosition = layerImplTreeRoot->position(); 247 gfx::PointF rootLayerImplPosition = layerImplTreeRoot->position();
248 EXPECT_EQ(rootPosition.x(), rootLayerImplPosition.x()); 248 EXPECT_EQ(rootPosition.x(), rootLayerImplPosition.x());
249 EXPECT_EQ(rootPosition.y(), rootLayerImplPosition.y()); 249 EXPECT_EQ(rootPosition.y(), rootLayerImplPosition.y());
250 250
251 EXPECT_EQ(firstChildOpacity, layerImplTreeRoot->children()[0]->opacity()); 251 EXPECT_EQ(firstChildOpacity, layerImplTreeRoot->children()[0]->opacity());
252 252
(...skipping 16 matching lines...) Expand all
269 scoped_refptr<Layer> layerA = layerTreeRoot->children()[0].get(); 269 scoped_refptr<Layer> layerA = layerTreeRoot->children()[0].get();
270 layerA->AddChild(MockLayer::Create(&layerImplDestructionList)); 270 layerA->AddChild(MockLayer::Create(&layerImplDestructionList));
271 271
272 scoped_refptr<Layer> layerB = layerA->children()[0].get(); 272 scoped_refptr<Layer> layerB = layerA->children()[0].get();
273 layerB->AddChild(MockLayer::Create(&layerImplDestructionList)); 273 layerB->AddChild(MockLayer::Create(&layerImplDestructionList));
274 274
275 scoped_refptr<Layer> layerC = layerB->children()[0].get(); 275 scoped_refptr<Layer> layerC = layerB->children()[0].get();
276 layerB->AddChild(MockLayer::Create(&layerImplDestructionList)); 276 layerB->AddChild(MockLayer::Create(&layerImplDestructionList));
277 scoped_refptr<Layer> layerD = layerB->children()[1].get(); 277 scoped_refptr<Layer> layerD = layerB->children()[1].get();
278 278
279 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 279 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
280 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 280 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
281 281
282 // We have to push properties to pick up the destruction list pointer. 282 // We have to push properties to pick up the destruction list pointer.
283 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 283 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
284 284
285 // Now restructure the tree to look like this: 285 // Now restructure the tree to look like this:
286 // root --- D ---+--- A 286 // root --- D ---+--- A
287 // | 287 // |
288 // +--- C --- B 288 // +--- C --- B
289 layerTreeRoot->RemoveAllChildren(); 289 layerTreeRoot->RemoveAllChildren();
290 layerD->RemoveAllChildren(); 290 layerD->RemoveAllChildren();
291 layerTreeRoot->AddChild(layerD); 291 layerTreeRoot->AddChild(layerD);
292 layerA->RemoveAllChildren(); 292 layerA->RemoveAllChildren();
293 layerD->AddChild(layerA); 293 layerD->AddChild(layerA);
294 layerC->RemoveAllChildren(); 294 layerC->RemoveAllChildren();
295 layerD->AddChild(layerC); 295 layerD->AddChild(layerC);
296 layerB->RemoveAllChildren(); 296 layerB->RemoveAllChildren();
297 layerC->AddChild(layerB); 297 layerC->AddChild(layerB);
298 298
299 // After another synchronize our trees should match and we should not have d estroyed any LayerImpls 299 // After another synchronize our trees should match and we should not have d estroyed any LayerImpls
300 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 300 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
301 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 301 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
302 302
303 EXPECT_EQ(0u, layerImplDestructionList.size()); 303 EXPECT_EQ(0u, layerImplDestructionList.size());
304 } 304 }
305 305
306 // Constructs a very simple tree, synchronizes it, then synchronizes to a totall y new tree. All layers from the old tree should be deleted. 306 // Constructs a very simple tree, synchronizes it, then synchronizes to a totall y new tree. All layers from the old tree should be deleted.
307 TEST_F(TreeSynchronizerTest, syncSimpleTreeThenDestroy) 307 TEST_F(TreeSynchronizerTest, syncSimpleTreeThenDestroy)
308 { 308 {
309 std::vector<int> layerImplDestructionList; 309 std::vector<int> layerImplDestructionList;
310 310
311 scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::Create(&layerImplDestruct ionList); 311 scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::Create(&layerImplDestruct ionList);
312 oldLayerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList)); 312 oldLayerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList));
313 oldLayerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList)); 313 oldLayerTreeRoot->AddChild(MockLayer::Create(&layerImplDestructionList));
314 314
315 int oldTreeRootLayerId = oldLayerTreeRoot->id(); 315 int oldTreeRootLayerId = oldLayerTreeRoot->id();
316 int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id(); 316 int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id();
317 int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id(); 317 int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id();
318 318
319 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 319 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
320 expectTreesAreIdentical(oldLayerTreeRoot.get(), layerImplTreeRoot.get(), m_h ostImpl.activeTree()); 320 expectTreesAreIdentical(oldLayerTreeRoot.get(), layerImplTreeRoot.get(), m_h ostImpl.active_tree());
321 321
322 // We have to push properties to pick up the destruction list pointer. 322 // We have to push properties to pick up the destruction list pointer.
323 TreeSynchronizer::pushProperties(oldLayerTreeRoot.get(), layerImplTreeRoot.g et()); 323 TreeSynchronizer::pushProperties(oldLayerTreeRoot.get(), layerImplTreeRoot.g et());
324 324
325 // Remove all children on the Layer side. 325 // Remove all children on the Layer side.
326 oldLayerTreeRoot->RemoveAllChildren(); 326 oldLayerTreeRoot->RemoveAllChildren();
327 327
328 // Synchronize again. After the sync all LayerImpls from the old tree should be deleted. 328 // Synchronize again. After the sync all LayerImpls from the old tree should be deleted.
329 scoped_refptr<Layer> newLayerTreeRoot = Layer::Create(); 329 scoped_refptr<Layer> newLayerTreeRoot = Layer::Create();
330 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(newLayerTreeRoot.get( ), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 330 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(newLayerTreeRoot.get( ), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
331 expectTreesAreIdentical(newLayerTreeRoot.get(), layerImplTreeRoot.get(), m_h ostImpl.activeTree()); 331 expectTreesAreIdentical(newLayerTreeRoot.get(), layerImplTreeRoot.get(), m_h ostImpl.active_tree());
332 332
333 ASSERT_EQ(3u, layerImplDestructionList.size()); 333 ASSERT_EQ(3u, layerImplDestructionList.size());
334 334
335 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction List.end(), oldTreeRootLayerId) != layerImplDestructionList.end()); 335 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction List.end(), oldTreeRootLayerId) != layerImplDestructionList.end());
336 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction List.end(), oldTreeFirstChildLayerId) != layerImplDestructionList.end()); 336 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction List.end(), oldTreeFirstChildLayerId) != layerImplDestructionList.end());
337 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction List.end(), oldTreeSecondChildLayerId) != layerImplDestructionList.end()); 337 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction List.end(), oldTreeSecondChildLayerId) != layerImplDestructionList.end());
338 } 338 }
339 339
340 // Constructs+syncs a tree with mask, replica, and replica mask layers. 340 // Constructs+syncs a tree with mask, replica, and replica mask layers.
341 TEST_F(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) 341 TEST_F(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers)
(...skipping 10 matching lines...) Expand all
352 // Second child gets a replica layer. 352 // Second child gets a replica layer.
353 scoped_refptr<Layer> replicaLayer = Layer::Create(); 353 scoped_refptr<Layer> replicaLayer = Layer::Create();
354 layerTreeRoot->children()[1]->SetReplicaLayer(replicaLayer.get()); 354 layerTreeRoot->children()[1]->SetReplicaLayer(replicaLayer.get());
355 355
356 // Third child gets a replica layer with a mask layer. 356 // Third child gets a replica layer with a mask layer.
357 scoped_refptr<Layer> replicaLayerWithMask = Layer::Create(); 357 scoped_refptr<Layer> replicaLayerWithMask = Layer::Create();
358 scoped_refptr<Layer> replicaMaskLayer = Layer::Create(); 358 scoped_refptr<Layer> replicaMaskLayer = Layer::Create();
359 replicaLayerWithMask->SetMaskLayer(replicaMaskLayer.get()); 359 replicaLayerWithMask->SetMaskLayer(replicaMaskLayer.get());
360 layerTreeRoot->children()[2]->SetReplicaLayer(replicaLayerWithMask.get()); 360 layerTreeRoot->children()[2]->SetReplicaLayer(replicaLayerWithMask.get());
361 361
362 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 362 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
363 363
364 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 364 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
365 365
366 // Remove the mask layer. 366 // Remove the mask layer.
367 layerTreeRoot->children()[0]->SetMaskLayer(0); 367 layerTreeRoot->children()[0]->SetMaskLayer(0);
368 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 368 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
369 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 369 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
370 370
371 // Remove the replica layer. 371 // Remove the replica layer.
372 layerTreeRoot->children()[1]->SetReplicaLayer(0); 372 layerTreeRoot->children()[1]->SetReplicaLayer(0);
373 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 373 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
374 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 374 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
375 375
376 // Remove the replica mask. 376 // Remove the replica mask.
377 replicaLayerWithMask->SetMaskLayer(0); 377 replicaLayerWithMask->SetMaskLayer(0);
378 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 378 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
379 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.activeTree()); 379 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_host Impl.active_tree());
380 } 380 }
381 381
382 TEST_F(TreeSynchronizerTest, synchronizeAnimations) 382 TEST_F(TreeSynchronizerTest, synchronizeAnimations)
383 { 383 {
384 LayerTreeSettings settings; 384 LayerTreeSettings settings;
385 FakeProxy proxy(scoped_ptr<Thread>(NULL)); 385 FakeProxy proxy(scoped_ptr<Thread>(NULL));
386 DebugScopedSetImplThread impl(&proxy); 386 DebugScopedSetImplThread impl(&proxy);
387 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); 387 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::Create(settings, NULL, &proxy);
388 388
389 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 389 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
390 390
391 layerTreeRoot->SetLayerAnimationController(FakeLayerAnimationController::Cre ate()); 391 layerTreeRoot->SetLayerAnimationController(FakeLayerAnimationController::Cre ate());
392 392
393 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer _animation_controller())->synchronizedAnimations()); 393 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer _animation_controller())->synchronizedAnimations());
394 394
395 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); 395 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.active_tree());
396 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 396 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
397 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); 397 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.active_tree());
398 398
399 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer_ animation_controller())->synchronizedAnimations()); 399 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer_ animation_controller())->synchronizedAnimations());
400 } 400 }
401 401
402 } // namespace 402 } // namespace
403 } // namespace cc 403 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiled_layer_unittest.cc ('k') | webkit/compositor_bindings/web_to_ccinput_handler_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698