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/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } else { | 387 } else { |
388 advance_commit_state_task_.Cancel(); | 388 advance_commit_state_task_.Cancel(); |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 // BeginFrame is the mechanism that tells us that now is a good time to start | 392 // BeginFrame is the mechanism that tells us that now is a good time to start |
393 // making a frame. Usually this means that user input for the frame is complete. | 393 // making a frame. Usually this means that user input for the frame is complete. |
394 // If the scheduler is busy, we queue the BeginFrame to be handled later as | 394 // If the scheduler is busy, we queue the BeginFrame to be handled later as |
395 // a BeginRetroFrame. | 395 // a BeginRetroFrame. |
396 void Scheduler::BeginFrame(const BeginFrameArgs& args) { | 396 void Scheduler::BeginFrame(const BeginFrameArgs& args) { |
397 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "frame_time", args.frame_time); | 397 TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsTrace()); |
| 398 // scoped_refptr<base::debug::ConvertableToTraceFormat>(args)); |
398 DCHECK(settings_.throttle_frame_production); | 399 DCHECK(settings_.throttle_frame_production); |
399 | 400 |
400 bool should_defer_begin_frame; | 401 bool should_defer_begin_frame; |
401 if (settings_.using_synchronous_renderer_compositor) { | 402 if (settings_.using_synchronous_renderer_compositor) { |
402 should_defer_begin_frame = false; | 403 should_defer_begin_frame = false; |
403 } else { | 404 } else { |
404 should_defer_begin_frame = | 405 should_defer_begin_frame = |
405 !begin_retro_frame_args_.empty() || begin_retro_frame_posted_ || | 406 !begin_retro_frame_args_.empty() || begin_retro_frame_posted_ || |
406 !last_set_needs_begin_frame_ || | 407 !last_set_needs_begin_frame_ || |
407 (state_machine_.begin_impl_frame_state() != | 408 (state_machine_.begin_impl_frame_state() != |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 return; | 482 return; |
482 | 483 |
483 begin_retro_frame_posted_ = true; | 484 begin_retro_frame_posted_ = true; |
484 impl_task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_); | 485 impl_task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_); |
485 } | 486 } |
486 | 487 |
487 // BeginImplFrame starts a compositor frame that will wait up until a deadline | 488 // BeginImplFrame starts a compositor frame that will wait up until a deadline |
488 // for a BeginMainFrame+activation to complete before it times out and draws | 489 // for a BeginMainFrame+activation to complete before it times out and draws |
489 // any asynchronous animation and scroll/pinch updates. | 490 // any asynchronous animation and scroll/pinch updates. |
490 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 491 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
491 TRACE_EVENT1( | 492 TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", args.AsTrace()); |
492 "cc", "Scheduler::BeginImplFrame", "frame_time", args.frame_time); | |
493 DCHECK(state_machine_.begin_impl_frame_state() == | 493 DCHECK(state_machine_.begin_impl_frame_state() == |
494 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 494 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
495 DCHECK(state_machine_.HasInitializedOutputSurface()); | 495 DCHECK(state_machine_.HasInitializedOutputSurface()); |
496 | 496 |
497 advance_commit_state_task_.Cancel(); | 497 advance_commit_state_task_.Cancel(); |
498 | 498 |
499 base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate(); | 499 base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate(); |
500 begin_impl_frame_args_ = args; | 500 begin_impl_frame_args_ = args; |
501 begin_impl_frame_args_.deadline -= draw_duration_estimate; | 501 begin_impl_frame_args_.deadline -= draw_duration_estimate; |
502 | 502 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 scheduler_state->SetBoolean("begin_retro_frame_posted_", | 706 scheduler_state->SetBoolean("begin_retro_frame_posted_", |
707 begin_retro_frame_posted_); | 707 begin_retro_frame_posted_); |
708 scheduler_state->SetInteger("begin_retro_frame_args_", | 708 scheduler_state->SetInteger("begin_retro_frame_args_", |
709 begin_retro_frame_args_.size()); | 709 begin_retro_frame_args_.size()); |
710 scheduler_state->SetBoolean("begin_impl_frame_deadline_task_", | 710 scheduler_state->SetBoolean("begin_impl_frame_deadline_task_", |
711 !begin_impl_frame_deadline_task_.IsCancelled()); | 711 !begin_impl_frame_deadline_task_.IsCancelled()); |
712 scheduler_state->SetBoolean("poll_for_draw_triggers_task_", | 712 scheduler_state->SetBoolean("poll_for_draw_triggers_task_", |
713 !poll_for_draw_triggers_task_.IsCancelled()); | 713 !poll_for_draw_triggers_task_.IsCancelled()); |
714 scheduler_state->SetBoolean("advance_commit_state_task_", | 714 scheduler_state->SetBoolean("advance_commit_state_task_", |
715 !advance_commit_state_task_.IsCancelled()); | 715 !advance_commit_state_task_.IsCancelled()); |
| 716 scheduler_state->Set("begin_impl_frame_args", |
| 717 begin_impl_frame_args_.AsValue().release()); |
| 718 |
716 state->Set("scheduler_state", scheduler_state.release()); | 719 state->Set("scheduler_state", scheduler_state.release()); |
717 | 720 |
718 scoped_ptr<base::DictionaryValue> client_state(new base::DictionaryValue); | 721 scoped_ptr<base::DictionaryValue> client_state(new base::DictionaryValue); |
719 client_state->SetDouble("draw_duration_estimate_ms", | 722 client_state->SetDouble("draw_duration_estimate_ms", |
720 client_->DrawDurationEstimate().InMillisecondsF()); | 723 client_->DrawDurationEstimate().InMillisecondsF()); |
721 client_state->SetDouble( | 724 client_state->SetDouble( |
722 "begin_main_frame_to_commit_duration_estimate_ms", | 725 "begin_main_frame_to_commit_duration_estimate_ms", |
723 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); | 726 client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); |
724 client_state->SetDouble( | 727 client_state->SetDouble( |
725 "commit_to_activate_duration_estimate_ms", | 728 "commit_to_activate_duration_estimate_ms", |
(...skipping 22 matching lines...) Expand all Loading... |
748 } | 751 } |
749 | 752 |
750 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 753 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
751 return (state_machine_.commit_state() == | 754 return (state_machine_.commit_state() == |
752 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 755 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
753 state_machine_.commit_state() == | 756 state_machine_.commit_state() == |
754 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 757 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
755 } | 758 } |
756 | 759 |
757 } // namespace cc | 760 } // namespace cc |
OLD | NEW |