Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 1126253005: cc: Add LayerTreeHost::InitParams for LayerTreeHost creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: all Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 TestHooks* test_hooks_; 447 TestHooks* test_hooks_;
448 }; 448 };
449 449
450 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 450 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
451 class LayerTreeHostForTesting : public LayerTreeHost { 451 class LayerTreeHostForTesting : public LayerTreeHost {
452 public: 452 public:
453 static scoped_ptr<LayerTreeHostForTesting> Create( 453 static scoped_ptr<LayerTreeHostForTesting> Create(
454 TestHooks* test_hooks, 454 TestHooks* test_hooks,
455 LayerTreeHostClientForTesting* client, 455 LayerTreeHostClientForTesting* client,
456 SharedBitmapManager* shared_bitmap_manager,
457 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
458 TaskGraphRunner* task_graph_runner,
459 const LayerTreeSettings& settings,
460 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
461 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 456 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
462 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 457 LayerTreeHost::InitParams* params) {
danakj 2015/05/07 00:59:56 I think maybe I prefer passing in all the things h
sadrul 2015/05/07 04:39:25 Done.
463 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 458 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
464 new LayerTreeHostForTesting(test_hooks, client, shared_bitmap_manager, 459 new LayerTreeHostForTesting(test_hooks, params));
465 gpu_memory_buffer_manager,
466 task_graph_runner, settings));
467 if (impl_task_runner.get()) { 460 if (impl_task_runner.get()) {
468 layer_tree_host->InitializeForTesting( 461 layer_tree_host->InitializeForTesting(ThreadProxyForTest::Create(
469 ThreadProxyForTest::Create(test_hooks, 462 test_hooks, layer_tree_host.get(), params->main_task_runner,
470 layer_tree_host.get(), 463 impl_task_runner, params->external_begin_frame_source.Pass()));
471 main_task_runner,
472 impl_task_runner,
473 external_begin_frame_source.Pass()));
474 } else { 464 } else {
475 layer_tree_host->InitializeForTesting( 465 layer_tree_host->InitializeForTesting(SingleThreadProxyForTest::Create(
476 SingleThreadProxyForTest::Create( 466 test_hooks, layer_tree_host.get(), client, params->main_task_runner,
477 test_hooks, 467 params->external_begin_frame_source.Pass()));
478 layer_tree_host.get(),
479 client,
480 main_task_runner,
481 external_begin_frame_source.Pass()));
482 } 468 }
483 return layer_tree_host.Pass(); 469 return layer_tree_host.Pass();
484 } 470 }
485 471
486 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 472 scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
487 LayerTreeHostImplClient* host_impl_client) override { 473 LayerTreeHostImplClient* host_impl_client) override {
488 return LayerTreeHostImplForTesting::Create( 474 return LayerTreeHostImplForTesting::Create(
489 test_hooks_, settings(), host_impl_client, proxy(), 475 test_hooks_, settings(), host_impl_client, proxy(),
490 shared_bitmap_manager_, gpu_memory_buffer_manager_, task_graph_runner_, 476 shared_bitmap_manager_, gpu_memory_buffer_manager_, task_graph_runner_,
491 rendering_stats_instrumentation()); 477 rendering_stats_instrumentation());
492 } 478 }
493 479
494 void SetNeedsCommit() override { 480 void SetNeedsCommit() override {
495 if (!test_started_) 481 if (!test_started_)
496 return; 482 return;
497 LayerTreeHost::SetNeedsCommit(); 483 LayerTreeHost::SetNeedsCommit();
498 } 484 }
499 485
500 void set_test_started(bool started) { test_started_ = started; } 486 void set_test_started(bool started) { test_started_ = started; }
501 487
502 private: 488 private:
503 LayerTreeHostForTesting( 489 LayerTreeHostForTesting(TestHooks* test_hooks,
504 TestHooks* test_hooks, 490 LayerTreeHost::InitParams* params)
505 LayerTreeHostClient* client, 491 : LayerTreeHost(params),
506 SharedBitmapManager* shared_bitmap_manager, 492 shared_bitmap_manager_(params->shared_bitmap_manager),
507 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 493 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager),
508 TaskGraphRunner* task_graph_runner, 494 task_graph_runner_(params->task_graph_runner),
509 const LayerTreeSettings& settings)
510 : LayerTreeHost(client, NULL, NULL, NULL, settings),
511 shared_bitmap_manager_(shared_bitmap_manager),
512 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
513 task_graph_runner_(task_graph_runner),
514 test_hooks_(test_hooks), 495 test_hooks_(test_hooks),
515 test_started_(false) {} 496 test_started_(false) {}
516 497
517 SharedBitmapManager* shared_bitmap_manager_; 498 SharedBitmapManager* shared_bitmap_manager_;
518 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; 499 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
519 TaskGraphRunner* task_graph_runner_; 500 TaskGraphRunner* task_graph_runner_;
520 TestHooks* test_hooks_; 501 TestHooks* test_hooks_;
521 bool test_started_; 502 bool test_started_;
522 }; 503 };
523 504
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 client_ = LayerTreeHostClientForTesting::Create(this); 641 client_ = LayerTreeHostClientForTesting::Create(this);
661 642
662 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source; 643 scoped_ptr<FakeExternalBeginFrameSource> external_begin_frame_source;
663 if (settings_.use_external_begin_frame_source) { 644 if (settings_.use_external_begin_frame_source) {
664 external_begin_frame_source.reset(new FakeExternalBeginFrameSource( 645 external_begin_frame_source.reset(new FakeExternalBeginFrameSource(
665 settings_.renderer_settings.refresh_rate)); 646 settings_.renderer_settings.refresh_rate));
666 external_begin_frame_source_ = external_begin_frame_source.get(); 647 external_begin_frame_source_ = external_begin_frame_source.get();
667 } 648 }
668 649
669 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); 650 DCHECK(!impl_thread_ || impl_thread_->task_runner().get());
651 LayerTreeHost::InitParams params;
652
danakj 2015/05/07 00:59:56 nit: no whitespace
sadrul 2015/05/07 04:39:25 Done.
653 params.client = client_.get();
654 params.shared_bitmap_manager = shared_bitmap_manager_.get();
655 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager_.get();
656 params.task_graph_runner = task_graph_runner_.get();
657 params.settings = &settings_;
658 params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
659 params.external_begin_frame_source = external_begin_frame_source.Pass();
660
670 layer_tree_host_ = LayerTreeHostForTesting::Create( 661 layer_tree_host_ = LayerTreeHostForTesting::Create(
671 this, client_.get(), shared_bitmap_manager_.get(), 662 this, client_.get(), impl_thread_ ? impl_thread_->task_runner() : NULL,
672 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, 663 &params);
673 base::ThreadTaskRunnerHandle::Get(),
674 impl_thread_ ? impl_thread_->task_runner() : NULL,
675 external_begin_frame_source.Pass());
676 ASSERT_TRUE(layer_tree_host_); 664 ASSERT_TRUE(layer_tree_host_);
677 665
678 started_ = true; 666 started_ = true;
679 beginning_ = true; 667 beginning_ = true;
680 SetupTree(); 668 SetupTree();
681 WillBeginTest(); 669 WillBeginTest();
682 BeginTest(); 670 BeginTest();
683 beginning_ = false; 671 beginning_ = false;
684 if (end_when_begin_returns_) 672 if (end_when_begin_returns_)
685 RealEndTest(); 673 RealEndTest();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 LayerTreeHost* LayerTreeTest::layer_tree_host() { 877 LayerTreeHost* LayerTreeTest::layer_tree_host() {
890 // We check for a null proxy here as we sometimes ask for the layer tree host 878 // We check for a null proxy here as we sometimes ask for the layer tree host
891 // when the proxy does not exist, often for checking settings after a test has 879 // when the proxy does not exist, often for checking settings after a test has
892 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See 880 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See
893 // elsewhere in this file for other examples. 881 // elsewhere in this file for other examples.
894 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); 882 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked());
895 return layer_tree_host_.get(); 883 return layer_tree_host_.get();
896 } 884 }
897 885
898 } // namespace cc 886 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698