| 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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 UpdateBackgroundAnimateTicking(); | 109 UpdateBackgroundAnimateTicking(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 112 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
| 113 TRACE_EVENT0( | 113 TRACE_EVENT0( |
| 114 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 114 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
| 115 DCHECK(Proxy::IsMainThread()); | 115 DCHECK(Proxy::IsMainThread()); |
| 116 | 116 |
| 117 scoped_ptr<OutputSurface> output_surface = | 117 scoped_ptr<OutputSurface> output_surface = |
| 118 layer_tree_host_->CreateOutputSurface(); | 118 layer_tree_host_->CreateOutputSurface(); |
| 119 if (!output_surface) { | |
| 120 OnOutputSurfaceInitializeAttempted(false); | |
| 121 return; | |
| 122 } | |
| 123 | 119 |
| 124 { | 120 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
| 121 |
| 122 bool success = !!output_surface; |
| 123 if (success) { |
| 125 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 124 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 126 DebugScopedSetImplThread impl(this); | 125 DebugScopedSetImplThread impl(this); |
| 127 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 126 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
| 128 layer_tree_host_impl_->resource_provider()); | 127 layer_tree_host_impl_->resource_provider()); |
| 128 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool initialized; | 131 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
| 132 { | |
| 133 DebugScopedSetImplThread impl(this); | |
| 134 | 132 |
| 135 DCHECK(output_surface); | 133 if (!success) { |
| 136 initialized = layer_tree_host_impl_->InitializeRenderer( | |
| 137 output_surface.Pass()); | |
| 138 } | |
| 139 | |
| 140 OnOutputSurfaceInitializeAttempted(initialized); | |
| 141 } | |
| 142 | |
| 143 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { | |
| 144 LayerTreeHost::CreateResult result = | |
| 145 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | |
| 146 if (result == LayerTreeHost::CreateFailedButTryAgain) { | |
| 147 // Force another recreation attempt to happen by requesting another commit. | 134 // Force another recreation attempt to happen by requesting another commit. |
| 148 SetNeedsCommit(); | 135 SetNeedsCommit(); |
| 149 } | 136 } |
| 150 } | 137 } |
| 151 | 138 |
| 152 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 139 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 153 DCHECK(Proxy::IsMainThread()); | 140 DCHECK(Proxy::IsMainThread()); |
| 154 DCHECK(!layer_tree_host_->output_surface_lost()); | 141 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 155 return renderer_capabilities_for_main_thread_; | 142 return renderer_capabilities_for_main_thread_; |
| 156 } | 143 } |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 void SingleThreadProxy::DidSwapFrame() { | 508 void SingleThreadProxy::DidSwapFrame() { |
| 522 if (next_frame_is_newly_committed_frame_) { | 509 if (next_frame_is_newly_committed_frame_) { |
| 523 next_frame_is_newly_committed_frame_ = false; | 510 next_frame_is_newly_committed_frame_ = false; |
| 524 layer_tree_host_->DidCommitAndDrawFrame(); | 511 layer_tree_host_->DidCommitAndDrawFrame(); |
| 525 } | 512 } |
| 526 } | 513 } |
| 527 | 514 |
| 528 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 515 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 529 | 516 |
| 530 } // namespace cc | 517 } // namespace cc |
| OLD | NEW |