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

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

Issue 2320823003: cc/blimp: Remove Initialize and Close messages. (Closed)
Patch Set: format Created 4 years, 3 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
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/remote_proto_channel_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 455 }
456 void DisplayDidDrawAndSwap() override { 456 void DisplayDidDrawAndSwap() override {
457 hooks_->DisplayDidDrawAndSwapOnThread(); 457 hooks_->DisplayDidDrawAndSwapOnThread();
458 } 458 }
459 459
460 private: 460 private:
461 TestHooks* hooks_; 461 TestHooks* hooks_;
462 }; 462 };
463 463
464 LayerTreeTest::LayerTreeTest() 464 LayerTreeTest::LayerTreeTest()
465 : remote_proto_channel_bridge_(this), 465 : image_serialization_processor_(
466 image_serialization_processor_(
467 base::WrapUnique(new FakeImageSerializationProcessor)), 466 base::WrapUnique(new FakeImageSerializationProcessor)),
468 delegating_output_surface_client_( 467 delegating_output_surface_client_(
469 new LayerTreeTestDelegatingOutputSurfaceClient(this)), 468 new LayerTreeTestDelegatingOutputSurfaceClient(this)),
470 weak_factory_(this) { 469 weak_factory_(this) {
471 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); 470 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr();
472 471
473 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was 472 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was
474 // specified (for running in a debugger). 473 // specified (for running in a debugger).
475 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 474 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
476 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout)) 475 if (!command_line->HasSwitch(switches::kCCLayerTreeTestNoTimeout))
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 DCHECK(!impl_thread_ || impl_thread_->task_runner().get()); 632 DCHECK(!impl_thread_ || impl_thread_->task_runner().get());
634 633
635 if (IsRemoteTest()) { 634 if (IsRemoteTest()) {
636 DCHECK(impl_thread_); 635 DCHECK(impl_thread_);
637 layer_tree_host_ = LayerTreeHostForTesting::Create( 636 layer_tree_host_ = LayerTreeHostForTesting::Create(
638 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main, 637 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_main,
639 nullptr, nullptr, task_graph_runner_.get(), settings_, 638 nullptr, nullptr, task_graph_runner_.get(), settings_,
640 base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr, 639 base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr,
641 image_serialization_processor_.get()); 640 image_serialization_processor_.get());
642 DCHECK(remote_proto_channel_bridge_.channel_main.HasReceiver()); 641 DCHECK(remote_proto_channel_bridge_.channel_main.HasReceiver());
642
643 LayerTreeSettings settings = settings_;
644 settings.abort_commit_before_output_surface_creation = false;
645 remote_client_layer_tree_host_ = LayerTreeHostForTesting::Create(
646 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_impl,
647 nullptr, nullptr, task_graph_runner_.get(), settings,
648 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner(),
649 nullptr, image_serialization_processor_.get());
650 DCHECK(remote_proto_channel_bridge_.channel_impl.HasReceiver());
643 } else { 651 } else {
644 layer_tree_host_ = LayerTreeHostForTesting::Create( 652 layer_tree_host_ = LayerTreeHostForTesting::Create(
645 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(), 653 this, mode_, client_.get(), nullptr, shared_bitmap_manager_.get(),
646 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_, 654 gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_,
647 base::ThreadTaskRunnerHandle::Get(), 655 base::ThreadTaskRunnerHandle::Get(),
648 impl_thread_ ? impl_thread_->task_runner() : nullptr, nullptr, 656 impl_thread_ ? impl_thread_->task_runner() : nullptr, nullptr,
649 image_serialization_processor_.get()); 657 image_serialization_processor_.get());
650 } 658 }
651 659
652 ASSERT_TRUE(layer_tree_host_); 660 ASSERT_TRUE(layer_tree_host_);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 return FakeOutputSurface::Create3d(std::move(compositor_context_provider)); 887 return FakeOutputSurface::Create3d(std::move(compositor_context_provider));
880 } 888 }
881 889
882 void LayerTreeTest::DestroyLayerTreeHost() { 890 void LayerTreeTest::DestroyLayerTreeHost() {
883 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer()) 891 if (layer_tree_host_ && layer_tree_host_->GetLayerTree()->root_layer())
884 layer_tree_host_->GetLayerTree()->root_layer()->SetLayerTreeHost(NULL); 892 layer_tree_host_->GetLayerTree()->root_layer()->SetLayerTreeHost(NULL);
885 layer_tree_host_ = nullptr; 893 layer_tree_host_ = nullptr;
886 894
887 DCHECK(!remote_proto_channel_bridge_.channel_main.HasReceiver()); 895 DCHECK(!remote_proto_channel_bridge_.channel_main.HasReceiver());
888 896
889 // Destroying the LayerTreeHost should destroy the remote client
890 // LayerTreeHost.
891 DCHECK(!remote_client_layer_tree_host_);
892 }
893
894 void LayerTreeTest::DestroyRemoteClientHost() {
895 DCHECK(IsRemoteTest());
896 DCHECK(remote_client_layer_tree_host_);
897
898 remote_client_layer_tree_host_ = nullptr; 897 remote_client_layer_tree_host_ = nullptr;
899 DCHECK(!remote_proto_channel_bridge_.channel_impl.HasReceiver()); 898 DCHECK(!remote_proto_channel_bridge_.channel_impl.HasReceiver());
900 } 899 }
901 900
902 void LayerTreeTest::CreateRemoteClientHost(
903 const proto::CompositorMessageToImpl& proto) {
904 DCHECK(IsRemoteTest());
905 DCHECK(!remote_client_layer_tree_host_);
906 DCHECK(impl_thread_);
907 DCHECK(proto.message_type() ==
908 proto::CompositorMessageToImpl::INITIALIZE_IMPL);
909
910 LayerTreeSettings settings = settings_;
911 settings.abort_commit_before_output_surface_creation = false;
912 remote_client_layer_tree_host_ = LayerTreeHostForTesting::Create(
913 this, mode_, client_.get(), &remote_proto_channel_bridge_.channel_impl,
914 nullptr, nullptr, task_graph_runner_.get(), settings,
915 base::ThreadTaskRunnerHandle::Get(), impl_thread_->task_runner(), nullptr,
916 image_serialization_processor_.get());
917
918 DCHECK(remote_proto_channel_bridge_.channel_impl.HasReceiver());
919 DCHECK(task_runner_provider()->HasImplThread());
920 }
921
922 TaskRunnerProvider* LayerTreeTest::task_runner_provider() const { 901 TaskRunnerProvider* LayerTreeTest::task_runner_provider() const {
923 // All LayerTreeTests can use the task runner provider to access the impl 902 // All LayerTreeTests can use the task runner provider to access the impl
924 // thread. In the remote mode, the impl thread of the compositor lives on 903 // thread. In the remote mode, the impl thread of the compositor lives on
925 // the client, so return the task runner provider owned by the remote client 904 // the client, so return the task runner provider owned by the remote client
926 // LayerTreeHost. 905 // LayerTreeHost.
927 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get() 906 LayerTreeHost* host = IsRemoteTest() ? remote_client_layer_tree_host_.get()
928 : layer_tree_host_.get(); 907 : layer_tree_host_.get();
929 908
930 // 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
931 // anymore. 910 // anymore.
932 DCHECK(host); 911 DCHECK(host);
933 912
934 return host->GetTaskRunnerProvider(); 913 return host->GetTaskRunnerProvider();
935 } 914 }
936 915
937 LayerTreeHost* LayerTreeTest::layer_tree_host() { 916 LayerTreeHost* LayerTreeTest::layer_tree_host() {
938 DCHECK(task_runner_provider()->IsMainThread() || 917 DCHECK(task_runner_provider()->IsMainThread() ||
939 task_runner_provider()->IsMainThreadBlocked()); 918 task_runner_provider()->IsMainThreadBlocked());
940 return layer_tree_host_.get(); 919 return layer_tree_host_.get();
941 } 920 }
942 921
943 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() { 922 LayerTreeHost* LayerTreeTest::remote_client_layer_tree_host() {
944 DCHECK(IsRemoteTest()); 923 DCHECK(IsRemoteTest());
945 DCHECK(task_runner_provider()->IsMainThread() || 924 DCHECK(task_runner_provider()->IsMainThread() ||
946 task_runner_provider()->IsMainThreadBlocked()); 925 task_runner_provider()->IsMainThreadBlocked());
947 return remote_client_layer_tree_host_.get(); 926 return remote_client_layer_tree_host_.get();
948 } 927 }
949 928
950 } // namespace cc 929 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/test/remote_proto_channel_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698