| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 impl_task_runner, | 55 impl_task_runner, |
| 56 external_begin_frame_source.Pass())); | 56 external_begin_frame_source.Pass())); |
| 57 } | 57 } |
| 58 | 58 |
| 59 ThreadProxy::ThreadProxy( | 59 ThreadProxy::ThreadProxy( |
| 60 LayerTreeHost* layer_tree_host, | 60 LayerTreeHost* layer_tree_host, |
| 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 63 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 63 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 64 : Proxy(main_task_runner, impl_task_runner), | 64 : Proxy(main_task_runner, impl_task_runner), |
| 65 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), | 65 main_thread_only_vars_unsafe_(this, layer_tree_host), |
| 66 main_thread_or_blocked_vars_unsafe_(layer_tree_host), | |
| 67 compositor_thread_vars_unsafe_( | 66 compositor_thread_vars_unsafe_( |
| 68 this, | 67 this, |
| 69 layer_tree_host->id(), | 68 layer_tree_host->id(), |
| 70 layer_tree_host->rendering_stats_instrumentation(), | 69 layer_tree_host->rendering_stats_instrumentation(), |
| 71 external_begin_frame_source.Pass()) { | 70 external_begin_frame_source.Pass()) { |
| 72 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 73 DCHECK(IsMainThread()); | 72 DCHECK(IsMainThread()); |
| 74 DCHECK(this->layer_tree_host()); | 73 DCHECK(this->main().layer_tree_host); |
| 75 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once | 74 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once |
| 76 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to | 75 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to |
| 77 // ProxyMain#SetChannel. | 76 // ProxyMain#SetChannel. |
| 78 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); | 77 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); |
| 79 } | 78 } |
| 80 | 79 |
| 81 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 80 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
| 82 int layer_tree_host_id) | 81 LayerTreeHost* layer_tree_host) |
| 83 : layer_tree_host_id(layer_tree_host_id), | 82 : layer_tree_host_id(layer_tree_host->id()), |
| 83 layer_tree_host(layer_tree_host), |
| 84 max_requested_pipeline_stage(NO_PIPELINE_STAGE), | 84 max_requested_pipeline_stage(NO_PIPELINE_STAGE), |
| 85 current_pipeline_stage(NO_PIPELINE_STAGE), | 85 current_pipeline_stage(NO_PIPELINE_STAGE), |
| 86 final_pipeline_stage(NO_PIPELINE_STAGE), | 86 final_pipeline_stage(NO_PIPELINE_STAGE), |
| 87 commit_waits_for_activation(false), |
| 87 started(false), | 88 started(false), |
| 88 prepare_tiles_pending(false), | 89 prepare_tiles_pending(false), |
| 89 defer_commits(false), | 90 defer_commits(false), |
| 90 weak_factory(proxy) {} | 91 weak_factory(proxy) {} |
| 91 | 92 |
| 92 ThreadProxy::MainThreadOnly::~MainThreadOnly() {} | 93 ThreadProxy::MainThreadOnly::~MainThreadOnly() {} |
| 93 | 94 |
| 94 ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread( | 95 ThreadProxy::BlockedMainCommitOnly::BlockedMainCommitOnly() |
| 95 LayerTreeHost* host) | 96 : layer_tree_host(nullptr) {} |
| 96 : layer_tree_host(host), | |
| 97 commit_waits_for_activation(false), | |
| 98 main_thread_inside_commit(false) {} | |
| 99 | 97 |
| 100 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} | 98 ThreadProxy::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} |
| 101 | 99 |
| 102 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( | 100 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( |
| 103 ThreadProxy* proxy, | 101 ThreadProxy* proxy, |
| 104 int layer_tree_host_id, | 102 int layer_tree_host_id, |
| 105 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 103 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 106 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 104 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 107 : layer_tree_host_id(layer_tree_host_id), | 105 : layer_tree_host_id(layer_tree_host_id), |
| 106 next_commit_waits_for_activation(false), |
| 108 commit_completion_event(nullptr), | 107 commit_completion_event(nullptr), |
| 109 completion_event_for_commit_held_on_tree_activation(nullptr), | |
| 110 next_frame_is_newly_committed_frame(false), | 108 next_frame_is_newly_committed_frame(false), |
| 111 inside_draw(false), | 109 inside_draw(false), |
| 112 input_throttled_until_commit(false), | 110 input_throttled_until_commit(false), |
| 113 smoothness_priority_expiration_notifier( | 111 smoothness_priority_expiration_notifier( |
| 114 proxy->ImplThreadTaskRunner(), | 112 proxy->ImplThreadTaskRunner(), |
| 115 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
| 116 base::TimeDelta::FromMilliseconds( | 114 base::TimeDelta::FromMilliseconds( |
| 117 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 115 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 118 external_begin_frame_source(external_begin_frame_source.Pass()), | 116 external_begin_frame_source(external_begin_frame_source.Pass()), |
| 119 rendering_stats_instrumentation(rendering_stats_instrumentation), | 117 rendering_stats_instrumentation(rendering_stats_instrumentation), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 171 |
| 174 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { | 172 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { |
| 175 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", | 173 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", |
| 176 "throttle", throttle); | 174 "throttle", throttle); |
| 177 impl().scheduler->SetThrottleFrameProduction(throttle); | 175 impl().scheduler->SetThrottleFrameProduction(throttle); |
| 178 } | 176 } |
| 179 | 177 |
| 180 void ThreadProxy::DidLoseOutputSurface() { | 178 void ThreadProxy::DidLoseOutputSurface() { |
| 181 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); | 179 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
| 182 DCHECK(IsMainThread()); | 180 DCHECK(IsMainThread()); |
| 183 layer_tree_host()->DidLoseOutputSurface(); | 181 main().layer_tree_host->DidLoseOutputSurface(); |
| 184 } | 182 } |
| 185 | 183 |
| 186 void ThreadProxy::RequestNewOutputSurface() { | 184 void ThreadProxy::RequestNewOutputSurface() { |
| 187 DCHECK(IsMainThread()); | 185 DCHECK(IsMainThread()); |
| 188 layer_tree_host()->RequestNewOutputSurface(); | 186 main().layer_tree_host->RequestNewOutputSurface(); |
| 189 } | 187 } |
| 190 | 188 |
| 191 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 189 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
| 192 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); | 190 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); |
| 193 } | 191 } |
| 194 | 192 |
| 195 void ThreadProxy::ReleaseOutputSurface() { | 193 void ThreadProxy::ReleaseOutputSurface() { |
| 196 DCHECK(IsMainThread()); | 194 DCHECK(IsMainThread()); |
| 197 DCHECK(layer_tree_host()->output_surface_lost()); | 195 DCHECK(main().layer_tree_host->output_surface_lost()); |
| 198 | 196 |
| 199 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 197 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 200 CompletionEvent completion; | 198 CompletionEvent completion; |
| 201 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion); | 199 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion); |
| 202 completion.Wait(); | 200 completion.Wait(); |
| 203 } | 201 } |
| 204 | 202 |
| 205 void ThreadProxy::DidInitializeOutputSurface( | 203 void ThreadProxy::DidInitializeOutputSurface( |
| 206 bool success, | 204 bool success, |
| 207 const RendererCapabilities& capabilities) { | 205 const RendererCapabilities& capabilities) { |
| 208 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); | 206 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); |
| 209 DCHECK(IsMainThread()); | 207 DCHECK(IsMainThread()); |
| 210 | 208 |
| 211 if (!success) { | 209 if (!success) { |
| 212 layer_tree_host()->DidFailToInitializeOutputSurface(); | 210 main().layer_tree_host->DidFailToInitializeOutputSurface(); |
| 213 return; | 211 return; |
| 214 } | 212 } |
| 215 main().renderer_capabilities_main_thread_copy = capabilities; | 213 main().renderer_capabilities_main_thread_copy = capabilities; |
| 216 layer_tree_host()->DidInitializeOutputSurface(); | 214 main().layer_tree_host->DidInitializeOutputSurface(); |
| 217 } | 215 } |
| 218 | 216 |
| 219 void ThreadProxy::SetRendererCapabilitiesMainCopy( | 217 void ThreadProxy::SetRendererCapabilitiesMainCopy( |
| 220 const RendererCapabilities& capabilities) { | 218 const RendererCapabilities& capabilities) { |
| 221 main().renderer_capabilities_main_thread_copy = capabilities; | 219 main().renderer_capabilities_main_thread_copy = capabilities; |
| 222 } | 220 } |
| 223 | 221 |
| 224 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( | 222 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( |
| 225 CommitPipelineStage required_stage) { | 223 CommitPipelineStage required_stage) { |
| 226 DCHECK(IsMainThread()); | 224 DCHECK(IsMainThread()); |
| 227 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); | 225 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); |
| 228 bool already_posted = | 226 bool already_posted = |
| 229 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; | 227 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; |
| 230 main().max_requested_pipeline_stage = | 228 main().max_requested_pipeline_stage = |
| 231 std::max(main().max_requested_pipeline_stage, required_stage); | 229 std::max(main().max_requested_pipeline_stage, required_stage); |
| 232 if (already_posted) | 230 if (already_posted) |
| 233 return false; | 231 return false; |
| 234 main().channel_main->SetNeedsCommitOnImpl(); | 232 main().channel_main->SetNeedsCommitOnImpl(); |
| 235 return true; | 233 return true; |
| 236 } | 234 } |
| 237 | 235 |
| 238 void ThreadProxy::SetNeedsCommitOnImpl() { | 236 void ThreadProxy::SetNeedsCommitOnImpl() { |
| 239 SetNeedsCommitOnImplThread(); | 237 SetNeedsCommitOnImplThread(); |
| 240 } | 238 } |
| 241 | 239 |
| 242 void ThreadProxy::DidCompletePageScaleAnimation() { | 240 void ThreadProxy::DidCompletePageScaleAnimation() { |
| 243 DCHECK(IsMainThread()); | 241 DCHECK(IsMainThread()); |
| 244 layer_tree_host()->DidCompletePageScaleAnimation(); | 242 main().layer_tree_host->DidCompletePageScaleAnimation(); |
| 245 } | 243 } |
| 246 | 244 |
| 247 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { | 245 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { |
| 248 DCHECK(IsMainThread()); | 246 DCHECK(IsMainThread()); |
| 249 DCHECK(!layer_tree_host()->output_surface_lost()); | 247 DCHECK(!main().layer_tree_host->output_surface_lost()); |
| 250 return main().renderer_capabilities_main_thread_copy; | 248 return main().renderer_capabilities_main_thread_copy; |
| 251 } | 249 } |
| 252 | 250 |
| 253 void ThreadProxy::SetNeedsAnimate() { | 251 void ThreadProxy::SetNeedsAnimate() { |
| 254 DCHECK(IsMainThread()); | 252 DCHECK(IsMainThread()); |
| 255 if (SendCommitRequestToImplThreadIfNeeded(ANIMATE_PIPELINE_STAGE)) { | 253 if (SendCommitRequestToImplThreadIfNeeded(ANIMATE_PIPELINE_STAGE)) { |
| 256 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsAnimate", | 254 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsAnimate", |
| 257 TRACE_EVENT_SCOPE_THREAD); | 255 TRACE_EVENT_SCOPE_THREAD); |
| 258 } | 256 } |
| 259 } | 257 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); | 394 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); |
| 397 } | 395 } |
| 398 | 396 |
| 399 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) { | 397 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) { |
| 400 DCHECK(IsImplThread()); | 398 DCHECK(IsImplThread()); |
| 401 SetNeedsRedrawRectOnImplThread(damage_rect); | 399 SetNeedsRedrawRectOnImplThread(damage_rect); |
| 402 } | 400 } |
| 403 | 401 |
| 404 void ThreadProxy::SetNextCommitWaitsForActivation() { | 402 void ThreadProxy::SetNextCommitWaitsForActivation() { |
| 405 DCHECK(IsMainThread()); | 403 DCHECK(IsMainThread()); |
| 406 DCHECK(!blocked_main().main_thread_inside_commit); | 404 main().commit_waits_for_activation = true; |
| 407 blocked_main().commit_waits_for_activation = true; | |
| 408 } | 405 } |
| 409 | 406 |
| 410 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 407 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| 411 DCHECK(IsMainThread()); | 408 DCHECK(IsMainThread()); |
| 412 if (main().defer_commits == defer_commits) | 409 if (main().defer_commits == defer_commits) |
| 413 return; | 410 return; |
| 414 | 411 |
| 415 main().defer_commits = defer_commits; | 412 main().defer_commits = defer_commits; |
| 416 if (main().defer_commits) | 413 if (main().defer_commits) |
| 417 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 414 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 475 } |
| 479 | 476 |
| 480 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { | 477 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| 481 DCHECK(IsImplThread()); | 478 DCHECK(IsImplThread()); |
| 482 if (is_throttled == impl().input_throttled_until_commit) | 479 if (is_throttled == impl().input_throttled_until_commit) |
| 483 return; | 480 return; |
| 484 impl().input_throttled_until_commit = is_throttled; | 481 impl().input_throttled_until_commit = is_throttled; |
| 485 RenewTreePriority(); | 482 RenewTreePriority(); |
| 486 } | 483 } |
| 487 | 484 |
| 488 LayerTreeHost* ThreadProxy::layer_tree_host() { | |
| 489 return blocked_main().layer_tree_host; | |
| 490 } | |
| 491 | |
| 492 const LayerTreeHost* ThreadProxy::layer_tree_host() const { | |
| 493 return blocked_main().layer_tree_host; | |
| 494 } | |
| 495 | |
| 496 ThreadProxy::MainThreadOnly& ThreadProxy::main() { | 485 ThreadProxy::MainThreadOnly& ThreadProxy::main() { |
| 497 DCHECK(IsMainThread()); | 486 DCHECK(IsMainThread()); |
| 498 return main_thread_only_vars_unsafe_; | 487 return main_thread_only_vars_unsafe_; |
| 499 } | 488 } |
| 500 const ThreadProxy::MainThreadOnly& ThreadProxy::main() const { | 489 const ThreadProxy::MainThreadOnly& ThreadProxy::main() const { |
| 501 DCHECK(IsMainThread()); | 490 DCHECK(IsMainThread()); |
| 502 return main_thread_only_vars_unsafe_; | 491 return main_thread_only_vars_unsafe_; |
| 503 } | 492 } |
| 504 | 493 |
| 505 ThreadProxy::MainThreadOrBlockedMainThread& ThreadProxy::blocked_main() { | 494 ThreadProxy::BlockedMainCommitOnly& ThreadProxy::blocked_main_commit() { |
| 506 DCHECK(IsMainThread() || IsMainThreadBlocked()); | 495 DCHECK(IsMainThreadBlocked()); |
| 507 return main_thread_or_blocked_vars_unsafe_; | 496 DCHECK(impl().commit_completion_event); |
| 508 } | 497 return main_thread_blocked_commit_vars_unsafe_; |
| 509 | |
| 510 const ThreadProxy::MainThreadOrBlockedMainThread& ThreadProxy::blocked_main() | |
| 511 const { | |
| 512 DCHECK(IsMainThread() || IsMainThreadBlocked()); | |
| 513 return main_thread_or_blocked_vars_unsafe_; | |
| 514 } | 498 } |
| 515 | 499 |
| 516 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { | 500 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { |
| 517 DCHECK(IsImplThread()); | 501 DCHECK(IsImplThread()); |
| 518 return compositor_thread_vars_unsafe_; | 502 return compositor_thread_vars_unsafe_; |
| 519 } | 503 } |
| 520 | 504 |
| 521 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { | 505 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { |
| 522 DCHECK(IsImplThread()); | 506 DCHECK(IsImplThread()); |
| 523 return compositor_thread_vars_unsafe_; | 507 return compositor_thread_vars_unsafe_; |
| 524 } | 508 } |
| 525 | 509 |
| 526 void ThreadProxy::Start() { | 510 void ThreadProxy::Start() { |
| 527 DCHECK(IsMainThread()); | 511 DCHECK(IsMainThread()); |
| 528 DCHECK(Proxy::HasImplThread()); | 512 DCHECK(Proxy::HasImplThread()); |
| 529 | 513 |
| 530 // Create LayerTreeHostImpl. | 514 // Create LayerTreeHostImpl. |
| 531 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 515 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 532 CompletionEvent completion; | 516 CompletionEvent completion; |
| 533 Proxy::ImplThreadTaskRunner()->PostTask( | 517 main().channel_main->InitializeImplOnImpl(&completion, |
| 534 FROM_HERE, | 518 main().layer_tree_host); |
| 535 base::Bind(&ThreadProxy::InitializeImplOnImplThread, | |
| 536 base::Unretained(this), | |
| 537 &completion)); | |
| 538 completion.Wait(); | 519 completion.Wait(); |
| 539 | 520 |
| 540 main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr(); | 521 main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr(); |
| 541 | 522 |
| 542 main().started = true; | 523 main().started = true; |
| 543 } | 524 } |
| 544 | 525 |
| 545 void ThreadProxy::Stop() { | 526 void ThreadProxy::Stop() { |
| 546 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 527 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
| 547 DCHECK(IsMainThread()); | 528 DCHECK(IsMainThread()); |
| 548 DCHECK(main().started); | 529 DCHECK(main().started); |
| 549 | 530 |
| 550 // Synchronously finishes pending GL operations and deletes the impl. | 531 // Synchronously finishes pending GL operations and deletes the impl. |
| 551 // The two steps are done as separate post tasks, so that tasks posted | 532 // The two steps are done as separate post tasks, so that tasks posted |
| 552 // by the GL implementation due to the Finish can be executed by the | 533 // by the GL implementation due to the Finish can be executed by the |
| 553 // renderer before shutting it down. | 534 // renderer before shutting it down. |
| 554 { | 535 { |
| 555 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 536 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 556 CompletionEvent completion; | 537 CompletionEvent completion; |
| 557 main().channel_main->FinishGLOnImpl(&completion); | 538 main().channel_main->FinishGLOnImpl(&completion); |
| 558 completion.Wait(); | 539 completion.Wait(); |
| 559 } | 540 } |
| 560 { | 541 { |
| 561 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 542 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 562 | 543 |
| 563 CompletionEvent completion; | 544 CompletionEvent completion; |
| 564 Proxy::ImplThreadTaskRunner()->PostTask( | 545 main().channel_main->LayerTreeHostClosedOnImpl(&completion); |
| 565 FROM_HERE, | |
| 566 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, | |
| 567 impl_thread_weak_ptr_, | |
| 568 &completion)); | |
| 569 completion.Wait(); | 546 completion.Wait(); |
| 570 } | 547 } |
| 571 | 548 |
| 572 main().weak_factory.InvalidateWeakPtrs(); | 549 main().weak_factory.InvalidateWeakPtrs(); |
| 573 blocked_main().layer_tree_host = NULL; | 550 main().layer_tree_host = nullptr; |
| 574 main().started = false; | 551 main().started = false; |
| 575 } | 552 } |
| 576 | 553 |
| 577 bool ThreadProxy::SupportsImplScrolling() const { | 554 bool ThreadProxy::SupportsImplScrolling() const { |
| 578 return true; | 555 return true; |
| 579 } | 556 } |
| 580 | 557 |
| 581 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { | 558 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { |
| 582 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 559 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| 583 DCHECK(IsImplThread()); | 560 DCHECK(IsImplThread()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 603 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
| 627 TRACE_EVENT_SCOPE_THREAD); | 604 TRACE_EVENT_SCOPE_THREAD); |
| 628 main().channel_main->BeginMainFrameAbortedOnImpl( | 605 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 629 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); | 606 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
| 630 return; | 607 return; |
| 631 } | 608 } |
| 632 | 609 |
| 633 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 610 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 634 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the | 611 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
| 635 // remaining swap promises. | 612 // remaining swap promises. |
| 636 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); | 613 ScopedAbortRemainingSwapPromises swap_promise_checker(main().layer_tree_host); |
| 637 | 614 |
| 638 main().final_pipeline_stage = main().max_requested_pipeline_stage; | 615 main().final_pipeline_stage = main().max_requested_pipeline_stage; |
| 639 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; | 616 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; |
| 640 | 617 |
| 641 if (!layer_tree_host()->visible()) { | 618 if (!main().layer_tree_host->visible()) { |
| 642 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 619 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
| 643 main().channel_main->BeginMainFrameAbortedOnImpl( | 620 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 644 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); | 621 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
| 645 return; | 622 return; |
| 646 } | 623 } |
| 647 | 624 |
| 648 if (layer_tree_host()->output_surface_lost()) { | 625 if (main().layer_tree_host->output_surface_lost()) { |
| 649 TRACE_EVENT_INSTANT0( | 626 TRACE_EVENT_INSTANT0( |
| 650 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 627 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
| 651 main().channel_main->BeginMainFrameAbortedOnImpl( | 628 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 652 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); | 629 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); |
| 653 return; | 630 return; |
| 654 } | 631 } |
| 655 | 632 |
| 656 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; | 633 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; |
| 657 | 634 |
| 658 layer_tree_host()->ApplyScrollAndScale( | 635 main().layer_tree_host->ApplyScrollAndScale( |
| 659 begin_main_frame_state->scroll_info.get()); | 636 begin_main_frame_state->scroll_info.get()); |
| 660 | 637 |
| 661 layer_tree_host()->WillBeginMainFrame(); | 638 main().layer_tree_host->WillBeginMainFrame(); |
| 662 | 639 |
| 663 layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args); | 640 main().layer_tree_host->BeginMainFrame( |
| 664 layer_tree_host()->AnimateLayers( | 641 begin_main_frame_state->begin_frame_args); |
| 642 main().layer_tree_host->AnimateLayers( |
| 665 begin_main_frame_state->begin_frame_args.frame_time); | 643 begin_main_frame_state->begin_frame_args.frame_time); |
| 666 | 644 |
| 667 // Recreate all UI resources if there were evicted UI resources when the impl | 645 // Recreate all UI resources if there were evicted UI resources when the impl |
| 668 // thread initiated the commit. | 646 // thread initiated the commit. |
| 669 if (begin_main_frame_state->evicted_ui_resources) | 647 if (begin_main_frame_state->evicted_ui_resources) |
| 670 layer_tree_host()->RecreateUIResources(); | 648 main().layer_tree_host->RecreateUIResources(); |
| 671 | 649 |
| 672 layer_tree_host()->RequestMainFrameUpdate(); | 650 main().layer_tree_host->RequestMainFrameUpdate(); |
| 673 TRACE_EVENT_SYNTHETIC_DELAY_END("cc.BeginMainFrame"); | 651 TRACE_EVENT_SYNTHETIC_DELAY_END("cc.BeginMainFrame"); |
| 674 | 652 |
| 675 bool can_cancel_this_commit = | 653 bool can_cancel_this_commit = |
| 676 main().final_pipeline_stage < COMMIT_PIPELINE_STAGE && | 654 main().final_pipeline_stage < COMMIT_PIPELINE_STAGE && |
| 677 !begin_main_frame_state->evicted_ui_resources; | 655 !begin_main_frame_state->evicted_ui_resources; |
| 678 | 656 |
| 679 main().current_pipeline_stage = UPDATE_LAYERS_PIPELINE_STAGE; | 657 main().current_pipeline_stage = UPDATE_LAYERS_PIPELINE_STAGE; |
| 680 bool should_update_layers = | 658 bool should_update_layers = |
| 681 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; | 659 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; |
| 682 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); | 660 bool updated = should_update_layers && main().layer_tree_host->UpdateLayers(); |
| 683 | 661 |
| 684 layer_tree_host()->WillCommit(); | 662 main().layer_tree_host->WillCommit(); |
| 685 devtools_instrumentation::ScopedCommitTrace commit_task( | 663 devtools_instrumentation::ScopedCommitTrace commit_task( |
| 686 layer_tree_host()->id()); | 664 main().layer_tree_host->id()); |
| 687 | 665 |
| 688 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; | 666 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; |
| 689 if (!updated && can_cancel_this_commit) { | 667 if (!updated && can_cancel_this_commit) { |
| 690 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); | 668 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); |
| 691 main().channel_main->BeginMainFrameAbortedOnImpl( | 669 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 692 CommitEarlyOutReason::FINISHED_NO_UPDATES); | 670 CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 693 | 671 |
| 694 // Although the commit is internally aborted, this is because it has been | 672 // Although the commit is internally aborted, this is because it has been |
| 695 // detected to be a no-op. From the perspective of an embedder, this commit | 673 // detected to be a no-op. From the perspective of an embedder, this commit |
| 696 // went through, and input should no longer be throttled, etc. | 674 // went through, and input should no longer be throttled, etc. |
| 697 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 675 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 698 layer_tree_host()->CommitComplete(); | 676 main().layer_tree_host->CommitComplete(); |
| 699 layer_tree_host()->DidBeginMainFrame(); | 677 main().layer_tree_host->DidBeginMainFrame(); |
| 700 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); | 678 main().layer_tree_host->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); |
| 701 return; | 679 return; |
| 702 } | 680 } |
| 703 | 681 |
| 704 // Notify the impl thread that the main thread is ready to commit. This will | 682 // Notify the impl thread that the main thread is ready to commit. This will |
| 705 // begin the commit process, which is blocking from the main thread's | 683 // begin the commit process, which is blocking from the main thread's |
| 706 // point of view, but asynchronously performed on the impl thread, | 684 // point of view, but asynchronously performed on the impl thread, |
| 707 // coordinated by the Scheduler. | 685 // coordinated by the Scheduler. |
| 708 { | 686 { |
| 709 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); | 687 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); |
| 710 | 688 |
| 711 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 689 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 712 | 690 |
| 713 // This CapturePostTasks should be destroyed before CommitComplete() is | 691 // This CapturePostTasks should be destroyed before CommitComplete() is |
| 714 // called since that goes out to the embedder, and we want the embedder | 692 // called since that goes out to the embedder, and we want the embedder |
| 715 // to receive its callbacks before that. | 693 // to receive its callbacks before that. |
| 716 BlockingTaskRunner::CapturePostTasks blocked( | 694 BlockingTaskRunner::CapturePostTasks blocked( |
| 717 blocking_main_thread_task_runner()); | 695 blocking_main_thread_task_runner()); |
| 718 | 696 |
| 719 CompletionEvent completion; | 697 CompletionEvent completion; |
| 720 main().channel_main->StartCommitOnImpl(&completion); | 698 main().channel_main->StartCommitOnImpl(&completion, main().layer_tree_host, |
| 699 main().commit_waits_for_activation); |
| 721 completion.Wait(); | 700 completion.Wait(); |
| 701 main().commit_waits_for_activation = false; |
| 722 } | 702 } |
| 723 | 703 |
| 724 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 704 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 725 layer_tree_host()->CommitComplete(); | 705 main().layer_tree_host->CommitComplete(); |
| 726 layer_tree_host()->DidBeginMainFrame(); | 706 main().layer_tree_host->DidBeginMainFrame(); |
| 727 } | 707 } |
| 728 | 708 |
| 729 void ThreadProxy::BeginMainFrameNotExpectedSoon() { | 709 void ThreadProxy::BeginMainFrameNotExpectedSoon() { |
| 730 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); | 710 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); |
| 731 DCHECK(IsMainThread()); | 711 DCHECK(IsMainThread()); |
| 732 layer_tree_host()->BeginMainFrameNotExpectedSoon(); | 712 main().layer_tree_host->BeginMainFrameNotExpectedSoon(); |
| 733 } | 713 } |
| 734 | 714 |
| 735 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion) { | 715 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion, |
| 716 LayerTreeHost* layer_tree_host, |
| 717 bool hold_commit_for_activation) { |
| 736 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 718 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
| 737 DCHECK(!impl().commit_completion_event); | 719 DCHECK(!impl().commit_completion_event); |
| 738 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 720 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
| 739 DCHECK(impl().scheduler); | 721 DCHECK(impl().scheduler); |
| 740 DCHECK(impl().scheduler->CommitPending()); | 722 DCHECK(impl().scheduler->CommitPending()); |
| 741 | 723 |
| 724 if (hold_commit_for_activation) { |
| 725 // This commit may be aborted. Store the value for |
| 726 // hold_commit_for_activation so that whenever the next commit is started, |
| 727 // the main thread will be unblocked only after pending tree activation. |
| 728 impl().next_commit_waits_for_activation = hold_commit_for_activation; |
| 729 } |
| 730 |
| 742 if (!impl().layer_tree_host_impl) { | 731 if (!impl().layer_tree_host_impl) { |
| 743 TRACE_EVENT_INSTANT0( | 732 TRACE_EVENT_INSTANT0( |
| 744 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); | 733 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); |
| 745 completion->Signal(); | 734 completion->Signal(); |
| 746 return; | 735 return; |
| 747 } | 736 } |
| 748 | 737 |
| 749 // Ideally, we should inform to impl thread when BeginMainFrame is started. | 738 // Ideally, we should inform to impl thread when BeginMainFrame is started. |
| 750 // But, we can avoid a PostTask in here. | 739 // But, we can avoid a PostTask in here. |
| 751 impl().scheduler->NotifyBeginMainFrameStarted(); | 740 impl().scheduler->NotifyBeginMainFrameStarted(); |
| 752 impl().commit_completion_event = completion; | 741 impl().commit_completion_event = completion; |
| 742 DCHECK(!blocked_main_commit().layer_tree_host); |
| 743 blocked_main_commit().layer_tree_host = layer_tree_host; |
| 753 impl().scheduler->NotifyReadyToCommit(); | 744 impl().scheduler->NotifyReadyToCommit(); |
| 754 } | 745 } |
| 755 | 746 |
| 756 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { | 747 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { |
| 757 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", | 748 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", |
| 758 CommitEarlyOutReasonToString(reason)); | 749 CommitEarlyOutReasonToString(reason)); |
| 759 DCHECK(IsImplThread()); | 750 DCHECK(IsImplThread()); |
| 760 DCHECK(impl().scheduler); | 751 DCHECK(impl().scheduler); |
| 761 DCHECK(impl().scheduler->CommitPending()); | 752 DCHECK(impl().scheduler->CommitPending()); |
| 762 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 753 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 775 DCHECK(IsImplThread()); | 766 DCHECK(IsImplThread()); |
| 776 | 767 |
| 777 impl().layer_tree_host_impl->Animate(); | 768 impl().layer_tree_host_impl->Animate(); |
| 778 } | 769 } |
| 779 | 770 |
| 780 void ThreadProxy::ScheduledActionCommit() { | 771 void ThreadProxy::ScheduledActionCommit() { |
| 781 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 772 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
| 782 DCHECK(IsImplThread()); | 773 DCHECK(IsImplThread()); |
| 783 DCHECK(IsMainThreadBlocked()); | 774 DCHECK(IsMainThreadBlocked()); |
| 784 DCHECK(impl().commit_completion_event); | 775 DCHECK(impl().commit_completion_event); |
| 776 DCHECK(blocked_main_commit().layer_tree_host); |
| 785 | 777 |
| 786 blocked_main().main_thread_inside_commit = true; | |
| 787 impl().layer_tree_host_impl->BeginCommit(); | 778 impl().layer_tree_host_impl->BeginCommit(); |
| 788 layer_tree_host()->FinishCommitOnImplThread( | 779 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread( |
| 789 impl().layer_tree_host_impl.get()); | 780 impl().layer_tree_host_impl.get()); |
| 790 blocked_main().main_thread_inside_commit = false; | |
| 791 | 781 |
| 792 bool hold_commit = blocked_main().commit_waits_for_activation; | 782 // Remove the LayerTreeHost reference before the completion event is signaled |
| 793 blocked_main().commit_waits_for_activation = false; | 783 // and cleared. This is necessary since blocked_main_commit() allows access |
| 784 // only while we have the completion event to ensure the main thread is |
| 785 // blocked for a commit. |
| 786 blocked_main_commit().layer_tree_host = nullptr; |
| 794 | 787 |
| 795 if (hold_commit) { | 788 if (impl().next_commit_waits_for_activation) { |
| 796 // For some layer types in impl-side painting, the commit is held until | 789 // For some layer types in impl-side painting, the commit is held until |
| 797 // the sync tree is activated. It's also possible that the | 790 // the sync tree is activated. It's also possible that the |
| 798 // sync tree has already activated if there was no work to be done. | 791 // sync tree has already activated if there was no work to be done. |
| 799 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 792 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
| 800 impl().completion_event_for_commit_held_on_tree_activation = | |
| 801 impl().commit_completion_event; | |
| 802 impl().commit_completion_event = nullptr; | |
| 803 } else { | 793 } else { |
| 804 impl().commit_completion_event->Signal(); | 794 impl().commit_completion_event->Signal(); |
| 805 impl().commit_completion_event = nullptr; | 795 impl().commit_completion_event = nullptr; |
| 806 } | 796 } |
| 807 | 797 |
| 808 impl().scheduler->DidCommit(); | 798 impl().scheduler->DidCommit(); |
| 809 | 799 |
| 810 // Delay this step until afer the main thread has been released as it's | 800 // Delay this step until afer the main thread has been released as it's |
| 811 // often a good bit of work to update the tree and prepare the new frame. | 801 // often a good bit of work to update the tree and prepare the new frame. |
| 812 impl().layer_tree_host_impl->CommitComplete(); | 802 impl().layer_tree_host_impl->CommitComplete(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 NOTREACHED() << "Only used by SingleThreadProxy"; | 915 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 926 } | 916 } |
| 927 | 917 |
| 928 void ThreadProxy::SetAuthoritativeVSyncInterval( | 918 void ThreadProxy::SetAuthoritativeVSyncInterval( |
| 929 const base::TimeDelta& interval) { | 919 const base::TimeDelta& interval) { |
| 930 NOTREACHED() << "Only used by SingleThreadProxy"; | 920 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 931 } | 921 } |
| 932 | 922 |
| 933 void ThreadProxy::DidCommitAndDrawFrame() { | 923 void ThreadProxy::DidCommitAndDrawFrame() { |
| 934 DCHECK(IsMainThread()); | 924 DCHECK(IsMainThread()); |
| 935 layer_tree_host()->DidCommitAndDrawFrame(); | 925 main().layer_tree_host->DidCommitAndDrawFrame(); |
| 936 } | 926 } |
| 937 | 927 |
| 938 void ThreadProxy::DidCompleteSwapBuffers() { | 928 void ThreadProxy::DidCompleteSwapBuffers() { |
| 939 DCHECK(IsMainThread()); | 929 DCHECK(IsMainThread()); |
| 940 layer_tree_host()->DidCompleteSwapBuffers(); | 930 main().layer_tree_host->DidCompleteSwapBuffers(); |
| 941 } | 931 } |
| 942 | 932 |
| 943 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { | 933 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { |
| 944 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); | 934 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); |
| 945 DCHECK(IsMainThread()); | 935 DCHECK(IsMainThread()); |
| 946 layer_tree_host()->SetAnimationEvents(events.Pass()); | 936 main().layer_tree_host->SetAnimationEvents(events.Pass()); |
| 947 } | 937 } |
| 948 | 938 |
| 949 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { | 939 void ThreadProxy::InitializeImplOnImpl(CompletionEvent* completion, |
| 940 LayerTreeHost* layer_tree_host) { |
| 950 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 941 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
| 951 DCHECK(IsImplThread()); | 942 DCHECK(IsImplThread()); |
| 943 DCHECK(IsMainThreadBlocked()); |
| 944 DCHECK(layer_tree_host); |
| 952 | 945 |
| 953 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a | 946 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a |
| 954 // reference to itself. | 947 // reference to itself. |
| 955 impl().channel_impl = threaded_channel_.get(); | 948 impl().channel_impl = threaded_channel_.get(); |
| 956 | 949 |
| 957 impl().layer_tree_host_impl = | 950 impl().layer_tree_host_impl = layer_tree_host->CreateLayerTreeHostImpl(this); |
| 958 layer_tree_host()->CreateLayerTreeHostImpl(this); | |
| 959 | 951 |
| 960 SchedulerSettings scheduler_settings( | 952 SchedulerSettings scheduler_settings( |
| 961 layer_tree_host()->settings().ToSchedulerSettings()); | 953 layer_tree_host->settings().ToSchedulerSettings()); |
| 962 | 954 |
| 963 scoped_ptr<CompositorTimingHistory> compositor_timing_history( | 955 scoped_ptr<CompositorTimingHistory> compositor_timing_history( |
| 964 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, | 956 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, |
| 965 impl().rendering_stats_instrumentation)); | 957 impl().rendering_stats_instrumentation)); |
| 966 | 958 |
| 967 impl().scheduler = Scheduler::Create( | 959 impl().scheduler = Scheduler::Create( |
| 968 this, scheduler_settings, impl().layer_tree_host_id, | 960 this, scheduler_settings, impl().layer_tree_host_id, |
| 969 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), | 961 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), |
| 970 compositor_timing_history.Pass()); | 962 compositor_timing_history.Pass()); |
| 971 | 963 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 DCHECK(IsImplThread()); | 1000 DCHECK(IsImplThread()); |
| 1009 if (impl().layer_tree_host_impl->output_surface()) { | 1001 if (impl().layer_tree_host_impl->output_surface()) { |
| 1010 ContextProvider* context_provider = | 1002 ContextProvider* context_provider = |
| 1011 impl().layer_tree_host_impl->output_surface()->context_provider(); | 1003 impl().layer_tree_host_impl->output_surface()->context_provider(); |
| 1012 if (context_provider) | 1004 if (context_provider) |
| 1013 context_provider->ContextGL()->Finish(); | 1005 context_provider->ContextGL()->Finish(); |
| 1014 } | 1006 } |
| 1015 completion->Signal(); | 1007 completion->Signal(); |
| 1016 } | 1008 } |
| 1017 | 1009 |
| 1018 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1010 void ThreadProxy::LayerTreeHostClosedOnImpl(CompletionEvent* completion) { |
| 1019 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1011 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1020 DCHECK(IsImplThread()); | 1012 DCHECK(IsImplThread()); |
| 1021 DCHECK(IsMainThreadBlocked()); | 1013 DCHECK(IsMainThreadBlocked()); |
| 1022 impl().scheduler = nullptr; | 1014 impl().scheduler = nullptr; |
| 1023 impl().external_begin_frame_source = nullptr; | 1015 impl().external_begin_frame_source = nullptr; |
| 1024 impl().layer_tree_host_impl = nullptr; | 1016 impl().layer_tree_host_impl = nullptr; |
| 1025 impl().weak_factory.InvalidateWeakPtrs(); | 1017 impl().weak_factory.InvalidateWeakPtrs(); |
| 1026 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 1018 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
| 1027 // holding while still on the compositor thread. This also ensures any | 1019 // holding while still on the compositor thread. This also ensures any |
| 1028 // callbacks holding a ThreadProxy pointer are cancelled. | 1020 // callbacks holding a ThreadProxy pointer are cancelled. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( | 1104 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( |
| 1113 const base::Closure& task, | 1105 const base::Closure& task, |
| 1114 base::TimeDelta delay) { | 1106 base::TimeDelta delay) { |
| 1115 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, task, delay); | 1107 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, task, delay); |
| 1116 } | 1108 } |
| 1117 | 1109 |
| 1118 void ThreadProxy::DidActivateSyncTree() { | 1110 void ThreadProxy::DidActivateSyncTree() { |
| 1119 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); | 1111 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); |
| 1120 DCHECK(IsImplThread()); | 1112 DCHECK(IsImplThread()); |
| 1121 | 1113 |
| 1122 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1114 if (impl().next_commit_waits_for_activation) { |
| 1123 TRACE_EVENT_INSTANT0( | 1115 TRACE_EVENT_INSTANT0( |
| 1124 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1116 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
| 1125 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1117 DCHECK(impl().commit_completion_event); |
| 1126 impl().completion_event_for_commit_held_on_tree_activation = nullptr; | 1118 impl().commit_completion_event->Signal(); |
| 1119 impl().commit_completion_event = nullptr; |
| 1120 impl().next_commit_waits_for_activation = false; |
| 1127 } | 1121 } |
| 1128 | 1122 |
| 1129 impl().last_processed_begin_main_frame_args = | 1123 impl().last_processed_begin_main_frame_args = |
| 1130 impl().last_begin_main_frame_args; | 1124 impl().last_begin_main_frame_args; |
| 1131 } | 1125 } |
| 1132 | 1126 |
| 1133 void ThreadProxy::WillPrepareTiles() { | 1127 void ThreadProxy::WillPrepareTiles() { |
| 1134 DCHECK(IsImplThread()); | 1128 DCHECK(IsImplThread()); |
| 1135 impl().scheduler->WillPrepareTiles(); | 1129 impl().scheduler->WillPrepareTiles(); |
| 1136 } | 1130 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1164 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1171 DCHECK(IsImplThread()); | 1165 DCHECK(IsImplThread()); |
| 1172 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), | 1166 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), |
| 1173 main_frame_events.Pass()); | 1167 main_frame_events.Pass()); |
| 1174 } | 1168 } |
| 1175 | 1169 |
| 1176 void ThreadProxy::PostFrameTimingEventsOnMain( | 1170 void ThreadProxy::PostFrameTimingEventsOnMain( |
| 1177 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1171 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1178 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1172 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1179 DCHECK(IsMainThread()); | 1173 DCHECK(IsMainThread()); |
| 1180 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), | 1174 main().layer_tree_host->RecordFrameTimingEvents(composite_events.Pass(), |
| 1181 main_frame_events.Pass()); | 1175 main_frame_events.Pass()); |
| 1182 } | 1176 } |
| 1183 | 1177 |
| 1184 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | 1178 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { |
| 1185 return main_thread_weak_ptr_; | 1179 return main_thread_weak_ptr_; |
| 1186 } | 1180 } |
| 1187 | 1181 |
| 1188 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | 1182 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { |
| 1189 return impl_thread_weak_ptr_; | 1183 return impl_thread_weak_ptr_; |
| 1190 } | 1184 } |
| 1191 | 1185 |
| 1192 } // namespace cc | 1186 } // namespace cc |
| OLD | NEW |