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

Side by Side Diff: cc/trees/remote_channel_impl.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_impl.h"
6
7 #include "base/bind_helpers.h"
8 #include "base/single_thread_task_runner.h"
9 #include "cc/proto/compositor_message.pb.h"
10 #include "cc/proto/compositor_message_to_impl.pb.h"
11 #include "cc/proto/compositor_message_to_main.pb.h"
12 #include "cc/trees/layer_tree_host.h"
13 #include "cc/trees/layer_tree_settings.h"
14
15 namespace cc {
16
17 scoped_ptr<RemoteChannelImpl> RemoteChannelImpl::Create(
18 RemoteChannelHost* remote_channel_host,
19 TaskGraphRunner* task_graph_runner,
20 const LayerTreeSettings& settings,
21 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
22 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
23 return make_scoped_ptr(
24 new RemoteChannelImpl(remote_channel_host, task_graph_runner, settings,
25 main_task_runner, impl_task_runner));
26 }
27
28 RemoteChannelImpl::RemoteChannelImpl(
29 RemoteChannelHost* remote_channel_host,
30 TaskGraphRunner* task_graph_runner,
31 const LayerTreeSettings& settings,
32 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
33 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
34 : main_thread_vars_unsafe_(this,
35 remote_channel_host,
36 task_graph_runner,
37 settings,
38 main_task_runner,
39 impl_task_runner) {
40 DCHECK(task_runner_provider_->IsMainThread());
41 }
42
43 RemoteChannelImpl::~RemoteChannelImpl() {
44 DCHECK(task_runner_provider_->IsMainThread());
45 {
46 CompletionEvent completion;
47 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
48 ImplThreadTaskRunner()->PostTask(
49 FROM_HERE, base::Bind(&ProxyImpl::FinishGLOnImpl, proxy_impl_weak_ptr_,
50 &completion));
51 completion.Wait();
52 }
53 {
54 CompletionEvent completion;
55 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
56 ImplThreadTaskRunner()->PostTask(
57 FROM_HERE, base::Bind(&RemoteChannelImpl::ShutdownImplOnImpl,
58 base::Unretained(this), &completion));
59 completion.Wait();
60 }
61 }
62
63 void RemoteChannelImpl::HandleProto(
64 const proto::CompositorMessageToImpl& proto) {
65 DCHECK(task_runner_provider_->IsMainThread());
66 switch (proto.message_type()) {
67 case proto::CompositorMessageToImpl::MainThreadHasStoppedFlingingOnImpl:
68 MainThreadHasStoppedFlinging();
69 break;
70 default:
71 // TODO(khushalsagar): Add more types here.
72 NOTIMPLEMENTED();
73 }
74 }
75
76 scoped_ptr<ProxyImpl> RemoteChannelImpl::CreateProxyImpl(
77 ChannelImpl* channel_impl,
78 LayerTreeHost* layer_tree_host,
79 TaskRunnerProvider* task_runner_provider,
80 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
81 DCHECK(task_runner_provider_->IsImplThread());
82 return ProxyImpl::Create(channel_impl, layer_tree_host, task_runner_provider,
83 std::move(external_begin_frame_source));
84 }
85
86 bool RemoteChannelImpl::MainFrameWillHappenForTesting() {
87 DCHECK(task_runner_provider_->IsMainThread());
88 bool main_frame_will_happen;
89 {
90 CompletionEvent completion;
91 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
92 ImplThreadTaskRunner()->PostTask(
93 FROM_HERE,
94 base::Bind(&ProxyImpl::MainFrameWillHappenOnImplForTesting,
95 proxy_impl_weak_ptr_, &completion, &main_frame_will_happen));
96 completion.Wait();
97 }
98 return main_frame_will_happen;
99 }
100
101 void RemoteChannelImpl::Initialize() {
102 CompletionEvent completion;
103 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
104 ImplThreadTaskRunner()->PostTask(
105 FROM_HERE, base::Bind(&RemoteChannelImpl::InitializeImplOnImpl,
106 base::Unretained(this), &completion,
107 main().layer_tree_host.get()));
108 completion.Wait();
109 }
110
111 void RemoteChannelImpl::InitializeImplOnImpl(CompletionEvent* completion,
112 LayerTreeHost* layer_tree_host) {
113 DCHECK(task_runner_provider_->IsMainThreadBlocked());
114 DCHECK(task_runner_provider_->IsImplThread());
115
116 impl().proxy_impl =
117 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, nullptr);
118 impl().proxy_impl_weak_factory = make_scoped_ptr(
119 new base::WeakPtrFactory<ProxyImpl>(impl().proxy_impl.get()));
120 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr();
121 completion->Signal();
122 }
123
124 void RemoteChannelImpl::ShutdownImplOnImpl(CompletionEvent* completion) {
125 DCHECK(task_runner_provider_->IsMainThreadBlocked());
126 DCHECK(task_runner_provider_->IsImplThread());
127
128 // We must invalidate the proxy_impl weak ptrs and destroy the weak ptr
129 // factory before destroying proxy_impl.
130 impl().proxy_impl_weak_factory->InvalidateWeakPtrs();
131 impl().proxy_impl_weak_factory.reset();
132
133 impl().proxy_impl.reset();
134 completion->Signal();
135 }
136
137 void RemoteChannelImpl::MainThreadHasStoppedFlinging() {
138 ImplThreadTaskRunner()->PostTask(
139 FROM_HERE, base::Bind(&ProxyImpl::MainThreadHasStoppedFlingingOnImpl,
140 proxy_impl_weak_ptr_));
141 }
142
143 void RemoteChannelImpl::DidCompleteSwapBuffers() {}
144
145 void RemoteChannelImpl::SetRendererCapabilitiesMainCopy(
146 const RendererCapabilities& capabilities) {}
147
148 void RemoteChannelImpl::BeginMainFrameNotExpectedSoon() {}
149
150 void RemoteChannelImpl::DidCommitAndDrawFrame() {}
151
152 void RemoteChannelImpl::SetAnimationEvents(
153 scoped_ptr<AnimationEventsVector> queue) {}
154
155 void RemoteChannelImpl::DidLoseOutputSurface() {}
156
157 void RemoteChannelImpl::RequestNewOutputSurface() {}
158
159 void RemoteChannelImpl::DidInitializeOutputSurface(
160 bool success,
161 const RendererCapabilities& capabilities) {}
162
163 void RemoteChannelImpl::DidCompletePageScaleAnimation() {}
164
165 void RemoteChannelImpl::PostFrameTimingEventsOnMain(
166 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
167 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {}
168
169 void RemoteChannelImpl::BeginMainFrame(
170 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {}
171
172 RemoteChannelImpl::MainThreadOnly& RemoteChannelImpl::main() {
173 DCHECK(task_runner_provider_->IsMainThread());
174 return main_thread_vars_unsafe_;
175 }
176
177 RemoteChannelImpl::CompositorThreadOnly& RemoteChannelImpl::impl() {
178 DCHECK(task_runner_provider_->IsImplThread());
179 return compositor_thread_vars_unsafe_;
180 }
181
182 const RemoteChannelImpl::CompositorThreadOnly& RemoteChannelImpl::impl() const {
183 DCHECK(task_runner_provider_->IsImplThread());
184 return compositor_thread_vars_unsafe_;
185 }
186
187 base::SingleThreadTaskRunner* RemoteChannelImpl::MainThreadTaskRunner() const {
188 return task_runner_provider_->MainThreadTaskRunner();
189 }
190
191 base::SingleThreadTaskRunner* RemoteChannelImpl::ImplThreadTaskRunner() const {
192 return task_runner_provider_->ImplThreadTaskRunner();
193 }
194
195 RemoteChannelImpl::MainThreadOnly::MainThreadOnly(
196 RemoteChannelImpl* remote_channel_impl,
197 RemoteChannelHost* remote_channel_host,
198 TaskGraphRunner* task_graph_runner,
199 const LayerTreeSettings& settings,
200 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
201 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
202 : remote_channel_host(remote_channel_host) {
203 LayerTreeHost::InitParams params;
204 params.task_graph_runner = task_graph_runner;
205 params.main_task_runner = main_task_runner;
206 params.settings = &settings;
207 layer_tree_host =
208 LayerTreeHost::CreateDeserializable(impl_task_runner, &params);
209 remote_channel_impl->task_runner_provider_ =
210 layer_tree_host->task_runner_provider();
211 }
212
213 RemoteChannelImpl::MainThreadOnly::~MainThreadOnly() {}
214
215 RemoteChannelImpl::CompositorThreadOnly::CompositorThreadOnly()
216 : proxy_impl(nullptr), proxy_impl_weak_factory(nullptr) {}
217
218 RemoteChannelImpl::CompositorThreadOnly::~CompositorThreadOnly() {}
219
220 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698