Chromium Code Reviews| OLD | NEW |
|---|---|
| (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(false); | |
|
David Trainor- moved to gerrit
2015/12/11 17:13:44
Remove?
Khushal
2015/12/11 22:49:37
Woops. Debugging fun. :P
| |
| 82 DCHECK(task_runner_provider_->IsImplThread()); | |
| 83 return ProxyImpl::Create(channel_impl, layer_tree_host, task_runner_provider, | |
| 84 std::move(external_begin_frame_source)); | |
| 85 } | |
| 86 | |
| 87 bool RemoteChannelImpl::MainFrameWillHappenForTesting() { | |
| 88 DCHECK(task_runner_provider_->IsMainThread()); | |
| 89 bool main_frame_will_happen; | |
| 90 { | |
| 91 CompletionEvent completion; | |
| 92 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 93 ImplThreadTaskRunner()->PostTask( | |
| 94 FROM_HERE, | |
| 95 base::Bind(&ProxyImpl::MainFrameWillHappenOnImplForTesting, | |
| 96 proxy_impl_weak_ptr_, &completion, &main_frame_will_happen)); | |
| 97 completion.Wait(); | |
| 98 } | |
| 99 return main_frame_will_happen; | |
| 100 } | |
| 101 | |
| 102 void RemoteChannelImpl::Initialize() { | |
| 103 { | |
|
David Trainor- moved to gerrit
2015/12/11 17:13:44
You don't need this extra scope here. But if it's
Khushal
2015/12/11 22:49:37
Done. I don't think there is any particular style
| |
| 104 CompletionEvent completion; | |
| 105 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
| 106 ImplThreadTaskRunner()->PostTask( | |
| 107 FROM_HERE, base::Bind(&RemoteChannelImpl::InitializeImplOnImpl, | |
| 108 base::Unretained(this), &completion, | |
| 109 main().layer_tree_host.get())); | |
| 110 completion.Wait(); | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 void RemoteChannelImpl::InitializeImplOnImpl(CompletionEvent* completion, | |
| 115 LayerTreeHost* layer_tree_host) { | |
| 116 DCHECK(task_runner_provider_->IsImplThread()); | |
| 117 impl().proxy_impl = | |
| 118 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, nullptr); | |
| 119 impl().proxy_impl_weak_factory = make_scoped_ptr( | |
| 120 new base::WeakPtrFactory<ProxyImpl>(impl().proxy_impl.get())); | |
| 121 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); | |
| 122 completion->Signal(); | |
| 123 } | |
| 124 | |
| 125 void RemoteChannelImpl::ShutdownImplOnImpl(CompletionEvent* completion) { | |
| 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, ¶ms); | |
| 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 | |
| OLD | NEW |