Chromium Code Reviews| Index: cc/trees/thread_proxy.cc |
| diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc |
| index b7c19d06109a515fc7f4aaabf3a887afead2ae3c..525b44290c6c0a3f9247027778ca04fce018d3a1 100644 |
| --- a/cc/trees/thread_proxy.cc |
| +++ b/cc/trees/thread_proxy.cc |
| @@ -194,40 +194,59 @@ void ThreadProxy::UpdateBackgroundAnimateTicking() { |
| impl().animations_frozen_until_next_draw = false; |
| } |
| -void ThreadProxy::DoCreateAndInitializeOutputSurface() { |
| +void ThreadProxy::DidLoseOutputSurface() { |
| + TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
| + DCHECK(IsMainThread()); |
| + layer_tree_host()->DidLoseOutputSurface(); |
| + |
| + { |
| + DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| + |
| + // Return lost resources to their owners immediately. |
| + BlockingTaskRunner::CapturePostTasks blocked; |
| + |
| + CompletionEvent completion; |
| + Proxy::ImplThreadTaskRunner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&ThreadProxy::DeleteContentsTexturesOnImplThread, |
| + impl_thread_weak_ptr_, |
| + &completion)); |
| + completion.Wait(); |
| + } |
| +} |
| + |
| +void ThreadProxy::CreateAndInitializeOutputSurface() { |
| TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); |
| DCHECK(IsMainThread()); |
| scoped_ptr<OutputSurface> output_surface = |
| layer_tree_host()->CreateOutputSurface(); |
| - RendererCapabilities capabilities; |
| - bool success = !!output_surface; |
| - if (success) { |
| - // Make a blocking call to InitializeOutputSurfaceOnImplThread. The results |
| - // of that call are pushed into the success and capabilities local |
| - // variables. |
| - CompletionEvent completion; |
| - DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| - |
| + if (output_surface) { |
| Proxy::ImplThreadTaskRunner()->PostTask( |
| FROM_HERE, |
| base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, |
| impl_thread_weak_ptr_, |
| - &completion, |
| - base::Passed(&output_surface), |
| - &success, |
| - &capabilities)); |
| - completion.Wait(); |
| + base::Passed(&output_surface))); |
| + return; |
| } |
| + |
| + DidInitializeOutputSurface(false, RendererCapabilities()); |
| +} |
| + |
| +void ThreadProxy::DidInitializeOutputSurface( |
| + bool success, |
| + const RendererCapabilities& capabilities) { |
| + TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); |
| + DCHECK(IsMainThread()); |
| main().renderer_capabilities_main_thread_copy = capabilities; |
| layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); |
| - if (success) { |
| - main().output_surface_creation_callback.Cancel(); |
| - } else if (!main().output_surface_creation_callback.IsCancelled()) { |
| + if (!success) { |
| Proxy::MainThreadTaskRunner()->PostTask( |
| - FROM_HERE, main().output_surface_creation_callback.callback()); |
| + FROM_HERE, |
| + base::Bind(&ThreadProxy::CreateAndInitializeOutputSurface, |
|
enne (OOO)
2014/05/16 22:37:29
How is this not an infinite loop during failure?
danakj
2014/05/16 22:45:29
After 5 failures, LayerTreeHost will LOG(FATAL) in
enne (OOO)
2014/05/16 22:46:31
And this will just keep posting tasks?
danakj
2014/05/16 22:48:40
This calls OnCreateAndInitializeOutputSurfaceAttem
|
| + main_thread_weak_ptr_)); |
| } |
| } |
| @@ -308,6 +327,9 @@ void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { |
| DCHECK(IsImplThread()); |
| if (!impl().layer_tree_host_impl->IsContextLost()) |
| return; |
| + Proxy::MainThreadTaskRunner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); |
| impl().scheduler->DidLoseOutputSurface(); |
| } |
| @@ -1197,42 +1219,6 @@ void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { |
| layer_tree_host()->SetAnimationEvents(events.Pass()); |
| } |
| -void ThreadProxy::CreateAndInitializeOutputSurface() { |
| - TRACE_EVENT0("cc", "ThreadProxy::CreateAndInitializeOutputSurface"); |
| - DCHECK(IsMainThread()); |
| - |
| - // Check that output surface has not been recreated by CompositeAndReadback |
| - // after this task is posted but before it is run. |
| - bool has_initialized_output_surface = true; |
| - { |
| - CompletionEvent completion; |
| - Proxy::ImplThreadTaskRunner()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&ThreadProxy::HasInitializedOutputSurfaceOnImplThread, |
| - impl_thread_weak_ptr_, |
| - &completion, |
| - &has_initialized_output_surface)); |
| - completion.Wait(); |
| - } |
| - if (has_initialized_output_surface) |
| - return; |
| - |
| - layer_tree_host()->DidLoseOutputSurface(); |
| - main().output_surface_creation_callback.Reset( |
| - base::Bind(&ThreadProxy::DoCreateAndInitializeOutputSurface, |
| - base::Unretained(this))); |
| - main().output_surface_creation_callback.callback().Run(); |
| -} |
| - |
| -void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( |
| - CompletionEvent* completion, |
| - bool* has_initialized_output_surface) { |
| - DCHECK(IsImplThread()); |
| - *has_initialized_output_surface = |
| - impl().scheduler->HasInitializedOutputSurface(); |
| - completion->Signal(); |
| -} |
| - |
| void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { |
| TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
| DCHECK(IsImplThread()); |
| @@ -1265,31 +1251,38 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { |
| completion->Signal(); |
| } |
| -void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
| - CompletionEvent* completion, |
| - scoped_ptr<OutputSurface> output_surface, |
| - bool* success, |
| - RendererCapabilities* capabilities) { |
| - TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| +void ThreadProxy::DeleteContentsTexturesOnImplThread( |
| + CompletionEvent* completion) { |
| + TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); |
| DCHECK(IsImplThread()); |
| DCHECK(IsMainThreadBlocked()); |
| - DCHECK(success); |
| - DCHECK(capabilities); |
| - |
| layer_tree_host()->DeleteContentsTexturesOnImplThread( |
| impl().layer_tree_host_impl->resource_provider()); |
| + completion->Signal(); |
| +} |
| - *success = |
| - impl().layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| +void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
| + scoped_ptr<OutputSurface> output_surface) { |
| + TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| + DCHECK(IsImplThread()); |
| - if (*success) { |
| - *capabilities = impl() |
| - .layer_tree_host_impl->GetRendererCapabilities() |
| - .MainThreadCapabilities(); |
| - impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| + LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); |
| + bool success = host_impl->InitializeRenderer(output_surface.Pass()); |
| + RendererCapabilities capabilities; |
| + if (success) { |
| + capabilities = |
| + host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| } |
| - completion->Signal(); |
| + Proxy::MainThreadTaskRunner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&ThreadProxy::DidInitializeOutputSurface, |
| + main_thread_weak_ptr_, |
| + success, |
| + capabilities)); |
| + |
| + if (success) |
| + impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| } |
| void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
| @@ -1303,6 +1296,7 @@ void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
| void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| DCHECK(IsImplThread()); |
| + DCHECK(IsMainThreadBlocked()); |
| layer_tree_host()->DeleteContentsTexturesOnImplThread( |
| impl().layer_tree_host_impl->resource_provider()); |
| impl().current_resource_update_controller.reset(); |