| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/trees/threaded_channel.h" | 5 #include "cc/trees/threaded_channel.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool hold_commit_for_activation) { | 141 bool hold_commit_for_activation) { |
| 142 DCHECK(IsMainThread()); | 142 DCHECK(IsMainThread()); |
| 143 ImplThreadTaskRunner()->PostTask( | 143 ImplThreadTaskRunner()->PostTask( |
| 144 FROM_HERE, | 144 FROM_HERE, |
| 145 base::Bind(&ProxyImpl::NotifyReadyToCommitOnImpl, proxy_impl_weak_ptr_, | 145 base::Bind(&ProxyImpl::NotifyReadyToCommitOnImpl, proxy_impl_weak_ptr_, |
| 146 completion, layer_tree_host, main_thread_start_time, | 146 completion, layer_tree_host, main_thread_start_time, |
| 147 hold_commit_for_activation)); | 147 hold_commit_for_activation)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void ThreadedChannel::SynchronouslyInitializeImpl( | 150 void ThreadedChannel::SynchronouslyInitializeImpl( |
| 151 LayerTreeHostInProcess* layer_tree_host, | 151 LayerTreeHostInProcess* layer_tree_host) { |
| 152 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 153 TRACE_EVENT0("cc", "ThreadChannel::SynchronouslyInitializeImpl"); | 152 TRACE_EVENT0("cc", "ThreadChannel::SynchronouslyInitializeImpl"); |
| 154 DCHECK(IsMainThread()); | 153 DCHECK(IsMainThread()); |
| 155 { | 154 { |
| 156 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 155 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 157 CompletionEvent completion; | 156 CompletionEvent completion; |
| 158 ImplThreadTaskRunner()->PostTask( | 157 ImplThreadTaskRunner()->PostTask( |
| 159 FROM_HERE, | 158 FROM_HERE, |
| 160 base::Bind(&ThreadedChannel::InitializeImplOnImpl, | 159 base::Bind(&ThreadedChannel::InitializeImplOnImpl, |
| 161 base::Unretained(this), &completion, layer_tree_host, | 160 base::Unretained(this), &completion, layer_tree_host)); |
| 162 base::Passed(&external_begin_frame_source))); | |
| 163 completion.Wait(); | 161 completion.Wait(); |
| 164 } | 162 } |
| 165 main().initialized = true; | 163 main().initialized = true; |
| 166 } | 164 } |
| 167 | 165 |
| 168 void ThreadedChannel::SynchronouslyCloseImpl() { | 166 void ThreadedChannel::SynchronouslyCloseImpl() { |
| 169 TRACE_EVENT0("cc", "ThreadChannel::~SynchronouslyCloseImpl"); | 167 TRACE_EVENT0("cc", "ThreadChannel::~SynchronouslyCloseImpl"); |
| 170 DCHECK(IsMainThread()); | 168 DCHECK(IsMainThread()); |
| 171 | 169 |
| 172 // Synchronously finishes pending GL operations and deletes the impl. | 170 // Synchronously finishes pending GL operations and deletes the impl. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 DCHECK(IsImplThread()); | 253 DCHECK(IsImplThread()); |
| 256 MainThreadTaskRunner()->PostTask( | 254 MainThreadTaskRunner()->PostTask( |
| 257 FROM_HERE, | 255 FROM_HERE, |
| 258 base::Bind(&ProxyMain::BeginMainFrame, impl().proxy_main_weak_ptr, | 256 base::Bind(&ProxyMain::BeginMainFrame, impl().proxy_main_weak_ptr, |
| 259 base::Passed(&begin_main_frame_state))); | 257 base::Passed(&begin_main_frame_state))); |
| 260 } | 258 } |
| 261 | 259 |
| 262 std::unique_ptr<ProxyImpl> ThreadedChannel::CreateProxyImpl( | 260 std::unique_ptr<ProxyImpl> ThreadedChannel::CreateProxyImpl( |
| 263 ChannelImpl* channel_impl, | 261 ChannelImpl* channel_impl, |
| 264 LayerTreeHostInProcess* layer_tree_host, | 262 LayerTreeHostInProcess* layer_tree_host, |
| 265 TaskRunnerProvider* task_runner_provider, | 263 TaskRunnerProvider* task_runner_provider) { |
| 266 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 267 DCHECK(IsImplThread()); | 264 DCHECK(IsImplThread()); |
| 268 return base::MakeUnique<ProxyImpl>(channel_impl, layer_tree_host, | 265 return base::MakeUnique<ProxyImpl>(channel_impl, layer_tree_host, |
| 269 task_runner_provider, | 266 task_runner_provider); |
| 270 std::move(external_begin_frame_source)); | |
| 271 } | 267 } |
| 272 | 268 |
| 273 void ThreadedChannel::InitializeImplOnImpl( | 269 void ThreadedChannel::InitializeImplOnImpl( |
| 274 CompletionEvent* completion, | 270 CompletionEvent* completion, |
| 275 LayerTreeHostInProcess* layer_tree_host, | 271 LayerTreeHostInProcess* layer_tree_host) { |
| 276 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
| 277 DCHECK(IsImplThread()); | 272 DCHECK(IsImplThread()); |
| 278 impl().proxy_impl = | 273 impl().proxy_impl = |
| 279 CreateProxyImpl(this, layer_tree_host, task_runner_provider_, | 274 CreateProxyImpl(this, layer_tree_host, task_runner_provider_); |
| 280 std::move(external_begin_frame_source)); | |
| 281 impl().proxy_impl_weak_factory = | 275 impl().proxy_impl_weak_factory = |
| 282 base::MakeUnique<base::WeakPtrFactory<ProxyImpl>>( | 276 base::MakeUnique<base::WeakPtrFactory<ProxyImpl>>( |
| 283 impl().proxy_impl.get()); | 277 impl().proxy_impl.get()); |
| 284 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); | 278 proxy_impl_weak_ptr_ = impl().proxy_impl_weak_factory->GetWeakPtr(); |
| 285 completion->Signal(); | 279 completion->Signal(); |
| 286 } | 280 } |
| 287 | 281 |
| 288 void ThreadedChannel::CloseImplOnImpl(CompletionEvent* completion) { | 282 void ThreadedChannel::CloseImplOnImpl(CompletionEvent* completion) { |
| 289 DCHECK(IsImplThread()); | 283 DCHECK(IsImplThread()); |
| 290 | 284 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 335 |
| 342 ThreadedChannel::MainThreadOnly::~MainThreadOnly() {} | 336 ThreadedChannel::MainThreadOnly::~MainThreadOnly() {} |
| 343 | 337 |
| 344 ThreadedChannel::CompositorThreadOnly::CompositorThreadOnly( | 338 ThreadedChannel::CompositorThreadOnly::CompositorThreadOnly( |
| 345 base::WeakPtr<ProxyMain> proxy_main_weak_ptr) | 339 base::WeakPtr<ProxyMain> proxy_main_weak_ptr) |
| 346 : proxy_main_weak_ptr(proxy_main_weak_ptr) {} | 340 : proxy_main_weak_ptr(proxy_main_weak_ptr) {} |
| 347 | 341 |
| 348 ThreadedChannel::CompositorThreadOnly::~CompositorThreadOnly() {} | 342 ThreadedChannel::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 349 | 343 |
| 350 } // namespace cc | 344 } // namespace cc |
| OLD | NEW |