| 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 | 1366 |
| 1350 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1367 if (impl().completion_event_for_commit_held_on_tree_activation) { |
| 1351 TRACE_EVENT_INSTANT0( | 1368 TRACE_EVENT_INSTANT0( |
| 1352 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1369 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
| 1353 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1370 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
| 1354 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1371 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
| 1355 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1372 impl().completion_event_for_commit_held_on_tree_activation = NULL; |
| 1356 } | 1373 } |
| 1357 | 1374 |
| 1358 impl().timing_history.DidActivateSyncTree(); | 1375 impl().timing_history.DidActivateSyncTree(); |
| 1376 impl().last_processed_begin_main_frame_args = |
| 1377 impl().last_begin_main_frame_args; |
| 1359 } | 1378 } |
| 1360 | 1379 |
| 1361 void ThreadProxy::DidPrepareTiles() { | 1380 void ThreadProxy::DidPrepareTiles() { |
| 1362 DCHECK(IsImplThread()); | 1381 DCHECK(IsImplThread()); |
| 1363 impl().scheduler->DidPrepareTiles(); | 1382 impl().scheduler->DidPrepareTiles(); |
| 1364 } | 1383 } |
| 1365 | 1384 |
| 1366 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1385 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 1367 DCHECK(IsImplThread()); | 1386 DCHECK(IsImplThread()); |
| 1368 Proxy::MainThreadTaskRunner()->PostTask( | 1387 Proxy::MainThreadTaskRunner()->PostTask( |
| 1369 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | 1388 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, |
| 1370 main_thread_weak_ptr_)); | 1389 main_thread_weak_ptr_)); |
| 1371 } | 1390 } |
| 1372 | 1391 |
| 1373 } // namespace cc | 1392 } // namespace cc |
| OLD | NEW |