OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/proxy_impl.h" | 5 #include "cc/trees/proxy_impl.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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 CommitEarlyOutReason reason, | 181 CommitEarlyOutReason reason, |
182 base::TimeTicks main_thread_start_time) { | 182 base::TimeTicks main_thread_start_time) { |
183 TRACE_EVENT1("cc", "ProxyImpl::BeginMainFrameAbortedOnImplThread", "reason", | 183 TRACE_EVENT1("cc", "ProxyImpl::BeginMainFrameAbortedOnImplThread", "reason", |
184 CommitEarlyOutReasonToString(reason)); | 184 CommitEarlyOutReasonToString(reason)); |
185 DCHECK(IsImplThread()); | 185 DCHECK(IsImplThread()); |
186 DCHECK(scheduler_->CommitPending()); | 186 DCHECK(scheduler_->CommitPending()); |
187 DCHECK(!layer_tree_host_impl_->pending_tree()); | 187 DCHECK(!layer_tree_host_impl_->pending_tree()); |
188 | 188 |
189 if (CommitEarlyOutHandledCommit(reason)) { | 189 if (CommitEarlyOutHandledCommit(reason)) { |
190 SetInputThrottledUntilCommitOnImpl(false); | 190 SetInputThrottledUntilCommitOnImpl(false); |
191 last_processed_begin_main_frame_args_ = last_begin_main_frame_args_; | |
192 } | 191 } |
193 layer_tree_host_impl_->BeginMainFrameAborted(reason); | 192 layer_tree_host_impl_->BeginMainFrameAborted(reason); |
194 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); | 193 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); |
195 scheduler_->BeginMainFrameAborted(reason); | 194 scheduler_->BeginMainFrameAborted(reason); |
196 } | 195 } |
197 | 196 |
198 void ProxyImpl::FinishAllRenderingOnImpl(CompletionEvent* completion) { | 197 void ProxyImpl::FinishAllRenderingOnImpl(CompletionEvent* completion) { |
199 TRACE_EVENT0("cc", "ProxyImpl::FinishAllRenderingOnImplThread"); | 198 TRACE_EVENT0("cc", "ProxyImpl::FinishAllRenderingOnImplThread"); |
200 DCHECK(IsImplThread()); | 199 DCHECK(IsImplThread()); |
201 layer_tree_host_impl_->FinishAllRendering(); | 200 layer_tree_host_impl_->FinishAllRendering(); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 DCHECK(IsImplThread()); | 448 DCHECK(IsImplThread()); |
450 | 449 |
451 if (next_commit_waits_for_activation_) { | 450 if (next_commit_waits_for_activation_) { |
452 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 451 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
453 TRACE_EVENT_SCOPE_THREAD); | 452 TRACE_EVENT_SCOPE_THREAD); |
454 DCHECK(commit_completion_event_); | 453 DCHECK(commit_completion_event_); |
455 commit_completion_event_->Signal(); | 454 commit_completion_event_->Signal(); |
456 commit_completion_event_ = nullptr; | 455 commit_completion_event_ = nullptr; |
457 next_commit_waits_for_activation_ = false; | 456 next_commit_waits_for_activation_ = false; |
458 } | 457 } |
459 | |
460 last_processed_begin_main_frame_args_ = last_begin_main_frame_args_; | |
461 } | 458 } |
462 | 459 |
463 void ProxyImpl::WillPrepareTiles() { | 460 void ProxyImpl::WillPrepareTiles() { |
464 DCHECK(IsImplThread()); | 461 DCHECK(IsImplThread()); |
465 scheduler_->WillPrepareTiles(); | 462 scheduler_->WillPrepareTiles(); |
466 } | 463 } |
467 | 464 |
468 void ProxyImpl::DidPrepareTiles() { | 465 void ProxyImpl::DidPrepareTiles() { |
469 DCHECK(IsImplThread()); | 466 DCHECK(IsImplThread()); |
470 scheduler_->DidPrepareTiles(); | 467 scheduler_->DidPrepareTiles(); |
471 } | 468 } |
472 | 469 |
473 void ProxyImpl::DidCompletePageScaleAnimationOnImplThread() { | 470 void ProxyImpl::DidCompletePageScaleAnimationOnImplThread() { |
474 DCHECK(IsImplThread()); | 471 DCHECK(IsImplThread()); |
475 channel_impl_->DidCompletePageScaleAnimation(); | 472 channel_impl_->DidCompletePageScaleAnimation(); |
476 } | 473 } |
477 | 474 |
478 void ProxyImpl::OnDrawForOutputSurface(bool resourceless_software_draw) { | 475 void ProxyImpl::OnDrawForOutputSurface(bool resourceless_software_draw) { |
479 DCHECK(IsImplThread()); | 476 DCHECK(IsImplThread()); |
480 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); | 477 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); |
481 } | 478 } |
482 | 479 |
483 void ProxyImpl::PostFrameTimingEventsOnImplThread( | |
484 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | |
485 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | |
486 DCHECK(IsImplThread()); | |
487 channel_impl_->PostFrameTimingEventsOnMain(std::move(composite_events), | |
488 std::move(main_frame_events)); | |
489 } | |
490 | |
491 void ProxyImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 480 void ProxyImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
492 DCHECK(IsImplThread()); | 481 DCHECK(IsImplThread()); |
493 layer_tree_host_impl_->WillBeginImplFrame(args); | 482 layer_tree_host_impl_->WillBeginImplFrame(args); |
494 if (last_processed_begin_main_frame_args_.IsValid()) { | |
495 // Last processed begin main frame args records the frame args that we sent | |
496 // to the main thread for the last frame that we've processed. If that is | |
497 // set, that means the current frame is one past the frame in which we've | |
498 // finished the processing. | |
499 layer_tree_host_impl_->RecordMainFrameTiming( | |
500 last_processed_begin_main_frame_args_, args); | |
501 last_processed_begin_main_frame_args_ = BeginFrameArgs(); | |
502 } | |
503 } | 483 } |
504 | 484 |
505 void ProxyImpl::DidFinishImplFrame() { | 485 void ProxyImpl::DidFinishImplFrame() { |
506 DCHECK(IsImplThread()); | 486 DCHECK(IsImplThread()); |
507 layer_tree_host_impl_->DidFinishImplFrame(); | 487 layer_tree_host_impl_->DidFinishImplFrame(); |
508 } | 488 } |
509 | 489 |
510 void ProxyImpl::ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) { | 490 void ProxyImpl::ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) { |
511 DCHECK(IsImplThread()); | 491 DCHECK(IsImplThread()); |
512 unsigned int begin_frame_id = nextBeginFrameId++; | 492 unsigned int begin_frame_id = nextBeginFrameId++; |
513 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 493 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
514 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); | 494 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); |
515 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 495 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
516 new BeginMainFrameAndCommitState); | 496 new BeginMainFrameAndCommitState); |
517 begin_main_frame_state->begin_frame_id = begin_frame_id; | 497 begin_main_frame_state->begin_frame_id = begin_frame_id; |
518 begin_main_frame_state->begin_frame_args = args; | 498 begin_main_frame_state->begin_frame_args = args; |
519 begin_main_frame_state->begin_frame_callbacks = | 499 begin_main_frame_state->begin_frame_callbacks = |
520 layer_tree_host_impl_->ProcessLayerTreeMutations(); | 500 layer_tree_host_impl_->ProcessLayerTreeMutations(); |
521 begin_main_frame_state->scroll_info = | 501 begin_main_frame_state->scroll_info = |
522 layer_tree_host_impl_->ProcessScrollDeltas(); | 502 layer_tree_host_impl_->ProcessScrollDeltas(); |
523 begin_main_frame_state->memory_allocation_limit_bytes = | 503 begin_main_frame_state->memory_allocation_limit_bytes = |
524 layer_tree_host_impl_->memory_allocation_limit_bytes(); | 504 layer_tree_host_impl_->memory_allocation_limit_bytes(); |
525 begin_main_frame_state->evicted_ui_resources = | 505 begin_main_frame_state->evicted_ui_resources = |
526 layer_tree_host_impl_->EvictedUIResourcesExist(); | 506 layer_tree_host_impl_->EvictedUIResourcesExist(); |
527 // TODO(vmpstr): This needs to be fixed if | |
528 // main_frame_before_activation_enabled is set, since we might run this code | |
529 // twice before recording a duration. crbug.com/469824 | |
530 last_begin_main_frame_args_ = begin_main_frame_state->begin_frame_args; | |
531 channel_impl_->BeginMainFrame(std::move(begin_main_frame_state)); | 507 channel_impl_->BeginMainFrame(std::move(begin_main_frame_state)); |
532 devtools_instrumentation::DidRequestMainThreadFrame(layer_tree_host_id_); | 508 devtools_instrumentation::DidRequestMainThreadFrame(layer_tree_host_id_); |
533 } | 509 } |
534 | 510 |
535 DrawResult ProxyImpl::ScheduledActionDrawAndSwapIfPossible() { | 511 DrawResult ProxyImpl::ScheduledActionDrawAndSwapIfPossible() { |
536 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDrawAndSwap"); | 512 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDrawAndSwap"); |
537 DCHECK(IsImplThread()); | 513 DCHECK(IsImplThread()); |
538 | 514 |
539 // SchedulerStateMachine::DidDrawIfPossibleCompleted isn't set up to | 515 // SchedulerStateMachine::DidDrawIfPossibleCompleted isn't set up to |
540 // handle DRAW_ABORTED_CANT_DRAW. Moreover, the scheduler should | 516 // handle DRAW_ABORTED_CANT_DRAW. Moreover, the scheduler should |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 bool ProxyImpl::IsMainThreadBlocked() const { | 662 bool ProxyImpl::IsMainThreadBlocked() const { |
687 return task_runner_provider_->IsMainThreadBlocked(); | 663 return task_runner_provider_->IsMainThreadBlocked(); |
688 } | 664 } |
689 | 665 |
690 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 666 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
691 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 667 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
692 return main_thread_blocked_commit_vars_unsafe_; | 668 return main_thread_blocked_commit_vars_unsafe_; |
693 } | 669 } |
694 | 670 |
695 } // namespace cc | 671 } // namespace cc |
OLD | NEW |