| 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 frame_sink_bound_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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 292 |
| 292 bool ProxyMain::CommitToActiveTree() const { | 293 bool ProxyMain::CommitToActiveTree() const { |
| 293 // With ProxyMain, we use a pending tree and activate it once it's ready to | 294 // With ProxyMain, we use a pending tree and activate it once it's ready to |
| 294 // draw to allow input to modify the active tree and draw during raster. | 295 // draw to allow input to modify the active tree and draw during raster. |
| 295 return false; | 296 return false; |
| 296 } | 297 } |
| 297 | 298 |
| 298 void ProxyMain::SetCompositorFrameSink( | 299 void ProxyMain::SetCompositorFrameSink( |
| 299 CompositorFrameSink* compositor_frame_sink) { | 300 CompositorFrameSink* compositor_frame_sink) { |
| 300 ImplThreadTaskRunner()->PostTask( | 301 ImplThreadTaskRunner()->PostTask( |
| 301 FROM_HERE, base::BindOnce(&ProxyImpl::InitializeCompositorFrameSinkOnImpl, | 302 FROM_HERE, |
| 302 base::Unretained(proxy_impl_.get()), | 303 base::BindOnce(&ProxyImpl::InitializeCompositorFrameSinkOnImpl, |
| 303 compositor_frame_sink)); | 304 base::Unretained(proxy_impl_.get()), compositor_frame_sink, |
| 305 frame_sink_bound_weak_factory_.GetWeakPtr())); |
| 304 } | 306 } |
| 305 | 307 |
| 306 void ProxyMain::SetVisible(bool visible) { | 308 void ProxyMain::SetVisible(bool visible) { |
| 307 TRACE_EVENT1("cc", "ProxyMain::SetVisible", "visible", visible); | 309 TRACE_EVENT1("cc", "ProxyMain::SetVisible", "visible", visible); |
| 308 ImplThreadTaskRunner()->PostTask( | 310 ImplThreadTaskRunner()->PostTask( |
| 309 FROM_HERE, base::BindOnce(&ProxyImpl::SetVisibleOnImpl, | 311 FROM_HERE, base::BindOnce(&ProxyImpl::SetVisibleOnImpl, |
| 310 base::Unretained(proxy_impl_.get()), visible)); | 312 base::Unretained(proxy_impl_.get()), visible)); |
| 311 } | 313 } |
| 312 | 314 |
| 313 void ProxyMain::SetNeedsAnimate() { | 315 void ProxyMain::SetNeedsAnimate() { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 base::BindOnce(&ProxyImpl::MainFrameWillHappenOnImplForTesting, | 474 base::BindOnce(&ProxyImpl::MainFrameWillHappenOnImplForTesting, |
| 473 base::Unretained(proxy_impl_.get()), &completion, | 475 base::Unretained(proxy_impl_.get()), &completion, |
| 474 &main_frame_will_happen)); | 476 &main_frame_will_happen)); |
| 475 completion.Wait(); | 477 completion.Wait(); |
| 476 } | 478 } |
| 477 return main_frame_will_happen; | 479 return main_frame_will_happen; |
| 478 } | 480 } |
| 479 | 481 |
| 480 void ProxyMain::ReleaseCompositorFrameSink() { | 482 void ProxyMain::ReleaseCompositorFrameSink() { |
| 481 DCHECK(IsMainThread()); | 483 DCHECK(IsMainThread()); |
| 484 frame_sink_bound_weak_factory_.InvalidateWeakPtrs(); |
| 482 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 485 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 483 CompletionEvent completion; | 486 CompletionEvent completion; |
| 484 ImplThreadTaskRunner()->PostTask( | 487 ImplThreadTaskRunner()->PostTask( |
| 485 FROM_HERE, | 488 FROM_HERE, |
| 486 base::BindOnce(&ProxyImpl::ReleaseCompositorFrameSinkOnImpl, | 489 base::BindOnce(&ProxyImpl::ReleaseCompositorFrameSinkOnImpl, |
| 487 base::Unretained(proxy_impl_.get()), &completion)); | 490 base::Unretained(proxy_impl_.get()), &completion)); |
| 488 completion.Wait(); | 491 completion.Wait(); |
| 489 } | 492 } |
| 490 | 493 |
| 491 void ProxyMain::UpdateBrowserControlsState(BrowserControlsState constraints, | 494 void ProxyMain::UpdateBrowserControlsState(BrowserControlsState constraints, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 519 | 522 |
| 520 bool ProxyMain::IsImplThread() const { | 523 bool ProxyMain::IsImplThread() const { |
| 521 return task_runner_provider_->IsImplThread(); | 524 return task_runner_provider_->IsImplThread(); |
| 522 } | 525 } |
| 523 | 526 |
| 524 base::SingleThreadTaskRunner* ProxyMain::ImplThreadTaskRunner() { | 527 base::SingleThreadTaskRunner* ProxyMain::ImplThreadTaskRunner() { |
| 525 return task_runner_provider_->ImplThreadTaskRunner(); | 528 return task_runner_provider_->ImplThreadTaskRunner(); |
| 526 } | 529 } |
| 527 | 530 |
| 528 } // namespace cc | 531 } // namespace cc |
| OLD | NEW |