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

Side by Side Diff: cc/trees/remote_channel_host.cc

Issue 1513643010: cc:: Add remote mode to the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use LayerTreeSettings::ToProtobuf, update comments. Created 5 years 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/trees/remote_channel_host.h"
6
7 #include "cc/proto/compositor_message.pb.h"
8 #include "cc/proto/compositor_message_to_impl.pb.h"
9
10 namespace cc {
11
12 scoped_ptr<RemoteChannelHost> RemoteChannelHost::Create(
13 RemoteProtoChannel* remote_proto_channel,
14 RemoteChannelHostClient* client,
15 TaskGraphRunner* task_graph_runner,
16 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
17 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
18 return make_scoped_ptr(
19 new RemoteChannelHost(remote_proto_channel, client, task_graph_runner,
20 main_task_runner, impl_task_runner));
21 }
22
23 RemoteChannelHost::RemoteChannelHost(
24 RemoteProtoChannel* remote_proto_channel,
25 RemoteChannelHostClient* client,
26 TaskGraphRunner* task_graph_runner,
27 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
28 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
29 : remote_proto_channel_(remote_proto_channel),
30 client_(client),
31 task_graph_runner_(task_graph_runner),
32 main_task_runner_(main_task_runner),
33 impl_task_runner_(impl_task_runner),
34 did_shutdown_(false) {
35 DCHECK(main_thread_checker_.CalledOnValidThread());
36 DCHECK(remote_proto_channel_);
37 DCHECK(client_);
38 DCHECK(task_graph_runner_);
39
40 remote_proto_channel_->SetProtoReceiver(this);
41 }
42
43 RemoteChannelHost::~RemoteChannelHost() {
44 DCHECK(main_thread_checker_.CalledOnValidThread());
45
46 remote_proto_channel_->SetProtoReceiver(nullptr);
47 remote_channel_impl_.reset();
48 }
49
50 scoped_ptr<RemoteChannelImpl> RemoteChannelHost::CreateRemoteChannelImpl(
51 RemoteChannelHost* remote_channel_host,
52 TaskGraphRunner* task_graph_runner,
53 const LayerTreeSettings& settings,
54 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
55 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
56 return RemoteChannelImpl::Create(remote_channel_host, task_graph_runner,
57 settings, main_task_runner,
58 impl_task_runner);
59 }
60
61 void RemoteChannelHost::SendProto(const proto::CompositorMessage& proto) {
62 DCHECK(main_thread_checker_.CalledOnValidThread());
63
64 remote_proto_channel_->SendCompositorProto(proto);
65 }
66
67 void RemoteChannelHost::OnProtoReceived(
68 scoped_ptr<proto::CompositorMessage> proto) {
69 DCHECK(main_thread_checker_.CalledOnValidThread());
70 DCHECK(!did_shutdown_);
71 DCHECK(proto->has_to_impl());
72
73 proto::CompositorMessageToImpl to_impl_proto = proto->to_impl();
74 switch (to_impl_proto.message_type()) {
75 case proto::CompositorMessageToImpl::Unknown:
76 return;
77 case proto::CompositorMessageToImpl::InitializeImpl:
78 InitializeImpl(to_impl_proto.initialize_impl_message());
79 return;
80 case proto::CompositorMessageToImpl::CloseImpl:
81 DCHECK(remote_channel_impl_);
82 remote_channel_impl_.reset();
83
84 did_shutdown_ = true;
85
86 // It is not safe to access any variables after this method is called. The
87 // client may destroy us now so |this| will not be there anymore.
88 client_->DidShutdown();
89 return;
90 default:
91 DCHECK(remote_channel_impl_);
92 remote_channel_impl_->HandleProto(to_impl_proto);
93 }
94 }
95
96 void RemoteChannelHost::InitializeImpl(const proto::InitializeImpl& proto) {
97 DCHECK(main_thread_checker_.CalledOnValidThread());
98 DCHECK(!remote_channel_impl_);
99
100 LayerTreeSettings settings;
101 settings.FromProtobuf(proto.layer_tree_settings());
102
103 client_->OverrideLayerTreeSettings(&settings);
104
105 remote_channel_impl_ = CreateRemoteChannelImpl(
106 this, task_graph_runner_, settings, main_task_runner_, impl_task_runner_);
107 remote_channel_impl_->Initialize();
108
109 task_graph_runner_ = nullptr;
110 main_task_runner_ = nullptr;
111 impl_task_runner_ = nullptr;
112 }
113
114 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698