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/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 , m_layerImplDestructionList(layerImplDestructionList) | 70 , m_layerImplDestructionList(layerImplDestructionList) |
71 { | 71 { |
72 } | 72 } |
73 virtual ~MockLayer() { } | 73 virtual ~MockLayer() { } |
74 | 74 |
75 std::vector<int>* m_layerImplDestructionList; | 75 std::vector<int>* m_layerImplDestructionList; |
76 }; | 76 }; |
77 | 77 |
78 class FakeLayerAnimationController : public LayerAnimationController { | 78 class FakeLayerAnimationController : public LayerAnimationController { |
79 public: | 79 public: |
80 static scoped_ptr<FakeLayerAnimationController> create(LayerAnimationControl
lerClient* client) | 80 static scoped_refptr<LayerAnimationController> create() |
81 { | 81 { |
82 return make_scoped_ptr(new FakeLayerAnimationController(client)); | 82 return static_cast<LayerAnimationController*>(new FakeLayerAnimationCont
roller); |
83 } | 83 } |
84 | 84 |
85 bool synchronizedAnimations() const { return m_synchronizedAnimations; } | 85 bool synchronizedAnimations() const { return m_synchronizedAnimations; } |
86 | 86 |
87 private: | 87 private: |
88 explicit FakeLayerAnimationController(LayerAnimationControllerClient* client
) | 88 FakeLayerAnimationController() |
89 : LayerAnimationController(client) | 89 : LayerAnimationController(AnimationRegistrar::MainThread) |
90 , m_synchronizedAnimations(false) | 90 , m_synchronizedAnimations(false) |
91 { | 91 { } |
92 } | 92 |
| 93 virtual ~FakeLayerAnimationController() { } |
93 | 94 |
94 virtual void pushAnimationUpdatesTo(LayerAnimationController* controllerImpl
) | 95 virtual void pushAnimationUpdatesTo(LayerAnimationController* controllerImpl
) |
95 { | 96 { |
96 LayerAnimationController::pushAnimationUpdatesTo(controllerImpl); | 97 LayerAnimationController::pushAnimationUpdatesTo(controllerImpl); |
97 m_synchronizedAnimations = true; | 98 m_synchronizedAnimations = true; |
98 } | 99 } |
99 | 100 |
100 bool m_synchronizedAnimations; | 101 bool m_synchronizedAnimations; |
101 }; | 102 }; |
102 | 103 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 388 |
388 TEST(TreeSynchronizerTest, synchronizeAnimations) | 389 TEST(TreeSynchronizerTest, synchronizeAnimations) |
389 { | 390 { |
390 LayerTreeSettings settings; | 391 LayerTreeSettings settings; |
391 FakeProxy proxy(scoped_ptr<Thread>(NULL)); | 392 FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
392 DebugScopedSetImplThread impl(&proxy); | 393 DebugScopedSetImplThread impl(&proxy); |
393 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); | 394 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings,
0, &proxy); |
394 | 395 |
395 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 396 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
396 | 397 |
397 FakeLayerAnimationControllerClient dummy; | 398 layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::cre
ate()); |
398 layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::cre
ate(&dummy).PassAs<LayerAnimationController>()); | |
399 | 399 |
400 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer
AnimationController())->synchronizedAnimations()); | 400 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer
AnimationController())->synchronizedAnimations()); |
401 | 401 |
402 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); | 402 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); |
403 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); | 403 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), hostImpl.get()); |
404 | 404 |
405 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerA
nimationController())->synchronizedAnimations()); | 405 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerA
nimationController())->synchronizedAnimations()); |
406 } | 406 } |
407 | 407 |
408 } // namespace | 408 } // namespace |
409 } // namespace cc | 409 } // namespace cc |
OLD | NEW |