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

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

Issue 54913003: Scheduler: Switch from high to low latency mode if possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renaming and comments. Created 7 years, 1 month 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 #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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 178
179 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { 179 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
180 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame"); 180 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame");
181 DCHECK(state_machine_.begin_impl_frame_state() == 181 DCHECK(state_machine_.begin_impl_frame_state() ==
182 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 182 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
183 DCHECK(state_machine_.HasInitializedOutputSurface()); 183 DCHECK(state_machine_.HasInitializedOutputSurface());
184 last_begin_impl_frame_args_ = args; 184 last_begin_impl_frame_args_ = args;
185 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); 185 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate();
186 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); 186 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_);
187
188 if (settings_.switch_to_low_latency_if_possible) {
189 state_machine_.SetSkipBeginMainFrameToReduceLatency(
190 state_machine_.InHighLatencyMode() && CanOperateInLowLatencyMode());
191 }
192
187 ProcessScheduledActions(); 193 ProcessScheduledActions();
188 194
189 if (!state_machine_.HasInitializedOutputSurface()) 195 if (!state_machine_.HasInitializedOutputSurface())
190 return; 196 return;
191 197
192 state_machine_.OnBeginImplFrameDeadlinePending(); 198 state_machine_.OnBeginImplFrameDeadlinePending();
193 199
194 if (settings_.using_synchronous_renderer_compositor) { 200 if (settings_.using_synchronous_renderer_compositor) {
195 // The synchronous renderer compositor has to make its GL calls 201 // The synchronous renderer compositor has to make its GL calls
196 // within this call to BeginImplFrame. 202 // within this call to BeginImplFrame.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); 343 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime());
338 344
339 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) 345 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly())
340 PostBeginImplFrameDeadline(base::TimeTicks()); 346 PostBeginImplFrameDeadline(base::TimeTicks());
341 } 347 }
342 348
343 bool Scheduler::WillDrawIfNeeded() const { 349 bool Scheduler::WillDrawIfNeeded() const {
344 return !state_machine_.PendingDrawsShouldBeAborted(); 350 return !state_machine_.PendingDrawsShouldBeAborted();
345 } 351 }
346 352
353 bool Scheduler::CanOperateInLowLatencyMode() const {
354 // If the main thread computation and commit can be finished before the
355 // deadline we can operate in low latency mode.
356 base::TimeTicks estimated_draw_time =
357 last_begin_impl_frame_args_.frame_time +
358 client_->BeginMainFrameToCommitDurationEstimate() +
359 client_->CommitToActivateDurationEstimate();
360
361 return estimated_draw_time < last_begin_impl_frame_args_.deadline;
362 }
363
347 } // namespace cc 364 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698