| 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" |
| 11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
| 12 #include "cc/base/switches.h" | 12 #include "cc/base/switches.h" |
| 13 #include "cc/input/input_handler.h" | 13 #include "cc/input/input_handler.h" |
| 14 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
| 15 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
| 16 #include "cc/layers/layer_impl.h" | 16 #include "cc/layers/layer_impl.h" |
| 17 #include "cc/test/animation_test_common.h" | 17 #include "cc/test/animation_test_common.h" |
| 18 #include "cc/test/fake_layer_tree_host_client.h" | 18 #include "cc/test/fake_layer_tree_host_client.h" |
| 19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
| 20 #include "cc/test/test_context_provider.h" | 20 #include "cc/test/test_context_provider.h" |
| 21 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 21 #include "cc/test/test_shared_bitmap_manager.h" | 22 #include "cc/test/test_shared_bitmap_manager.h" |
| 22 #include "cc/test/tiled_layer_test_common.h" | 23 #include "cc/test/tiled_layer_test_common.h" |
| 23 #include "cc/trees/layer_tree_host_client.h" | 24 #include "cc/trees/layer_tree_host_client.h" |
| 24 #include "cc/trees/layer_tree_host_impl.h" | 25 #include "cc/trees/layer_tree_host_impl.h" |
| 25 #include "cc/trees/layer_tree_host_single_thread_client.h" | 26 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 26 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
| 27 #include "cc/trees/single_thread_proxy.h" | 28 #include "cc/trees/single_thread_proxy.h" |
| 28 #include "cc/trees/thread_proxy.h" | 29 #include "cc/trees/thread_proxy.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "ui/gfx/frame_time.h" | 31 #include "ui/gfx/frame_time.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 108 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
| 108 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 109 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
| 109 public: | 110 public: |
| 110 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 111 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
| 111 TestHooks* test_hooks, | 112 TestHooks* test_hooks, |
| 112 const LayerTreeSettings& settings, | 113 const LayerTreeSettings& settings, |
| 113 LayerTreeHostImplClient* host_impl_client, | 114 LayerTreeHostImplClient* host_impl_client, |
| 114 Proxy* proxy, | 115 Proxy* proxy, |
| 115 SharedBitmapManager* manager, | 116 SharedBitmapManager* shared_bitmap_manager, |
| 117 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 116 RenderingStatsInstrumentation* stats_instrumentation) { | 118 RenderingStatsInstrumentation* stats_instrumentation) { |
| 117 return make_scoped_ptr( | 119 return make_scoped_ptr( |
| 118 new LayerTreeHostImplForTesting(test_hooks, | 120 new LayerTreeHostImplForTesting(test_hooks, |
| 119 settings, | 121 settings, |
| 120 host_impl_client, | 122 host_impl_client, |
| 121 proxy, | 123 proxy, |
| 122 manager, | 124 shared_bitmap_manager, |
| 125 gpu_memory_buffer_manager, |
| 123 stats_instrumentation)); | 126 stats_instrumentation)); |
| 124 } | 127 } |
| 125 | 128 |
| 126 protected: | 129 protected: |
| 127 LayerTreeHostImplForTesting( | 130 LayerTreeHostImplForTesting( |
| 128 TestHooks* test_hooks, | 131 TestHooks* test_hooks, |
| 129 const LayerTreeSettings& settings, | 132 const LayerTreeSettings& settings, |
| 130 LayerTreeHostImplClient* host_impl_client, | 133 LayerTreeHostImplClient* host_impl_client, |
| 131 Proxy* proxy, | 134 Proxy* proxy, |
| 132 SharedBitmapManager* manager, | 135 SharedBitmapManager* shared_bitmap_manager, |
| 136 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 133 RenderingStatsInstrumentation* stats_instrumentation) | 137 RenderingStatsInstrumentation* stats_instrumentation) |
| 134 : LayerTreeHostImpl(settings, | 138 : LayerTreeHostImpl(settings, |
| 135 host_impl_client, | 139 host_impl_client, |
| 136 proxy, | 140 proxy, |
| 137 stats_instrumentation, | 141 stats_instrumentation, |
| 138 manager, | 142 shared_bitmap_manager, |
| 143 gpu_memory_buffer_manager, |
| 139 0), | 144 0), |
| 140 test_hooks_(test_hooks), | 145 test_hooks_(test_hooks), |
| 141 block_notify_ready_to_activate_for_testing_(false), | 146 block_notify_ready_to_activate_for_testing_(false), |
| 142 notify_ready_to_activate_was_blocked_(false) {} | 147 notify_ready_to_activate_was_blocked_(false) {} |
| 143 | 148 |
| 144 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override { | 149 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override { |
| 145 LayerTreeHostImpl::WillBeginImplFrame(args); | 150 LayerTreeHostImpl::WillBeginImplFrame(args); |
| 146 test_hooks_->WillBeginImplFrameOnThread(this, args); | 151 test_hooks_->WillBeginImplFrameOnThread(this, args); |
| 147 } | 152 } |
| 148 | 153 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 364 } |
| 360 | 365 |
| 361 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 366 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
| 362 LayerTreeHostImplClient* host_impl_client) override { | 367 LayerTreeHostImplClient* host_impl_client) override { |
| 363 return LayerTreeHostImplForTesting::Create( | 368 return LayerTreeHostImplForTesting::Create( |
| 364 test_hooks_, | 369 test_hooks_, |
| 365 settings(), | 370 settings(), |
| 366 host_impl_client, | 371 host_impl_client, |
| 367 proxy(), | 372 proxy(), |
| 368 shared_bitmap_manager_.get(), | 373 shared_bitmap_manager_.get(), |
| 374 gpu_memory_buffer_manager_.get(), |
| 369 rendering_stats_instrumentation()); | 375 rendering_stats_instrumentation()); |
| 370 } | 376 } |
| 371 | 377 |
| 372 virtual void SetNeedsCommit() override { | 378 virtual void SetNeedsCommit() override { |
| 373 if (!test_started_) | 379 if (!test_started_) |
| 374 return; | 380 return; |
| 375 LayerTreeHost::SetNeedsCommit(); | 381 LayerTreeHost::SetNeedsCommit(); |
| 376 } | 382 } |
| 377 | 383 |
| 378 void set_test_started(bool started) { test_started_ = started; } | 384 void set_test_started(bool started) { test_started_ = started; } |
| 379 | 385 |
| 380 virtual void DidDeferCommit() override { test_hooks_->DidDeferCommit(); } | 386 virtual void DidDeferCommit() override { test_hooks_->DidDeferCommit(); } |
| 381 | 387 |
| 382 private: | 388 private: |
| 383 LayerTreeHostForTesting(TestHooks* test_hooks, | 389 LayerTreeHostForTesting(TestHooks* test_hooks, |
| 384 LayerTreeHostClient* client, | 390 LayerTreeHostClient* client, |
| 385 const LayerTreeSettings& settings) | 391 const LayerTreeSettings& settings) |
| 386 : LayerTreeHost(client, NULL, settings), | 392 : LayerTreeHost(client, NULL, NULL, settings), |
| 387 shared_bitmap_manager_(new TestSharedBitmapManager()), | 393 shared_bitmap_manager_(new TestSharedBitmapManager), |
| 394 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), |
| 388 test_hooks_(test_hooks), | 395 test_hooks_(test_hooks), |
| 389 test_started_(false) {} | 396 test_started_(false) {} |
| 390 | 397 |
| 391 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 398 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
| 399 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 392 TestHooks* test_hooks_; | 400 TestHooks* test_hooks_; |
| 393 bool test_started_; | 401 bool test_started_; |
| 394 }; | 402 }; |
| 395 | 403 |
| 396 LayerTreeTest::LayerTreeTest() | 404 LayerTreeTest::LayerTreeTest() |
| 397 : beginning_(false), | 405 : beginning_(false), |
| 398 end_when_begin_returns_(false), | 406 end_when_begin_returns_(false), |
| 399 timed_out_(false), | 407 timed_out_(false), |
| 400 scheduled_(false), | 408 scheduled_(false), |
| 401 started_(false), | 409 started_(false), |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 return -1; | 718 return -1; |
| 711 } | 719 } |
| 712 | 720 |
| 713 void LayerTreeTest::DestroyLayerTreeHost() { | 721 void LayerTreeTest::DestroyLayerTreeHost() { |
| 714 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 722 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 715 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 723 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 716 layer_tree_host_ = nullptr; | 724 layer_tree_host_ = nullptr; |
| 717 } | 725 } |
| 718 | 726 |
| 719 } // namespace cc | 727 } // namespace cc |
| OLD | NEW |