| 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 28 matching lines...) Expand all Loading... |
| 39 LayerTreeHostImpl* host_impl, | 39 LayerTreeHostImpl* host_impl, |
| 40 LayerTreeHostImpl::FrameData* frame_data, | 40 LayerTreeHostImpl::FrameData* frame_data, |
| 41 DrawResult draw_result) { | 41 DrawResult draw_result) { |
| 42 return draw_result; | 42 return draw_result; |
| 43 } | 43 } |
| 44 | 44 |
| 45 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { | 45 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { |
| 46 return base::TimeDelta::FromMilliseconds(16); | 46 return base::TimeDelta::FromMilliseconds(16); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Adapts ThreadProxy for test. Injects test hooks for testing. |
| 50 class ThreadProxyForTest : public ThreadProxy { |
| 51 public: |
| 52 static scoped_ptr<Proxy> Create( |
| 53 TestHooks* test_hooks, |
| 54 LayerTreeHost* host, |
| 55 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 56 return make_scoped_ptr( |
| 57 new ThreadProxyForTest(test_hooks, |
| 58 host, |
| 59 impl_task_runner)).PassAs<Proxy>(); |
| 60 } |
| 61 |
| 62 const ThreadProxy::MainThreadOnly& main() const { |
| 63 return ThreadProxy::main(); |
| 64 } |
| 65 |
| 66 const ThreadProxy::CompositorThreadOnly& impl() const { |
| 67 return ThreadProxy::impl(); |
| 68 } |
| 69 |
| 70 virtual ~ThreadProxyForTest() {} |
| 71 |
| 72 private: |
| 73 TestHooks* test_hooks_; |
| 74 |
| 75 ThreadProxyForTest( |
| 76 TestHooks* test_hooks, |
| 77 LayerTreeHost* host, |
| 78 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) |
| 79 : ThreadProxy(host, impl_task_runner), |
| 80 test_hooks_(test_hooks) { |
| 81 } |
| 82 }; |
| 83 |
| 49 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 84 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
| 50 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 85 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
| 51 public: | 86 public: |
| 52 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 87 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
| 53 TestHooks* test_hooks, | 88 TestHooks* test_hooks, |
| 54 const LayerTreeSettings& settings, | 89 const LayerTreeSettings& settings, |
| 55 LayerTreeHostImplClient* host_impl_client, | 90 LayerTreeHostImplClient* host_impl_client, |
| 56 Proxy* proxy, | 91 Proxy* proxy, |
| 57 SharedBitmapManager* manager, | 92 SharedBitmapManager* manager, |
| 58 RenderingStatsInstrumentation* stats_instrumentation) { | 93 RenderingStatsInstrumentation* stats_instrumentation) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 315 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
| 281 class LayerTreeHostForTesting : public LayerTreeHost { | 316 class LayerTreeHostForTesting : public LayerTreeHost { |
| 282 public: | 317 public: |
| 283 static scoped_ptr<LayerTreeHostForTesting> Create( | 318 static scoped_ptr<LayerTreeHostForTesting> Create( |
| 284 TestHooks* test_hooks, | 319 TestHooks* test_hooks, |
| 285 LayerTreeHostClientForTesting* client, | 320 LayerTreeHostClientForTesting* client, |
| 286 const LayerTreeSettings& settings, | 321 const LayerTreeSettings& settings, |
| 287 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 322 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 288 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( | 323 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
| 289 new LayerTreeHostForTesting(test_hooks, client, settings)); | 324 new LayerTreeHostForTesting(test_hooks, client, settings)); |
| 290 if (impl_task_runner.get()) | 325 if (impl_task_runner.get()) { |
| 291 layer_tree_host->InitializeThreaded(impl_task_runner); | 326 layer_tree_host->InitializeForTesting( |
| 292 else | 327 ThreadProxyForTest::Create(test_hooks, |
| 293 layer_tree_host->InitializeSingleThreaded(client); | 328 layer_tree_host.get(), |
| 329 impl_task_runner)); |
| 330 } else { |
| 331 layer_tree_host->InitializeForTesting( |
| 332 SingleThreadProxy::Create(layer_tree_host.get(), client)); |
| 333 } |
| 294 return layer_tree_host.Pass(); | 334 return layer_tree_host.Pass(); |
| 295 } | 335 } |
| 296 | 336 |
| 297 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 337 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 298 LayerTreeHostImplClient* host_impl_client) OVERRIDE { | 338 LayerTreeHostImplClient* host_impl_client) OVERRIDE { |
| 299 return LayerTreeHostImplForTesting::Create( | 339 return LayerTreeHostImplForTesting::Create( |
| 300 test_hooks_, | 340 test_hooks_, |
| 301 settings(), | 341 settings(), |
| 302 host_impl_client, | 342 host_impl_client, |
| 303 proxy(), | 343 proxy(), |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 FAIL() << "Test timed out"; | 695 FAIL() << "Test timed out"; |
| 656 return; | 696 return; |
| 657 } | 697 } |
| 658 AfterTest(); | 698 AfterTest(); |
| 659 } | 699 } |
| 660 | 700 |
| 661 void LayerTreeTest::RunTestWithImplSidePainting() { | 701 void LayerTreeTest::RunTestWithImplSidePainting() { |
| 662 RunTest(true, false, true); | 702 RunTest(true, false, true); |
| 663 } | 703 } |
| 664 | 704 |
| 705 const ThreadProxy::MainThreadOnly& |
| 706 LayerTreeTest::ThreadProxyMainOnly() const { |
| 707 DCHECK(proxy()); |
| 708 DCHECK(proxy()->HasImplThread()); |
| 709 return static_cast<ThreadProxyForTest*>(proxy())->main(); |
| 710 } |
| 711 |
| 712 const ThreadProxy::CompositorThreadOnly& |
| 713 LayerTreeTest::ThreadProxyImplOnly() const { |
| 714 DCHECK(proxy()); |
| 715 DCHECK(proxy()->HasImplThread()); |
| 716 return static_cast<ThreadProxyForTest*>(proxy())->impl(); |
| 717 } |
| 718 |
| 665 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { | 719 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { |
| 666 scoped_ptr<FakeOutputSurface> output_surface = | 720 scoped_ptr<FakeOutputSurface> output_surface = |
| 667 CreateFakeOutputSurface(fallback); | 721 CreateFakeOutputSurface(fallback); |
| 668 if (output_surface) { | 722 if (output_surface) { |
| 669 DCHECK_EQ(delegating_renderer_, | 723 DCHECK_EQ(delegating_renderer_, |
| 670 output_surface->capabilities().delegated_rendering); | 724 output_surface->capabilities().delegated_rendering); |
| 671 } | 725 } |
| 672 output_surface_ = output_surface.get(); | 726 output_surface_ = output_surface.get(); |
| 673 return output_surface.PassAs<OutputSurface>(); | 727 return output_surface.PassAs<OutputSurface>(); |
| 674 } | 728 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 696 return -1; | 750 return -1; |
| 697 } | 751 } |
| 698 | 752 |
| 699 void LayerTreeTest::DestroyLayerTreeHost() { | 753 void LayerTreeTest::DestroyLayerTreeHost() { |
| 700 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 754 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 701 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 755 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 702 layer_tree_host_.reset(); | 756 layer_tree_host_.reset(); |
| 703 } | 757 } |
| 704 | 758 |
| 705 } // namespace cc | 759 } // namespace cc |
| OLD | NEW |