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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 void ThreadProxy::DoCreateAndInitializeOutputSurface() { | 282 void ThreadProxy::DoCreateAndInitializeOutputSurface() { |
283 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); | 283 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); |
284 DCHECK(IsMainThread()); | 284 DCHECK(IsMainThread()); |
285 | 285 |
286 scoped_ptr<OutputSurface> output_surface = | 286 scoped_ptr<OutputSurface> output_surface = |
287 layer_tree_host()->CreateOutputSurface(); | 287 layer_tree_host()->CreateOutputSurface(); |
288 | 288 |
289 RendererCapabilities capabilities; | 289 RendererCapabilities capabilities; |
290 bool success = !!output_surface; | 290 bool success = !!output_surface; |
291 if (!success) { | 291 if (success) { |
292 OnOutputSurfaceInitializeAttempted(false, capabilities); | |
293 return; | |
294 } | |
295 | |
296 success = false; | |
297 { | |
298 // Make a blocking call to InitializeOutputSurfaceOnImplThread. The results | 292 // Make a blocking call to InitializeOutputSurfaceOnImplThread. The results |
299 // of that call are pushed into the success and capabilities local | 293 // of that call are pushed into the success and capabilities local |
300 // variables. | 294 // variables. |
301 CompletionEvent completion; | 295 CompletionEvent completion; |
302 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 296 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
303 | 297 |
304 Proxy::ImplThreadTaskRunner()->PostTask( | 298 Proxy::ImplThreadTaskRunner()->PostTask( |
305 FROM_HERE, | 299 FROM_HERE, |
306 base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, | 300 base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, |
307 impl_thread_weak_ptr_, | 301 impl_thread_weak_ptr_, |
308 &completion, | 302 &completion, |
309 base::Passed(&output_surface), | 303 base::Passed(&output_surface), |
310 &success, | 304 &success, |
311 &capabilities)); | 305 &capabilities)); |
312 completion.Wait(); | 306 completion.Wait(); |
313 } | 307 } |
| 308 main().renderer_capabilities_main_thread_copy = capabilities; |
| 309 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); |
314 | 310 |
315 OnOutputSurfaceInitializeAttempted(success, capabilities); | 311 if (success) { |
| 312 main().output_surface_creation_callback.Cancel(); |
| 313 } else if (!main().output_surface_creation_callback.IsCancelled()) { |
| 314 Proxy::MainThreadTaskRunner()->PostTask( |
| 315 FROM_HERE, main().output_surface_creation_callback.callback()); |
| 316 } |
316 } | 317 } |
317 | 318 |
318 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( | 319 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( |
319 const RendererCapabilities& capabilities) { | 320 const RendererCapabilities& capabilities) { |
320 main().renderer_capabilities_main_thread_copy = capabilities; | 321 main().renderer_capabilities_main_thread_copy = capabilities; |
321 } | 322 } |
322 | 323 |
323 void ThreadProxy::OnOutputSurfaceInitializeAttempted( | |
324 bool success, | |
325 const RendererCapabilities& capabilities) { | |
326 DCHECK(IsMainThread()); | |
327 DCHECK(layer_tree_host()); | |
328 | |
329 if (success) { | |
330 main().renderer_capabilities_main_thread_copy = capabilities; | |
331 } | |
332 | |
333 LayerTreeHost::CreateResult result = | |
334 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); | |
335 if (result == LayerTreeHost::CreateFailedButTryAgain) { | |
336 if (!main().output_surface_creation_callback.callback().is_null()) { | |
337 Proxy::MainThreadTaskRunner()->PostTask( | |
338 FROM_HERE, main().output_surface_creation_callback.callback()); | |
339 } | |
340 } else { | |
341 main().output_surface_creation_callback.Cancel(); | |
342 } | |
343 } | |
344 | |
345 void ThreadProxy::SendCommitRequestToImplThreadIfNeeded() { | 324 void ThreadProxy::SendCommitRequestToImplThreadIfNeeded() { |
346 DCHECK(IsMainThread()); | 325 DCHECK(IsMainThread()); |
347 if (main().commit_request_sent_to_impl_thread) | 326 if (main().commit_request_sent_to_impl_thread) |
348 return; | 327 return; |
349 main().commit_request_sent_to_impl_thread = true; | 328 main().commit_request_sent_to_impl_thread = true; |
350 Proxy::ImplThreadTaskRunner()->PostTask( | 329 Proxy::ImplThreadTaskRunner()->PostTask( |
351 FROM_HERE, | 330 FROM_HERE, |
352 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread, | 331 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread, |
353 impl_thread_weak_ptr_)); | 332 impl_thread_weak_ptr_)); |
354 } | 333 } |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 | 1634 |
1656 impl().timing_history.DidActivatePendingTree(); | 1635 impl().timing_history.DidActivatePendingTree(); |
1657 } | 1636 } |
1658 | 1637 |
1659 void ThreadProxy::DidManageTiles() { | 1638 void ThreadProxy::DidManageTiles() { |
1660 DCHECK(IsImplThread()); | 1639 DCHECK(IsImplThread()); |
1661 impl().scheduler->DidManageTiles(); | 1640 impl().scheduler->DidManageTiles(); |
1662 } | 1641 } |
1663 | 1642 |
1664 } // namespace cc | 1643 } // namespace cc |
OLD | NEW |