Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: cc/scheduler/scheduler.cc

Issue 775143003: cc: Implement unified BeginFrame on aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 80 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
81 base::PowerMonitor* power_monitor, 81 base::PowerMonitor* power_monitor,
82 scoped_ptr<BeginFrameSource> external_begin_frame_source, 82 scoped_ptr<BeginFrameSource> external_begin_frame_source,
83 SchedulerFrameSourcesConstructor* frame_sources_constructor) 83 SchedulerFrameSourcesConstructor* frame_sources_constructor)
84 : frame_source_(), 84 : frame_source_(),
85 primary_frame_source_(NULL), 85 primary_frame_source_(NULL),
86 background_frame_source_(NULL), 86 background_frame_source_(NULL),
87 primary_frame_source_internal_(external_begin_frame_source.Pass()), 87 primary_frame_source_internal_(external_begin_frame_source.Pass()),
88 background_frame_source_internal_(), 88 background_frame_source_internal_(),
89 vsync_observer_(NULL), 89 vsync_observer_(NULL),
90 authoritative_vsync_interval_(base::TimeDelta()),
91 last_timebase_(base::TimeTicks()),
90 throttle_frame_production_(scheduler_settings.throttle_frame_production), 92 throttle_frame_production_(scheduler_settings.throttle_frame_production),
91 settings_(scheduler_settings), 93 settings_(scheduler_settings),
92 client_(client), 94 client_(client),
93 layer_tree_host_id_(layer_tree_host_id), 95 layer_tree_host_id_(layer_tree_host_id),
94 task_runner_(task_runner), 96 task_runner_(task_runner),
95 power_monitor_(power_monitor), 97 power_monitor_(power_monitor),
96 state_machine_(scheduler_settings), 98 state_machine_(scheduler_settings),
97 inside_process_scheduled_actions_(false), 99 inside_process_scheduled_actions_(false),
98 inside_action_(SchedulerStateMachine::ACTION_NONE), 100 inside_action_(SchedulerStateMachine::ACTION_NONE),
99 weak_factory_(this) { 101 weak_factory_(this) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 168 }
167 } 169 }
168 170
169 void Scheduler::OnPowerStateChange(bool on_battery_power) { 171 void Scheduler::OnPowerStateChange(bool on_battery_power) {
170 DCHECK(settings_.disable_hi_res_timer_tasks_on_battery); 172 DCHECK(settings_.disable_hi_res_timer_tasks_on_battery);
171 state_machine_.SetImplLatencyTakesPriorityOnBattery(on_battery_power); 173 state_machine_.SetImplLatencyTakesPriorityOnBattery(on_battery_power);
172 } 174 }
173 175
174 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, 176 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
175 base::TimeDelta interval) { 177 base::TimeDelta interval) {
176 // TODO(brianderson): We should not be receiving 0 intervals. 178 if (authoritative_vsync_interval_ != base::TimeDelta()) {
177 if (interval == base::TimeDelta()) 179 interval = authoritative_vsync_interval_;
180 } else if (interval == base::TimeDelta()) {
181 // TODO(brianderson): We should not be receiving 0 intervals.
178 interval = BeginFrameArgs::DefaultInterval(); 182 interval = BeginFrameArgs::DefaultInterval();
183 }
184
185 last_timebase_ = timebase;
179 186
180 if (vsync_observer_) 187 if (vsync_observer_)
181 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); 188 vsync_observer_->OnUpdateVSyncParameters(timebase, interval);
182 } 189 }
183 190
184 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 191 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
185 DCHECK_GE(draw_time.ToInternalValue(), 0); 192 DCHECK_GE(draw_time.ToInternalValue(), 0);
186 estimated_parent_draw_time_ = draw_time; 193 estimated_parent_draw_time_ = draw_time;
187 } 194 }
188 195
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 461 }
455 return true; 462 return true;
456 } 463 }
457 464
458 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { 465 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) {
459 DCHECK(settings_.forward_begin_frames_to_children); 466 DCHECK(settings_.forward_begin_frames_to_children);
460 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); 467 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames);
461 ProcessScheduledActions(); 468 ProcessScheduledActions();
462 } 469 }
463 470
471 void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) {
472 authoritative_vsync_interval_ = interval;
473 if (vsync_observer_)
474 vsync_observer_->OnUpdateVSyncParameters(last_timebase_, interval);
475 }
476
464 // BeginRetroFrame is called for BeginFrames that we've deferred because 477 // BeginRetroFrame is called for BeginFrames that we've deferred because
465 // the scheduler was in the middle of processing a previous BeginFrame. 478 // the scheduler was in the middle of processing a previous BeginFrame.
466 void Scheduler::BeginRetroFrame() { 479 void Scheduler::BeginRetroFrame() {
467 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame"); 480 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame");
468 DCHECK(!settings_.using_synchronous_renderer_compositor); 481 DCHECK(!settings_.using_synchronous_renderer_compositor);
469 DCHECK(!begin_retro_frame_args_.empty()); 482 DCHECK(!begin_retro_frame_args_.empty());
470 DCHECK(!begin_retro_frame_task_.IsCancelled()); 483 DCHECK(!begin_retro_frame_task_.IsCancelled());
471 DCHECK_EQ(state_machine_.begin_impl_frame_state(), 484 DCHECK_EQ(state_machine_.begin_impl_frame_state(),
472 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 485 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
473 486
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 834 }
822 835
823 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 836 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
824 return (state_machine_.commit_state() == 837 return (state_machine_.commit_state() ==
825 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 838 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
826 state_machine_.commit_state() == 839 state_machine_.commit_state() ==
827 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 840 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
828 } 841 }
829 842
830 } // namespace cc 843 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698