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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 base::Passed(&output_surface), | 331 base::Passed(&output_surface), |
332 offscreen_context_provider, | 332 offscreen_context_provider, |
333 &success, | 333 &success, |
334 &capabilities)); | 334 &capabilities)); |
335 completion.Wait(); | 335 completion.Wait(); |
336 } | 336 } |
337 | 337 |
338 OnOutputSurfaceInitializeAttempted(success, capabilities); | 338 OnOutputSurfaceInitializeAttempted(success, capabilities); |
339 } | 339 } |
340 | 340 |
341 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( | |
342 const RendererCapabilities& capabilities) { | |
343 DCHECK(IsMainThread()); | |
344 main().renderer_capabilities_main_thread_copy = capabilities; | |
345 layer_tree_host()->RendererCapabilitiesChanged(); | |
346 } | |
347 | |
341 void ThreadProxy::OnOutputSurfaceInitializeAttempted( | 348 void ThreadProxy::OnOutputSurfaceInitializeAttempted( |
342 bool success, | 349 bool success, |
343 const RendererCapabilities& capabilities) { | 350 const RendererCapabilities& capabilities) { |
344 DCHECK(IsMainThread()); | 351 DCHECK(IsMainThread()); |
345 DCHECK(layer_tree_host()); | 352 DCHECK(layer_tree_host()); |
346 | 353 |
354 LayerTreeHost::CreateResult result = | |
355 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); | |
347 if (success) { | 356 if (success) { |
348 main().renderer_capabilities_main_thread_copy = capabilities; | 357 SetRendererCapabilitiesMainThreadCopy(capabilities); |
349 } | 358 } |
350 | 359 |
351 LayerTreeHost::CreateResult result = | |
352 layer_tree_host()->OnCreateAndInitializeOutputSurfaceAttempted(success); | |
353 if (result == LayerTreeHost::CreateFailedButTryAgain) { | 360 if (result == LayerTreeHost::CreateFailedButTryAgain) { |
354 if (!main().output_surface_creation_callback.callback().is_null()) { | 361 if (!main().output_surface_creation_callback.callback().is_null()) { |
355 Proxy::MainThreadTaskRunner()->PostTask( | 362 Proxy::MainThreadTaskRunner()->PostTask( |
356 FROM_HERE, main().output_surface_creation_callback.callback()); | 363 FROM_HERE, main().output_surface_creation_callback.callback()); |
357 } | 364 } |
358 } else { | 365 } else { |
359 main().output_surface_creation_callback.Cancel(); | 366 main().output_surface_creation_callback.Cancel(); |
360 } | 367 } |
361 } | 368 } |
362 | 369 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 main().can_cancel_commit = false; | 411 main().can_cancel_commit = false; |
405 | 412 |
406 if (main().commit_requested) | 413 if (main().commit_requested) |
407 return; | 414 return; |
408 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommit"); | 415 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommit"); |
409 main().commit_requested = true; | 416 main().commit_requested = true; |
410 | 417 |
411 SendCommitRequestToImplThreadIfNeeded(); | 418 SendCommitRequestToImplThreadIfNeeded(); |
412 } | 419 } |
413 | 420 |
421 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | |
422 DCHECK(IsImplThread()); | |
423 // PrioritizedResourceManager is not cleared, so this won't yet work with | |
424 // ContentLayer or ImageLayer, which are only used when impl_side_painting is | |
425 // off. | |
426 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | |
427 | |
428 Proxy::MainThreadTaskRunner()->PostTask( | |
429 FROM_HERE, | |
430 base::Bind(&ThreadProxy::SetRendererCapabilitiesMainThreadCopy, | |
431 main_thread_weak_ptr_, | |
432 impl() | |
433 .layer_tree_host_impl->GetRendererCapabilities() | |
434 .MainThreadCapabilities())); | |
435 } | |
436 | |
414 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 437 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
415 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 438 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
416 DCHECK(IsImplThread()); | 439 DCHECK(IsImplThread()); |
417 CheckOutputSurfaceStatusOnImplThread(); | 440 CheckOutputSurfaceStatusOnImplThread(); |
418 } | 441 } |
419 | 442 |
420 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { | 443 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { |
421 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); | 444 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); |
422 DCHECK(IsImplThread()); | 445 DCHECK(IsImplThread()); |
423 if (!impl().layer_tree_host_impl->IsContextLost()) | 446 if (!impl().layer_tree_host_impl->IsContextLost()) |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 // to receive its callbacks before that. | 978 // to receive its callbacks before that. |
956 BlockingTaskRunner::CapturePostTasks blocked; | 979 BlockingTaskRunner::CapturePostTasks blocked; |
957 | 980 |
958 CompletionEvent completion; | 981 CompletionEvent completion; |
959 Proxy::ImplThreadTaskRunner()->PostTask( | 982 Proxy::ImplThreadTaskRunner()->PostTask( |
960 FROM_HERE, | 983 FROM_HERE, |
961 base::Bind(&ThreadProxy::StartCommitOnImplThread, | 984 base::Bind(&ThreadProxy::StartCommitOnImplThread, |
962 impl_thread_weak_ptr_, | 985 impl_thread_weak_ptr_, |
963 &completion, | 986 &completion, |
964 queue.release(), | 987 queue.release(), |
965 offscreen_context_provider)); | 988 offscreen_context_provider, |
989 main().renderer_capabilities_main_thread_copy)); | |
966 completion.Wait(); | 990 completion.Wait(); |
967 | 991 |
968 RenderingStatsInstrumentation* stats_instrumentation = | 992 RenderingStatsInstrumentation* stats_instrumentation = |
969 layer_tree_host()->rendering_stats_instrumentation(); | 993 layer_tree_host()->rendering_stats_instrumentation(); |
970 BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( | 994 BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( |
971 stats_instrumentation->main_thread_rendering_stats()); | 995 stats_instrumentation->main_thread_rendering_stats()); |
972 stats_instrumentation->AccumulateAndClearMainThreadStats(); | 996 stats_instrumentation->AccumulateAndClearMainThreadStats(); |
973 } | 997 } |
974 | 998 |
975 layer_tree_host()->CommitComplete(); | 999 layer_tree_host()->CommitComplete(); |
976 layer_tree_host()->DidBeginMainFrame(); | 1000 layer_tree_host()->DidBeginMainFrame(); |
977 } | 1001 } |
978 | 1002 |
979 void ThreadProxy::StartCommitOnImplThread( | 1003 void ThreadProxy::StartCommitOnImplThread( |
980 CompletionEvent* completion, | 1004 CompletionEvent* completion, |
981 ResourceUpdateQueue* raw_queue, | 1005 ResourceUpdateQueue* raw_queue, |
982 scoped_refptr<ContextProvider> offscreen_context_provider) { | 1006 scoped_refptr<ContextProvider> offscreen_context_provider, |
1007 const RendererCapabilities& main_frame_renderer_caps) { | |
983 scoped_ptr<ResourceUpdateQueue> queue(raw_queue); | 1008 scoped_ptr<ResourceUpdateQueue> queue(raw_queue); |
984 | 1009 |
985 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 1010 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
986 DCHECK(!impl().commit_completion_event); | 1011 DCHECK(!impl().commit_completion_event); |
987 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 1012 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
988 DCHECK(impl().scheduler); | 1013 DCHECK(impl().scheduler); |
989 DCHECK(impl().scheduler->CommitPending()); | 1014 DCHECK(impl().scheduler->CommitPending()); |
990 | 1015 |
991 if (!impl().layer_tree_host_impl) { | 1016 if (!impl().layer_tree_host_impl) { |
992 TRACE_EVENT_INSTANT0( | 1017 TRACE_EVENT_INSTANT0( |
993 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); | 1018 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); |
994 completion->Signal(); | 1019 completion->Signal(); |
995 return; | 1020 return; |
996 } | 1021 } |
997 | 1022 |
danakj
2014/02/14 19:38:50
I think if we're going to abort the commit we need
boliu
2014/02/14 19:48:53
Unfortunately putting the check here is not going
danakj
2014/02/14 19:53:25
Is there still a good reason to be not synchronous
boliu
2014/02/14 20:06:14
I was wondering about that. So we can skip this wh
| |
998 if (offscreen_context_provider.get()) | 1023 if (offscreen_context_provider.get()) |
999 offscreen_context_provider->BindToCurrentThread(); | 1024 offscreen_context_provider->BindToCurrentThread(); |
1000 impl().layer_tree_host_impl->SetOffscreenContextProvider( | 1025 impl().layer_tree_host_impl->SetOffscreenContextProvider( |
1001 offscreen_context_provider); | 1026 offscreen_context_provider); |
1002 | 1027 |
1003 if (impl().contents_texture_manager) { | 1028 if (impl().contents_texture_manager) { |
1004 DCHECK_EQ(impl().contents_texture_manager, | 1029 DCHECK_EQ(impl().contents_texture_manager, |
1005 blocked_main().contents_texture_manager()); | 1030 blocked_main().contents_texture_manager()); |
1006 } else { | 1031 } else { |
1007 // Cache this pointer that was created on the main thread side to avoid a | 1032 // Cache this pointer that was created on the main thread side to avoid a |
1008 // data race between creating it and using it on the compositor thread. | 1033 // data race between creating it and using it on the compositor thread. |
1009 impl().contents_texture_manager = blocked_main().contents_texture_manager(); | 1034 impl().contents_texture_manager = blocked_main().contents_texture_manager(); |
1010 } | 1035 } |
1011 | 1036 |
1012 if (impl().contents_texture_manager) { | 1037 if (impl().contents_texture_manager) { |
1013 if (impl().contents_texture_manager->LinkedEvictedBackingsExist()) { | 1038 if (impl().contents_texture_manager->LinkedEvictedBackingsExist()) { |
1014 // Clear any uploads we were making to textures linked to evicted | 1039 // Clear any uploads we were making to textures linked to evicted |
1015 // resources | 1040 // resources |
1016 queue->ClearUploadsToEvictedResources(); | 1041 queue->ClearUploadsToEvictedResources(); |
1017 // Some textures in the layer tree are invalid. Kick off another commit | 1042 // Some textures in the layer tree are invalid. Kick off another commit |
1018 // to fill them again. | 1043 // to fill them again. |
1019 SetNeedsCommitOnImplThread(); | 1044 SetNeedsCommitOnImplThread(); |
1020 } | 1045 } |
1021 | 1046 |
1022 impl().contents_texture_manager->PushTexturePrioritiesToBackings(); | 1047 impl().contents_texture_manager->PushTexturePrioritiesToBackings(); |
1023 } | 1048 } |
1024 | 1049 |
1050 impl().renderer_capabilities_for_commit = main_frame_renderer_caps; | |
1025 impl().commit_completion_event = completion; | 1051 impl().commit_completion_event = completion; |
1026 impl().current_resource_update_controller = ResourceUpdateController::Create( | 1052 impl().current_resource_update_controller = ResourceUpdateController::Create( |
1027 this, | 1053 this, |
1028 Proxy::ImplThreadTaskRunner(), | 1054 Proxy::ImplThreadTaskRunner(), |
1029 queue.Pass(), | 1055 queue.Pass(), |
1030 impl().layer_tree_host_impl->resource_provider()); | 1056 impl().layer_tree_host_impl->resource_provider()); |
1031 impl().current_resource_update_controller->PerformMoreUpdates( | 1057 impl().current_resource_update_controller->PerformMoreUpdates( |
1032 impl().scheduler->AnticipatedDrawTime()); | 1058 impl().scheduler->AnticipatedDrawTime()); |
1033 } | 1059 } |
1034 | 1060 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1377 delta = base::TimeDelta(); | 1403 delta = base::TimeDelta(); |
1378 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta); | 1404 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta); |
1379 } | 1405 } |
1380 | 1406 |
1381 void ThreadProxy::DidBeginImplFrameDeadline() { | 1407 void ThreadProxy::DidBeginImplFrameDeadline() { |
1382 impl().layer_tree_host_impl->ResetCurrentFrameTimeForNextFrame(); | 1408 impl().layer_tree_host_impl->ResetCurrentFrameTimeForNextFrame(); |
1383 } | 1409 } |
1384 | 1410 |
1385 void ThreadProxy::ReadyToFinalizeTextureUpdates() { | 1411 void ThreadProxy::ReadyToFinalizeTextureUpdates() { |
1386 DCHECK(IsImplThread()); | 1412 DCHECK(IsImplThread()); |
1387 impl().scheduler->FinishCommit(); | 1413 |
1414 const RendererCapabilitiesImpl& impl_caps = | |
enne (OOO)
2014/02/14 20:21:48
I don't quite follow what sorts of caps aren't sup
boliu
2014/02/14 20:45:42
I thought it might be a problem. But I don't know
| |
1415 impl().layer_tree_host_impl->GetRendererCapabilities(); | |
1416 if (impl_caps.MainThreadCapabilities() == | |
1417 impl().renderer_capabilities_for_commit) { | |
1418 impl().scheduler->FinishCommit(); | |
1419 } else { | |
1420 TRACE_EVENT_INSTANT0( | |
1421 "cc", "EarlyOut_StaleRendererCaps", TRACE_EVENT_SCOPE_THREAD); | |
1422 if (impl().commit_completion_event) { | |
1423 impl().commit_completion_event->Signal(); | |
1424 impl().commit_completion_event = NULL; | |
1425 bool did_handle = true; | |
1426 BeginMainFrameAbortedOnImplThread(did_handle); | |
1427 } | |
1428 } | |
1388 } | 1429 } |
1389 | 1430 |
1390 void ThreadProxy::DidCommitAndDrawFrame() { | 1431 void ThreadProxy::DidCommitAndDrawFrame() { |
1391 DCHECK(IsMainThread()); | 1432 DCHECK(IsMainThread()); |
1392 if (!layer_tree_host()) | 1433 if (!layer_tree_host()) |
1393 return; | 1434 return; |
1394 layer_tree_host()->DidCommitAndDrawFrame(); | 1435 layer_tree_host()->DidCommitAndDrawFrame(); |
1395 } | 1436 } |
1396 | 1437 |
1397 void ThreadProxy::DidCompleteSwapBuffers() { | 1438 void ThreadProxy::DidCompleteSwapBuffers() { |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1714 impl().commit_to_activate_duration_history.InsertSample( | 1755 impl().commit_to_activate_duration_history.InsertSample( |
1715 base::TimeTicks::HighResNow() - impl().commit_complete_time); | 1756 base::TimeTicks::HighResNow() - impl().commit_complete_time); |
1716 } | 1757 } |
1717 | 1758 |
1718 void ThreadProxy::DidManageTiles() { | 1759 void ThreadProxy::DidManageTiles() { |
1719 DCHECK(IsImplThread()); | 1760 DCHECK(IsImplThread()); |
1720 impl().scheduler->DidManageTiles(); | 1761 impl().scheduler->DidManageTiles(); |
1721 } | 1762 } |
1722 | 1763 |
1723 } // namespace cc | 1764 } // namespace cc |
OLD | NEW |