Chromium Code Reviews| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 layer_tree_host_impl_->resource_provider()); | 140 layer_tree_host_impl_->resource_provider()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool initialized; | 143 bool initialized; |
| 144 { | 144 { |
| 145 DebugScopedSetImplThread impl(this); | 145 DebugScopedSetImplThread impl(this); |
| 146 | 146 |
| 147 DCHECK(output_surface); | 147 DCHECK(output_surface); |
| 148 initialized = layer_tree_host_impl_->InitializeRenderer( | 148 initialized = layer_tree_host_impl_->InitializeRenderer( |
| 149 output_surface.Pass()); | 149 output_surface.Pass()); |
| 150 if (initialized) { | 150 if (!initialized && offscreen_context_provider.get()) { |
| 151 renderer_capabilities_for_main_thread_ = | |
| 152 layer_tree_host_impl_->GetRendererCapabilities() | |
| 153 .MainThreadCapabilities(); | |
| 154 } else if (offscreen_context_provider.get()) { | |
| 155 offscreen_context_provider->VerifyContexts(); | 151 offscreen_context_provider->VerifyContexts(); |
| 156 offscreen_context_provider = NULL; | 152 offscreen_context_provider = NULL; |
| 157 } | 153 } |
| 158 | 154 |
| 159 layer_tree_host_impl_->SetOffscreenContextProvider( | 155 layer_tree_host_impl_->SetOffscreenContextProvider( |
| 160 offscreen_context_provider); | 156 offscreen_context_provider); |
| 161 } | 157 } |
| 162 | 158 |
| 163 OnOutputSurfaceInitializeAttempted(initialized); | 159 OnOutputSurfaceInitializeAttempted(initialized); |
| 164 } | 160 } |
| 165 | 161 |
| 166 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { | 162 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { |
| 167 LayerTreeHost::CreateResult result = | 163 LayerTreeHost::CreateResult result = |
| 168 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 164 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
| 169 if (result == LayerTreeHost::CreateFailedButTryAgain) { | 165 if (result == LayerTreeHost::CreateFailedButTryAgain) { |
| 170 // Force another recreation attempt to happen by requesting another commit. | 166 // Force another recreation attempt to happen by requesting another commit. |
| 171 SetNeedsCommit(); | 167 SetNeedsCommit(); |
| 172 } | 168 } |
| 173 } | 169 } |
| 174 | 170 |
| 175 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 171 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 176 DCHECK(Proxy::IsMainThread()); | 172 DCHECK(Proxy::IsMainThread()); |
| 177 DCHECK(!layer_tree_host_->output_surface_lost()); | |
| 178 return renderer_capabilities_for_main_thread_; | 173 return renderer_capabilities_for_main_thread_; |
| 179 } | 174 } |
| 180 | 175 |
| 181 void SingleThreadProxy::SetNeedsAnimate() { | 176 void SingleThreadProxy::SetNeedsAnimate() { |
| 182 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 177 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
| 183 DCHECK(Proxy::IsMainThread()); | 178 DCHECK(Proxy::IsMainThread()); |
| 184 client_->ScheduleAnimation(); | 179 client_->ScheduleAnimation(); |
| 185 } | 180 } |
| 186 | 181 |
| 187 void SingleThreadProxy::SetNeedsUpdateLayers() { | 182 void SingleThreadProxy::SetNeedsUpdateLayers() { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 return; | 358 return; |
| 364 | 359 |
| 365 layer_tree_host_impl_->SendManagedMemoryStats( | 360 layer_tree_host_impl_->SendManagedMemoryStats( |
| 366 contents_texture_manager->MemoryVisibleBytes(), | 361 contents_texture_manager->MemoryVisibleBytes(), |
| 367 contents_texture_manager->MemoryVisibleAndNearbyBytes(), | 362 contents_texture_manager->MemoryVisibleAndNearbyBytes(), |
| 368 contents_texture_manager->MemoryUseBytes()); | 363 contents_texture_manager->MemoryUseBytes()); |
| 369 } | 364 } |
| 370 | 365 |
| 371 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 366 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
| 372 | 367 |
| 368 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | |
| 369 DCHECK(IsImplThread()); | |
| 370 renderer_capabilities_for_main_thread_ = | |
| 371 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); | |
| 372 { | |
| 373 DebugScopedSetMainThread main(this); | |
| 374 layer_tree_host_->RendererCapabilitiesChanged(); | |
|
enne (OOO)
2014/02/14 23:57:32
Should this check the previous ones and only call
boliu
2014/02/14 23:59:14
This was explicit choice too. Webview doesn't run
enne (OOO)
2014/02/15 00:00:15
Why don't we want the check?
| |
| 375 } | |
| 376 } | |
| 377 | |
| 373 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 378 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| 374 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 379 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| 375 // Cause a commit so we can notice the lost context. | 380 // Cause a commit so we can notice the lost context. |
| 376 SetNeedsCommitOnImplThread(); | 381 SetNeedsCommitOnImplThread(); |
| 377 client_->DidAbortSwapBuffers(); | 382 client_->DidAbortSwapBuffers(); |
| 378 } | 383 } |
| 379 | 384 |
| 380 void SingleThreadProxy::DidSwapBuffersOnImplThread() { | 385 void SingleThreadProxy::DidSwapBuffersOnImplThread() { |
| 381 client_->DidPostSwapBuffers(); | 386 client_->DidPostSwapBuffers(); |
| 382 } | 387 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 void SingleThreadProxy::DidSwapFrame() { | 569 void SingleThreadProxy::DidSwapFrame() { |
| 565 if (next_frame_is_newly_committed_frame_) { | 570 if (next_frame_is_newly_committed_frame_) { |
| 566 next_frame_is_newly_committed_frame_ = false; | 571 next_frame_is_newly_committed_frame_ = false; |
| 567 layer_tree_host_->DidCommitAndDrawFrame(); | 572 layer_tree_host_->DidCommitAndDrawFrame(); |
| 568 } | 573 } |
| 569 } | 574 } |
| 570 | 575 |
| 571 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 576 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 572 | 577 |
| 573 } // namespace cc | 578 } // namespace cc |
| OLD | NEW |