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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/tree_synchronizer.h" | 7 #include "cc/tree_synchronizer.h" |
8 | 8 |
9 #include "Region.h" | 9 #include "Region.h" |
10 #include "cc/layer.h" | 10 #include "cc/layer.h" |
11 #include "cc/layer_animation_controller.h" | 11 #include "cc/layer_animation_controller.h" |
12 #include "cc/layer_impl.h" | 12 #include "cc/layer_impl.h" |
13 #include "cc/proxy.h" | 13 #include "cc/proxy.h" |
14 #include "cc/single_thread_proxy.h" | 14 #include "cc/single_thread_proxy.h" |
15 #include "cc/test/animation_test_common.h" | 15 #include "cc/test/animation_test_common.h" |
16 #include "cc/test/fake_proxy.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 | 17 |
19 using namespace cc; | 18 using namespace cc; |
20 using namespace WebKitTests; | 19 using namespace WebKitTests; |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 class MockLayerImpl : public LayerImpl { | 23 class MockLayerImpl : public LayerImpl { |
25 public: | 24 public: |
26 static scoped_ptr<MockLayerImpl> create(int layerId) | 25 static scoped_ptr<MockLayerImpl> create(int layerId) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 ASSERT_EQ(layerChildren.size(), layerImplChildren.size()); | 124 ASSERT_EQ(layerChildren.size(), layerImplChildren.size()); |
126 | 125 |
127 for (size_t i = 0; i < layerChildren.size(); ++i) | 126 for (size_t i = 0; i < layerChildren.size(); ++i) |
128 expectTreesAreIdentical(layerChildren[i].get(), layerImplChildren[i], ho
stImpl); | 127 expectTreesAreIdentical(layerChildren[i].get(), layerImplChildren[i], ho
stImpl); |
129 } | 128 } |
130 | 129 |
131 // Attempts to synchronizes a null tree. This should not crash, and should | 130 // Attempts to synchronizes a null tree. This should not crash, and should |
132 // return a null tree. | 131 // return a null tree. |
133 TEST(TreeSynchronizerTest, syncNullTree) | 132 TEST(TreeSynchronizerTest, syncNullTree) |
134 { | 133 { |
| 134 DebugScopedSetImplThread impl; |
| 135 |
135 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(0, scoped_ptr<LayerImpl>(), 0); | 136 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(0, scoped_ptr<LayerImpl>(), 0); |
136 | 137 |
137 EXPECT_TRUE(!layerImplTreeRoot.get()); | 138 EXPECT_TRUE(!layerImplTreeRoot.get()); |
138 } | 139 } |
139 | 140 |
140 // Constructs a very simple tree and synchronizes it without trying to reuse any
preexisting layers. | 141 // Constructs a very simple tree and synchronizes it without trying to reuse any
preexisting layers. |
141 TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty) | 142 TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty) |
142 { | 143 { |
| 144 DebugScopedSetImplThread impl; |
| 145 |
143 LayerTreeSettings settings; | 146 LayerTreeSettings settings; |
144 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 147 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
145 DebugScopedSetImplThread impl(&proxy); | |
146 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
147 | 148 |
148 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 149 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
149 layerTreeRoot->addChild(Layer::create()); | 150 layerTreeRoot->addChild(Layer::create()); |
150 layerTreeRoot->addChild(Layer::create()); | 151 layerTreeRoot->addChild(Layer::create()); |
151 | 152 |
152 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); | 153 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); |
153 | 154 |
154 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 155 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
155 } | 156 } |
156 | 157 |
157 // Constructs a very simple tree and synchronizes it attempting to reuse some la
yers | 158 // Constructs a very simple tree and synchronizes it attempting to reuse some la
yers |
158 TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) | 159 TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) |
159 { | 160 { |
| 161 DebugScopedSetImplThread impl; |
160 std::vector<int> layerImplDestructionList; | 162 std::vector<int> layerImplDestructionList; |
161 | 163 |
162 LayerTreeSettings settings; | 164 LayerTreeSettings settings; |
163 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 165 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
164 DebugScopedSetImplThread impl(&proxy); | |
165 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
166 | 166 |
167 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction
List); | 167 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction
List); |
168 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); | 168 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
169 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); | 169 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
170 | 170 |
171 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); | 171 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); |
172 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 172 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
173 | 173 |
174 // Add a new layer to the Layer side | 174 // Add a new layer to the Layer side |
175 layerTreeRoot->children()[0]->addChild(MockLayer::create(&layerImplDestructi
onList)); | 175 layerTreeRoot->children()[0]->addChild(MockLayer::create(&layerImplDestructi
onList)); |
176 // Remove one. | 176 // Remove one. |
177 layerTreeRoot->children()[1]->removeFromParent(); | 177 layerTreeRoot->children()[1]->removeFromParent(); |
178 int secondLayerImplId = layerImplTreeRoot->children()[1]->id(); | 178 int secondLayerImplId = layerImplTreeRoot->children()[1]->id(); |
179 | 179 |
180 // Synchronize again. After the sync the trees should be equivalent and we s
hould have created and destroyed one LayerImpl. | 180 // Synchronize again. After the sync the trees should be equivalent and we s
hould have created and destroyed one LayerImpl. |
181 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); | 181 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); |
182 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 182 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
183 | 183 |
184 ASSERT_EQ(1u, layerImplDestructionList.size()); | 184 ASSERT_EQ(1u, layerImplDestructionList.size()); |
185 EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]); | 185 EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]); |
186 } | 186 } |
187 | 187 |
188 // Constructs a very simple tree and checks that a stacking-order change is trac
ked properly. | 188 // Constructs a very simple tree and checks that a stacking-order change is trac
ked properly. |
189 TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) | 189 TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) |
190 { | 190 { |
| 191 DebugScopedSetImplThread impl; |
191 std::vector<int> layerImplDestructionList; | 192 std::vector<int> layerImplDestructionList; |
192 | 193 |
193 LayerTreeSettings settings; | 194 LayerTreeSettings settings; |
194 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 195 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
195 DebugScopedSetImplThread impl(&proxy); | |
196 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
197 | 196 |
198 // 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 |
199 // remove it to set up the intended scenario. | 198 // remove it to set up the intended scenario. |
200 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction
List); | 199 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction
List); |
201 scoped_refptr<Layer> child2 = MockLayer::create(&layerImplDestructionList); | 200 scoped_refptr<Layer> child2 = MockLayer::create(&layerImplDestructionList); |
202 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); | 201 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
203 layerTreeRoot->addChild(child2); | 202 layerTreeRoot->addChild(child2); |
204 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); | 203 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); |
205 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 204 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
206 layerImplTreeRoot->resetAllChangeTrackingForSubtree(); | 205 layerImplTreeRoot->resetAllChangeTrackingForSubtree(); |
207 | 206 |
208 // re-insert the layer and sync again. | 207 // re-insert the layer and sync again. |
209 child2->removeFromParent(); | 208 child2->removeFromParent(); |
210 layerTreeRoot->addChild(child2); | 209 layerTreeRoot->addChild(child2); |
211 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); | 210 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); |
212 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 211 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
213 | 212 |
214 // Check that the impl thread properly tracked the change. | 213 // Check that the impl thread properly tracked the change. |
215 EXPECT_FALSE(layerImplTreeRoot->layerPropertyChanged()); | 214 EXPECT_FALSE(layerImplTreeRoot->layerPropertyChanged()); |
216 EXPECT_FALSE(layerImplTreeRoot->children()[0]->layerPropertyChanged()); | 215 EXPECT_FALSE(layerImplTreeRoot->children()[0]->layerPropertyChanged()); |
217 EXPECT_TRUE(layerImplTreeRoot->children()[1]->layerPropertyChanged()); | 216 EXPECT_TRUE(layerImplTreeRoot->children()[1]->layerPropertyChanged()); |
218 } | 217 } |
219 | 218 |
220 TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) | 219 TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) |
221 { | 220 { |
| 221 DebugScopedSetImplThread impl; |
| 222 |
222 LayerTreeSettings settings; | 223 LayerTreeSettings settings; |
223 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 224 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
224 DebugScopedSetImplThread impl(&proxy); | |
225 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
226 | 225 |
227 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 226 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
228 layerTreeRoot->addChild(Layer::create()); | 227 layerTreeRoot->addChild(Layer::create()); |
229 layerTreeRoot->addChild(Layer::create()); | 228 layerTreeRoot->addChild(Layer::create()); |
230 | 229 |
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. | 230 // 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); | 231 gfx::PointF rootPosition = gfx::PointF(2.3f, 7.4f); |
233 layerTreeRoot->setPosition(rootPosition); | 232 layerTreeRoot->setPosition(rootPosition); |
234 | 233 |
235 float firstChildOpacity = 0.25f; | 234 float firstChildOpacity = 0.25f; |
(...skipping 12 matching lines...) Expand all Loading... |
248 | 247 |
249 EXPECT_EQ(firstChildOpacity, layerImplTreeRoot->children()[0]->opacity()); | 248 EXPECT_EQ(firstChildOpacity, layerImplTreeRoot->children()[0]->opacity()); |
250 | 249 |
251 gfx::Size secondLayerImplChildBounds = layerImplTreeRoot->children()[1]->bou
nds(); | 250 gfx::Size secondLayerImplChildBounds = layerImplTreeRoot->children()[1]->bou
nds(); |
252 EXPECT_EQ(secondChildBounds.width(), secondLayerImplChildBounds.width()); | 251 EXPECT_EQ(secondChildBounds.width(), secondLayerImplChildBounds.width()); |
253 EXPECT_EQ(secondChildBounds.height(), secondLayerImplChildBounds.height()); | 252 EXPECT_EQ(secondChildBounds.height(), secondLayerImplChildBounds.height()); |
254 } | 253 } |
255 | 254 |
256 TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) | 255 TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) |
257 { | 256 { |
| 257 DebugScopedSetImplThread impl; |
258 std::vector<int> layerImplDestructionList; | 258 std::vector<int> layerImplDestructionList; |
259 | 259 |
260 LayerTreeSettings settings; | 260 LayerTreeSettings settings; |
261 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 261 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
262 DebugScopedSetImplThread impl(&proxy); | |
263 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
264 | 262 |
265 // Set up a tree with this sort of structure: | 263 // Set up a tree with this sort of structure: |
266 // root --- A --- B ---+--- C | 264 // root --- A --- B ---+--- C |
267 // | | 265 // | |
268 // +--- D | 266 // +--- D |
269 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction
List); | 267 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction
List); |
270 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); | 268 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
271 | 269 |
272 scoped_refptr<Layer> layerA = layerTreeRoot->children()[0].get(); | 270 scoped_refptr<Layer> layerA = layerTreeRoot->children()[0].get(); |
273 layerA->addChild(MockLayer::create(&layerImplDestructionList)); | 271 layerA->addChild(MockLayer::create(&layerImplDestructionList)); |
(...skipping 25 matching lines...) Expand all Loading... |
299 // After another synchronize our trees should match and we should not have d
estroyed any LayerImpls | 297 // After another synchronize our trees should match and we should not have d
estroyed any LayerImpls |
300 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); | 298 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); |
301 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 299 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
302 | 300 |
303 EXPECT_EQ(0u, layerImplDestructionList.size()); | 301 EXPECT_EQ(0u, layerImplDestructionList.size()); |
304 } | 302 } |
305 | 303 |
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. | 304 // 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(TreeSynchronizerTest, syncSimpleTreeThenDestroy) | 305 TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) |
308 { | 306 { |
| 307 DebugScopedSetImplThread impl; |
309 std::vector<int> layerImplDestructionList; | 308 std::vector<int> layerImplDestructionList; |
310 | 309 |
311 LayerTreeSettings settings; | 310 LayerTreeSettings settings; |
312 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 311 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
313 DebugScopedSetImplThread impl(&proxy); | |
314 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
315 | 312 |
316 scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::create(&layerImplDestruct
ionList); | 313 scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::create(&layerImplDestruct
ionList); |
317 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); | 314 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
318 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); | 315 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
319 | 316 |
320 int oldTreeRootLayerId = oldLayerTreeRoot->id(); | 317 int oldTreeRootLayerId = oldLayerTreeRoot->id(); |
321 int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id(); | 318 int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id(); |
322 int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id(); | 319 int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id(); |
323 | 320 |
324 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); | 321 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); |
(...skipping 10 matching lines...) Expand all Loading... |
335 ASSERT_EQ(3u, layerImplDestructionList.size()); | 332 ASSERT_EQ(3u, layerImplDestructionList.size()); |
336 | 333 |
337 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction
List.end(), oldTreeRootLayerId) != layerImplDestructionList.end()); | 334 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction
List.end(), oldTreeRootLayerId) != layerImplDestructionList.end()); |
338 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction
List.end(), oldTreeFirstChildLayerId) != layerImplDestructionList.end()); | 335 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction
List.end(), oldTreeFirstChildLayerId) != layerImplDestructionList.end()); |
339 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction
List.end(), oldTreeSecondChildLayerId) != layerImplDestructionList.end()); | 336 EXPECT_TRUE(std::find(layerImplDestructionList.begin(), layerImplDestruction
List.end(), oldTreeSecondChildLayerId) != layerImplDestructionList.end()); |
340 } | 337 } |
341 | 338 |
342 // Constructs+syncs a tree with mask, replica, and replica mask layers. | 339 // Constructs+syncs a tree with mask, replica, and replica mask layers. |
343 TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) | 340 TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) |
344 { | 341 { |
| 342 DebugScopedSetImplThread impl; |
| 343 |
345 LayerTreeSettings settings; | 344 LayerTreeSettings settings; |
346 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 345 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
347 DebugScopedSetImplThread impl(&proxy); | |
348 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
349 | 346 |
350 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 347 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
351 layerTreeRoot->addChild(Layer::create()); | 348 layerTreeRoot->addChild(Layer::create()); |
352 layerTreeRoot->addChild(Layer::create()); | 349 layerTreeRoot->addChild(Layer::create()); |
353 layerTreeRoot->addChild(Layer::create()); | 350 layerTreeRoot->addChild(Layer::create()); |
354 | 351 |
355 // First child gets a mask layer. | 352 // First child gets a mask layer. |
356 scoped_refptr<Layer> maskLayer = Layer::create(); | 353 scoped_refptr<Layer> maskLayer = Layer::create(); |
357 layerTreeRoot->children()[0]->setMaskLayer(maskLayer.get()); | 354 layerTreeRoot->children()[0]->setMaskLayer(maskLayer.get()); |
358 | 355 |
(...skipping 22 matching lines...) Expand all Loading... |
381 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 378 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
382 | 379 |
383 // Remove the replica mask. | 380 // Remove the replica mask. |
384 replicaLayerWithMask->setMaskLayer(0); | 381 replicaLayerWithMask->setMaskLayer(0); |
385 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); | 382 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); |
386 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); | 383 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm
pl.get()); |
387 } | 384 } |
388 | 385 |
389 TEST(TreeSynchronizerTest, synchronizeAnimations) | 386 TEST(TreeSynchronizerTest, synchronizeAnimations) |
390 { | 387 { |
| 388 DebugScopedSetImplThread impl; |
| 389 |
391 LayerTreeSettings settings; | 390 LayerTreeSettings settings; |
392 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 391 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0); |
393 DebugScopedSetImplThread impl(&proxy); | |
394 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | |
395 | 392 |
396 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 393 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
397 | 394 |
398 FakeLayerAnimationControllerClient dummy; | 395 FakeLayerAnimationControllerClient dummy; |
399 layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::cre
ate(&dummy).PassAs<LayerAnimationController>()); | 396 layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::cre
ate(&dummy).PassAs<LayerAnimationController>()); |
400 | 397 |
401 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer
AnimationController())->synchronizedAnimations()); | 398 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer
AnimationController())->synchronizedAnimations()); |
402 | 399 |
403 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); | 400 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); |
404 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); | 401 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); |
405 | 402 |
406 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerA
nimationController())->synchronizedAnimations()); | 403 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerA
nimationController())->synchronizedAnimations()); |
407 } | 404 } |
408 | 405 |
409 } // namespace | 406 } // namespace |
OLD | NEW |