| 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 "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 | 335 |
| 336 private: | 336 private: |
| 337 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) | 337 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) |
| 338 : test_hooks_(test_hooks) {} | 338 : test_hooks_(test_hooks) {} |
| 339 | 339 |
| 340 TestHooks* test_hooks_; | 340 TestHooks* test_hooks_; |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 343 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
| 344 class LayerTreeHostForTesting : public LayerTreeHost { | 344 class LayerTreeHostForTesting : public LayerTreeHostInProcess { |
| 345 public: | 345 public: |
| 346 static std::unique_ptr<LayerTreeHostForTesting> Create( | 346 static std::unique_ptr<LayerTreeHostForTesting> Create( |
| 347 TestHooks* test_hooks, | 347 TestHooks* test_hooks, |
| 348 CompositorMode mode, | 348 CompositorMode mode, |
| 349 LayerTreeHostClientForTesting* client, | 349 LayerTreeHostClientForTesting* client, |
| 350 RemoteProtoChannel* remote_proto_channel, | 350 RemoteProtoChannel* remote_proto_channel, |
| 351 SharedBitmapManager* shared_bitmap_manager, | 351 SharedBitmapManager* shared_bitmap_manager, |
| 352 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 352 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 353 TaskGraphRunner* task_graph_runner, | 353 TaskGraphRunner* task_graph_runner, |
| 354 const LayerTreeSettings& settings, | 354 const LayerTreeSettings& settings, |
| 355 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 355 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 356 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 356 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 357 std::unique_ptr<BeginFrameSource> external_begin_frame_source, | 357 std::unique_ptr<BeginFrameSource> external_begin_frame_source, |
| 358 ImageSerializationProcessor* image_serialization_processor) { | 358 ImageSerializationProcessor* image_serialization_processor) { |
| 359 LayerTreeHost::InitParams params; | 359 LayerTreeHostInProcess::InitParams params; |
| 360 params.client = client; | 360 params.client = client; |
| 361 params.shared_bitmap_manager = shared_bitmap_manager; | 361 params.shared_bitmap_manager = shared_bitmap_manager; |
| 362 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | 362 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; |
| 363 params.task_graph_runner = task_graph_runner; | 363 params.task_graph_runner = task_graph_runner; |
| 364 params.settings = &settings; | 364 params.settings = &settings; |
| 365 params.image_serialization_processor = image_serialization_processor; | 365 params.image_serialization_processor = image_serialization_processor; |
| 366 | 366 |
| 367 params.animation_host = | 367 params.animation_host = |
| 368 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 368 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 369 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( | 369 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 GetTaskRunnerProvider(), shared_bitmap_manager(), | 409 GetTaskRunnerProvider(), shared_bitmap_manager(), |
| 410 gpu_memory_buffer_manager(), task_graph_runner(), | 410 gpu_memory_buffer_manager(), task_graph_runner(), |
| 411 rendering_stats_instrumentation()); | 411 rendering_stats_instrumentation()); |
| 412 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); | 412 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); |
| 413 return host_impl; | 413 return host_impl; |
| 414 } | 414 } |
| 415 | 415 |
| 416 void SetNeedsCommit() override { | 416 void SetNeedsCommit() override { |
| 417 if (!test_started_) | 417 if (!test_started_) |
| 418 return; | 418 return; |
| 419 LayerTreeHost::SetNeedsCommit(); | 419 LayerTreeHostInProcess::SetNeedsCommit(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 void SetNeedsUpdateLayers() override { | 422 void SetNeedsUpdateLayers() override { |
| 423 if (!test_started_) | 423 if (!test_started_) |
| 424 return; | 424 return; |
| 425 LayerTreeHost::SetNeedsUpdateLayers(); | 425 LayerTreeHostInProcess::SetNeedsUpdateLayers(); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void set_test_started(bool started) { test_started_ = started; } | 428 void set_test_started(bool started) { test_started_ = started; } |
| 429 | 429 |
| 430 private: | 430 private: |
| 431 LayerTreeHostForTesting(TestHooks* test_hooks, | 431 LayerTreeHostForTesting(TestHooks* test_hooks, |
| 432 LayerTreeHost::InitParams* params, | 432 LayerTreeHostInProcess::InitParams* params, |
| 433 CompositorMode mode) | 433 CompositorMode mode) |
| 434 : LayerTreeHost(params, mode), | 434 : LayerTreeHostInProcess(params, mode), |
| 435 test_hooks_(test_hooks), | 435 test_hooks_(test_hooks), |
| 436 test_started_(false) {} | 436 test_started_(false) {} |
| 437 | 437 |
| 438 TestHooks* test_hooks_; | 438 TestHooks* test_hooks_; |
| 439 bool test_started_; | 439 bool test_started_; |
| 440 }; | 440 }; |
| 441 | 441 |
| 442 class LayerTreeTestDelegatingOutputSurfaceClient | 442 class LayerTreeTestDelegatingOutputSurfaceClient |
| 443 : public TestDelegatingOutputSurfaceClient { | 443 : public TestDelegatingOutputSurfaceClient { |
| 444 public: | 444 public: |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get() | 906 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get() |
| 907 : layer_tree_host_.get(); | 907 : layer_tree_host_.get(); |
| 908 | 908 |
| 909 // If this fails, the test has ended and there is no task runners to find | 909 // If this fails, the test has ended and there is no task runners to find |
| 910 // anymore. | 910 // anymore. |
| 911 DCHECK(host); | 911 DCHECK(host); |
| 912 | 912 |
| 913 return host->GetTaskRunnerProvider(); | 913 return host->GetTaskRunnerProvider(); |
| 914 } | 914 } |
| 915 | 915 |
| 916 LayerTreeHost* LayerTreeTest::layer_tree_host() { | 916 LayerTreeHostInProcess* LayerTreeTest::layer_tree_host() { |
| 917 DCHECK(task_runner_provider()->IsMainThread() || | 917 DCHECK(task_runner_provider()->IsMainThread() || |
| 918 task_runner_provider()->IsMainThreadBlocked()); | 918 task_runner_provider()->IsMainThreadBlocked()); |
| 919 return layer_tree_host_.get(); | 919 return layer_tree_host_.get(); |
| 920 } | 920 } |
| 921 | 921 |
| 922 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { | 922 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { |
| 923 DCHECK(IsRemoteTest()); | 923 DCHECK(IsRemoteTest()); |
| 924 DCHECK(task_runner_provider()->IsMainThread() || | 924 DCHECK(task_runner_provider()->IsMainThread() || |
| 925 task_runner_provider()->IsMainThreadBlocked()); | 925 task_runner_provider()->IsMainThreadBlocked()); |
| 926 return remote_client_layer_tree_host_.get(); | 926 return remote_client_layer_tree_host_.get(); |
| 927 } | 927 } |
| 928 | 928 |
| 929 } // namespace cc | 929 } // namespace cc |
| OLD | NEW |