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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 93 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
94 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 94 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
95 public: | 95 public: |
96 static std::unique_ptr<LayerTreeHostImplForTesting> Create( | 96 static std::unique_ptr<LayerTreeHostImplForTesting> Create( |
97 TestHooks* test_hooks, | 97 TestHooks* test_hooks, |
98 const LayerTreeSettings& settings, | 98 const LayerTreeSettings& settings, |
99 LayerTreeHostImplClient* host_impl_client, | 99 LayerTreeHostImplClient* host_impl_client, |
100 TaskRunnerProvider* task_runner_provider, | 100 TaskRunnerProvider* task_runner_provider, |
101 SharedBitmapManager* shared_bitmap_manager, | |
102 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
103 TaskGraphRunner* task_graph_runner, | 101 TaskGraphRunner* task_graph_runner, |
104 RenderingStatsInstrumentation* stats_instrumentation) { | 102 RenderingStatsInstrumentation* stats_instrumentation) { |
105 return base::WrapUnique(new LayerTreeHostImplForTesting( | 103 return base::WrapUnique(new LayerTreeHostImplForTesting( |
106 test_hooks, settings, host_impl_client, task_runner_provider, | 104 test_hooks, settings, host_impl_client, task_runner_provider, |
107 shared_bitmap_manager, gpu_memory_buffer_manager, task_graph_runner, | 105 task_graph_runner, stats_instrumentation)); |
108 stats_instrumentation)); | |
109 } | 106 } |
110 | 107 |
111 protected: | 108 protected: |
112 LayerTreeHostImplForTesting( | 109 LayerTreeHostImplForTesting( |
113 TestHooks* test_hooks, | 110 TestHooks* test_hooks, |
114 const LayerTreeSettings& settings, | 111 const LayerTreeSettings& settings, |
115 LayerTreeHostImplClient* host_impl_client, | 112 LayerTreeHostImplClient* host_impl_client, |
116 TaskRunnerProvider* task_runner_provider, | 113 TaskRunnerProvider* task_runner_provider, |
117 SharedBitmapManager* shared_bitmap_manager, | |
118 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
119 TaskGraphRunner* task_graph_runner, | 114 TaskGraphRunner* task_graph_runner, |
120 RenderingStatsInstrumentation* stats_instrumentation) | 115 RenderingStatsInstrumentation* stats_instrumentation) |
121 : LayerTreeHostImpl(settings, | 116 : LayerTreeHostImpl(settings, |
122 host_impl_client, | 117 host_impl_client, |
123 task_runner_provider, | 118 task_runner_provider, |
124 stats_instrumentation, | 119 stats_instrumentation, |
125 shared_bitmap_manager, | |
126 gpu_memory_buffer_manager, | |
127 task_graph_runner, | 120 task_graph_runner, |
128 AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 121 AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
129 0), | 122 0), |
130 test_hooks_(test_hooks), | 123 test_hooks_(test_hooks), |
131 block_notify_ready_to_activate_for_testing_(false), | 124 block_notify_ready_to_activate_for_testing_(false), |
132 notify_ready_to_activate_was_blocked_(false) {} | 125 notify_ready_to_activate_was_blocked_(false) {} |
133 | 126 |
134 void CreateResourceAndRasterBufferProvider( | 127 void CreateResourceAndRasterBufferProvider( |
135 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, | 128 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, |
136 std::unique_ptr<ResourcePool>* resource_pool) override { | 129 std::unique_ptr<ResourcePool>* resource_pool) override { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 }; | 333 }; |
341 | 334 |
342 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 335 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
343 class LayerTreeHostForTesting : public LayerTreeHostInProcess { | 336 class LayerTreeHostForTesting : public LayerTreeHostInProcess { |
344 public: | 337 public: |
345 static std::unique_ptr<LayerTreeHostForTesting> Create( | 338 static std::unique_ptr<LayerTreeHostForTesting> Create( |
346 TestHooks* test_hooks, | 339 TestHooks* test_hooks, |
347 CompositorMode mode, | 340 CompositorMode mode, |
348 LayerTreeHostClient* client, | 341 LayerTreeHostClient* client, |
349 LayerTreeHostSingleThreadClient* single_thread_client, | 342 LayerTreeHostSingleThreadClient* single_thread_client, |
350 SharedBitmapManager* shared_bitmap_manager, | |
351 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
352 TaskGraphRunner* task_graph_runner, | 343 TaskGraphRunner* task_graph_runner, |
353 const LayerTreeSettings& settings, | 344 const LayerTreeSettings& settings, |
354 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 345 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
355 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 346 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
356 LayerTreeHostInProcess::InitParams params; | 347 LayerTreeHostInProcess::InitParams params; |
357 params.client = client; | 348 params.client = client; |
358 params.shared_bitmap_manager = shared_bitmap_manager; | |
359 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | |
360 params.task_graph_runner = task_graph_runner; | 349 params.task_graph_runner = task_graph_runner; |
361 params.settings = &settings; | 350 params.settings = &settings; |
362 | 351 |
363 params.animation_host = | 352 params.animation_host = |
364 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 353 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
365 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( | 354 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host( |
366 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); | 355 new LayerTreeHostForTesting(test_hooks, ¶ms, mode)); |
367 std::unique_ptr<TaskRunnerProvider> task_runner_provider = | 356 std::unique_ptr<TaskRunnerProvider> task_runner_provider = |
368 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 357 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
369 std::unique_ptr<Proxy> proxy; | 358 std::unique_ptr<Proxy> proxy; |
(...skipping 14 matching lines...) Expand all Loading... |
384 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), | 373 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), |
385 std::move(proxy)); | 374 std::move(proxy)); |
386 return layer_tree_host; | 375 return layer_tree_host; |
387 } | 376 } |
388 | 377 |
389 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 378 std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
390 LayerTreeHostImplClient* host_impl_client) override { | 379 LayerTreeHostImplClient* host_impl_client) override { |
391 std::unique_ptr<LayerTreeHostImpl> host_impl = | 380 std::unique_ptr<LayerTreeHostImpl> host_impl = |
392 LayerTreeHostImplForTesting::Create( | 381 LayerTreeHostImplForTesting::Create( |
393 test_hooks_, GetSettings(), host_impl_client, | 382 test_hooks_, GetSettings(), host_impl_client, |
394 GetTaskRunnerProvider(), shared_bitmap_manager(), | 383 GetTaskRunnerProvider(), task_graph_runner(), |
395 gpu_memory_buffer_manager(), task_graph_runner(), | |
396 rendering_stats_instrumentation()); | 384 rendering_stats_instrumentation()); |
397 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); | 385 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); |
398 return host_impl; | 386 return host_impl; |
399 } | 387 } |
400 | 388 |
401 void SetNeedsCommit() override { | 389 void SetNeedsCommit() override { |
402 if (!test_started_) | 390 if (!test_started_) |
403 return; | 391 return; |
404 LayerTreeHostInProcess::SetNeedsCommit(); | 392 LayerTreeHostInProcess::SetNeedsCommit(); |
405 } | 393 } |
(...skipping 20 matching lines...) Expand all Loading... |
426 | 414 |
427 // Adapts the LayerTreeHostRemoteForTesting to inject the | 415 // Adapts the LayerTreeHostRemoteForTesting to inject the |
428 // LayerTreeHostInProcess. | 416 // LayerTreeHostInProcess. |
429 class LayerTreeHostRemoteForLayerTreeTest | 417 class LayerTreeHostRemoteForLayerTreeTest |
430 : public LayerTreeHostRemoteForTesting { | 418 : public LayerTreeHostRemoteForTesting { |
431 public: | 419 public: |
432 static std::unique_ptr<LayerTreeHostRemoteForLayerTreeTest> Create( | 420 static std::unique_ptr<LayerTreeHostRemoteForLayerTreeTest> Create( |
433 TestHooks* test_hooks, | 421 TestHooks* test_hooks, |
434 LayerTreeHostClient* client, | 422 LayerTreeHostClient* client, |
435 LayerTreeSettings const* settings, | 423 LayerTreeSettings const* settings, |
436 SharedBitmapManager* shared_bitmap_manager, | |
437 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
438 TaskGraphRunner* task_graph_runner, | 424 TaskGraphRunner* task_graph_runner, |
439 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 425 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
440 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 426 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
441 std::unique_ptr<FakeImageSerializationProcessor> | 427 std::unique_ptr<FakeImageSerializationProcessor> |
442 image_serialization_processor = | 428 image_serialization_processor = |
443 base::MakeUnique<FakeImageSerializationProcessor>(); | 429 base::MakeUnique<FakeImageSerializationProcessor>(); |
444 | 430 |
445 LayerTreeHostRemote::InitParams params; | 431 LayerTreeHostRemote::InitParams params; |
446 params.client = client; | 432 params.client = client; |
447 params.main_task_runner = main_task_runner; | 433 params.main_task_runner = main_task_runner; |
448 params.animation_host = | 434 params.animation_host = |
449 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 435 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
450 params.remote_compositor_bridge = | 436 params.remote_compositor_bridge = |
451 CreateRemoteCompositorBridge(main_task_runner); | 437 CreateRemoteCompositorBridge(main_task_runner); |
452 params.engine_picture_cache = | 438 params.engine_picture_cache = |
453 image_serialization_processor->CreateEnginePictureCache(); | 439 image_serialization_processor->CreateEnginePictureCache(); |
454 params.settings = settings; | 440 params.settings = settings; |
455 | 441 |
456 std::unique_ptr<LayerTreeHostRemoteForLayerTreeTest> layer_tree_host = | 442 std::unique_ptr<LayerTreeHostRemoteForLayerTreeTest> layer_tree_host = |
457 base::WrapUnique( | 443 base::WrapUnique( |
458 new LayerTreeHostRemoteForLayerTreeTest(¶ms, test_hooks)); | 444 new LayerTreeHostRemoteForLayerTreeTest(¶ms, test_hooks)); |
459 layer_tree_host->Initialize(shared_bitmap_manager, | 445 layer_tree_host->Initialize(task_graph_runner, main_task_runner, |
460 gpu_memory_buffer_manager, task_graph_runner, | 446 impl_task_runner, |
461 main_task_runner, impl_task_runner, | |
462 std::move(image_serialization_processor)); | 447 std::move(image_serialization_processor)); |
463 return layer_tree_host; | 448 return layer_tree_host; |
464 } | 449 } |
465 | 450 |
466 ~LayerTreeHostRemoteForLayerTreeTest() override = default; | 451 ~LayerTreeHostRemoteForLayerTreeTest() override = default; |
467 | 452 |
468 std::unique_ptr<LayerTreeHostInProcess> CreateLayerTreeHostInProcess( | 453 std::unique_ptr<LayerTreeHostInProcess> CreateLayerTreeHostInProcess( |
469 LayerTreeHostClient* client, | 454 LayerTreeHostClient* client, |
470 SharedBitmapManager* shared_bitmap_manager, | |
471 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
472 TaskGraphRunner* task_graph_runner, | 455 TaskGraphRunner* task_graph_runner, |
473 const LayerTreeSettings& settings, | 456 const LayerTreeSettings& settings, |
474 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 457 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
475 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) override { | 458 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) override { |
476 return LayerTreeHostForTesting::Create( | 459 return LayerTreeHostForTesting::Create( |
477 test_hooks_, CompositorMode::THREADED, client, nullptr, | 460 test_hooks_, CompositorMode::THREADED, client, nullptr, |
478 shared_bitmap_manager, gpu_memory_buffer_manager, task_graph_runner, | 461 task_graph_runner, settings, main_task_runner, impl_task_runner); |
479 settings, main_task_runner, impl_task_runner); | |
480 } | 462 } |
481 | 463 |
482 private: | 464 private: |
483 LayerTreeHostRemoteForLayerTreeTest(InitParams* params, TestHooks* test_hooks) | 465 LayerTreeHostRemoteForLayerTreeTest(InitParams* params, TestHooks* test_hooks) |
484 : LayerTreeHostRemoteForTesting(params), test_hooks_(test_hooks) {} | 466 : LayerTreeHostRemoteForTesting(params), test_hooks_(test_hooks) {} |
485 | 467 |
486 TestHooks* test_hooks_; | 468 TestHooks* test_hooks_; |
487 }; | 469 }; |
488 | 470 |
489 class LayerTreeTestCompositorFrameSinkClient | 471 class LayerTreeTestCompositorFrameSinkClient |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 647 |
666 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); | 648 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); |
667 | 649 |
668 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner = | 650 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner = |
669 base::ThreadTaskRunnerHandle::Get(); | 651 base::ThreadTaskRunnerHandle::Get(); |
670 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner = | 652 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner = |
671 impl_thread_ ? impl_thread_->task_runner() : nullptr; | 653 impl_thread_ ? impl_thread_->task_runner() : nullptr; |
672 if (IsRemoteTest()) { | 654 if (IsRemoteTest()) { |
673 std::unique_ptr<LayerTreeHostRemoteForLayerTreeTest> | 655 std::unique_ptr<LayerTreeHostRemoteForLayerTreeTest> |
674 layer_tree_host_remote = LayerTreeHostRemoteForLayerTreeTest::Create( | 656 layer_tree_host_remote = LayerTreeHostRemoteForLayerTreeTest::Create( |
675 this, client_.get(), &settings_, shared_bitmap_manager_.get(), | 657 this, client_.get(), &settings_, task_graph_runner_.get(), |
676 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), | |
677 main_task_runner, impl_task_runner); | 658 main_task_runner, impl_task_runner); |
678 layer_tree_host_in_process_ = | 659 layer_tree_host_in_process_ = |
679 layer_tree_host_remote->layer_tree_host_in_process(); | 660 layer_tree_host_remote->layer_tree_host_in_process(); |
680 layer_tree_host_ = std::move(layer_tree_host_remote); | 661 layer_tree_host_ = std::move(layer_tree_host_remote); |
681 } else { | 662 } else { |
682 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host_for_testing = | 663 std::unique_ptr<LayerTreeHostForTesting> layer_tree_host_for_testing = |
683 LayerTreeHostForTesting::Create( | 664 LayerTreeHostForTesting::Create( |
684 this, mode_, client_.get(), client_.get(), | 665 this, mode_, client_.get(), client_.get(), task_graph_runner_.get(), |
685 shared_bitmap_manager_.get(), gpu_memory_buffer_manager_.get(), | 666 settings_, main_task_runner, impl_task_runner); |
686 task_graph_runner_.get(), settings_, main_task_runner, | |
687 impl_task_runner); | |
688 layer_tree_host_in_process_ = layer_tree_host_for_testing.get(); | 667 layer_tree_host_in_process_ = layer_tree_host_for_testing.get(); |
689 layer_tree_host_ = std::move(layer_tree_host_for_testing); | 668 layer_tree_host_ = std::move(layer_tree_host_for_testing); |
690 } | 669 } |
691 | 670 |
692 ASSERT_TRUE(layer_tree_host_); | 671 ASSERT_TRUE(layer_tree_host_); |
693 | 672 |
694 main_task_runner_ = | 673 main_task_runner_ = |
695 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); | 674 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); |
696 impl_task_runner_ = | 675 impl_task_runner_ = |
697 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); | 676 layer_tree_host_->GetTaskRunnerProvider()->ImplThreadTaskRunner(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 DCHECK(!IsRemoteTest()); | 912 DCHECK(!IsRemoteTest()); |
934 return layer_tree_host_in_process_; | 913 return layer_tree_host_in_process_; |
935 } | 914 } |
936 | 915 |
937 Proxy* LayerTreeTest::proxy() { | 916 Proxy* LayerTreeTest::proxy() { |
938 return layer_tree_host_in_process() ? layer_tree_host_in_process()->proxy() | 917 return layer_tree_host_in_process() ? layer_tree_host_in_process()->proxy() |
939 : NULL; | 918 : NULL; |
940 } | 919 } |
941 | 920 |
942 } // namespace cc | 921 } // namespace cc |
OLD | NEW |