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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 359 "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
360 DCHECK(IsImplThread()); | 360 DCHECK(IsImplThread()); |
361 impl().scheduler->DidSwapBuffersComplete(); | 361 impl().scheduler->DidSwapBuffersComplete(); |
362 Proxy::MainThreadTaskRunner()->PostTask( | 362 Proxy::MainThreadTaskRunner()->PostTask( |
363 FROM_HERE, | 363 FROM_HERE, |
364 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); | 364 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); |
365 } | 365 } |
366 | 366 |
367 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 367 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
368 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 368 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
| 369 if (impl().last_processed_begin_main_frame_args.IsValid()) { |
| 370 // Last processed begin main frame args records the frame args that we sent |
| 371 // to the main thread for the last frame that we've processed. If that is |
| 372 // set, that means the current frame is one past the frame in which we've |
| 373 // finished the processing. |
| 374 impl().layer_tree_host_impl->RecordMainFrameTiming( |
| 375 impl().last_processed_begin_main_frame_args, |
| 376 impl().layer_tree_host_impl->CurrentBeginFrameArgs()); |
| 377 impl().last_processed_begin_main_frame_args = BeginFrameArgs(); |
| 378 } |
369 } | 379 } |
370 | 380 |
371 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 381 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
372 TRACE_EVENT1( | 382 TRACE_EVENT1( |
373 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 383 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
374 DCHECK(IsImplThread()); | 384 DCHECK(IsImplThread()); |
375 impl().scheduler->SetCanDraw(can_draw); | 385 impl().scheduler->SetCanDraw(can_draw); |
376 } | 386 } |
377 | 387 |
378 void ThreadProxy::NotifyReadyToActivate() { | 388 void ThreadProxy::NotifyReadyToActivate() { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 694 |
685 if (!impl().layer_tree_host_impl->settings().impl_side_painting) { | 695 if (!impl().layer_tree_host_impl->settings().impl_side_painting) { |
686 DCHECK_GT(impl().layer_tree_host_impl->memory_allocation_limit_bytes(), 0u); | 696 DCHECK_GT(impl().layer_tree_host_impl->memory_allocation_limit_bytes(), 0u); |
687 } | 697 } |
688 begin_main_frame_state->memory_allocation_limit_bytes = | 698 begin_main_frame_state->memory_allocation_limit_bytes = |
689 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); | 699 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); |
690 begin_main_frame_state->memory_allocation_priority_cutoff = | 700 begin_main_frame_state->memory_allocation_priority_cutoff = |
691 impl().layer_tree_host_impl->memory_allocation_priority_cutoff(); | 701 impl().layer_tree_host_impl->memory_allocation_priority_cutoff(); |
692 begin_main_frame_state->evicted_ui_resources = | 702 begin_main_frame_state->evicted_ui_resources = |
693 impl().layer_tree_host_impl->EvictedUIResourcesExist(); | 703 impl().layer_tree_host_impl->EvictedUIResourcesExist(); |
| 704 // TODO(vmpstr): This needs to be fixed if |
| 705 // main_frame_before_activation_enabled is set, since we might run this code |
| 706 // twice before recording a duration. crbug.com/469824 |
| 707 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; |
694 Proxy::MainThreadTaskRunner()->PostTask( | 708 Proxy::MainThreadTaskRunner()->PostTask( |
695 FROM_HERE, | 709 FROM_HERE, |
696 base::Bind(&ThreadProxy::BeginMainFrame, | 710 base::Bind(&ThreadProxy::BeginMainFrame, |
697 main_thread_weak_ptr_, | 711 main_thread_weak_ptr_, |
698 base::Passed(&begin_main_frame_state))); | 712 base::Passed(&begin_main_frame_state))); |
699 devtools_instrumentation::DidRequestMainThreadFrame( | 713 devtools_instrumentation::DidRequestMainThreadFrame( |
700 impl().layer_tree_host_id); | 714 impl().layer_tree_host_id); |
701 impl().timing_history.DidBeginMainFrame(); | 715 impl().timing_history.DidBeginMainFrame(); |
702 } | 716 } |
703 | 717 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 | 942 |
929 void ThreadProxy::BeginMainFrameAbortedOnImplThread( | 943 void ThreadProxy::BeginMainFrameAbortedOnImplThread( |
930 CommitEarlyOutReason reason) { | 944 CommitEarlyOutReason reason) { |
931 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", | 945 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", |
932 CommitEarlyOutReasonToString(reason)); | 946 CommitEarlyOutReasonToString(reason)); |
933 DCHECK(IsImplThread()); | 947 DCHECK(IsImplThread()); |
934 DCHECK(impl().scheduler); | 948 DCHECK(impl().scheduler); |
935 DCHECK(impl().scheduler->CommitPending()); | 949 DCHECK(impl().scheduler->CommitPending()); |
936 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 950 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
937 | 951 |
938 if (CommitEarlyOutHandledCommit(reason)) | 952 if (CommitEarlyOutHandledCommit(reason)) { |
939 SetInputThrottledUntilCommitOnImplThread(false); | 953 SetInputThrottledUntilCommitOnImplThread(false); |
| 954 impl().last_processed_begin_main_frame_args = |
| 955 impl().last_begin_main_frame_args; |
| 956 } |
940 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); | 957 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); |
941 impl().scheduler->BeginMainFrameAborted(reason); | 958 impl().scheduler->BeginMainFrameAborted(reason); |
942 } | 959 } |
943 | 960 |
944 void ThreadProxy::ScheduledActionAnimate() { | 961 void ThreadProxy::ScheduledActionAnimate() { |
945 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 962 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
946 DCHECK(IsImplThread()); | 963 DCHECK(IsImplThread()); |
947 | 964 |
948 // Don't animate if there is no root layer. | 965 // Don't animate if there is no root layer. |
949 // TODO(mithro): Both Animate and UpdateAnimationState already have a | 966 // TODO(mithro): Both Animate and UpdateAnimationState already have a |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 | 1377 |
1361 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1378 if (impl().completion_event_for_commit_held_on_tree_activation) { |
1362 TRACE_EVENT_INSTANT0( | 1379 TRACE_EVENT_INSTANT0( |
1363 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1380 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
1364 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1381 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
1365 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1382 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
1366 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1383 impl().completion_event_for_commit_held_on_tree_activation = NULL; |
1367 } | 1384 } |
1368 | 1385 |
1369 impl().timing_history.DidActivateSyncTree(); | 1386 impl().timing_history.DidActivateSyncTree(); |
| 1387 impl().last_processed_begin_main_frame_args = |
| 1388 impl().last_begin_main_frame_args; |
1370 } | 1389 } |
1371 | 1390 |
1372 void ThreadProxy::DidPrepareTiles() { | 1391 void ThreadProxy::DidPrepareTiles() { |
1373 DCHECK(IsImplThread()); | 1392 DCHECK(IsImplThread()); |
1374 impl().scheduler->DidPrepareTiles(); | 1393 impl().scheduler->DidPrepareTiles(); |
1375 } | 1394 } |
1376 | 1395 |
1377 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1396 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
1378 DCHECK(IsImplThread()); | 1397 DCHECK(IsImplThread()); |
1379 Proxy::MainThreadTaskRunner()->PostTask( | 1398 Proxy::MainThreadTaskRunner()->PostTask( |
1380 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | 1399 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, |
1381 main_thread_weak_ptr_)); | 1400 main_thread_weak_ptr_)); |
1382 } | 1401 } |
1383 | 1402 |
1384 void ThreadProxy::OnDrawForOutputSurface() { | 1403 void ThreadProxy::OnDrawForOutputSurface() { |
1385 DCHECK(IsImplThread()); | 1404 DCHECK(IsImplThread()); |
1386 impl().scheduler->OnDrawForOutputSurface(); | 1405 impl().scheduler->OnDrawForOutputSurface(); |
1387 } | 1406 } |
1388 | 1407 |
1389 } // namespace cc | 1408 } // namespace cc |
OLD | NEW |