Chromium Code Reviews| 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 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 SchedulerClient* client, | 42 SchedulerClient* client, |
| 43 const SchedulerSettings& settings, | 43 const SchedulerSettings& settings, |
| 44 int layer_tree_host_id, | 44 int layer_tree_host_id, |
| 45 base::SingleThreadTaskRunner* task_runner, | 45 base::SingleThreadTaskRunner* task_runner, |
| 46 BeginFrameSource* begin_frame_source, | 46 BeginFrameSource* begin_frame_source, |
| 47 scoped_ptr<CompositorTimingHistory> compositor_timing_history) | 47 scoped_ptr<CompositorTimingHistory> compositor_timing_history) |
| 48 : settings_(settings), | 48 : settings_(settings), |
| 49 client_(client), | 49 client_(client), |
| 50 layer_tree_host_id_(layer_tree_host_id), | 50 layer_tree_host_id_(layer_tree_host_id), |
| 51 task_runner_(task_runner), | 51 task_runner_(task_runner), |
| 52 begin_frame_source_(begin_frame_source), | 52 begin_frame_source_(nullptr), |
| 53 observing_begin_frame_source_(false), | 53 observing_begin_frame_source_(false), |
| 54 compositor_timing_history_(std::move(compositor_timing_history)), | 54 compositor_timing_history_(std::move(compositor_timing_history)), |
| 55 begin_impl_frame_deadline_mode_( | 55 begin_impl_frame_deadline_mode_( |
| 56 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), | 56 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), |
| 57 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 57 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
| 58 state_machine_(settings), | 58 state_machine_(settings), |
| 59 inside_process_scheduled_actions_(false), | 59 inside_process_scheduled_actions_(false), |
| 60 inside_action_(SchedulerStateMachine::ACTION_NONE), | 60 inside_action_(SchedulerStateMachine::ACTION_NONE), |
| 61 weak_factory_(this) { | 61 weak_factory_(this) { |
| 62 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); | 62 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); |
| 63 DCHECK(client_); | 63 DCHECK(client_); |
| 64 DCHECK(!state_machine_.BeginFrameNeeded()); | 64 DCHECK(!state_machine_.BeginFrameNeeded()); |
| 65 | 65 |
| 66 begin_retro_frame_closure_ = | 66 begin_retro_frame_closure_ = |
| 67 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()); | 67 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()); |
| 68 begin_impl_frame_deadline_closure_ = base::Bind( | 68 begin_impl_frame_deadline_closure_ = base::Bind( |
| 69 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); | 69 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); |
| 70 | 70 |
| 71 begin_frame_source_->SetClientReady(); | 71 SetBeginFrameSource(begin_frame_source); |
| 72 ProcessScheduledActions(); | 72 ProcessScheduledActions(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 Scheduler::~Scheduler() { | 75 Scheduler::~Scheduler() { |
| 76 if (observing_begin_frame_source_) | 76 if (observing_begin_frame_source_) |
| 77 begin_frame_source_->RemoveObserver(this); | 77 begin_frame_source_->RemoveObserver(this); |
| 78 } | 78 } |
| 79 | 79 |
| 80 base::TimeTicks Scheduler::Now() const { | 80 base::TimeTicks Scheduler::Now() const { |
| 81 base::TimeTicks now = base::TimeTicks::Now(); | 81 base::TimeTicks now = base::TimeTicks::Now(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 107 state_machine_.NotifyReadyToActivate(); | 107 state_machine_.NotifyReadyToActivate(); |
| 108 ProcessScheduledActions(); | 108 ProcessScheduledActions(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void Scheduler::NotifyReadyToDraw() { | 111 void Scheduler::NotifyReadyToDraw() { |
| 112 // Future work might still needed for crbug.com/352894. | 112 // Future work might still needed for crbug.com/352894. |
| 113 state_machine_.NotifyReadyToDraw(); | 113 state_machine_.NotifyReadyToDraw(); |
| 114 ProcessScheduledActions(); | 114 ProcessScheduledActions(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void Scheduler::SetBeginFrameSource(BeginFrameSource* source) { | |
|
Sami
2016/03/09 17:09:15
Not sure how often this would actually be used, bu
enne (OOO)
2016/03/09 19:46:10
Yeah, I think something needs to change here, as t
| |
| 118 DCHECK(source); | |
| 119 if (begin_frame_source_ && observing_begin_frame_source_) | |
| 120 begin_frame_source_->RemoveObserver(this); | |
| 121 begin_frame_source_ = source; | |
| 122 if (observing_begin_frame_source_) | |
| 123 begin_frame_source_->AddObserver(this); | |
| 124 begin_frame_source_->SetClientReady(); | |
|
Sami
2016/03/09 17:09:15
One problem here is that some begin frame sources
| |
| 125 } | |
| 126 | |
| 117 void Scheduler::SetNeedsBeginMainFrame() { | 127 void Scheduler::SetNeedsBeginMainFrame() { |
| 118 state_machine_.SetNeedsBeginMainFrame(); | 128 state_machine_.SetNeedsBeginMainFrame(); |
| 119 ProcessScheduledActions(); | 129 ProcessScheduledActions(); |
| 120 } | 130 } |
| 121 | 131 |
| 122 void Scheduler::SetNeedsOneBeginImplFrame() { | 132 void Scheduler::SetNeedsOneBeginImplFrame() { |
| 123 state_machine_.SetNeedsOneBeginImplFrame(); | 133 state_machine_.SetNeedsOneBeginImplFrame(); |
| 124 ProcessScheduledActions(); | 134 ProcessScheduledActions(); |
| 125 } | 135 } |
| 126 | 136 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 | 748 |
| 739 state->BeginDictionary("state_machine"); | 749 state->BeginDictionary("state_machine"); |
| 740 state_machine_.AsValueInto(state); | 750 state_machine_.AsValueInto(state); |
| 741 state->EndDictionary(); | 751 state->EndDictionary(); |
| 742 | 752 |
| 743 // Only trace frame sources when explicitly enabled - http://crbug.com/420607 | 753 // Only trace frame sources when explicitly enabled - http://crbug.com/420607 |
| 744 bool frame_tracing_enabled = false; | 754 bool frame_tracing_enabled = false; |
| 745 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 755 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 746 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), | 756 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), |
| 747 &frame_tracing_enabled); | 757 &frame_tracing_enabled); |
| 748 if (frame_tracing_enabled) { | 758 if (frame_tracing_enabled && begin_frame_source_) { |
| 749 state->BeginDictionary("begin_frame_source_"); | 759 state->BeginDictionary("begin_frame_source_"); |
| 750 begin_frame_source_->AsValueInto(state); | 760 begin_frame_source_->AsValueInto(state); |
| 751 state->EndDictionary(); | 761 state->EndDictionary(); |
| 752 } | 762 } |
| 753 | 763 |
| 754 state->BeginDictionary("scheduler_state"); | 764 state->BeginDictionary("scheduler_state"); |
| 755 state->SetBoolean("throttle_frame_production_", | 765 state->SetBoolean("throttle_frame_production_", |
| 756 settings_.throttle_frame_production); | 766 settings_.throttle_frame_production); |
| 757 state->SetDouble("estimated_parent_draw_time_ms", | 767 state->SetDouble("estimated_parent_draw_time_ms", |
| 758 estimated_parent_draw_time_.InMillisecondsF()); | 768 estimated_parent_draw_time_.InMillisecondsF()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 } | 861 } |
| 852 | 862 |
| 853 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 863 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 854 return (state_machine_.begin_main_frame_state() == | 864 return (state_machine_.begin_main_frame_state() == |
| 855 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 865 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
| 856 state_machine_.begin_main_frame_state() == | 866 state_machine_.begin_main_frame_state() == |
| 857 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 867 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
| 858 } | 868 } |
| 859 | 869 |
| 860 } // namespace cc | 870 } // namespace cc |
| OLD | NEW |