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) { |
danakj
2014/02/14 19:38:50
The "main vs impl" side stuff in here is kinda mes
boliu
2014/02/14 22:03:08
1) it is. Done
| |
167 LayerTreeHost::CreateResult result = | 163 LayerTreeHost::CreateResult result = |
168 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 164 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
165 if (success) { | |
danakj
2014/02/14 19:38:50
nit: no {}
boliu
2014/02/14 22:03:08
Done.
| |
166 UpdateRendererCapabilitiesOnImplThread(); | |
167 } | |
168 | |
169 if (result == LayerTreeHost::CreateFailedButTryAgain) { | 169 if (result == LayerTreeHost::CreateFailedButTryAgain) { |
170 // Force another recreation attempt to happen by requesting another commit. | 170 // Force another recreation attempt to happen by requesting another commit. |
171 SetNeedsCommit(); | 171 SetNeedsCommit(); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 175 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
176 DCHECK(Proxy::IsMainThread()); | 176 DCHECK(Proxy::IsMainThread()); |
177 DCHECK(!layer_tree_host_->output_surface_lost()); | 177 DCHECK(!layer_tree_host_->output_surface_lost()); |
178 return renderer_capabilities_for_main_thread_; | 178 return renderer_capabilities_for_main_thread_; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 return; | 363 return; |
364 | 364 |
365 layer_tree_host_impl_->SendManagedMemoryStats( | 365 layer_tree_host_impl_->SendManagedMemoryStats( |
366 contents_texture_manager->MemoryVisibleBytes(), | 366 contents_texture_manager->MemoryVisibleBytes(), |
367 contents_texture_manager->MemoryVisibleAndNearbyBytes(), | 367 contents_texture_manager->MemoryVisibleAndNearbyBytes(), |
368 contents_texture_manager->MemoryUseBytes()); | 368 contents_texture_manager->MemoryUseBytes()); |
369 } | 369 } |
370 | 370 |
371 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 371 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
372 | 372 |
373 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | |
374 renderer_capabilities_for_main_thread_ = | |
375 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); | |
376 layer_tree_host_->RendererCapabilitiesChanged(); | |
377 } | |
378 | |
373 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 379 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
374 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 380 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
375 // Cause a commit so we can notice the lost context. | 381 // Cause a commit so we can notice the lost context. |
376 SetNeedsCommitOnImplThread(); | 382 SetNeedsCommitOnImplThread(); |
377 client_->DidAbortSwapBuffers(); | 383 client_->DidAbortSwapBuffers(); |
378 } | 384 } |
379 | 385 |
380 void SingleThreadProxy::DidSwapBuffersOnImplThread() { | 386 void SingleThreadProxy::DidSwapBuffersOnImplThread() { |
381 client_->DidPostSwapBuffers(); | 387 client_->DidPostSwapBuffers(); |
382 } | 388 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 void SingleThreadProxy::DidSwapFrame() { | 570 void SingleThreadProxy::DidSwapFrame() { |
565 if (next_frame_is_newly_committed_frame_) { | 571 if (next_frame_is_newly_committed_frame_) { |
566 next_frame_is_newly_committed_frame_ = false; | 572 next_frame_is_newly_committed_frame_ = false; |
567 layer_tree_host_->DidCommitAndDrawFrame(); | 573 layer_tree_host_->DidCommitAndDrawFrame(); |
568 } | 574 } |
569 } | 575 } |
570 | 576 |
571 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 577 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
572 | 578 |
573 } // namespace cc | 579 } // namespace cc |
OLD | NEW |