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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 test_hooks_->ScheduleComposite(); | 264 test_hooks_->ScheduleComposite(); |
265 } | 265 } |
266 | 266 |
267 virtual void ScheduleAnimation() OVERRIDE { | 267 virtual void ScheduleAnimation() OVERRIDE { |
268 test_hooks_->ScheduleAnimation(); | 268 test_hooks_->ScheduleAnimation(); |
269 } | 269 } |
270 | 270 |
271 virtual void DidPostSwapBuffers() OVERRIDE {} | 271 virtual void DidPostSwapBuffers() OVERRIDE {} |
272 virtual void DidAbortSwapBuffers() OVERRIDE {} | 272 virtual void DidAbortSwapBuffers() OVERRIDE {} |
273 | 273 |
274 virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE { | |
275 return test_hooks_->OffscreenContextProvider(); | |
276 } | |
277 | |
278 private: | 274 private: |
279 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) | 275 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) |
280 : test_hooks_(test_hooks) {} | 276 : test_hooks_(test_hooks) {} |
281 | 277 |
282 TestHooks* test_hooks_; | 278 TestHooks* test_hooks_; |
283 }; | 279 }; |
284 | 280 |
285 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 281 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
286 class LayerTreeHostForTesting : public LayerTreeHost { | 282 class LayerTreeHostForTesting : public LayerTreeHost { |
287 public: | 283 public: |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 671 } |
676 | 672 |
677 scoped_ptr<FakeOutputSurface> LayerTreeTest::CreateFakeOutputSurface( | 673 scoped_ptr<FakeOutputSurface> LayerTreeTest::CreateFakeOutputSurface( |
678 bool fallback) { | 674 bool fallback) { |
679 if (delegating_renderer_) | 675 if (delegating_renderer_) |
680 return FakeOutputSurface::CreateDelegating3d(); | 676 return FakeOutputSurface::CreateDelegating3d(); |
681 else | 677 else |
682 return FakeOutputSurface::Create3d(); | 678 return FakeOutputSurface::Create3d(); |
683 } | 679 } |
684 | 680 |
685 scoped_refptr<ContextProvider> LayerTreeTest::OffscreenContextProvider() { | |
686 if (!compositor_contexts_.get() || | |
687 compositor_contexts_->DestroyedOnMainThread()) | |
688 compositor_contexts_ = TestContextProvider::Create(); | |
689 return compositor_contexts_; | |
690 } | |
691 | |
692 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { | 681 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { |
693 return static_cast<TestContextProvider*>( | 682 return static_cast<TestContextProvider*>( |
694 output_surface_->context_provider().get())->TestContext3d(); | 683 output_surface_->context_provider().get())->TestContext3d(); |
695 } | 684 } |
696 | 685 |
697 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) | 686 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) |
698 const { | 687 const { |
699 if (impl->pending_tree()) | 688 if (impl->pending_tree()) |
700 return impl->pending_tree()->source_frame_number(); | 689 return impl->pending_tree()->source_frame_number(); |
701 if (impl->active_tree()) | 690 if (impl->active_tree()) |
702 return impl->active_tree()->source_frame_number(); | 691 return impl->active_tree()->source_frame_number(); |
703 // Source frames start at 0, so this is invalid. | 692 // Source frames start at 0, so this is invalid. |
704 return -1; | 693 return -1; |
705 } | 694 } |
706 | 695 |
707 void LayerTreeTest::DestroyLayerTreeHost() { | 696 void LayerTreeTest::DestroyLayerTreeHost() { |
708 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 697 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
709 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 698 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
710 layer_tree_host_.reset(); | 699 layer_tree_host_.reset(); |
711 } | 700 } |
712 | 701 |
713 } // namespace cc | 702 } // namespace cc |
OLD | NEW |