| 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/proxy_main.h" | 5 #include "cc/trees/proxy_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 TaskRunnerProvider* task_runner_provider) | 29 TaskRunnerProvider* task_runner_provider) |
| 30 : layer_tree_host_(layer_tree_host), | 30 : layer_tree_host_(layer_tree_host), |
| 31 task_runner_provider_(task_runner_provider), | 31 task_runner_provider_(task_runner_provider), |
| 32 layer_tree_host_id_(layer_tree_host->GetId()), | 32 layer_tree_host_id_(layer_tree_host->GetId()), |
| 33 max_requested_pipeline_stage_(NO_PIPELINE_STAGE), | 33 max_requested_pipeline_stage_(NO_PIPELINE_STAGE), |
| 34 current_pipeline_stage_(NO_PIPELINE_STAGE), | 34 current_pipeline_stage_(NO_PIPELINE_STAGE), |
| 35 final_pipeline_stage_(NO_PIPELINE_STAGE), | 35 final_pipeline_stage_(NO_PIPELINE_STAGE), |
| 36 commit_waits_for_activation_(false), | 36 commit_waits_for_activation_(false), |
| 37 started_(false), | 37 started_(false), |
| 38 defer_commits_(false), | 38 defer_commits_(false), |
| 39 compositor_frame_sink_weak_factory_(this), |
| 39 weak_factory_(this) { | 40 weak_factory_(this) { |
| 40 TRACE_EVENT0("cc", "ProxyMain::ProxyMain"); | 41 TRACE_EVENT0("cc", "ProxyMain::ProxyMain"); |
| 41 DCHECK(task_runner_provider_); | 42 DCHECK(task_runner_provider_); |
| 42 DCHECK(IsMainThread()); | 43 DCHECK(IsMainThread()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 ProxyMain::~ProxyMain() { | 46 ProxyMain::~ProxyMain() { |
| 46 TRACE_EVENT0("cc", "ProxyMain::~ProxyMain"); | 47 TRACE_EVENT0("cc", "ProxyMain::~ProxyMain"); |
| 47 DCHECK(IsMainThread()); | 48 DCHECK(IsMainThread()); |
| 48 DCHECK(!started_); | 49 DCHECK(!started_); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 82 |
| 82 void ProxyMain::SetAnimationEvents(std::unique_ptr<MutatorEvents> events) { | 83 void ProxyMain::SetAnimationEvents(std::unique_ptr<MutatorEvents> events) { |
| 83 TRACE_EVENT0("cc", "ProxyMain::SetAnimationEvents"); | 84 TRACE_EVENT0("cc", "ProxyMain::SetAnimationEvents"); |
| 84 DCHECK(IsMainThread()); | 85 DCHECK(IsMainThread()); |
| 85 layer_tree_host_->SetAnimationEvents(std::move(events)); | 86 layer_tree_host_->SetAnimationEvents(std::move(events)); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void ProxyMain::DidLoseCompositorFrameSink() { | 89 void ProxyMain::DidLoseCompositorFrameSink() { |
| 89 TRACE_EVENT0("cc", "ProxyMain::DidLoseCompositorFrameSink"); | 90 TRACE_EVENT0("cc", "ProxyMain::DidLoseCompositorFrameSink"); |
| 90 DCHECK(IsMainThread()); | 91 DCHECK(IsMainThread()); |
| 92 compositor_frame_sink_weak_factory_.InvalidateWeakPtrs(); |
| 91 layer_tree_host_->DidLoseCompositorFrameSink(); | 93 layer_tree_host_->DidLoseCompositorFrameSink(); |
| 92 } | 94 } |
| 93 | 95 |
| 94 void ProxyMain::RequestNewCompositorFrameSink() { | 96 void ProxyMain::RequestNewCompositorFrameSink() { |
| 95 TRACE_EVENT0("cc", "ProxyMain::RequestNewCompositorFrameSink"); | 97 TRACE_EVENT0("cc", "ProxyMain::RequestNewCompositorFrameSink"); |
| 96 DCHECK(IsMainThread()); | 98 DCHECK(IsMainThread()); |
| 97 layer_tree_host_->RequestNewCompositorFrameSink(); | 99 layer_tree_host_->RequestNewCompositorFrameSink(); |
| 98 } | 100 } |
| 99 | 101 |
| 100 void ProxyMain::DidInitializeCompositorFrameSink(bool success) { | 102 void ProxyMain::DidInitializeCompositorFrameSink(bool success) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // With ProxyMain, we use a pending tree and activate it once it's ready to | 284 // With ProxyMain, we use a pending tree and activate it once it's ready to |
| 283 // draw to allow input to modify the active tree and draw during raster. | 285 // draw to allow input to modify the active tree and draw during raster. |
| 284 return false; | 286 return false; |
| 285 } | 287 } |
| 286 | 288 |
| 287 void ProxyMain::SetCompositorFrameSink( | 289 void ProxyMain::SetCompositorFrameSink( |
| 288 CompositorFrameSink* compositor_frame_sink) { | 290 CompositorFrameSink* compositor_frame_sink) { |
| 289 ImplThreadTaskRunner()->PostTask( | 291 ImplThreadTaskRunner()->PostTask( |
| 290 FROM_HERE, | 292 FROM_HERE, |
| 291 base::Bind(&ProxyImpl::InitializeCompositorFrameSinkOnImpl, | 293 base::Bind(&ProxyImpl::InitializeCompositorFrameSinkOnImpl, |
| 292 base::Unretained(proxy_impl_.get()), compositor_frame_sink)); | 294 base::Unretained(proxy_impl_.get()), compositor_frame_sink, |
| 295 compositor_frame_sink_weak_factory_.GetWeakPtr())); |
| 293 } | 296 } |
| 294 | 297 |
| 295 void ProxyMain::SetVisible(bool visible) { | 298 void ProxyMain::SetVisible(bool visible) { |
| 296 TRACE_EVENT1("cc", "ProxyMain::SetVisible", "visible", visible); | 299 TRACE_EVENT1("cc", "ProxyMain::SetVisible", "visible", visible); |
| 297 ImplThreadTaskRunner()->PostTask( | 300 ImplThreadTaskRunner()->PostTask( |
| 298 FROM_HERE, base::Bind(&ProxyImpl::SetVisibleOnImpl, | 301 FROM_HERE, base::Bind(&ProxyImpl::SetVisibleOnImpl, |
| 299 base::Unretained(proxy_impl_.get()), visible)); | 302 base::Unretained(proxy_impl_.get()), visible)); |
| 300 } | 303 } |
| 301 | 304 |
| 302 void ProxyMain::SetNeedsAnimate() { | 305 void ProxyMain::SetNeedsAnimate() { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 FROM_HERE, base::Bind(&ProxyImpl::MainFrameWillHappenOnImplForTesting, | 462 FROM_HERE, base::Bind(&ProxyImpl::MainFrameWillHappenOnImplForTesting, |
| 460 base::Unretained(proxy_impl_.get()), &completion, | 463 base::Unretained(proxy_impl_.get()), &completion, |
| 461 &main_frame_will_happen)); | 464 &main_frame_will_happen)); |
| 462 completion.Wait(); | 465 completion.Wait(); |
| 463 } | 466 } |
| 464 return main_frame_will_happen; | 467 return main_frame_will_happen; |
| 465 } | 468 } |
| 466 | 469 |
| 467 void ProxyMain::ReleaseCompositorFrameSink() { | 470 void ProxyMain::ReleaseCompositorFrameSink() { |
| 468 DCHECK(IsMainThread()); | 471 DCHECK(IsMainThread()); |
| 472 compositor_frame_sink_weak_factory_.InvalidateWeakPtrs(); |
| 469 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 473 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 470 CompletionEvent completion; | 474 CompletionEvent completion; |
| 471 ImplThreadTaskRunner()->PostTask( | 475 ImplThreadTaskRunner()->PostTask( |
| 472 FROM_HERE, base::Bind(&ProxyImpl::ReleaseCompositorFrameSinkOnImpl, | 476 FROM_HERE, base::Bind(&ProxyImpl::ReleaseCompositorFrameSinkOnImpl, |
| 473 base::Unretained(proxy_impl_.get()), &completion)); | 477 base::Unretained(proxy_impl_.get()), &completion)); |
| 474 completion.Wait(); | 478 completion.Wait(); |
| 475 } | 479 } |
| 476 | 480 |
| 477 void ProxyMain::UpdateBrowserControlsState(BrowserControlsState constraints, | 481 void ProxyMain::UpdateBrowserControlsState(BrowserControlsState constraints, |
| 478 BrowserControlsState current, | 482 BrowserControlsState current, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 505 | 509 |
| 506 bool ProxyMain::IsImplThread() const { | 510 bool ProxyMain::IsImplThread() const { |
| 507 return task_runner_provider_->IsImplThread(); | 511 return task_runner_provider_->IsImplThread(); |
| 508 } | 512 } |
| 509 | 513 |
| 510 base::SingleThreadTaskRunner* ProxyMain::ImplThreadTaskRunner() { | 514 base::SingleThreadTaskRunner* ProxyMain::ImplThreadTaskRunner() { |
| 511 return task_runner_provider_->ImplThreadTaskRunner(); | 515 return task_runner_provider_->ImplThreadTaskRunner(); |
| 512 } | 516 } |
| 513 | 517 |
| 514 } // namespace cc | 518 } // namespace cc |
| OLD | NEW |