Chromium Code Reviews| Index: cc/trees/thread_proxy.cc |
| diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc |
| index 8f23e5c96b7abab620e3071ff2cc1ca4b4aa6f40..682ef2ce44f8eb9f324f88ef027ad79f56e3e713 100644 |
| --- a/cc/trees/thread_proxy.cc |
| +++ b/cc/trees/thread_proxy.cc |
| @@ -138,13 +138,7 @@ void ThreadProxy::FinishAllRendering() { |
| // Make sure all GL drawing is finished on the impl thread. |
| DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| - CompletionEvent completion; |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread, |
| - impl_thread_weak_ptr_, |
| - &completion)); |
| - completion.Wait(); |
| + main().channel_main->FinishAllRenderingOnImpl(); |
| } |
| bool ThreadProxy::IsStarted() const { |
| @@ -162,22 +156,13 @@ void ThreadProxy::SetVisible(bool visible) { |
| TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); |
| DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| - CompletionEvent completion; |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::SetVisibleOnImplThread, |
| - impl_thread_weak_ptr_, |
| - &completion, |
| - visible)); |
| - completion.Wait(); |
| + main().channel_main->SetVisibleOnImpl(visible); |
|
danakj
2015/10/08 19:21:08
i'd like it if it was obvious which calls are goin
Khushal
2015/10/08 20:32:07
We will try to make some calls asynchronous for Bl
danakj
2015/10/09 17:54:43
I think we should mark everything as Sync that is
Khushal
2015/10/09 19:46:55
That would definitely be better. Just had one doub
|
| } |
| -void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, |
| - bool visible) { |
| +void ThreadProxy::SetVisibleOnImpl(bool visible) { |
| TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); |
| impl().layer_tree_host_impl->SetVisible(visible); |
| impl().scheduler->SetVisible(visible); |
| - completion->Signal(); |
| } |
| void ThreadProxy::SetThrottleFrameProduction(bool throttle) { |
| @@ -204,9 +189,7 @@ void ThreadProxy::RequestNewOutputSurface() { |
| } |
| void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, |
| - impl_thread_weak_ptr_, output_surface)); |
| + main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); |
| } |
| void ThreadProxy::ReleaseOutputSurface() { |
| @@ -214,11 +197,7 @@ void ThreadProxy::ReleaseOutputSurface() { |
| DCHECK(layer_tree_host()->output_surface_lost()); |
| DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| - CompletionEvent completion; |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread, |
| - impl_thread_weak_ptr_, &completion)); |
| - completion.Wait(); |
| + main().channel_main->ReleaseOutputSurfaceOnImpl(); |
| } |
| void ThreadProxy::DidInitializeOutputSurface( |
| @@ -235,7 +214,7 @@ void ThreadProxy::DidInitializeOutputSurface( |
| layer_tree_host()->DidInitializeOutputSurface(); |
| } |
| -void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( |
| +void ThreadProxy::SetRendererCapabilitiesMainCopy( |
| const RendererCapabilities& capabilities) { |
| main().renderer_capabilities_main_thread_copy = capabilities; |
| } |
| @@ -308,21 +287,16 @@ void ThreadProxy::SetNeedsCommit() { |
| void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
| DCHECK(IsImplThread()); |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::SetRendererCapabilitiesMainThreadCopy, |
| - main_thread_weak_ptr_, |
| - impl() |
| - .layer_tree_host_impl->GetRendererCapabilities() |
| - .MainThreadCapabilities())); |
| + impl().channel_impl->SetRendererCapabilitiesMainCopy( |
| + impl() |
| + .layer_tree_host_impl->GetRendererCapabilities() |
| + .MainThreadCapabilities()); |
| } |
| void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| DCHECK(IsImplThread()); |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); |
| + impl().channel_impl->DidLoseOutputSurface(); |
| impl().scheduler->DidLoseOutputSurface(); |
| } |
| @@ -402,11 +376,7 @@ void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| TRACE_EVENT0("cc", |
| "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
| DCHECK(IsImplThread()); |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::SetAnimationEvents, |
| - main_thread_weak_ptr_, |
| - base::Passed(&events))); |
| + impl().channel_impl->SetAnimationEvents(events.Pass()); |
| } |
| bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } |
| @@ -438,14 +408,10 @@ void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| else |
| TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread, |
| - impl_thread_weak_ptr_, |
| - defer_commits)); |
| + main().channel_main->SetDeferCommitsOnImpl(defer_commits); |
| } |
| -void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { |
| +void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) { |
| DCHECK(IsImplThread()); |
| impl().scheduler->SetDeferCommits(defer_commits); |
| } |
| @@ -488,27 +454,20 @@ void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { |
| void ThreadProxy::MainThreadHasStoppedFlinging() { |
| DCHECK(IsMainThread()); |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, |
| - impl_thread_weak_ptr_)); |
| + main().channel_main->MainThreadHasStoppedFlingingOnImpl(); |
| } |
| -void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { |
| +void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() { |
| DCHECK(IsImplThread()); |
| impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); |
| } |
| void ThreadProxy::NotifyInputThrottledUntilCommit() { |
| DCHECK(IsMainThread()); |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::SetInputThrottledUntilCommitOnImplThread, |
| - impl_thread_weak_ptr_, |
| - true)); |
| + main().channel_main->SetInputThrottledUntilCommitOnImpl(true); |
| } |
| -void ThreadProxy::SetInputThrottledUntilCommitOnImplThread(bool is_throttled) { |
| +void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| DCHECK(IsImplThread()); |
| if (is_throttled == impl().input_throttled_until_commit) |
| return; |
| @@ -584,14 +543,7 @@ void ThreadProxy::Stop() { |
| // renderer before shutting it down. |
| { |
| DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| - |
| - CompletionEvent completion; |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::FinishGLOnImplThread, |
| - impl_thread_weak_ptr_, |
| - &completion)); |
| - completion.Wait(); |
| + main().channel_main->FinishGLOnImpl(); |
| } |
| { |
| DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| @@ -614,11 +566,10 @@ bool ThreadProxy::SupportsImplScrolling() const { |
| return true; |
| } |
| -void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { |
| +void ThreadProxy::FinishAllRenderingOnImpl() { |
| TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| DCHECK(IsImplThread()); |
| impl().layer_tree_host_impl->FinishAllRendering(); |
| - completion->Signal(); |
| } |
| void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| @@ -650,9 +601,7 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| } |
| void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon, |
| - main_thread_weak_ptr_)); |
| + impl().channel_impl->BeginMainFrameNotExpectedSoon(); |
| } |
| void ThreadProxy::BeginMainFrame( |
| @@ -816,7 +765,7 @@ void ThreadProxy::BeginMainFrameAbortedOnImplThread( |
| DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
| if (CommitEarlyOutHandledCommit(reason)) { |
| - SetInputThrottledUntilCommitOnImplThread(false); |
| + SetInputThrottledUntilCommitOnImpl(false); |
| impl().last_processed_begin_main_frame_args = |
| impl().last_begin_main_frame_args; |
| } |
| @@ -865,7 +814,7 @@ void ThreadProxy::ScheduledActionCommit() { |
| // often a good bit of work to update the tree and prepare the new frame. |
| impl().layer_tree_host_impl->CommitComplete(); |
| - SetInputThrottledUntilCommitOnImplThread(false); |
| + SetInputThrottledUntilCommitOnImpl(false); |
| impl().next_frame_is_newly_committed_frame = true; |
| } |
| @@ -879,9 +828,7 @@ void ThreadProxy::ScheduledActionActivateSyncTree() { |
| void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); |
| DCHECK(IsImplThread()); |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_)); |
| + impl().channel_impl->RequestNewOutputSurface(); |
| } |
| DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| @@ -937,9 +884,7 @@ DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| // Tell the main thread that the the newly-commited frame was drawn. |
| if (impl().next_frame_is_newly_committed_frame) { |
| impl().next_frame_is_newly_committed_frame = false; |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); |
| + impl().channel_impl->DidCommitAndDrawFrame(); |
| } |
| DCHECK_NE(INVALID_RESULT, result); |
| @@ -1030,11 +975,11 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { |
| DCHECK_EQ(impl().scheduler->visible(), |
| impl().layer_tree_host_impl->visible()); |
| impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
| + threaded_channel_->InitImplThreadWeakPtr(); |
| completion->Signal(); |
| } |
| -void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
| - OutputSurface* output_surface) { |
| +void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { |
| TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| DCHECK(IsImplThread()); |
| @@ -1046,29 +991,22 @@ void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
| host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| } |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::DidInitializeOutputSurface, |
| - main_thread_weak_ptr_, |
| - success, |
| - capabilities)); |
| + impl().channel_impl->DidInitializeOutputSurface(success, capabilities); |
| if (success) |
| impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| } |
| -void ThreadProxy::ReleaseOutputSurfaceOnImplThread( |
| - CompletionEvent* completion) { |
| +void ThreadProxy::ReleaseOutputSurfaceOnImpl() { |
| DCHECK(IsImplThread()); |
| // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call |
| // LayerTreeHost::DidLoseOutputSurface since it already knows. |
| impl().scheduler->DidLoseOutputSurface(); |
| impl().layer_tree_host_impl->ReleaseOutputSurface(); |
| - completion->Signal(); |
| } |
| -void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
| +void ThreadProxy::FinishGLOnImpl() { |
| TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| DCHECK(IsImplThread()); |
| if (impl().layer_tree_host_impl->output_surface()) { |
| @@ -1077,7 +1015,6 @@ void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
| if (context_provider) |
| context_provider->ContextGL()->Finish(); |
| } |
| - completion->Signal(); |
| } |
| void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| @@ -1088,6 +1025,7 @@ void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| impl().external_begin_frame_source = nullptr; |
| impl().layer_tree_host_impl = nullptr; |
| impl().weak_factory.InvalidateWeakPtrs(); |
| + threaded_channel_->InvalidateImplThreadWeakPtr(); |
| // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
| // holding while still on the compositor thread. This also ensures any |
| // callbacks holding a ThreadProxy pointer are cancelled. |
| @@ -1103,17 +1041,11 @@ ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} |
| bool ThreadProxy::MainFrameWillHappenForTesting() { |
| DCHECK(IsMainThread()); |
| - CompletionEvent completion; |
| bool main_frame_will_happen = false; |
| { |
| DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, |
| - impl_thread_weak_ptr_, |
| - &completion, |
| - &main_frame_will_happen)); |
| - completion.Wait(); |
| + main().channel_main->MainFrameWillHappenOnImplForTesting( |
| + &main_frame_will_happen); |
| } |
| return main_frame_will_happen; |
| } |
| @@ -1122,8 +1054,7 @@ void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| NOTREACHED() << "Only used by SingleThreadProxy"; |
| } |
| -void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( |
| - CompletionEvent* completion, |
| +void ThreadProxy::MainFrameWillHappenOnImplForTesting( |
| bool* main_frame_will_happen) { |
| DCHECK(IsImplThread()); |
| if (impl().layer_tree_host_impl->output_surface()) { |
| @@ -1131,7 +1062,6 @@ void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( |
| } else { |
| *main_frame_will_happen = false; |
| } |
| - completion->Signal(); |
| } |
| void ThreadProxy::RenewTreePriority() { |
| @@ -1217,9 +1147,7 @@ void ThreadProxy::DidPrepareTiles() { |
| void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| DCHECK(IsImplThread()); |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, |
| - main_thread_weak_ptr_)); |
| + impl().channel_impl->DidCompletePageScaleAnimation(); |
| } |
| void ThreadProxy::OnDrawForOutputSurface() { |
| @@ -1231,14 +1159,11 @@ void ThreadProxy::PostFrameTimingEventsOnImplThread( |
| scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| DCHECK(IsImplThread()); |
| - Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::PostFrameTimingEvents, main_thread_weak_ptr_, |
| - base::Passed(composite_events.Pass()), |
| - base::Passed(main_frame_events.Pass()))); |
| + impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), |
| + main_frame_events.Pass()); |
| } |
| -void ThreadProxy::PostFrameTimingEvents( |
| +void ThreadProxy::PostFrameTimingEventsOnMain( |
| scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| DCHECK(IsMainThread()); |